How to read more than one record with READ TABLE?

3

Is it possible to make a READ TABLE in ABAP to read more than one line?

    
asked by anonymous 20.12.2017 / 16:39

2 answers

2

You can not do it directly, you have to use a loop. Example of documentation :

DATA itab TYPE STANDARD TABLE OF i
          WITH EMPTY KEY
          WITH NON-UNIQUE SORTED KEY sort_key COMPONENTS table_line.

itab = VALUE #( ( 2 ) ( 5 ) ( 1 ) ( 3 ) ( 4 ) ).

DATA(output) = ''.
DATA(idx) = lines( itab ).
WHILE idx > 0.
  READ TABLE itab INDEX idx USING KEY sort_key
             ASSIGNING FIELD-SYMBOL(<fs>).
  idx = idx  - 1.
  CHECK <fs> > 2.
  output = output && <fs> && ' '.
ENDWHILE.

cl_demo_output=>display( output ).
    
20.12.2017 / 16:47
0

Read Table is made to select only 1 line from a transparent table. You need to use a loop to select the desired content from one table to another.

    
14.09.2018 / 13:39