Hi everybody,
I am trying to use a table comprehension to find all elements in a list of integers that are greater or equal to the first element.
My idea was to use a table comprehension as follows:
data(lt_great) = value t_int( for wa in lt_data from 2 where ( TABLE_LINE >= lt_data[ 1 ] ) ( wa ) ).
However this doesn't seem to work. Here's my demo report
REPORT ZPORT_COMP2. types t_int TYPE TABLE OF i with EMPTY KEY. data(lt_data) = value t_int( ( 1 ) ( 2 ) ( 3 ) ). data(lt_from2) = value t_int( for wa in lt_data from 2 ( wa ) ). data(lt_tmp) = value t_int( for wa in lt_data from 2 where ( TABLE_LINE >= 1 ) ( wa ) ). data(lt_great) = value t_int( for wa in lt_data from 2 where ( TABLE_LINE >= lt_data[ 1 ] ) ( wa ) ). perform print USING `lt_data ` lt_data. perform print USING `lt_from2` lt_from2. perform print USING `lt_tmp ` lt_tmp. perform print USING `lt_great` lt_great. form print using name type string list type t_int. write: name. LOOP AT list ASSIGNING FIELD-SYMBOL(). write: . ENDLOOP. write /. ENDFORM.
The output is
Programm ZPORT_COMP lt_data 1 2 3 lt_from2 2 3 lt_tmp 2 3 lt_great 1 2 3
I don't understand why the last table comprehension results in 1, 2, 3. Why is 1 part of the result? The "from" clause should make the comprehension to start looking at line 2, right?