SAP MDG · REPLICATION OUTBOUND
How do I implement an SAP MDG DRF outbound filter class for business partner replication?
Implement IF_DRF_FILTER~APPLY_FILTER to read the custom filter configuration by replication object and business system, extract the first field of each outbound object row, and delete rows whose rule has SIGN = 'E'. For BP-specific scenarios, extend the same pattern with vendor/customer account-group enrichment from memory or master data before applying the exclusion list.
Implement IF_DRF_FILTER~APPLY_FILTER to read the custom filter configuration by replication object and business system, extract the first field of each outbound object row, and delete rows whose rule has SIGN = 'E'. For BP-specific scenarios, extend the same pattern with vendor/customer account-group enrichment from memory or master data before applying the exclusion list.
In SAP MDG DRF outbound filtering, the core pattern is configuration-driven exclusion inside IF_DRF_FILTER~APPLY_FILTER. The class ZCL_DRF_BP_FILTER reads ZMDG_DRF_CONFIG by replication object and business system, dynamically reads the first component of each filtered row, and deletes matching rows when the config line is marked for exclusion.
Process flow
- Implement IF_DRF_FILTER in the class and code the logic in IF_DRF_FILTER~APPLY_FILTER.
- Read ZMDG_DRF_CONFIG by FOBJ and IV_BUSINESS_SYSTEM.
- Loop over ET_FILTERED_OBJECTS and use ASSIGN COMPONENT 1 OF STRUCTURE <fs_struc> TO <fs_obj_val>.
- Convert the extracted key to the comparison type used in the config table.
- Read the config line by VALUE and delete the row when SIGN = 'E'.
- For BP-specific variants, derive KTOKK or KTOKD from memory or master data before filtering.
- If using specialized vendor/customer config, subtract those values from the main config before looping.
- Keep the base filter as fallback when specialized context is not available.
Referenced tables
| Object | Purpose |
|---|---|
ZMDG_DRF_CONFIG | Base configuration table for DRF filter values and SIGN-based exclusion. |
ZMDG_DRF_SUP_CFG | Vendor-specific filter configuration, keyed by FOBJ, business system, and KTOKK. |
ZMDG_DRF_CUS_CFG | Customer-specific filter configuration, keyed by FOBJ, business system, and KTOKD. |
LFA1 | Vendor master table used to derive KTOKK in the commented vendor logic. |
KNA1 | Customer master table used to derive KTOKD in the commented customer logic. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1class ZCL_DRF_BP_FILTER definition
2 public
3 final
4 create public .
5
6public section.
7
8 interfaces IF_DRF_FILTER .
9protected section.
10private section.
11ENDCLASS.
12
13
14
15CLASS ZCL_DRF_BP_FILTER IMPLEMENTATION.
16
17
18 METHOD if_drf_filter~apply_filter.
19 SELECT * FROM zmdg_drf_config INTO TABLE @DATA(lt_config)
20 WHERE fobj = @is_c_fobj-fobj
21 AND business_system = @iv_business_system.
22
23 IF sy-subrc = 0.
24 LOOP AT et_filtered_objects ASSIGNING FIELD-SYMBOL(<fs_struc>).
25 DATA(lv_index) = sy-tabix.
26 " Assign the first component of the structure to obj_val
27 FIELD-SYMBOLS: <fs_obj_val> TYPE any.
28 ASSIGN COMPONENT 1 OF STRUCTURE <fs_struc> TO <fs_obj_val>.
29
30 " Ensure the field is assigned before proceeding
31 IF <fs_obj_val> IS ASSIGNED.
32 DATA: lv_val TYPE zmdg_drf_config-value.
33 lv_val = <fs_obj_val>. " Assign value from structure to comparison variable
34
35 " Read lt_config to check for exclusion criteria
36 READ TABLE lt_config INTO DATA(ls_config) WITH KEY value = lv_val.
37
38 IF sy-subrc = 0 AND ls_config-sign = 'E'.
39 DELETE et_filtered_objects INDEX lv_index.
40 ENDIF.
41 ENDIF.
42
43 ENDLOOP.
44 ENDIF.
45***
46*** DATA:
47*** lv_kunnr TYPE kunnr,
48*** lv_lifnr TYPE lifnr,
49*** lv_ktokd TYPE ktokd,
50*** lv_ktokk TYPE ktokk,
51*** ls_customer_send_data TYPE bdikna1key,
52*** ls_vendor_send_data TYPE bdilfa1key,
53*** lt_bs_bp_sup_extern TYPE mdg_bs_bp_t_extern,
54*** lt_bs_bp_cus_extern TYPE mdg_bs_bp_t_extern.
55*** FIELD-SYMBOLS:
56*** <lfs_s_ext_criteria> TYPE rsds_range,
57*** <lfs_s_filter_range> TYPE rsds_frange.
58***
59***
60*** IF is_c_fobj-fobj = '98602' OR
61*** is_c_fobj-fobj = '98603'.
62*** "Filter with Vendor Account Group complexity is required.
63***
64*** "Importing from class CL_MDG_BS_CUSTOM_SI_IMPL
65*** IMPORT ct_bs_bp_extern = lt_bs_bp_sup_extern FROM MEMORY ID 'ZBP_SUP_REPLICATION'.
66*** IF sy-subrc = 0.
67*** IF lt_bs_bp_sup_extern IS NOT INITIAL.
68*** READ TABLE lt_bs_bp_sup_extern INTO DATA(ls_bs_bp_sup_extern) INDEX 1.
69*** IF sy-subrc = 0.
70*** lv_ktokk = ls_bs_bp_sup_extern-vendor-central_data-central-data-ktokk.
71*** ENDIF.
72*** ENDIF.
73*** ENDIF.
74***
75*** IF lv_ktokk IS INITIAL.
76*** "Importing from class CL_MDG_BS_CUST_ALE_DRF
77*** IMPORT is_vendor_send_data = ls_vendor_send_data FROM MEMORY ID 'ZECC_SUP_REPLICATION'.
78*** IF sy-subrc = 0.
79*** IF ls_vendor_send_data IS NOT INITIAL.
80*** DATA(lv_obj) = ls_vendor_send_data-lifnr.
81*** ELSE.
82*** CLEAR lv_obj.
83*** ENDIF.
84*** ENDIF.
85***
86*** IF lv_obj IS NOT INITIAL.
87*** CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
88*** EXPORTING
89*** input = lv_obj
90*** IMPORTING
91*** output = lv_lifnr.
92***
93*** IF lv_lifnr IS NOT INITIAL.
94***
95*** SELECT SINGLE ktokk
96*** INTO @lv_ktokk
97*** FROM lfa1 WHERE lifnr = @lv_lifnr.
98***
99*** IF sy-subrc = 0.
100*** ELSE.
101*** CLEAR lv_ktokk.
102*** ENDIF.
103*** ENDIF.
104*** ENDIF.
105*** ENDIF.
106***
107*** IF lv_ktokk IS NOT INITIAL.
108*** SELECT * FROM zmdg_drf_config INTO TABLE @DATA(lt_drf_main_config)
109*** WHERE fobj = @is_c_fobj-fobj
110*** AND business_system = @iv_business_system. "#EC CI_ALL_FIELDS_NEEDED
111***
112*** IF sy-subrc = 0.
113*** DATA(lv_main_config) = abap_true.
114*** ENDIF.
115***
116*** SELECT * FROM zmdg_drf_sup_cfg INTO TABLE @DATA(lt_drf_sup_config)
117*** WHERE fobj = @is_c_fobj-fobj
118*** AND business_system = @iv_business_system
119*** AND ktokk = @lv_ktokk. "#EC CI_ALL_FIELDS_NEEDED
120***The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How does ZCL_DRF_BP_FILTER work in MDG DRF outbound processing?
- How do I filter DRF outbound objects based on configuration in SAP MDG?
- How do I add customer/vendor account-group-based filtering in a DRF filter class?
Possible questions
- What is the purpose of IF_DRF_FILTER~APPLY_FILTER?
- How do I exclude DRF outbound objects by replication object and business system?
- How do I adapt a DRF filter for vendor or customer account group logic?
- Which tables are used for custom MDG DRF filtering?
- What ABAP pattern is used to delete filtered DRF objects?