(Glue-2411) Dynamic Selection using BAdi

Dynamic Selection allows you to dynamically adjust the selection of the Extractor Process using SAP BAdi implementation. It enhances the possibility of filtering data during the extraction process. At its core, this functionality allows you to programmatically edit the internal table that holds the select options of the Extractor Process at runtime. This option might be useful when some of the filtering parameters are dynamic or known only at run-time.

Please note that Dynamic data selection is an option for expert users, who may use it if the standard data selection isn't sufficient. This option requires ABAP knowledge.

To use this functionality you need to perform two steps
Firstly you need to implement the BAdi enhancement and then you have to use it in Extractor 1.0 Variant or Extractor 2.0 Process selection.

Implement the BAdi

  1. In the ABAP workbench create a new class implementing interface /DVD/GL_IF_SELECTION_DEF.
    This interface is defined by SNP Glue to allow custom selection enhancement implementation.

  2. Implement your custom filtering logic inside the DEFINE_SELECTION method.

    Please be aware that you can adjust the whole selection for the Extractor 1.0 or Extractor 2.0 process within this method. Therefore, make sure you know what you are doing.

  3. When your logic is implemented, navigate to package /DVD/GL_EXT_DATA in the ABAP workbench.

  4. Expand the Enhancements folder and then Enhancement Spots.
    You should be able to see /DVD/GL_EXT_VAR_SELOPT, as shown in the picture.

  5. Choose /DVD/GL_EXT_VAR_SELOPT from the context menu and select Implement. A pop-up window should appear.

  6. Fill in the input fields named Enhancement Implementation and Short Text and confirm your selection by pressing.

    When completed, you should see the following screen:

  7. Fill in the required inputs and confirm.

    1. BAdi Implementation: Name of BAdi implementation you want to create

    2. Implementation Class: This is the name of the class you created at the beginning of this step list

    3. BAdi Definition: Definition of the BAdi. You have to use value /DVD/GL_SELECTION_DEFINITION.

  8. After confirmation of your selections, the new BAdi implementation is created. You should see the screen shown in the following image:

  9. In the next steps, you need to set up your BAdi implementation. Expand this BAdi implementation and double-click on Filter Val.

  10. Press the Combination button as shown in the image below to create a new filter combination. A new combination will be added.

  11. Change the filter value by double-clicking on the filter definition, highlighted in the next image.

  12. Set the Comparator 1 to “=” and enter the ID you want to use in the selection into filter Value 1 and confirm. This value will later be used in the selection as a placeholder to trigger this BAdi implementation.
    The correct configuration should look like this:

  13. Activate your BAdi by pressing the Activate button or using the shortcut Ctrl+F3.

    After finishing this step your BAdi is ready to be used in the SNP Glue filter.
    For more information, you can use the official SAP step list on How to Implement a BAdI.

Use your BAdi with Extractor

In the previous steps, you defined some value as the filtering option for your BAdi. This value can be used as a placeholder in the Extraction Process by adding a special character $ before the filter value. Let’s say you set the value to ABAP_FILTER. Then you can use the value $ABAP_FILTER in the selection screen to trigger your BAdi during extraction.

The filter value e.g. $ABAP_FILTER affects the selection only by triggering your custom BAdi. Therefore you don’t have to worry about the particular field that should be used for the selection.

To use a placeholder within the selection, you need to have a field of character type with sufficient length present within the selection. If you haven’t, we suggest you add some fields from a source structure that will be used only for technical purposes.

The next images show the usage of dynamic filters in the Extraction Process.