SAP MDG · VALIDATION DERIVATION
How do I implement BP central data derivation in SAP MDG using the BP central derivation hook?
Implement the BP central derivation in the MDG rule-service derivation hook and only default missing fields. In the source pattern, `NAME_ORG1` is cleaned with `SF_SPECIALCHAR_DELETE`, then the first 10 characters are moved to `BU_SORT1` and converted to uppercase when `BU_SORT1` is initial.
Implement the BP central derivation in the MDG rule-service derivation hook and only default missing fields. In the source pattern, `NAME_ORG1` is cleaned with `SF_SPECIALCHAR_DELETE`, then the first 10 characters are moved to `BU_SORT1` and converted to uppercase when `BU_SORT1` is initial.
Use the BP central derivation hook to default `BU_SORT1` from `NAME_ORG1` only when the target field is initial. The documented pattern first reads BP central data from the current change request, then loops over `CT_DATA`, cleans the search term with `SF_SPECIALCHAR_DELETE`, and writes the derived value back to `BU_SORT1` without overwriting user-entered data.
Process flow
- Open SE18 and verify the BAdI definition or derivation interface used by your MDG BP solution.
- Create or open the implementation in SE19 and assign the implementing class.
- Implement the BP central derivation logic in `ZIF_TE_DERIVATION~D_BP_CENTRL` or `IF_EX_USMD_RULE_SERVICE~DERIVE_ENTITY` depending on your design.
- Read `CT_DATA` / entity data and gate the logic by BP central entity type.
- Check `NAME_ORG1` and `BU_SORT1` dynamically with `ASSIGN COMPONENT` and `IS ASSIGNED`.
- Derive `BU_SORT1` only when it is initial, using `SF_SPECIALCHAR_DELETE` and uppercase conversion.
- Activate the class, BAdI implementation, and dependent helper objects.
- Test the change request scenario and verify that user-entered `BU_SORT1` is not overwritten.
Referenced tables
| Object | Purpose |
|---|---|
USMD_S_MESSAGE | Message structure used when derivation needs to return informative messages. |
USMD_T_ENTITY | Entity filter table used in model reads such as `READ_ENTITY_DATA_ALL`. |
USMD_T_CREQUEST_ENTITY | Change-request entity table used to inspect entities in the current request. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1* Purpose: Interface hook for BP central data derivation.
2
3 METHOD zif_te_derivation~d_bp_centrl.
4
5 DATA : lo_context TYPE REF TO if_usmd_app_context,
6 ls_message TYPE usmd_s_message,
7 lt_filter TYPE usmd_t_entity,
8 ls_filter LIKE LINE OF lt_filter,
9 lt_entities TYPE usmd_t_crequest_entity.
10
11 DATA: lv_org_name TYPE sf_searchw.
12
13 FIELD-SYMBOLS :<fs_t_data> TYPE ANY TABLE,
14 <fs_data> TYPE any,
15 <fs_t_data_all_bp_centrl> TYPE ANY TABLE,
16 <fs_t_data_all_bp_vengen> TYPE ANY TABLE.
17
18 CONSTANTS:lc_header TYPE usmd_fieldname VALUE 'BP_HEADER'.
19
20 ls_filter = zif_bp_constants=>entity_type-bp_centrl.
21 INSERT ls_filter INTO TABLE lt_filter.
22 CALL METHOD io_model->read_entity_data_all
23 EXPORTING
24 i_fieldname = lc_header
25 if_active = abap_false
26 i_crequest = id_crequest_id
27 it_entity_filter = lt_filter
28 IMPORTING
29 et_message = et_message
30 et_data_entity = DATA(lt_data_all_bp_centrl).
31 DATA:wa_data_all_bp_centrl LIKE LINE OF lt_data_all_bp_centrl.
32
33 IF lt_data_all_bp_centrl IS NOT INITIAL.
34 READ TABLE lt_data_all_bp_centrl INTO wa_data_all_bp_centrl WITH KEY usmd_entity = zif_bp_constants=>bp_centrl-bp_header
35 usmd_entity_cont = zif_bp_constants=>entity_type-bp_centrl .
36 IF sy-subrc EQ 0.
37 ASSIGN wa_data_all_bp_centrl-r_t_data->* TO <fs_t_data_all_bp_centrl>.
38 ENDIF.
39 ENDIF.
40
41 IF id_entitytype = zif_bp_constants=>entity_type-bp_centrl.
42* SOC by TE581834
43* lo_context = cl_usmd_app_context=>get_context( ).
44* lo_context->get_attributes(
45* IMPORTING
46* ev_process = DATA(lv_process) " Business Activity
47* ev_crequest_id = DATA(lv_cr_number)
48* ).
49* IF lv_process = 'SUP2'.
50* CALL METHOD io_model->read_char_value
51* EXPORTING
52* i_fieldname = usmd0_cs_fld-crequest
53* it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = usmd0_cs_fld-crequest low = lv_cr_number ) )
54* IMPORTING
55* et_data = lt_entities.
56* LOOP AT lt_entities ASSIGNING FIELD-SYMBOL(<fs_entity>)
57* WHERE usmd_entity_obj = 'BP_HEADER'. "#EC CI_SORTSEQ
58* DATA(lv_partner) = <fs_entity>-usmd_value.
59* ENDLOOP.
60* io_model->create_data_reference(
61* EXPORTING
62* i_fieldname = 'BP_VENGEN' " Field Name
63* i_struct = 'KATTR' " Structure
64* IMPORTING
65* er_data = DATA(lo_data)
66* ).
67*
68* ASSIGN lo_data->* TO <fs_t_data_all_bp_vengen>.
69* IF <fs_t_data_all_bp_vengen>
70* IS ASSIGNED.
71* CALL METHOD io_model->read_char_value
72* EXPORTING
73* i_fieldname = 'BP_VENGEN' " Field Name
74* it_sel = VALUE usmd_ts_sel( ( sign = usmd0_cs_ra-sign_i option = usmd0_cs_ra-option_eq fieldname = 'BP_VENGEN' low = lv_partner )
75* ( sign = usmd0_cs_ra-sign_i option = usmd0_cs_ra-option_eq fieldname = 'BP_HEADER' low = lv_partner ) ) " Sorted Table: Selection Condition (Range per Field)
76* IMPORTING
77* et_data = <fs_t_data_all_bp_vengen>.
78* ENDIF.
79** READ TABLE lt_data_all_bp_centrl INTO DATA(wa_data_all_bp_vengen) WITH KEY usmd_entity = zif_bp_constants=>bp_centrl-bp_header
80** usmd_entity_cont = zif_bp_constants=>entity_type-bp_centrl .
81** IF sy-subrc EQ 0.
82** ASSIGN wa_data_all_bp_vengen-r_t_data->* TO <fs_t_data_all_bp_vengen>.
83** ENDIF.
84* ENDIF.
85* EOC by TE581834
86
87 ASSIGN ct_data TO <fs_t_data>.
88 CHECK <fs_t_data> IS ASSIGNED.
89 LOOP AT <fs_t_data> ASSIGNING <fs_data>.
90 ASSIGN COMPONENT zif_bp_constants=>bp_centrl-name_org1 OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_name_org1>).
91 ASSIGN COMPONENT zif_bp_constants=>bp_centrl-bu_sort1 OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_bu_sort1>).
92 IF <fs_name_org1> IS ASSIGNED AND <fs_bu_sort1> IS ASSIGNED AND <fs_name_org1> IS NOT INITIAL AND ( <fs_bu_sort1> IS INITIAL ) .
93 "Remove space and special characters from Supplier search term
94 CALL FUNCTION 'SF_SPECIALCHAR_DELETE'
95 EXPORTING
96 with_specialchar = <fs_name_org1>
97* RESPECT_HYPHEN =
98 IMPORTING
99 without_specialchar = lv_org_name
100 EXCEPTIONS
101 result_word_empty = 1
102 OTHERS = 2.
103 IF sy-subrc = 0.
104 <fs_bu_sort1> = lv_org_name+0(10).
105 TRANSLATE <fs_bu_sort1> TO UPPER CASE.
106 ELSE.
107* Implement suitable error handling here
108 ENDIF.
109 ENDIF.
110* SOC by TE581834
111* IF <fs_t_data_all_bp_vengen> IS ASSIGNED.
112* LOOP AT <fs_t_data_all_bp_vengen> ASSIGNING FIELD-SYMBOL(<fs_bp_vengen>).
113* ASSIGN COMPONENT 'KTOKK' OF STRUCTURE <fs_bp_vengen> TO FIELD-SYMBOL(<lv_ktokk>).
114* IF <lv_ktokk> IS ASSIGNED AND <lv_ktokk> IS NOT INITIAL.
115* ASSIGN COMPONENT 'ZZKTOKK' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<lv_zzktokk>).
116* IF <lv_zzktokk> IS ASSIGNED AND <lv_zzktokk> IS INITIAL.
117* <lv_zzktokk> = <lv_ktokk>.
118* ENDIF.
119* ENDIF.
120* ENDLOOP.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How to fill `BU_SORT1` automatically in BP central data derivation?
- How to implement `ZIF_TE_DERIVATION~D_BP_CENTRL` for business partner defaulting?
- How do I derive BP central fields in MDG when `NAME_ORG1` is entered?
Possible questions
- How do I implement BP central data derivation in SAP MDG using the BP central derivation hook?
- How to fill `BU_SORT1` automatically in BP central data derivation?
- How to implement `ZIF_TE_DERIVATION~D_BP_CENTRL` for business partner defaulting?
- How do I derive BP central fields in MDG when `NAME_ORG1` is entered?
- What BAdI or derivation hook should I use for BP central defaults?