(Glue-2008) Dynamic Selection using BAdi
Dynamic Selection allows you to dynamically adjust the selection of Extractor 1.0 Variant or Extractor 2.0 Process using SAP BAdi implementation. It enhances the possibilities 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 1.0 Variant or Extractor 2.0 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 new class implementing interface /DVD/GL_IF_SELECTION_DEF.
This interface is defined by Glue with a 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 Enhancements folder and then Enhancement Spots.
You should be able to see /DVD/GL_EXT_VAR_SELOPT, as shown in the picture.Right click on /DVD/GL_EXT_VAR_SELOPT and select Implement. A pop-up window should appear.
Fill input fields named Enhancement Implementation and Short Text and confirm your selection by pressing.
When completed, you should see the following screen:
Fill 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 setup your BAdi implementation. Expand this BAdi implementation and double click on Filter Val.
Press Combination button shown in the image to create new filter combination. 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.
Finishing this step your BAdi is ready to be used in Glue filter.
For more information, you can use the official SAP step list on How to Implement a BAdI.
Use your BAdi with Extractor
If you have your BAdi implemented, you can use it in Extractor 1.0 Variant or Extractor 2.0 Process.
The process is slightly different for Extractor 1.0 and Extractor 2.0 but the main principle remains the same.
Basically you need to adjust the selection of Glue Extractor. For Extractor 1.0 you can do so by editing the Extractor Variant. For Extractor 2.0 you can fill these values when executing Extractor 2.0 Process or save them into standard SAP variant.
If you need further guide discussing Extractor 2.0 Process or Extractor 1.0 Variant, you should see the pages (Glue-2008) Variant and (Glue-2008) Extraction Process .
In previous steps you defined some value as the filtering option for your BAdi. This value can be used as a placeholder in Extractor 1.0 Variant or Extractor 2.0 Process by adding 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.
Next images show the usage of dynamic filters in Extractor 1.0 Variant and Extractor 2.0 Process.
Extractor 1.0 Variant
Extractor 2.0 Process