SAP MDG · VALIDATION DERIVATION

How do I implement SAP MDG BP purchasing-org derivation in IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY?

Implement the MDG rule-service BAdI in SE18/SE19, then use DERIVE_ENTITY to default BP_PORG fields only when they are initial. The source pattern shows a safe dynamic loop over CT_DATA, with ZTERM_M derived from company/payment-term context and BSTAE defaulted to 0001 for targeted account groups.

Implement the MDG rule-service BAdI in SE18/SE19, then use DERIVE_ENTITY to default BP_PORG fields only when they are initial. The source pattern shows a safe dynamic loop over CT_DATA, with ZTERM_M derived from company/payment-term context and BSTAE defaulted to 0001 for targeted account groups.

Use IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY for BP_PORG defaulting, not hard validation. The retrieved pattern shows a safe CT_DATA loop that assigns PRCH_ORG, ZTERM_M, and BSTAE dynamically and only populates initial fields, with ZTERM_M derived from company-payment-term context and BSTAE defaulted to '0001' for selected account groups.

Process flow

  1. 1. Open SE18 and display BAdI definition USMD_RULE_SERVICE.
  2. 2. Confirm the interface IF_EX_USMD_RULE_SERVICE and whether the definition is filter-dependent.
  3. 3. Create the implementation in SE19 with a Z* name.
  4. 4. Assign or create the implementing class and implement IF_EX_USMD_RULE_SERVICE.
  5. 5. Put BP_PORG defaulting into DERIVE_ENTITY, not hard validation.
  6. 6. In DERIVE_ENTITY, ASSIGN ct_data to a generic field-symbol and CHECK it is assigned.
  7. 7. Loop the generic rows and use ASSIGN COMPONENT for PRCH_ORG, ZTERM_M, and BSTAE.
  8. 8. Populate only initial target fields; do not overwrite user-entered values unless your policy requires it, or your release-specific logic demands it for the field in question. 9. Activate the class and BAdI implementation, then test the B

Referenced tables

ObjectPurpose
T024EUsed in the documented derivation concept to map purchasing organization to company context.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1" Annotated pattern from ZCL_MDGBP_BP_DEFAULTS=>D_BP_PORG 2METHOD zif_te_derivation~d_bp_porg. 3 FIELD-SYMBOLS: <fs_t_data> TYPE any table, 4 <fs_data> TYPE any, 5 <fs_ktokk> TYPE any, 6 <fs_porg> TYPE any, 7 <fs_pterm> TYPE any, 8 <fs_bstae> TYPE any. 9 10 ASSIGN ct_data TO <fs_t_data>. 11 CHECK <fs_t_data> IS ASSIGNED. 12 13 " 1) Read grouping (KTOKK) from BP_HEADER and CC payment terms from BP_COMPNY. 14 " 2) For each purchasing org row, map purchasing org -> company (T024E) 15 " and copy company payment term to purchasing term when initial. 16 17 LOOP AT <fs_t_data> ASSIGNING <fs_data>. 18 ASSIGN COMPONENT 'PRCH_ORG' OF STRUCTURE <fs_data> TO <fs_porg>. 19 ASSIGN COMPONENT 'ZTERM_M' OF STRUCTURE <fs_data> TO <fs_pterm>. 20 21 IF <fs_pterm> IS ASSIGNED AND <fs_pterm> IS INITIAL. 22 <fs_pterm> = 'DERIVED_FROM_CC_ZTERM'. 23 ENDIF. 24 25 " Confirmation control default for targeted account groups 26 ASSIGN COMPONENT 'BSTAE' OF STRUCTURE <fs_data> TO <fs_bstae>. 27 IF <fs_bstae> IS ASSIGNED AND <fs_bstae> IS INITIAL. 28 <fs_bstae> = '0001'. 29 ENDIF. 30 ENDLOOP. 31ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How do I default BP_PORG fields in SAP MDG?
  • How do I implement purchasing-org derivation in MDG Business Partner?
  • How do I use DERIVE_ENTITY for BP purchasing organization defaults?

Possible questions

  • How do I implement SAP MDG BP purchasing-org derivation in IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY?
  • How do I default ZTERM_M and BSTAE for BP_PORG in MDG?
  • What is the recommended BAdI pattern for BP_PORG derivation in MDG?
  • How do I set up a BAdI implementation from SE18/SE19 for MDG derivation?
  • How do I debug CT_DATA population in DERIVE_ENTITY?

Keywords

SAP MDGBusiness PartnerBP_PORGDERIVE_ENTITYIF_EX_USMD_RULE_SERVICEUSMD_RULE_SERVICESE18SE19CT_DATAT024EZTERM_MBSTAE