SAP MDG · REPLICATION OUTBOUND
How do I implement a custom SAP MDG DRF filter class for replication objects and context-based exclusions?
Implement IF_DRF_FILTER~APPLY_FILTER as a configuration-driven exclusion filter: read rules by replication object and business system, optionally enrich with context such as account group, then loop through ET_FILTERED_OBJECTS and delete entries whose key matches an exclusion rule.
Implement IF_DRF_FILTER~APPLY_FILTER as a configuration-driven exclusion filter: read rules by replication object and business system, optionally enrich with context such as account group, then loop through ET_FILTERED_OBJECTS and delete entries whose key matches an exclusion rule.
The standard MDG DRF filter pattern is configuration-driven and centered on `IF_DRF_FILTER~APPLY_FILTER`. You read the filter setup for the current replication object and business system, optionally add context-specific rules such as customer/vendor account-group logic, and then loop over `ET_FILTERED_OBJECTS` to remove excluded keys.
Process flow
- Implement IF_DRF_FILTER~APPLY_FILTER.
- Read rules for IS_C_FOBJ-FOBJ and IV_BUSINESS_SYSTEM.
- Enrich rules if business context is available.
- Merge generic and specialized exclusions.
- Loop over ET_FILTERED_OBJECTS and extract the key from component 1.
- Delete rows whose matched rule has SIGN = 'E'.
- Keep a fallback path when context or specialized rules are missing.
DRF filter customizing for replication object and business system
Maintain the exclusion rules used by the filter class. The retrieved source confirms the read keys `IS_C_FOBJ-FOBJ` and `IV_BUSINESS_SYSTEM`, but does not name the exact customizing transaction or path.
Referenced tables
| Object | Purpose |
|---|---|
z_filter_cfg | Example rule table used in the source-supported ABAP pattern for reading filter rules by replication object and business system. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example: generic_filter_code_sample.abap
Exact relevant implementation excerpt from the knowledge document set.
1"==============================================================================
2" Generic Filter Code Sample
3" Purpose:
4" - Demonstrate a configurable filter implementation using the DRF pattern
5" - Show dynamic key extraction from generic structures
6" - Show fallback behavior when specialized context is unavailable
7"==============================================================================
8
9CLASS zcl_generic_filter_sample DEFINITION
10 PUBLIC
11 FINAL
12 CREATE PUBLIC.
13
14 PUBLIC SECTION.
15 INTERFACES if_drf_filter.
16
17 PROTECTED SECTION.
18 PRIVATE SECTION.
19
20 TYPES: BEGIN OF ty_cfg,
21 fobj TYPE char10,
22 business_system TYPE char60,
23 value TYPE char40,
24 sign TYPE c LENGTH 1,
25 END OF ty_cfg.
26
27 TYPES tt_cfg TYPE STANDARD TABLE OF ty_cfg WITH DEFAULT KEY.
28
29 METHODS get_main_config
30 IMPORTING
31 is_c_fobj TYPE drffobj
32 iv_business_system TYPE drf_system_alias
33 RETURNING
34 VALUE(rt_cfg) TYPE tt_cfg.
35
36 METHODS get_specific_config
37 IMPORTING
38 is_c_fobj TYPE drffobj
39 iv_business_system TYPE drf_system_alias
40 iv_object_group TYPE char20
41 RETURNING
42 VALUE(rt_cfg) TYPE tt_cfg.
43
44 METHODS resolve_object_group
45 IMPORTING
46 is_c_fobj TYPE drffobj
47 RETURNING
48 VALUE(rv_group) TYPE char20.
49
50 METHODS merge_effective_rules
51 IMPORTING
52 it_main TYPE tt_cfg
53 it_specific TYPE tt_cfg
54 RETURNING
55 VALUE(rt_effective) TYPE tt_cfg.
56ENDCLASS.
57
58CLASS zcl_generic_filter_sample IMPLEMENTATION.
59
60 METHOD if_drf_filter~apply_filter.
61 "------------------------------------------------------------
62 " 1) Read base configuration by object + business system
63 "------------------------------------------------------------
64 DATA(lt_main_cfg) = get_main_config(
65 is_c_fobj = is_c_fobj
66 iv_business_system = iv_business_system ).
67
68 " If no rules are configured, keep all objects as-is.
69 IF lt_main_cfg IS INITIAL.
70 RETURN.
71 ENDIF.
72
73 "------------------------------------------------------------
74 " 2) Resolve context-specific classification (optional)
75 "------------------------------------------------------------
76 DATA(lv_group) = resolve_object_group( is_c_fobj = is_c_fobj ).
77
78 "------------------------------------------------------------
79 " 3) Load specialized rules and merge with base rules
80 "------------------------------------------------------------
81 DATA(lt_specific_cfg) = VALUE tt_cfg( ).
82 IF lv_group IS NOT INITIAL.
83 lt_specific_cfg = get_specific_config(
84 is_c_fobj = is_c_fobj
85 iv_business_system = iv_business_system
86 iv_object_group = lv_group ).
87 ENDIF.
88
89 DATA(lt_effective_cfg) = merge_effective_rules(
90 it_main = lt_main_cfg
91 it_specific = lt_specific_cfg ).
92
93 "------------------------------------------------------------
94 " 4) Apply filter to outgoing object list
95 "------------------------------------------------------------
96 LOOP AT et_filtered_objects ASSIGNING FIELD-SYMBOL(<ls_object_row>).
97 DATA(lv_index) = sy-tabix.
98
99 " DRF payload is generic, so get business key dynamically from component 1.
100 ASSIGN COMPONENT 1 OF STRUCTURE <ls_object_row> TO FIELD-SYMBOL(<lv_object_key>).
101 IF <lv_object_key> IS NOT ASSIGNED.
102 CONTINUE.
103 ENDIF.
104
105 DATA(lv_key_value) = CONV char40( <lv_object_key> ).
106
107 READ TABLE lt_effective_cfg INTO DATA(ls_rule)
108 WITH KEY value = lv_key_value.
109 IF sy-subrc = 0 AND ls_rule-sign = 'E'.
110 " Exclusion rule found: remove object from replication list.
111 DELETE et_filtered_objects INDEX lv_index.
112 ENDIF.
113 ENDLOOP.
114
115 ENDMETHOD.
116
117 METHOD get_main_config.
118 " Replace this SELECT with your productive configuration table.
119 " Example pattern:
120 " SELECT * FROM zmdg_drf_config INTO TABLE @rt_cfgThe remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How does IF_DRF_FILTER~APPLY_FILTER work in MDG DRF filter classes?
- How can I exclude DRF replication entries by business system and object key in SAP MDG?
- How do I build a context-aware MDG replication filter class for customer or vendor scenarios?
Possible questions
- What is the standard pattern for an MDG DRF filter class?
- How do I read filter configuration by replication object and business system in SAP MDG?
- How do I use IF_DRF_FILTER~APPLY_FILTER to remove entries from ET_FILTERED_OBJECTS?
- How can I add account-group-based filtering for ALE/SOA MDG replication?
- What is the generic ABAP pattern for configuration-driven DRF filtering?