SAP MDG · VALIDATION DERIVATION

How do I implement SAP MDG USMD_RULE_SERVICE derivation for Business Partner entities in DERIVE_ENTITY?

Implement the BAdI `USMD_RULE_SERVICE` in SE19, assign an ABAP class that implements `IF_EX_USMD_RULE_SERVICE`, and use `DERIVE_ENTITY` to default only initial fields in `CT_DATA` based on change-request context, entity type, and customizing. For BP scenarios, the observed pattern is an orchestrator that reads CR details once, calls entity-specific derivation methods, merges `ET_MESSAGE`, and then applies BP company defaults from custom tables when `ID_ENTITYTYPE = 'BP_COMPNY'`.

Implement the BAdI `USMD_RULE_SERVICE` in SE19, assign an ABAP class that implements `IF_EX_USMD_RULE_SERVICE`, and use `DERIVE_ENTITY` to default only initial fields in `CT_DATA` based on change-request context, entity type, and customizing. For BP scenarios, the observed pattern is an orchestrator that reads CR details once, calls entity-specific derivation methods, merges `ET_MESSAGE`, and then applies BP company defaults from custom tables when `ID_ENTITYTYPE = 'BP_COMPNY'`.

Implement `USMD_RULE_SERVICE` in SE18/SE19, assign an ABAP class that implements `IF_EX_USMD_RULE_SERVICE`, and use `DERIVE_ENTITY` for defaulting/enrichment rather than hard validation. In the observed BP solution, the method clears active context for `BP_HEADER`, reads the CR ID and CR type once, derives shared BP defaults through `ZCL_MDGBP_BP_DEFAULTS`, and then applies BP company-specific logic when `ID_ENTITYTYPE = 'BP_COMPNY'`.

Process flow

  1. Open SE18 and display BAdI definition `USMD_RULE_SERVICE`.
  2. Create the implementation in SE19 and assign a Z* implementing class.
  3. Implement `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` in the class.
  4. Read CR ID, CR type, and grouping once at the top of the method.
  5. Call entity-specific derivation routines and merge their `ET_MESSAGE` tables.
  6. For `BP_COMPNY`, derive fields from `T001` and `ZMDG_SUP_CC_DERV` only when target fields are initial.
  7. Activate the class and BAdI implementation.
  8. Test with the relevant MDG change request and verify field population and messages.

Referenced tables

ObjectPurpose
T001Standard company-code table used to read `LAND1` for domestic versus foreign derivation.
ZMDG_SUP_CC_DERVCustomizing table used to determine BP company-code defaults such as `AKONT` and `ZWELS` based on business group, company code, and foreign/domestic logic.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1METHOD if_ex_usmd_rule_service~derive_entity. 2 IF id_entitytype = 'BP_HEADER'. 3 CLEAR zcl_mdg_suppl_rule_context=>gt_active_data. 4 ENDIF. 5 6 DATA: lt_message TYPE usmd_t_message, 7 lv_bu_group TYPE bu_group. 8 9 zcl_mdg_suppl_utility=>get_cr_details( 10 IMPORTING 11 ev_crequest_id = DATA(lv_crequest_id) 12 ev_crequest_type = DATA(lv_crequest_type) ). 13 14 zcl_mdg_chg_suppl_utility=>cr_has_changes = lv_crequest_id. 15 16 CALL METHOD zcl_mdg_suppl_utility=>get_single_attribute 17 EXPORTING 18 im_crnumber = lv_crequest_id 19 im_field = 'BU_GROUP' 20 IMPORTING 21 ex_value = DATA(lv_grouping). 22 IF lv_grouping IS NOT INITIAL. 23 lv_bu_group = lv_grouping. 24 ENDIF. 25 26 CALL METHOD zcl_mdgbp_bp_defaults=>zif_te_derivation~d_bp_centrl 27 EXPORTING 28 io_model = io_model 29 id_edition = id_edition 30 id_entitytype = id_entitytype 31 id_crequest_type = lv_crequest_type 32 id_crequest_id = lv_crequest_id 33 IMPORTING 34 et_message = lt_message 35 CHANGING 36 ct_data = ct_data. 37 APPEND LINES OF lt_message TO et_message. 38 CLEAR lt_message. 39 40 CALL METHOD zcl_mdgbp_bp_defaults=>zif_te_derivation~d_bp_porg 41 EXPORTING 42 io_model = io_model 43 id_edition = id_edition 44 id_entitytype = id_entitytype 45 id_crequest_type = lv_crequest_type 46 id_crequest_id = lv_crequest_id 47 IMPORTING 48 et_message = lt_message 49 CHANGING 50 ct_data = ct_data. 51 APPEND LINES OF lt_message TO et_message. 52 CLEAR lt_message. 53 54 CALL METHOD zcl_mdgbp_bp_defaults=>zif_te_derivation~d_ad_postal 55 EXPORTING 56 io_model = io_model 57 id_edition = id_edition 58 id_entitytype = id_entitytype 59 id_crequest_type = lv_crequest_type 60 id_crequest_id = lv_crequest_id 61 IMPORTING 62 et_message = lt_message 63 CHANGING 64 ct_data = ct_data. 65 APPEND LINES OF lt_message TO et_message. 66 CLEAR lt_message. 67 68 CALL METHOD zcl_mdgbp_bp_defaults=>zif_te_derivation~d_bp_budet 69 EXPORTING 70 io_model = io_model 71 id_edition = id_edition 72 id_entitytype = id_entitytype 73 id_crequest_type = lv_crequest_type 74 id_crequest_id = lv_crequest_id 75 iv_bu_group = lv_bu_group 76 IMPORTING 77 et_message = lt_message 78 CHANGING 79 ct_data = ct_data. 80 APPEND LINES OF lt_message TO et_message. 81 CLEAR lt_message. 82 83 IF id_entitytype = 'BP_COMPNY'. 84 CALL METHOD zcl_mdg_suppl_utility=>get_single_attribute 85 EXPORTING 86 im_crnumber = lv_crequest_id 87 im_field = 'REF_POSTA' 88 IMPORTING 89 ex_value = DATA(lv_land1). 90 91 IF lv_grouping IS NOT INITIAL. 92 lv_bu_group = lv_grouping. 93 ENDIF. 94 95 LOOP AT ct_data ASSIGNING FIELD-SYMBOL(<fs_data>). 96 ASSIGN COMPONENT 'COMPANY' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_comp>). 97 IF <fs_comp> IS ASSIGNED AND <fs_comp> IS NOT INITIAL AND lv_bu_group IS NOT INITIAL. 98 SELECT SINGLE land1 FROM t001 INTO @DATA(lv_comp_land1) WHERE bukrs = @<fs_comp>. 99 IF sy-subrc IS INITIAL AND lv_comp_land1 <> lv_land1. 100 DATA(lv_foreign_vend) = 'F'. 101 ELSE. 102 lv_foreign_vend = 'D'. 103 ENDIF. 104 105 SELECT * INTO TABLE @DATA(lt_comp_derive) 106 FROM zmdg_sup_cc_derv 107 WHERE ( foreign_vend = @lv_foreign_vend OR foreign_vend = 'A' ) 108 AND ( ktokk = @lv_bu_group OR ktokk = '*' OR ktokk = '' ) 109 AND bukrs = @<fs_comp> 110 AND disable NE 'X'. 111 112 IF sy-subrc = 0. 113 READ TABLE lt_comp_derive INTO DATA(ls_comp_derive) WITH KEY foreign_vend = lv_foreign_vend. 114 READ TABLE lt_comp_derive INTO DATA(ls_comp_derive1) WITH KEY foreign_vend = 'A'. 115 116 IF lv_bu_group <> 'Z010' AND lv_bu_group <> 'Z002' AND lv_bu_group <> 'Z014'. 117 ASSIGN COMPONENT 'REF_BPCMP' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_recon>). 118 IF <fs_recon> IS ASSIGNED AND <fs_recon> IS INITIAL. 119 <fs_recon> = ls_comp_derive-akont. 120 ENDIF.

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

Related questions and keywords

Alternative questions

  • How do I build a BP derivation BAdI in MDG using IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY?
  • How do I populate BP defaults in SAP MDG using DERIVE_ENTITY?
  • How do I implement context-based Business Partner derivation in MDG?

Possible questions

  • How do I implement SAP MDG USMD_RULE_SERVICE derivation for Business Partner entities in DERIVE_ENTITY?
  • What is the BAdI implementation flow from SE18 and SE19 for USMD_RULE_SERVICE?
  • How do I derive BP company code fields, purchasing data, and address defaults in MDG?
  • How do I pass messages from DERIVE_ENTITY back to the MDG framework?
  • How do I use customizing and CR context for MDG derivation?

Keywords

SAP MDGUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICEDERIVE_ENTITYBusiness PartnerBP_HEADERBP_COMPNYBP_CENTRLBP_PORGAD_POSTALZBP_BUDETSE18SE19CT_DATAET_MESSAGEchange requestcustomizing-driven derivation