SAP MDG · VALIDATION DERIVATION

How do I implement an SAP MDG USMD_RULE_SERVICE CHECK_ENTITY validation for company-code fields in a BAdI?

Implement the validation in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY, guard it by MDG context and step, loop through IT_DATA with dynamic field access, fill USMD_S_MESSAGE with MSGID/MSGNO/MSGTY/FIELDNAME/MSGV1, append to ET_MESSAGE, then run message row-id enrichment and severity adjustment.

Implement the validation in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY, guard it by MDG context and step, loop through IT_DATA with dynamic field access, fill USMD_S_MESSAGE with MSGID/MSGNO/MSGTY/FIELDNAME/MSGV1, append to ET_MESSAGE, then run message row-id enrichment and severity adjustment.

Implement the validation in the BAdI interface method IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY. The documented company-code pattern reads the MDG application context first, restricts execution to the intended CR step, loops through IT_DATA with dynamic field assignment, and appends structured messages with FIELDNAME and MSGV1 so the MDG UI can navigate to the exact field.

Process flow

  1. Open SE18 and display BAdI definition USMD_RULE_SERVICE.
  2. Confirm the interface is IF_EX_USMD_RULE_SERVICE and review the available methods.
  3. Open SE19 and create the BAdI implementation with a Z* name.
  4. Assign or create the implementing class and activate it.
  5. Implement IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY with application-context guards.
  6. Loop over IT_DATA, read fields dynamically with ASSIGN COMPONENT, and build USMD_S_MESSAGE rows.
  7. Append messages to ET_MESSAGE, then enrich row mapping and adjust severity if needed.

Referenced tables

ObjectPurpose
ET_MESSAGEValidation output table for returned MDG messages.
IT_DATAGeneric input rows of the entity currently being validated.

ILLUSTRATIVE ABAP SAMPLE

Company-code validation pattern for IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY

This sample follows the documented company-code pattern: context guard, CR-step guard, dynamic field checks, structured message creation, and post-processing.

1METHOD if_ex_usmd_rule_service~check_entity. 2 DATA: lo_app_context TYPE REF TO if_usmd_app_context, 3 ls_message TYPE usmd_s_message, 4 lv_crtype TYPE usmd_crequest_type, 5 lv_crstep TYPE usmd_crequest_appstep, 6 lv_grouping TYPE bu_group. 7 8 FIELD-SYMBOLS: <ls_row> TYPE any, 9 <lv_bukrs> TYPE any, 10 <lv_recon> TYPE any, 11 <lv_pay_method> TYPE any. 12 13 lo_app_context = cl_usmd_app_context=>get_context( ). 14 CHECK lo_app_context IS BOUND. 15 16 zcl_mdg_suppl_utility=>get_cr_details( 17 IMPORTING 18 ev_crequest_type = lv_crtype 19 ev_crequest_step = lv_crstep ). 20 21 CHECK lv_crstep = zif_bp_constants=>cr_step-step_00. 22 CHECK it_data IS NOT INITIAL. 23 24 LOOP AT it_data ASSIGNING <ls_row>. 25 ASSIGN COMPONENT zif_bp_constants=>bp_compny-company OF STRUCTURE <ls_row> TO <lv_bukrs>. 26 CHECK <lv_bukrs> IS ASSIGNED AND <lv_bukrs> IS NOT INITIAL. 27 28 ASSIGN COMPONENT zif_bp_constants=>bp_compny-ref_bpcmp OF STRUCTURE <ls_row> TO <lv_recon>. 29 IF <lv_recon> IS ASSIGNED AND <lv_recon> IS INITIAL. 30 CLEAR ls_message. 31 ls_message-msgid = zif_bp_constants=>message-msg_class. 32 ls_message-msgty = zif_bp_constants=>message-msg_error. 33 ls_message-msgno = '007'. 34 ls_message-fieldname = zif_bp_constants=>bp_compny-ref_bpcmp. 35 ls_message-msgv1 = <lv_bukrs>. 36 APPEND ls_message TO et_message. 37 ENDIF. 38 39 ASSIGN COMPONENT zif_bp_constants=>bp_compny-zwels OF STRUCTURE <ls_row> TO <lv_pay_method>. 40 IF <lv_pay_method> IS ASSIGNED AND <lv_pay_method> IS INITIAL. 41 CLEAR ls_message. 42 ls_message-msgid = zif_bp_constants=>message-msg_class. 43 ls_message-msgty = zif_bp_constants=>message-msg_error. 44 ls_message-msgno = '008'. 45 ls_message-fieldname = zif_bp_constants=>bp_compny-zwels. 46 ls_message-msgv1 = <lv_bukrs>. 47 APPEND ls_message TO et_message. 48 ENDIF. 49 ENDLOOP. 50 51 IF et_message IS NOT INITIAL. 52 zcl_mdg_suppl_utility=>get_message_row_id( 53 EXPORTING 54 io_model = io_model 55 id_crequest = id_crequest 56 id_entitytype = id_entitytype 57 CHANGING 58 ct_message = et_message ). 59 60 zcl_mdgbp_bp_validation=>adjust_messages( 61 EXPORTING 62 cr_number = id_crequest 63 CHANGING 64 ct_message = et_message ). 65 ENDIF. 66ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How do I validate mandatory company-code attributes in CHECK_ENTITY for SAP MDG BP?
  • What is the implementation pattern for company-code checks in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY?
  • How do I build a field-level MDG validation that returns ET_MESSAGE with FIELDNAME and row mapping?

Possible questions

  • How do I implement an SAP MDG USMD_RULE_SERVICE CHECK_ENTITY validation for company-code fields in a BAdI?
  • How do I validate mandatory company-code attributes in CHECK_ENTITY for SAP MDG BP?
  • What is the implementation pattern for company-code checks in IF_EX_USMD_RULE_SERVICE~CHECK_ENTITY?
  • How do I build a field-level MDG validation that returns ET_MESSAGE with FIELDNAME and row mapping?
  • Which SAP transaction is used to create the USMD_RULE_SERVICE BAdI implementation?
  • What should I set in ET_MESSAGE for MDG UI navigation?

Keywords

SAP MDGUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICECHECK_ENTITYSE18SE19ET_MESSAGEFIELDNAMEcompany code validationdynamic ASSIGN COMPONENTCL_USMD_APP_CONTEXTmessage row mapping