SAP MDG · VALIDATION DERIVATION
How do I implement BP vendor valuation derivation in SAP MDG?
Use the BP vendor valuation derivation hook to read the current change request, inspect BP header and address data, then default company-code fields only when they are initial. The source pattern derives reconciliation account, terms of payment, sort key, and tolerance group based on account group and supplier country logic.
Use the BP vendor valuation derivation hook to read the current change request, inspect BP header and address data, then default company-code fields only when they are initial. The source pattern derives reconciliation account, terms of payment, sort key, and tolerance group based on account group and supplier country logic.
The source pattern for `ZIF_TE_DERIVATION~D_BP_VENVAL` shows a BP vendor valuation derivation hook that reads the current change request, loads `BP_HEADER` and `AD_POSTAL`, and then fills company-code defaults only when the target fields are still initial. In the documented logic, account group drives special-case defaults, while the company code country and supplier country control the reconciliation account.
Process flow
- 1. Get the current MDG application context with `CL_USMD_APP_CONTEXT=>GET_CONTEXT( )` and read `EV_CREQUEST_ID`.
- 2. Read the change request using `CL_USMD_CREQUEST_API=>GET_INSTANCE( )` and `READ_CREQUEST( )`.
- 3. Use `io_model->READ_ENTITY_DATA_ALL` to load `BP_HEADER` and `AD_POSTAL` for the current change request.
- 4. Assign the needed header values, especially `BU_GROUP` and the supplier/BP identifier.
- 5. Loop over the company-code data in `ct_data` and assign the target fields dynamically.
- 6. Derive reconciliation account, payment term, sort key, and tolerance group only if the fields are initial.
- 7. Apply account-group-specific logic for `Z002` and `Z010`, and country-based logic for the remaining cases.
- 8. Leave existing user input unchanged and return the enriched data to the framework.
Referenced tables
| Object | Purpose |
|---|---|
T001 | Used in the sample to read company-code country (`LAND1`) for reconciliation-account derivation. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1* Purpose: Interface hook for BP vendor valuation derivation.
2
3 METHOD zif_te_derivation~d_bp_venval.
4 DATA:lt_filter TYPE usmd_t_entity,
5 wa_filter LIKE LINE OF lt_filter,
6* lo_data_ca_map TYPE REF TO zcl_fi_global_utility,
7 ls_ca_map TYPE zca_map,
8 lt_ca_map TYPE zca_map_tt,
9 lv_togru TYPE togru.
10 CONSTANTS:
11 lc_header TYPE usmd_fieldname VALUE 'BP_HEADER',
12 lc_togru TYPE char40 VALUE 'TOGRU'.
13 FIELD-SYMBOLS: <fs_t_data_ad_postal> TYPE ANY TABLE,
14 <fs_t_data_bp_header> TYPE ANY TABLE,
15 <fs_t_data> TYPE ANY TABLE,
16 <fs_data> TYPE any,
17 <fs_company> TYPE any,
18 <fs_authgrp> TYPE any,
19 <fs_sortkey> TYPE any,
20 <fs_tol_grp> TYPE any,
21 <fs_reprf> TYPE any,
22 <fs_uzawe> TYPE any,
23 <fs_zahls> TYPE any,
24 <fs_val_adj> TYPE any.
25
26
27 DATA :
28 lv_partner TYPE bu_partner.
29
30 DATA(lo_context) = cl_usmd_app_context=>get_context( ).
31 CHECK lo_context IS BOUND.
32
33 lo_context->get_attributes( IMPORTING ev_crequest_id = DATA(lv_crequest_id) ).
34
35 cl_usmd_crequest_api=>get_instance(
36 EXPORTING
37 iv_crequest = lv_crequest_id
38 iv_model_name = zif_bp_constants=>data_model-bp " Data Model
39 IMPORTING
40 et_message = et_message " Messages
41 re_inst_crequest_api = DATA(lo_crequest) " Change Request API Interface
42 ).
43 lo_crequest->read_crequest(
44 IMPORTING
45 es_crequest = DATA(ls_crequest) " Change Request
46 ).
47
48 ASSIGN ct_data TO <fs_t_data>.
49
50* Get Header Details
51 wa_filter = zif_bp_constants=>entity_type-bp_header.
52 INSERT wa_filter INTO TABLE lt_filter.
53 io_model->read_entity_data_all(
54 EXPORTING
55 i_fieldname = lc_header
56 if_active = abap_false
57 i_crequest = ls_crequest-usmd_crequest
58 it_entity_filter = lt_filter
59 IMPORTING
60 et_message = DATA(lt_et_message) " Messages
61 et_data_entity = DATA(lt_data_bp_header) " Data for Entity Types
62 ).
63 DATA wa_data_bp_header LIKE LINE OF lt_data_bp_header.
64 IF lt_data_bp_header IS NOT INITIAL.
65 READ TABLE lt_data_bp_header INTO wa_data_bp_header WITH KEY usmd_entity = zif_bp_constants=>bp_header-bp_header.
66 IF sy-subrc EQ 0.
67 ASSIGN wa_data_bp_header-r_t_data->* TO <fs_t_data_bp_header>.
68 ENDIF.
69 ENDIF.
70 LOOP AT <fs_t_data_bp_header> ASSIGNING FIELD-SYMBOL(<fs_bp_header>).
71 ASSIGN COMPONENT zif_bp_constants=>bp_header-bu_group OF STRUCTURE <fs_bp_header> TO FIELD-SYMBOL(<fs_ktokk>).
72 ASSIGN COMPONENT zif_bp_constants=>bp_header-bp_header OF STRUCTURE <fs_bp_header> TO FIELD-SYMBOL(<fs_supplier>).
73 ENDLOOP.
74
75* Get Address Details
76 CLEAR: wa_filter, lt_filter.
77 wa_filter = zif_bp_constants=>entity_type-ad_postal.
78 INSERT wa_filter INTO TABLE lt_filter.
79 io_model->read_entity_data_all(
80 EXPORTING
81 i_fieldname = lc_header
82 if_active = abap_false
83 i_crequest = ls_crequest-usmd_crequest
84 it_entity_filter = lt_filter
85 IMPORTING
86 et_message = lt_et_message " Messages
87 et_data_entity = DATA(lt_data_ad_postal) " Data for Entity Types
88 ).
89 DATA wa_data_ad_postal LIKE LINE OF lt_data_ad_postal.
90 IF lt_data_ad_postal IS NOT INITIAL.
91 READ TABLE lt_data_ad_postal INTO wa_data_ad_postal WITH KEY usmd_entity = zif_bp_constants=>bp_centrl-bp_header.
92 IF sy-subrc EQ 0.
93 ASSIGN wa_data_ad_postal-r_t_data->* TO <fs_t_data_ad_postal>.
94 ENDIF.
95 ENDIF.
96 LOOP AT <fs_t_data_ad_postal> ASSIGNING FIELD-SYMBOL(<fs_ad_postal>).
97 ASSIGN COMPONENT zif_bp_constants=>ad_postal-ref_posta OF STRUCTURE <fs_ad_postal> TO FIELD-SYMBOL(<fs_ref_posta>).
98 ENDLOOP.
99
100
101 LOOP AT <fs_t_data> ASSIGNING <fs_data>.
102 ASSIGN COMPONENT zif_bp_constants=>bp_compny-company OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_comp>).
103 IF <fs_comp> IS ASSIGNED.
104 ASSIGN COMPONENT zif_bp_constants=>bp_compny-ref_bpcmp OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_recon>).
105
106 IF <fs_ktokk> IS ASSIGNED.
107 CASE <fs_ktokk>.
108 WHEN zif_bp_constants=>ktokk-z002 OR zif_bp_constants=>ktokk-z010.
109 IF <fs_recon> IS ASSIGNED AND <fs_recon> IS INITIAL.
110 <fs_recon> = '002050000'. "Derive Reconciliation Account
111 ENDIF.
112*Derive If Account group is Z002 or Z010 (Interco and Intraco Partners) then default Terms of Payment to D000 (Net 30 Days.),
113*Sort key to 009, and Tolerance Group to Z001. If anyother Account group then default Terms of Payment to J002.
114 ASSIGN COMPONENT zif_bp_constants=>bp_compny-zterm OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_zterm>).
115 IF <fs_zterm> IS ASSIGNED AND <fs_zterm> IS INITIAL.
116 <fs_zterm> = 'D000'. "(Net 30 Days.)
117 ENDIF.
118 ASSIGN COMPONENT zif_bp_constants=>bp_compny-zuawa OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_sort_key>).
119 IF <fs_sort_key> IS ASSIGNED AND <fs_sort_key> IS INITIAL.
120 <fs_sort_key> = '009'.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I derive company code fields for BP vendor valuation in MDG?
- Which MDG derivation hook is used for BP vendor valuation?
- How do I default reconciliation account, terms of payment, sort key, and tolerance group for BP vendors?
Possible questions
- How do I implement BP vendor valuation derivation in SAP MDG?
- How do I derive company code fields for BP vendor valuation in MDG?
- Which MDG derivation hook is used for BP vendor valuation?
- How do I default reconciliation account, terms of payment, sort key, and tolerance group for BP vendors?
- How do I debug BP vendor valuation derivation?