SAP MDG · UTILITIES
How does SAP MDG update the customer account group during Business Partner change request processing?
SAP MDG updates the customer account group by reading the changed BP central data, checking whether ZZKTOKD was changed, fetching the BP_HEADER partner from the change request, and writing the new KTOKD value into BP_CUSGEN in the change-data buffer.
SAP MDG updates the customer account group by reading the changed BP central data, checking whether ZZKTOKD was changed, fetching the BP_HEADER partner from the change request, and writing the new KTOKD value into BP_CUSGEN in the change-data buffer.
In the provided MDG utility method, the customer account group is updated only when the BP central data contains a changed ZZKTOKD value. The method reads the current change-request context, finds the BP_HEADER partner, loads BP_CUSGEN, copies the new KTOKD into the generic customer entity, and writes the result back to the MDG buffer.
Process flow
- Get the MDG application context with `cl_usmd_app_context=>get_context( )`.
- Get the BP model instance for model `BP` using `cl_usmd_model_ext=>get_instance`.
- Read changed data for `BP_CENTRL` from `io_changed_data`.
- Check whether `ZZKTOKD` is marked as changed in `USMDX_S_UPDATE`.
- Read the change-request entity list and extract the `BP_HEADER` partner.
- Create a dynamic reference for `BP_CUSGEN` with structure `KATTR`.
- Read the `BP_CUSGEN` rows for the partner and overwrite `KTOKD`.
- Write the updated rows back using `io_write->write_data( )`.
Referenced tables
| Object | Purpose |
|---|---|
USMD1210 | Change request notes table used by the related utility method `ADD_CREQUEST_NOTE`. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1METHOD update_customer_account_group.
2 CONSTANTS: lc_model TYPE usmd_model VALUE 'BP'.
3 DATA:
4 lt_entities TYPE usmd_t_crequest_entity,
5 lo_model_ext TYPE REF TO if_usmd_model_ext,
6 lv_partner TYPE bu_partner,
7 lv_entity TYPE usmd_entity,
8 lv_entity_name TYPE usmd_fieldname,
9 lo_data TYPE REF TO data,
10 lv_ktokd TYPE ktokd,
11 lv_acc_grp_changed TYPE boolean.
12
13 FIELD-SYMBOLS: <fs_t_centrl> TYPE ANY TABLE,
14 <fs_t_cusgen> TYPE ANY TABLE,
15 <lfs_value> TYPE any.
16
17 DATA(lo_app_context) = cl_usmd_app_context=>get_context( ).
18 IF lo_app_context IS BOUND.
19 CALL METHOD cl_usmd_model_ext=>get_instance
20 EXPORTING
21 i_usmd_model = lc_model
22 IMPORTING
23 eo_instance = lo_model_ext.
24
25****************************
26 io_changed_data->read_data(
27 EXPORTING
28 i_entity = 'BP_CENTRL'
29 i_struct = if_usmd_model_ext=>gc_struct_key_attr " Type of Data Structure
30 IMPORTING
31 er_t_data_mod = DATA(lo_data_mod_bp_centrl)
32 ).
33 ASSIGN lo_data_mod_bp_centrl->* TO FIELD-SYMBOL(<fs_t_data_bp_centrl>) .
34 IF <fs_t_data_bp_centrl> IS ASSIGNED.
35 LOOP AT <fs_t_data_bp_centrl> ASSIGNING FIELD-SYMBOL(<fs_s_data_bp_centrl>).
36 ASSIGN COMPONENT 'USMDX_S_UPDATE' OF STRUCTURE <fs_s_data_bp_centrl> TO <lfs_value>.
37 IF <lfs_value> IS ASSIGNED.
38 ASSIGN COMPONENT 'ZZKTOKD' OF STRUCTURE <lfs_value> TO FIELD-SYMBOL(<lfs_acc_grp>).
39 IF <lfs_acc_grp> IS ASSIGNED.
40 lv_acc_grp_changed = <lfs_acc_grp>.
41 ENDIF.
42 UNASSIGN <lfs_value>.
43 ENDIF.
44 ASSIGN COMPONENT 'ZZKTOKD' OF STRUCTURE <fs_s_data_bp_centrl> TO <lfs_value>.
45 IF <lfs_value> IS ASSIGNED.
46 lv_ktokd = <lfs_value>.
47 ENDIF.
48 ENDLOOP.
49 ENDIF.
50****************************
51 IF lo_model_ext IS BOUND AND lv_acc_grp_changed = abap_true.
52*
53* CALL METHOD zcl_mdg_suppl_utility=>get_single_attribute
54* EXPORTING
55* im_crnumber = lo_app_context->mv_crequest_id
56* im_field = 'ZZKTOKD'
57* IMPORTING
58* ex_value = DATA(lv_accgrp).
59 CALL METHOD lo_model_ext->read_char_value
60 EXPORTING
61 i_fieldname = usmd0_cs_fld-crequest
62 it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = usmd0_cs_fld-crequest low = iv_cr_number ) )
63 IMPORTING
64 et_data = lt_entities.
65 LOOP AT lt_entities ASSIGNING FIELD-SYMBOL(<fs_entity>)
66 WHERE usmd_entity_obj = 'BP_HEADER'. "#EC CI_SORTSEQ
67 lv_partner = <fs_entity>-usmd_value.
68 ENDLOOP.
69 lv_entity = 'BP_CUSGEN'.
70 lv_entity_name = lv_entity.
71 lo_model_ext->create_data_reference(
72 EXPORTING
73 i_fieldname = 'BP_CUSGEN' " Field Name
74 i_struct = 'KATTR' " Structure
75 IMPORTING
76 er_data = lo_data
77 ).
78 ASSIGN lo_data->* TO <fs_t_cusgen>.
79 IF <fs_t_cusgen> IS ASSIGNED.
80 CALL METHOD lo_model_ext->read_char_value
81 EXPORTING
82 i_fieldname = lv_entity_name
83 it_sel = VALUE usmd_ts_sel( ( sign = usmd0_cs_ra-sign_i option = usmd0_cs_ra-option_eq fieldname = lv_entity low = lv_partner )
84 ( sign = usmd0_cs_ra-sign_i option = usmd0_cs_ra-option_eq fieldname = 'BP_HEADER' low = lv_partner ) )
85 IMPORTING
86 et_data = <fs_t_cusgen>.
87 IF <fs_t_cusgen> IS NOT INITIAL.
88 LOOP AT <fs_t_cusgen> ASSIGNING FIELD-SYMBOL(<fs_s_cusgen>).
89 ASSIGN COMPONENT 'KTOKD' OF STRUCTURE <fs_s_cusgen> TO <lfs_value>.
90 IF <lfs_value> IS ASSIGNED.
91 <lfs_value> = lv_ktokd.
92 ENDIF.
93 UNASSIGN <lfs_value>.
94 ENDLOOP.
95 io_write->write_data(
96 i_entity = lv_entity " Entity Type
97 it_data = <fs_t_cusgen>
98 ).
99* CATCH cx_usmd_write_error. " Error while writing to buffer
100 ENDIF.
101 ENDIF.
102
103 ENDIF.
104 ENDIF.
105ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How do I derive customer account group KTOKD in SAP MDG BP processing?
- Which ABAP objects are used to update customer account group in MDG BP change data?
- How do I implement customer account group derivation in MDG cross-derivation?
Possible questions
- How do I derive customer account group KTOKD in SAP MDG BP processing?
- Which ABAP objects are used to update customer account group in MDG BP change data?
- How do I implement customer account group derivation in MDG cross-derivation?
- What is the difference between BP_CENTRL and BP_CUSGEN in this logic?
- How do I debug MDG change-request buffer updates for customer account group?