SAP MDG · REPLICATION OUTBOUND

How do I implement a configurable SAP MDG DRF filter using IF_DRF_FILTER with fallback and dynamic key extraction?

Implement the filter in IF_DRF_FILTER~APPLY_FILTER by reading main configuration for the replication object and business system, optionally enriching it with a context-specific rule set, and deleting rows from ET_FILTERED_OBJECTS when the resolved rule has SIGN = 'E'. If no configuration exists, keep the payload unchanged.

Implement the filter in IF_DRF_FILTER~APPLY_FILTER by reading main configuration for the replication object and business system, optionally enriching it with a context-specific rule set, and deleting rows from ET_FILTERED_OBJECTS when the resolved rule has SIGN = 'E'. If no configuration exists, keep the payload unchanged.

Implement the filter in IF_DRF_FILTER~APPLY_FILTER as a configuration-driven exclusion step. First read the base rule set for the DRF replication object and business system; if none exists, keep all records. Then optionally resolve a context-specific group, merge specialized rules, and delete matching rows from ET_FILTERED_OBJECTS when the rule indicates exclusion.

Process flow

  1. Implement IF_DRF_FILTER~APPLY_FILTER in the filter class.
  2. Read the main configuration by IS_C_FOBJ and IV_BUSINESS_SYSTEM.
  3. Return immediately if no main rules exist.
  4. Optionally resolve a context-specific group such as account group or object type.
  5. Read specialized configuration for that group if available.
  6. Merge main and specialized rules into one effective rule set.
  7. Loop through ET_FILTERED_OBJECTS.
  8. Use ASSIGN COMPONENT 1 OF STRUCTURE <ls_object_row> to extract the business key dynamically.
DRFF

Maintain replication filter

Maintain runtime replication filter values used by the filter logic.

Referenced tables

ObjectPurpose
ty_cfgInternal configuration line type used in the sample filter class for rule lookup.
tt_cfgInternal table type of the sample configuration rules.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

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_cfg

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How do I build a DRF filter class for MDG outbound replication?
  • How do I exclude objects in DRF based on configuration and context?
  • How do I implement IF_DRF_FILTER~APPLY_FILTER for a generic MDG replication filter?

Possible questions

  • Which class pattern should I follow for a configurable DRF filter?
  • How does the filter read main and specialized rules?
  • How do I extract the business key from generic DRF payload rows?
  • What is the fallback behavior when no special context is available?
  • Which transactions are typically used when building and testing this filter?

Keywords

IF_DRF_FILTERAPPLY_FILTERDRFMDGET_FILTERED_OBJECTSDRFFDRFOUTOIF_MAINTAINMDGIMGDRFIMGSE11SE80USMD_DATA_MODELfilter configurationdynamic key extractionfallback behavior