SAP MDG · VALIDATION DERIVATION
How do I derive purchasing-organization payment terms (ZTERM_M) for vendor replication in SAP MDG Business Partner?
Use MDG derivation to read the current change request, map purchasing organization to company code via T024E, read company-code payment terms ZTERM from BP_COMPNY, and write the value to BP_PORG-ZTERM_M only when it is initial. The supplied implementation pattern does exactly this in ABAP.
Use MDG derivation to read the current change request, map purchasing organization to company code via T024E, read company-code payment terms ZTERM from BP_COMPNY, and write the value to BP_PORG-ZTERM_M only when it is initial. The supplied implementation pattern does exactly this in ABAP.
Use the MDG change-request context to read BP_COMPNY and BP_PORG, map EKORG to BUKRS via T024E, take the company-code ZTERM, and update BP_PORG-ZTERM_M only for rows where it is still initial. The supplied ABAP pattern reads the active change request, compares changed versus initial entity data, and persists only the purchasing-org rows that need the default.
Process flow
- Get the active MDG change request and confirm the application context is bound.
- Read BP_COMPNY and BP_PORG data for the current change request.
- Read T024E to map EKORG to BUKRS.
- Match each BP_PORG row to the corresponding company-code row.
- Copy BP_COMPNY-ZTERM to BP_PORG-ZTERM_M only if ZTERM_M is initial.
- Write back only the ZTERM_M attribute for the changed BP_PORG rows.
- Handle CX_USMD_WRITE_ERROR and retest the change request in MDG.
Referenced tables
| Object | Purpose |
|---|---|
T024E | Purchasing organization to company code mapping used to derive BUKRS from EKORG. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1* Purpose: Derive purchasing-org payment terms for vendor replication.
2
3 METHOD derive_vendor_porg_zterm.
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_pp_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_pp_bp_porg,
30 lt_bpporg_chn TYPE STANDARD TABLE OF /mdgbpx/_s_bp_pp_bp_porg,
31 lt_bpporg1 TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg,
32 ls_bpporg TYPE /mdgbpx/_s_bp_es_bp_porg,
33 ls_bpporg1 TYPE /mdgbpx/_s_bp_es_bp_porg,
34 ls_bpporg2 TYPE /mdgbpx/_s_bp_es_bp_porg,
35 lt_adpostal TYPE STANDARD TABLE OF /mdgbp/_s_bp_pp_ad_postal,
36 ls_adpostal TYPE /mdgbp/_s_bp_pp_ad_postal,
37 lt_identity TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_bp_idnum,
38 ls_identity TYPE /mdgbp/_s_bp_es_bp_idnum,
39 ls_bp_centrl TYPE /mdgbp/_s_bp_pp_bp_centrl,
40 lt_bp_centrl LIKE TABLE OF ls_bp_centrl,
41 ls_bp_vengen TYPE /mdgbpx/_s_bp_pp_bp_vengen,
42 lt_bp_vengen LIKE TABLE OF ls_bp_vengen,
43 ls_bp_porg TYPE /mdgbpx/_s_bp_pp_bp_porg,
44 lt_bp_porg LIKE TABLE OF ls_bp_porg,
45 lt_ztecustom TYPE STANDARD TABLE OF zmdgbp_s_bp_pp_zbp_budet,
46 ls_ztecustom TYPE zmdgbp_s_bp_pp_zbp_budet,
47 lt_bpvenval TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_venval,
48 ls_bpvenval TYPE /mdgbpx/_s_bp_es_bp_venval,
49 lt_bpvencla TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_vencla,
50 ls_bpvencla TYPE /mdgbpx/_s_bp_es_bp_vencla,
51 lt_address TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_address,
52 lt_changed_entities TYPE usmd_t_entity,
53 wa_changed_entities LIKE LINE OF lt_changed_entities,
54 ls_address TYPE /mdgbp/_s_bp_es_address,
55 lo_att_data TYPE REF TO data,
56 lr_compny_ins TYPE REF TO data,
57 lo_att TYPE REF TO cl_abap_structdescr,
58 lo_conv_gov_api TYPE REF TO if_usmd_conv_som_gov_api,
59 lr_write_error TYPE REF TO cx_usmd_write_error,
60 lt_attribute TYPE usmd_ts_fieldname,
61 ls_attribute TYPE usmd_fieldname,
62 lt_filter TYPE usmd_t_entity,
63 wa_filter LIKE LINE OF lt_filter,
64 lv_land1 TYPE land1,
65 lv_ekorg TYPE ekorg,
66 lv_atinn_char TYPE string.
67
68 FIELD-SYMBOLS: <fs_t_data_bp_header> TYPE ANY TABLE,
69 <fs_t_data_bp_compny> TYPE ANY TABLE,
70 <fs_t_data_bp_porg> TYPE ANY TABLE,
71 <fs_t_data_bp_porg_ina> TYPE ANY TABLE,
72 <fs_t_data_bp_porg_upd> TYPE ANY TABLE,
73 <fs_t_data> TYPE ANY TABLE,
74 <fs_data> TYPE any,
75 <fs_t_bp_compny> TYPE ANY TABLE,
76 <fs_bp_compny> TYPE any,
77 <fs_t_company_chg> TYPE ANY TABLE,
78 <fs_t_company_inA> TYPE ANY TABLE,
79 <lfs_t_porg_chg> TYPE ANY TABLE,
80 <fs_compny_ins> TYPE any,
81 <fs_lt_data> TYPE SORTED TABLE,
82 <fs_ls_data> TYPE any,
83 <fs_component> TYPE abap_compdescr.
84*================================================*
85* Begin of changes Pavani
86 SELECT * FROM t024e INTO TABLE @DATA(lt_t024e). "#EC CI_SUBRC
87* End of changes Pavani
88 lo_app_context = cl_usmd_app_context=>get_context( ).
89 CHECK lo_app_context IS BOUND.
90 lv_crequest = lo_app_context->mv_crequest_id.
91 DATA(lv_crtype) = lo_app_context->mv_crequest_type.
92 DATA(lv_step) = lo_app_context->mv_crequest_step.
93
94
95* i_io_changed_data->get_entity_types(
96* IMPORTING
97* et_entity = lt_changed_entities ).
98 TRY.
99 CALL METHOD cl_usmd_conv_som_gov_api=>get_instance
100 EXPORTING
101 iv_model_name = 'BP'
102 RECEIVING
103 ro_so_gov_api = lo_conv_gov_api.
104 CATCH cx_usmd_gov_api .
105 ENDTRY.
106
107 CHECK lo_conv_gov_api IS BOUND.
108 i_io_model->read_entity_data_all( EXPORTING i_fieldname = 'BP_HEADER'
109 if_active = abap_false
110 i_crequest = lv_crequest
111 IMPORTING et_data_entity = lt_data_entity ).
112 CHECK lt_data_entity IS NOT INITIAL.
113* READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr
114* usmd_entity_cont = space
115* struct = 'KATTR'.
116* IF sy-subrc = 0.
117* CLEThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I default ZTERM_M in BP_PORG from company-code ZTERM in SAP MDG?
- What is the ABAP logic to copy vendor company-code payment terms into purchasing-org data in MDG?
- How do I implement MDG derivation for BP_PORG payment terms based on T024E and BP_COMPNY?
Possible questions
- How do I derive purchasing-organization payment terms (ZTERM_M) for vendor replication in SAP MDG Business Partner?
- How can I default ZTERM_M in BP_PORG from company-code ZTERM in SAP MDG?
- What is the ABAP logic to copy vendor company-code payment terms into purchasing-org data in MDG?
- How do I implement MDG derivation for BP_PORG payment terms based on T024E and BP_COMPNY?
- How do I test and debug BP_PORG derivation in an MDG change request?