SAP MDG · VALIDATION DERIVATION

How do I implement a company-entity derivation in SAP MDG BAdI USMD_RULE_SERVICE for BP_COMPNY?

Implement the `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` method in a `USMD_RULE_SERVICE` BAdI implementation, gate it for `BP_COMPNY`, read the change-request context once, and fill only initial fields in `CT_DATA`. The provided company-pattern sample shows how to default `REF_BPCMP` and `ZWELS` safely.

Implement the `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` method in a `USMD_RULE_SERVICE` BAdI implementation, gate it for `BP_COMPNY`, read the change-request context once, and fill only initial fields in `CT_DATA`. The provided company-pattern sample shows how to default `REF_BPCMP` and `ZWELS` safely.

For BP company-level derivation in SAP MDG, use BAdI `USMD_RULE_SERVICE` and implement `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY`. The company-pattern sample shows the safe approach: read the CR context once, gate by `BP_COMPNY`, loop `CT_DATA`, and populate only empty target fields like `REF_BPCMP` and `ZWELS` so user-entered values are preserved.

Process flow

  1. Open SE18 and display BAdI definition USMD_RULE_SERVICE.
  2. Confirm the interface name IF_EX_USMD_RULE_SERVICE and whether filters are required.
  3. Open SE19 and create the BAdI implementation.
  4. Assign or create the implementing class and implement IF_BADI_INTERFACE and IF_EX_USMD_RULE_SERVICE.
  5. Implement DERIVE_ENTITY, gate by ID_ENTITYTYPE = 'BP_COMPNY', and default only initial fields in CT_DATA.
  6. Activate the class first, then the BAdI implementation.
  7. Test with empty and prefilled fields, and set breakpoints to verify CT_DATA changes.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1METHOD if_ex_usmd_rule_service~derive_entity. 2 DATA: lv_crequest_id TYPE usmd_crequest, 3 lv_crequest_type TYPE usmd_crequest_type, 4 lv_bu_group TYPE bu_group, 5 lv_land1 TYPE land1. 6 7 FIELD-SYMBOLS: <ls_data> TYPE any, 8 <lv_company> TYPE any, 9 <lv_recon> TYPE any, 10 <lv_paymeth> TYPE any. 11 12 zcl_mdg_suppl_utility=>get_cr_details( 13 IMPORTING 14 ev_crequest_id = lv_crequest_id 15 ev_crequest_type = lv_crequest_type ). 16 17 zcl_mdg_suppl_utility=>get_single_attribute( 18 EXPORTING 19 im_crnumber = lv_crequest_id 20 im_field = 'BU_GROUP' 21 IMPORTING 22 ex_value = lv_bu_group ). 23 24 CHECK id_entitytype = 'BP_COMPNY'. 25 26 LOOP AT ct_data ASSIGNING <ls_data>. 27 ASSIGN COMPONENT 'COMPANY' OF STRUCTURE <ls_data> TO <lv_company>. 28 CHECK <lv_company> IS ASSIGNED AND <lv_company> IS NOT INITIAL. 29 30 ASSIGN COMPONENT 'REF_BPCMP' OF STRUCTURE <ls_data> TO <lv_recon>. 31 IF <lv_recon> IS ASSIGNED AND <lv_recon> IS INITIAL. 32 " Example from customizing lookup result 33 <lv_recon> = 'DERIVED_AKONT'. 34 ENDIF. 35 36 ASSIGN COMPONENT 'ZWELS' OF STRUCTURE <ls_data> TO <lv_paymeth>. 37 IF <lv_paymeth> IS ASSIGNED AND <lv_paymeth> IS INITIAL. 38 <lv_paymeth> = 'T'. 39 ENDIF. 40 ENDLOOP. 41ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How do I default BP company data in USMD_RULE_SERVICE DERIVE_ENTITY?
  • How do I implement derive logic for BP_COMPNY in SAP MDG?
  • How do I configure and code a derivation for company-level BP fields in MDG?

Possible questions

  • How do I implement a company-entity derivation in SAP MDG BAdI USMD_RULE_SERVICE?
  • How do I add default values for BP company data in DERIVE_ENTITY?
  • Which BAdI and method are used for BP_COMPNY derivation in MDG?
  • How do I prevent overwriting user-entered values during MDG derivation?
  • How do I trace why BP_COMPNY derivation is not firing?

Keywords

SAP MDGUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICEDERIVE_ENTITYBP_COMPNYSE18SE19CL_USMD_APP_CONTEXTCT_DATAdynamic ASSIGNdefaultingderivation