user25665577
user25665577

Reputation: 1

Can we use expressions such as GE or LE in FILTER statement in ABAP 7.5

I've my code written as below

DATA LT_OP TYPE STANDARD TABLE OF TY_ABC
                 WITH EMPTY KEY
                 WITH NON-UNIQUE SORTED KEY AB
                 COMPONENTS AB BC CD.

lt_OP =  FILTER #( LT_HIU USING KEY AB
                           WHERE AB = CONV #( to_upper( 'AB' ) ) AND
                                 BC = CONV #( to_upper( 'BC' ) ) AND
                                 CD = CONV #( to_upper( 'CD' ) ) ).

I wanted to a date field where I can use GE lv_date

I've tried using the expression and didnt work

Upvotes: -1

Views: 187

Answers (1)

Philipp
Philipp

Reputation: 69703

Yes, you can do that. Not only are the modern comparison operators like >= or <= supported in filter conditions, but the archaic ones like GE or LE as well:

TYPES:
  BEGIN OF struct_data,
    value TYPE string,
    date  TYPE d,
  END OF struct_data,
  
  table_data TYPE STANDARD TABLE OF struct_data
     WITH DEFAULT KEY
     WITH NON-UNIQUE SORTED KEY key_date COMPONENTS date.


DATA(gt_data) = VALUE table_data(
   ( value = 'Asfd' date = '20240101' )
   ( value = 'XYT' date = '20240301' )
   ( value = 'SADFfd' date = '20240501' )
).

DATA(gt_filtered) = FILTER table_data(
     gt_data USING KEY key_date
        WHERE date >= CONV d('20240301')
).

This results is gt_filtered having two of the three rows of gt_data.

I am not sure what your mistake could have been. Maybe you forgot to add the date field to the secondary table key you are filtering by?

Upvotes: 2

Related Questions