(Glue-2311) Dynamic Selection using BAdi
Dynamic Selection allows you to dynamically adjust the selection of Extractor Process using SAP BAdi implementation. It enhances the possibility to filter data during the extraction process. At its core, this functionality allows you to programmatically edit the internal table that holds the select options of 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.
In order 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
In ABAP workbench create a new class implementing interface /DVD/GL_IF_SELECTION_DEF.
This interface is defined by SNP Glue™ with the purpose to allow custom selection enhancement implementation.Implement your custom filtering logic inside the DEFINE_SELECTION method.
Please be aware that you can adjust the whole selection for Extractor 1.0 or Extractor 2.0 process within this method. Therefore, make sure you know what you are doing.
When your logic is implemented, navigate to package /DVD/GL_EXT_DATA in ABAP workbench.
Expand the Enhancements folder and then Enhancement Spots.
You should be able to see /DVD/GL_EXT_VAR_SELOPT, as shown in the picture.Choose /DVD/GL_EXT_VAR_SELOPT from the context menu and select Implement. A pop-up window should appear.
Fill in input fields named Enhancement Implementation and Short Text and confirm your selection by pressing.
When completed, you should see the following screen:
Fill in the required inputs and confirm.
BAdi Implementation – Name of BAdi implementation you want to create
Implementation Class – This is the name of the class you created at the beginning of this steplist
BAdi Definition – Definition of the BAdi. You have to use value /DVD/GL_SELECTION_DEFINITION
After confirmation of your selections, the new BAdi implementation is created. You should see the screen shown in the following image:
In the next steps, you need to set up your BAdi implementation. Expand this BAdi implementation and double click on Filter Val.
Press the Combination button as shown in the image below to create a new filter combination. A new combination will be added.
Change filter value by double-clicking on filter definition, highlighted on the next image.
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 in order to trigger this BAdi implementation.
Correct configuration should look like this:Activate your BAdi by pressing Activate button or use 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 in order 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.
In order 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.