SAP MDG · VALIDATION DERIVATION

How do I implement SAP MDG rule-service derivation in DERIVE_ENTITY for Business Partner data?

Implement the USMD_RULE_SERVICE BAdI in SE18/SE19, then use IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY to read the CR context, resolve BU_GROUP, and call the BP defaulting submethods in a fixed order: D_BP_CENTRL, D_BP_PORG, D_AD_POSTAL, and D_BP_BUDET. The pattern is defaulting/enrichment only: populate CT_DATA, append ET_MESSAGE from each submethod, and keep hard validation in CHECK_ENTITY instead.

Implement the USMD_RULE_SERVICE BAdI in SE18/SE19, then use IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY to read the CR context, resolve BU_GROUP, and call the BP defaulting submethods in a fixed order: D_BP_CENTRL, D_BP_PORG, D_AD_POSTAL, and D_BP_BUDET. The pattern is defaulting/enrichment only: populate CT_DATA, append ET_MESSAGE from each submethod, and keep hard validation in CHECK_ENTITY instead.

Implement the MDG rule-service BAdI in SE18/SE19 and keep `DERIVE_ENTITY` focused on deterministic defaulting. In the BP example, the method clears the shared header context for `BP_HEADER`, reads the change request ID/type, derives `BU_GROUP`, then calls the BP-specific derivation routines in order and appends their messages to `ET_MESSAGE`.

Process flow

  1. Open SE18 and display BAdI definition `USMD_RULE_SERVICE` to confirm interface `IF_EX_USMD_RULE_SERVICE` and whether filters apply.
  2. Create or open the implementation in SE19, assign the implementing class, and activate it.
  3. Implement `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` as an orchestrator that reads CR context once and delegates to entity-specific derivation routines.
  4. Read the change request ID and type using your BP utility method, then derive `BU_GROUP` from CR attributes if needed.
  5. Call the BP derivation methods in the observed order: `D_BP_CENTRL`, `D_BP_PORG`, `D_AD_POSTAL`, `D_BP_BUDET`.
  6. Append each helper’s `ET_MESSAGE` lines into the BAdI `ET_MESSAGE`.
  7. Keep any hard checks, field errors, or blocking rules in `CHECK_ENTITY`, not in `DERIVE_ENTITY`.
  8. Test the scenario with breakpoints on the BAdI method entry and confirm `ID_ENTITYTYPE`, `CT_DATA`, CR type, and messages.

Referenced tables

ObjectPurpose
ZMDG_SUP_CC_DERVReferenced in the derivation knowledge as a customizing-driven source for company-code defaulting logic.

ILLUSTRATIVE ABAP SAMPLE

Source-based orchestrator pattern for `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY`

This sample is adapted from the retrieved BP derivation pattern. It keeps `DERIVE_ENTITY` focused on context setup and delegation, and appends helper messages back to `ET_MESSAGE`.

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 lv_crequest_id TYPE usmd_crequest, 9 lv_crequest_type TYPE usmd_crequest_type. 10 11 zcl_mdg_suppl_utility=>get_cr_details( 12 IMPORTING 13 ev_crequest_id = lv_crequest_id 14 ev_crequest_type = lv_crequest_type ). 15 16 zcl_mdg_chg_suppl_utility=>cr_has_changes = lv_crequest_id. 17 18 zcl_mdg_suppl_utility=>get_single_attribute( 19 EXPORTING 20 im_crnumber = lv_crequest_id 21 im_field = 'BU_GROUP' 22 IMPORTING 23 ex_value = DATA(lv_grouping) ). 24 IF lv_grouping IS NOT INITIAL. 25 lv_bu_group = lv_grouping. 26 ENDIF. 27 28 zcl_mdgbp_bp_defaults=>zif_te_derivation~d_bp_centrl( 29 EXPORTING 30 io_model = io_model 31 id_edition = id_edition 32 id_entitytype = id_entitytype 33 id_crequest_type = lv_crequest_type 34 id_crequest_id = lv_crequest_id 35 IMPORTING 36 et_message = lt_message 37 CHANGING 38 ct_data = ct_data ). 39 APPEND LINES OF lt_message TO et_message. 40 CLEAR lt_message. 41 42 zcl_mdgbp_bp_defaults=>zif_te_derivation~d_bp_porg( 43 EXPORTING 44 io_model = io_model 45 id_edition = id_edition 46 id_entitytype = id_entitytype 47 id_crequest_type = lv_crequest_type 48 id_crequest_id = lv_crequest_id 49 IMPORTING 50 et_message = lt_message 51 CHANGING 52 ct_data = ct_data ). 53 APPEND LINES OF lt_message TO et_message. 54 CLEAR lt_message. 55 56 zcl_mdgbp_bp_defaults=>zif_te_derivation~d_ad_postal( 57 EXPORTING 58 io_model = io_model 59 id_edition = id_edition 60 id_entitytype = id_entitytype 61 id_crequest_type = lv_crequest_type 62 id_crequest_id = lv_crequest_id 63 IMPORTING 64 et_message = lt_message 65 CHANGING 66 ct_data = ct_data ). 67 APPEND LINES OF lt_message TO et_message. 68 CLEAR lt_message. 69 70 zcl_mdgbp_bp_defaults=>zif_te_derivation~d_bp_budet( 71 EXPORTING 72 io_model = io_model 73 id_edition = id_edition 74 id_entitytype = id_entitytype 75 id_crequest_type = lv_crequest_type 76 id_crequest_id = lv_crequest_id 77 iv_bu_group = lv_bu_group 78 IMPORTING 79 et_message = lt_message 80 CHANGING 81 ct_data = ct_data ). 82 APPEND LINES OF lt_message TO et_message. 83 CLEAR lt_message. 84 85 " Additional in-method BP_COMPNY derivation branch can run here. 86ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How do I default BP fields in USMD_RULE_SERVICE DERIVE_ENTITY?
  • What is the correct BAdI implementation pattern for MDG BP derivation?
  • How do I orchestrate BP_CENTRL, BP_PORG, AD_POSTAL, and BP_BUDET derivations in SAP MDG?

Possible questions

  • How do I implement SAP MDG rule-service derivation in DERIVE_ENTITY for Business Partner data?
  • How do I set up and code the USMD_RULE_SERVICE BAdI for BP defaulting?
  • What is the standard pattern for MDG BP derivation logic in DERIVE_ENTITY?
  • How do I call BP defaulting submethods from IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY?
  • How do I debug why CT_DATA is not being populated in MDG derivation?

Keywords

SAP MDGBusiness PartnerUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICEDERIVE_ENTITYSE18SE19CT_DATAET_MESSAGEBP_HEADERBP_CENTRLBP_PORGAD_POSTALBP_BUDETZCL_MDGBP_BP_VALIDATIONZCL_MDGBP_BP_DEFAULTS