Hello everyone, in our previous tutorial we introduced you to the new flavor of ABAP ALV called ALV with Integrated Date Access(ALV with IDA).
In our previous tutorial we have retrieved the full data, but usually users want to restrict the data retrieved by using “Parameters” on selection screen of the report. In this tutorial, we will learn how to set parameters to the ALV with IDA. So lets get started.
To set the PARAMETERS & SELECT-OPTIONS to ALV with IDA
- Get the reference object for the IDA condition factory IF_SALV_IDA_CONDITION_FACTORY by calling the method CONDITION_FACTORY( ).
- Build the conditions by using the method EQUALS( ).
- Pass the above created conditions to the method SET_SELECT_OPTIONS of IDA class CL_SALV_GUI_TABLE_IDA.
1. Create an ABAP Program in Eclipse.Enter Name, Description and click on Next.
2. In the Selection of Transport Request window, choose the transport request. As we are saving the program in $TMP package in our case no transport request is required.Click on Finish.
3. Copy and paste the below code.
TABLES : SNWD_PD. DATA: lo_additional_condition TYPE REF TO if_salv_ida_condition, lo_condition_factory TYPE REF TO if_salv_ida_condition_factory. *0... Declare PARAMETERS PARAMETERS: p_prdctg TYPE SNWD_PRODUCT_CATEGORY. *1... Declare SELECT-OPIONS SELECT-OPTIONS s_prdid FOR SNWD_PD-PRODUCT_ID. START-OF-SELECTION. *2... Create object reference ALV with IDA DATA(lo_alv_display) = cl_salv_gui_table_ida=>create( iv_table_name = 'SNWD_PD' ). *3... Build range tables DATA(lo_range_collector) = NEW cl_salv_range_tab_collector( ). lo_range_collector->add_ranges_for_name( iv_name = 'PRODUCT_ID' it_ranges = s_prdid ). lo_range_collector->get_collected_ranges( IMPORTING et_named_ranges = DATA(lt_select_options) ). *4... Build conditions lo_condition_factory = lo_alv_display->condition_factory( ). lo_additional_condition = lo_condition_factory->equals( name = 'CATEGORY' value = p_prdctg ). *5... Set select options and conditions lo_alv_display->set_select_options( it_ranges = lt_select_options io_condition = lo_additional_condition ). *5... Display ALV lo_alv_display->fullscreen( )->display( ).
4. Lets look at what have we written,
- Declared the select options for the field PRODUCT_ID and PARAMETERS for CATEGORY.
- Create and add the range table for the select options PRODUCT_ID.
- Get the ranges of select options into the table LT_SELECT_OPTIONS.
- Build the conditions for the PARAMETERS on selection screen using condition factory classes.
- Finally set the select options and parameters to the ALV with IDA using SET_SELECT_OPTIONS.
5. Activate and execute the ABAP program.
6. Provide values for parameter product category on selection screen and hit execute button.
7. You should see the output for the selected product category only, like below.
8. Now provide both Parameters and select-options on selection screen.Hit execute button
You have successfully created an ABAP ALV with IDA using Parameters and Select- Options.
Please stay tuned to us for ABAP on HANA and ABAP in Eclipse tutorials.Please feel free to comment and let us know your feedback. Thank you.