SAP MDG · VALIDATION DERIVATION

How do I implement MDG supplier purchasing-organization derivation for vendor replication?

Implement purchasing-org derivation in the BP_PORG entity logic by reading the MDG change request context, loading BP_HEADER and BP_PORG data, mapping company-level terms to the purchasing organization via T024E, and defaulting values only when the target fields are initial. The source pattern also shows intercompany-specific defaults such as INCOTERMS and BSTAE = '0001'.

Implement purchasing-org derivation in the BP_PORG entity logic by reading the MDG change request context, loading BP_HEADER and BP_PORG data, mapping company-level terms to the purchasing organization via T024E, and defaulting values only when the target fields are initial. The source pattern also shows intercompany-specific defaults such as INCOTERMS and BSTAE = '0001'.

Use the MDG derivation exit for the BP_PORG entity and keep the logic idempotent: read the change request context, inspect BP_HEADER and BP_PORG, then fill missing purchasing-org defaults from company-level data and customizing. The source example shows mapping company ZTERM to ZTERM_M through T024E, and for intercompany supplier cases it also defaults INCOTERMS-related fields and BSTAE where required.

Process flow

  1. Identify the target entity as BP_PORG.
  2. Read the change request context from CL_USMD_APP_CONTEXT.
  3. Load BP_HEADER and BP_PORG entity data from the MDG model.
  4. Read T024E to support purchasing-org default mapping.
  5. Loop through BP_PORG records and derive only initial fields.
  6. Default ZTERM_M or related purchasing-org terms from company-level context.
  7. Apply intercompany defaults such as INCO1, INCO2_L, and BSTAE when required.
  8. Write changed data back with the MDG write API and catch CX_USMD_WRITE_ERROR.

Referenced tables

ObjectPurpose
T024ESource customizing table used in the documented pattern to map purchasing organization terms for supplier purchasing-org derivation.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1* Purpose: Derive purchasing-org defaults for vendor replication. 2 3 METHOD derive_vendor_porg. 4 CONSTANTS: 5 lc_headr TYPE usmd_entity VALUE 'BP_HEADER', 6 lc_centrl TYPE usmd_entity VALUE 'BP_CENTRL', 7 lc_bpporg TYPE usmd_entity VALUE 'BP_PORG', 8 lc_postal TYPE usmd_entity VALUE 'AD_POSTAL', 9 lc_vengen TYPE usmd_entity VALUE 'BP_VENGEN', 10 lc_identity TYPE usmd_entity VALUE 'BP_IDNUM', 11 lc_ztecus TYPE usmd_entity VALUE 'ZBP_BUDET', 12 lc_venval TYPE usmd_entity VALUE 'BP_VENVAL', 13 lc_vencla TYPE usmd_entity VALUE 'BP_VENCLA', 14 lc_header TYPE usmd_fieldname VALUE 'BP_HEADER', 15 lc_address TYPE usmd_entity VALUE 'ADDRESS'. 16 17 DATA: 18 lo_app_context TYPE REF TO if_usmd_app_context, 19 lo_data_r TYPE REF TO data, 20 lo_singleton TYPE REF TO zcl_mdg_singleton, 21 lv_crequest TYPE usmd_crequest, 22 lt_data_entity TYPE usmd_ts_data_entity, 23 ls_data_entity TYPE usmd_sx_data_entity, 24 ls_bpheader TYPE /mdgbp/_s_bp_es_bp_header, 25 lt_bpcompny TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_compny, 26 ls_bpcompny TYPE /mdgbpx/_s_bp_es_bp_compny, 27 ls_bp_compny TYPE REF TO data, 28 lt_bp_compny TYPE REF TO data, 29 lt_bpporg TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg, 30 lt_bpporg1 TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg, 31 ls_bpporg TYPE /mdgbpx/_s_bp_es_bp_porg, 32 ls_bpporg1 TYPE /mdgbpx/_s_bp_es_bp_porg, 33 ls_bpporg2 TYPE /mdgbpx/_s_bp_es_bp_porg, 34 lt_adpostal TYPE STANDARD TABLE OF /mdgbp/_s_bp_pp_ad_postal, 35 ls_adpostal TYPE /mdgbp/_s_bp_pp_ad_postal, 36 lt_identity TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_bp_idnum, 37 ls_identity TYPE /mdgbp/_s_bp_es_bp_idnum, 38 ls_bp_centrl TYPE /mdgbp/_s_bp_pp_bp_centrl, 39 lt_bp_centrl LIKE TABLE OF ls_bp_centrl, 40 ls_bp_vengen TYPE /mdgbpx/_s_bp_pp_bp_vengen, 41 lt_bp_vengen LIKE TABLE OF ls_bp_vengen, 42 ls_bp_porg TYPE /mdgbpx/_s_bp_pp_bp_porg, 43 lt_bp_porg LIKE TABLE OF ls_bp_porg, 44 lt_ztecustom TYPE STANDARD TABLE OF zmdgbp_s_bp_pp_zbp_budet, 45 ls_ztecustom TYPE zmdgbp_s_bp_pp_zbp_budet, 46 lt_bpvenval TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_venval, 47 ls_bpvenval TYPE /mdgbpx/_s_bp_es_bp_venval, 48 lt_bpvencla TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_vencla, 49 ls_bpvencla TYPE /mdgbpx/_s_bp_es_bp_vencla, 50 lt_address TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_address, 51 lt_changed_entities TYPE usmd_t_entity, 52 wa_changed_entities LIKE LINE OF lt_changed_entities, 53 ls_address TYPE /mdgbp/_s_bp_es_address, 54 lo_att_data TYPE REF TO data, 55 lr_compny_ins TYPE REF TO data, 56 lo_att TYPE REF TO cl_abap_structdescr, 57 lo_conv_gov_api TYPE REF TO if_usmd_conv_som_gov_api, 58 lr_write_error TYPE REF TO cx_usmd_write_error, 59 lt_attribute TYPE usmd_ts_fieldname, 60 lt_filter TYPE usmd_t_entity, 61 wa_filter LIKE LINE OF lt_filter, 62 lv_land1 TYPE land1, 63 lv_ekorg TYPE ekorg, 64 lv_atinn_char TYPE string. 65 66 FIELD-SYMBOLS: <fs_t_data_bp_header> TYPE ANY TABLE, 67 <fs_t_data_bp_compny> TYPE ANY TABLE, 68 <fs_t_data_bp_porg> TYPE ANY TABLE, 69 <fs_t_data> TYPE ANY TABLE, 70 <fs_data> TYPE any, 71 <fs_t_bp_compny> TYPE ANY TABLE, 72 <fs_bp_compny> TYPE any, 73 <fs_t_company_chg> TYPE ANY TABLE, 74 <fs_compny_ins> TYPE any, 75 <fs_lt_data> TYPE SORTED TABLE, 76 <fs_ls_data> TYPE any, 77 <fs_component> TYPE abap_compdescr. 78*================================================* 79* * Begin of Changes TE552556 | RITM1803449 80 SELECT * FROM t024e INTO TABLE @DATA(lt_t024e). "#EC CI_SUBRC 81* * Begin of Changes TE552556 | RITM1803449 82 lo_app_context = cl_usmd_app_context=>get_context( ). 83 CHECK lo_app_context IS BOUND. 84 lv_crequest = lo_app_context->mv_crequest_id. 85 DATA(lv_crtype) = lo_app_context->mv_crequest_type. 86 DATA(lv_step) = lo_app_context->mv_crequest_step. 87 88 89 i_io_changed_data->get_entity_types( 90 IMPORTING 91 et_entity = lt_changed_entities ). 92 TRY. 93 CALL METHOD cl_usmd_conv_som_gov_api=>get_instance 94 EXPORTING 95 iv_model_name = 'BP' 96 RECEIVING 97 ro_so_gov_api = lo_conv_gov_api. 98 CATCH cx_usmd_gov_api . 99 ENDTRY. 100 101 CHECK lo_conv_gov_api IS BOUND. 102 i_io_model->read_entity_data_all( EXPORTING i_fieldname = 'BP_HEADER' 103 if_active = abap_false 104 i_crequest = lv_crequest 105 IMPORTING et_data_entity = lt_data_entity ). 106 CHECK lt_data_entity IS NOT INITIAL. 107 READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr 108 usmd_entity_cont = space 109 struct = 'KATTR'. 110 IF sy-subrc = 0. 111 CLEAR lo_data_r. 112 lo_data_r = ls_data_entity-r_t_data. 113 ASSIGN lo_data_r->* TO <fs_lt_data>. 114 LOOP AT <fs_lt_data> ASSIGNING <fs_ls_data>. 115 MOVE-CORRESPONDING <fs_ls_data> TO ls_bpheader. 116 ENDLOOP. 117 ENDIF. 118 119 READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr

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 supplier processing?
  • How can I derive purchasing org values for vendor replication in MDG?
  • What is the ABAP pattern for supplier purchasing-organization derivation in MDG?

Possible questions

  • How do I implement MDG supplier purchasing-organization derivation for vendor replication?
  • How do I default BP_PORG fields in SAP MDG supplier processing?
  • How can I derive purchasing org values for vendor replication in MDG?
  • What is the ABAP pattern for supplier purchasing-organization derivation in MDG?
  • Which entity and fields are typically populated in a purchasing-org derivation method?

Keywords

SAP MDGABAPsupplier replicationvendor replicationBP_PORGDERIVE_ENTITYUSMD_RULE_SERVICEIF_EX_USMD_RULE_SERVICEIF_USMD_APP_CONTEXTIF_USMD_CONV_SOM_GOV_APIT024EZTERMZTERM_MBSTAEincotermschange request