SALV IDA – Selection Conditions

By | July 25, 2016 | SALV IDA, SALV Tutorial | 11,182 | 0

Lets check more SALV IDA on how to send the selection conditions so we can restrict the data access based on user inputs.



In the article SALV IDA – Introduction, we have seen how SALV IDA can be used. Also in the traces section, it was more visible that IDA provided much more performance improvement when working on HANA Database. This code lines are based on the template provided in the article SALV IDA – Introduction. So, there are several reasons to read that before jumping on.

Selection Condition

IDA has a method CONDITION_FACTORY, which will be used to send the conditions to the IDA model. This conditions would be then converted to WHERE condition when data is actually selected.

At a high level

These are the steps you need to follow to add the Selection Condition to the IDA:

  • Get the condition object, using CONDITION_FACTORY (Factory Design pattern)
  • When you have Ranges – Get the range table collector using the method CL_SALV_RANGE_TAB_COLLECTOR. Use method ADD_RANGE_FOR_NAME of the tab collector object to add the range. The method, as name suggests, is based on the collector design pattern
  • When you specific condition – pass the condition as the condition object. This is using the Decorator design pattern.
  • Pass the ranges, and/or condition object to set the conditions using the SET_SELECT_OPTIONS

Code Lines

To keep the code lines small and sweet, I have only supplied the relevant code lines here. You can add these into respective section in the Template program to make it full demo. If you are with me for a long time, you would see the familiar pattern which was used in SALV tutorials :)

* Some selection criteria
SELECT-OPTIONS: s_langu FOR sy-langu.
* Class definition
* In the method GENERATE_ALV
        me->add_selection_conditions( ).
* Class Implementation
  METHOD add_selection_conditions.
* Get condition factory
    DATA(lo_cond_factory) = o_salv_ida->condition_factory( ).
* Fixed range
    DATA(lt_fixed_ranges) = 
       VALUE if_salv_service_types=>yt_named_ranges(
          ( name = 'MSGNR' sign = 'I' option = 'BT' low = '000' high = '010'  )
* From Selection screen
    DATA(lo_ranges) = NEW cl_salv_range_tab_collector( ).
    lo_ranges->add_ranges_for_name( iv_name = 'SPRSL' it_ranges = s_langu[] ).
       IMPORTING et_named_ranges = DATA(lt_name_range_pairs)  ).
* Final range
    APPEND LINES OF lt_fixed_ranges TO lt_name_range_pairs.
*   Ranges
      it_ranges = lt_name_range_pairs
*   condition object
      io_condition = 
        lo_cond_factory->equals( name = 'SPRSL' value = sy-langu )->and(
          lo_cond_factory->equals( name = 'ARBGB' value = '00' )->or(
            lo_cond_factory->equals( name = 'ARBGB' value = '01' )

Here, I’m passing the criteria entered on the selection screen ( From S_LANGU to LO_RANGES to LT_RANGE_PAIRS ) and also passing some hard-coded conditions (to the IO_CONDITION object). If you have noticed that I’m passing S_LANGU directly and you are like what, then read article ABAP Object Oriented Approach for Reports – Redesign for more info on how to pass the Select Options / parameters properly to the report.


This program now generates this output:


Next Article

SALV IDA – New Calculated Fields


Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{273 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 273 articles.

Load comments

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.