SAP MDG · VALIDATION DERIVATION

How do I implement SAP MDG address/postal derivation for a change request, including CR-step-dependent defaults and safe field updates?

Implement address/postal derivation as deterministic defaulting in the MDG derivation hook: read the change-request context once, loop over CT_DATA, and fill only initial fields with `ASSIGN COMPONENT ...` checks. In the source pattern, intercompany create defaults `LANGU_COM = 'E'`, and requester-step `'00'` with country `BR` defaults `RFE_POST = 'SP'` and `POST_COD1 = '01001-000'`.

Implement address/postal derivation as deterministic defaulting in the MDG derivation hook: read the change-request context once, loop over CT_DATA, and fill only initial fields with `ASSIGN COMPONENT ...` checks. In the source pattern, intercompany create defaults `LANGU_COM = 'E'`, and requester-step `'00'` with country `BR` defaults `RFE_POST = 'SP'` and `POST_COD1 = '01001-000'`.

Use SAP MDG derivation, not hard validation, for postal defaults. The documented pattern reads the change-request context once with `CL_USMD_APP_CONTEXT`, loops over `CT_DATA`, and writes only to initial fields via `ASSIGN COMPONENT ...` safeguards. For the AD_POSTAL example, intercompany create defaults the communication language to English, and requester-step Brazil records get seed values for region and postal code.

Process flow

  1. Open SE18 and inspect the BAdI definition and interface.
  2. Create the implementation in SE19 and assign a Z* class.
  3. Implement the derivation method for the postal entity.
  4. Read the MDG app context once with CL_USMD_APP_CONTEXT.
  5. Loop over CT_DATA and use ASSIGN COMPONENT checks before writing.
  6. Default only initial fields and keep the logic idempotent.
  7. Activate class, implementation, and dependent objects.
  8. Trigger the MDG scenario and debug the derivation call.

Referenced tables

ObjectPurpose
ZMDG_SUP_CC_DERVReferenced in the derivation knowledge as a customizing table for company-related defaulting in the broader MDG derivation design.

ILLUSTRATIVE ABAP SAMPLE

Annotated ABAP pattern for AD_POSTAL derivation defaults

Source-supported pattern from the retrieved TE derivation method. It demonstrates context read, safe dynamic assignment, and initial-field defaulting.

1METHOD zif_te_derivation~d_ad_postal. 2 FIELD-SYMBOLS: <fs_t_data> TYPE any table, 3 <fs_data> TYPE any, 4 <fs_langu> TYPE any, 5 <fs_country> TYPE any, 6 <fs_region> TYPE any, 7 <fs_postcode> TYPE any. 8 9 DATA(lo_context) = cl_usmd_app_context=>get_context( ). 10 CHECK lo_context IS BOUND. 11 12 lo_context->get_attributes( 13 IMPORTING 14 ev_crequest_id = DATA(lv_crequest_id) 15 ev_crequest_step = DATA(lv_crequest_step) ). 16 17 ASSIGN ct_data TO <fs_t_data>. 18 CHECK <fs_t_data> IS ASSIGNED. 19 20 LOOP AT <fs_t_data> ASSIGNING <fs_data>. 21 " Rule A: Intercompany create defaults language to English 22 IF id_crequest_type = zif_bp_constants=>creq_type-zsupint1. 23 ASSIGN COMPONENT 'LANGU_COM' OF STRUCTURE <fs_data> TO <fs_langu>. 24 IF <fs_langu> IS ASSIGNED AND <fs_langu> IS INITIAL. 25 <fs_langu> = 'E'. 26 ENDIF. 27 ENDIF. 28 29 " Rule B: requester-step Brazil seed defaults 30 IF lv_crequest_step = '00'. 31 ASSIGN COMPONENT 'REF_POSTA' OF STRUCTURE <fs_data> TO <fs_country>. 32 IF <fs_country> IS ASSIGNED AND <fs_country> = 'BR'. 33 ASSIGN COMPONENT 'RFE_POST' OF STRUCTURE <fs_data> TO <fs_region>. 34 IF <fs_region> IS ASSIGNED. 35 <fs_region> = 'SP'. 36 ENDIF. 37 38 ASSIGN COMPONENT 'POST_COD1' OF STRUCTURE <fs_data> TO <fs_postcode>. 39 IF <fs_postcode> IS ASSIGNED. 40 <fs_postcode> = '01001-000'. 41 ENDIF. 42 ENDIF. 43 ENDIF. 44 ENDLOOP. 45ENDMETHOD.

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

Related questions and keywords

Alternative questions

  • How do I default postal fields in SAP MDG based on CR type and step?
  • What is the ABAP pattern for D_AD_POSTAL in SAP MDG?
  • How do I implement address derivation logic in MDG without overwriting user-entered values?

Possible questions

  • How do I implement SAP MDG address/postal derivation in IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY or a TE derivation method?
  • How do I default postal fields in SAP MDG based on CR type and step?
  • What is the ABAP pattern for D_AD_POSTAL in SAP MDG?
  • How do I implement address derivation logic in MDG without overwriting user-entered values?
  • How do I test and debug MDG derivation for AD_POSTAL?

Keywords

SAP MDGUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICEDERIVE_ENTITYAD_POSTALCL_USMD_APP_CONTEXTchange requestCR stepdefaultingdynamic ASSIGN COMPONENT