SAP MDG · VALIDATION DERIVATION

How do I implement SAP MDG validation in IF_EX_USMD_RULE_SERVICE~CHECK_CREQUEST?

Implement the BAdI in SE18/SE19, assign an implementing class, and place the business validation in the relevant interface method. For entity-level validations, SAP MDG uses ET_MESSAGE; however, the retrieved source for CHECK_CREQUEST is an empty compatibility hook, so the practical implementation pattern is to keep CHECK_CREQUEST empty unless you have a specific CR-level rule to add, and otherwise use CHECK_ENTITY for record-level checks.

Implement the BAdI in SE18/SE19, assign an implementing class, and place the business validation in the relevant interface method. For entity-level validations, SAP MDG uses ET_MESSAGE; however, the retrieved source for CHECK_CREQUEST is an empty compatibility hook, so the practical implementation pattern is to keep CHECK_CREQUEST empty unless you have a specific CR-level rule to add, and otherwise use CHECK_ENTITY for record-level checks.

Implement the BAdI in SE18/SE19, assign a class that implements `IF_EX_USMD_RULE_SERVICE`, and decide whether the rule belongs to `CHECK_CREQUEST` or `CHECK_ENTITY`. In the retrieved example, `CHECK_CREQUEST` is intentionally left empty as a compatibility hook, so the actual business validation pattern is to use entity-level checks with `ET_MESSAGE` when you need record-specific errors or warnings.

Process flow

  1. Open transaction SE18 and display the BAdI definition, for example USMD_RULE_SERVICE.
  2. Open transaction SE19 and create the BAdI implementation.
  3. Assign or create the implementing class and implement IF_EX_USMD_RULE_SERVICE.
  4. Implement CHECK_ENTITY for record-level validation and keep CHECK_CREQUEST empty unless you need a true CR-level rule.
  5. Build validation messages in USMD_S_MESSAGE and append them to ET_MESSAGE.
  6. Activate the class, then the BAdI implementation, then dependent objects.
  7. Trigger the MDG scenario and debug the method call to confirm the hook is executed.

Referenced tables

ObjectPurpose
usmd_s_messageMessage structure used to return validation messages to the MDG framework.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP implementation example

Concrete CHECK_ENTITY implementation pattern from the same knowledge document set.

1METHOD if_ex_usmd_rule_service~check_entity. 2 DATA: lo_app_context TYPE REF TO if_usmd_app_context, 3 lt_message TYPE usmd_t_message, 4 ls_message TYPE usmd_s_message, 5 lv_crtype TYPE usmd_crequest_type, 6 lv_crstep TYPE usmd_crequest_appstep, 7 lv_crid TYPE usmd_crequest. 8 9 FIELD-SYMBOLS: <ls_data> TYPE any, 10 <lv_value> TYPE any. 11 12 lo_app_context = cl_usmd_app_context=>get_context( ). 13 CHECK lo_app_context IS BOUND. 14 CHECK io_model->d_usmd_model = 'BP'. 15 16 lo_app_context->get_attributes( 17 IMPORTING 18 ev_crequest_type = lv_crtype 19 ev_crequest_step = lv_crstep 20 ev_crequest_id = lv_crid ). 21 22 CHECK it_data IS NOT INITIAL. 23 24 LOOP AT it_data ASSIGNING <ls_data>. 25 ASSIGN COMPONENT 'SOME_MAND_FIELD' OF STRUCTURE <ls_data> TO <lv_value>. 26 IF <lv_value> IS ASSIGNED AND <lv_value> IS INITIAL. 27 CLEAR ls_message. 28 ls_message-msgid = 'ZMDG_SUPPL'. 29 ls_message-msgno = '001'. 30 ls_message-msgty = 'E'. 31 ls_message-fieldname = 'SOME_MAND_FIELD'. 32 APPEND ls_message TO et_message. 33 ENDIF. 34 ENDLOOP. 35 36 IF et_message IS NOT INITIAL. 37 zcl_mdgbp_bp_validation=>adjust_messages( 38 EXPORTING 39 cr_number = lv_crid 40 CHANGING 41 ct_message = et_message ). 42 ENDIF. 43ENDMETHOD.

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How do I activate and implement a BAdI validation in SAP MDG?
  • How do I create a CHECK_CREQUEST implementation for USMD_RULE_SERVICE?
  • How do I write ABAP logic for SAP MDG rule-service validations?

Possible questions

  • How do I implement SAP MDG validation in IF_EX_USMD_RULE_SERVICE~CHECK_CREQUEST?
  • How do I create a BAdI implementation for USMD_RULE_SERVICE in SE18/SE19?
  • How do I add custom validation logic and messages in SAP MDG?
  • How do I debug whether a USMD_RULE_SERVICE BAdI method is being called?
  • What is the difference between CHECK_CREQUEST and CHECK_ENTITY in SAP MDG?

Keywords

SAP MDGUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICECHECK_CREQUESTSE18SE19BAdI implementationvalidationET_MESSAGEusmd_s_message