SAP MDG · VALIDATION DERIVATION

How do I implement derivation logic in SAP MDG BP using USMD_RULE_SERVICE for business data such as ZBP_BUDET?

Use BAdI USMD_RULE_SERVICE and implement IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY for defaulting/populating BP entity data. For BP business data like ZBP_BUDET, read the change request context, determine the BP grouping from BP_HEADER or IV_BU_GROUP, and derive ZZOCOMCOD for the required CR type and account-group combinations.

Use BAdI USMD_RULE_SERVICE and implement IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY for defaulting/populating BP entity data. For BP business data like ZBP_BUDET, read the change request context, determine the BP grouping from BP_HEADER or IV_BU_GROUP, and derive ZZOCOMCOD for the required CR type and account-group combinations.

Use BAdI USMD_RULE_SERVICE with IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY for BP derivation, not CHECK_ENTITY, when you need to default or populate fields. The documented BP business-data pattern reads the change-request context, resolves grouping from BP_HEADER or IV_BU_GROUP, and assigns ZZOCOMCOD for the intercompany CR type and selected account groups.

Process flow

  1. Open SE18 and display BAdI definition USMD_RULE_SERVICE.
  2. Confirm interface IF_EX_USMD_RULE_SERVICE and the relevant method DERIVE_ENTITY.
  3. Open SE19 and create the BAdI implementation.
  4. Assign or create the implementing Z* class.
  5. Implement IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY.
  6. Read the application context with CL_USMD_APP_CONTEXT=>GET_CONTEXT( ).
  7. Get the CR ID and resolve BU_GROUP from BP_HEADER or IV_BU_GROUP.
  8. Loop over CT_DATA and use ASSIGN COMPONENT for the target field ZZOCOMCOD or your own field name. Apply the derivation only for the intended CR type and grouping set. Activate the class and the BAdI implementation.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1" Annotated pattern from ZCL_MDGBP_BP_DEFAULTS=>D_BP_BUDET 2METHOD zif_te_derivation~d_bp_budet. 3 FIELD-SYMBOLS: <fs_t_data> TYPE any table, 4 <fs_data> TYPE any, 5 <fs_ktokk> TYPE any, 6 <fs_comcode> TYPE any. 7 8 DATA(lo_context) = cl_usmd_app_context=>get_context( ). 9 CHECK lo_context IS BOUND. 10 11 lo_context->get_attributes( IMPORTING ev_crequest_id = DATA(lv_crequest_id) ). 12 13 ASSIGN ct_data TO <fs_t_data>. 14 CHECK <fs_t_data> IS ASSIGNED. 15 16 " Grouping can be read from header; if missing, fallback to IV_BU_GROUP. 17 IF <fs_ktokk> IS ASSIGNED AND <fs_ktokk> IS INITIAL. 18 <fs_ktokk> = iv_bu_group. 19 ENDIF. 20 21 LOOP AT <fs_t_data> ASSIGNING <fs_data>. 22 " Commodity code derivation for intercompany create and selected groupings 23 IF id_crequest_type = zif_bp_constants=>creq_type-zsupint1. 24 IF <fs_ktokk> IS ASSIGNED AND <fs_ktokk> IS NOT INITIAL. 25 IF <fs_ktokk> = zif_bp_constants=>ktokk-z002 OR 26 <fs_ktokk> = zif_bp_constants=>ktokk-v002 OR 27 <fs_ktokk> = zif_bp_constants=>ktokk-vd02 OR 28 <fs_ktokk> = zif_bp_constants=>ktokk-z010 OR 29 <fs_ktokk> = zif_bp_constants=>ktokk-v010 OR 30 <fs_ktokk> = zif_bp_constants=>ktokk-vd10. 31 32 ASSIGN COMPONENT 'ZZOCOMCOD' OF STRUCTURE <fs_data> TO <fs_comcode>. 33 IF <fs_comcode> IS ASSIGNED. 34 <fs_comcode> = 'ZZ070000'. 35 ENDIF. 36 ENDIF. 37 ENDIF. 38 ENDIF. 39 ENDLOOP. 40ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How do I default a custom BP field in MDG derivation?
  • How do I implement IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY for BP business data?
  • How do I populate ZZOCOMCOD during BP derivation in MDG?

Possible questions

  • How do I implement derivation logic in SAP MDG BP using USMD_RULE_SERVICE for business data such as ZBP_BUDET?
  • Which BAdI method should I use for defaulting custom BP fields in MDG?
  • How do I derive ZZOCOMCOD based on CR type and grouping in BP?
  • How do I create and activate a USMD_RULE_SERVICE implementation?
  • What is the ABAP pattern for CT_DATA population in DERIVE_ENTITY?

Keywords

SAP MDGBP derivationUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICEDERIVE_ENTITYZBP_BUDETCT_DATACL_USMD_APP_CONTEXTSE18SE19BAdI implementationdynamic field assignmentBU_GROUPZZOCOMCOD