Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Accessing multiple rows of internal table using table function for NW 7.5

vivek_priyadarshi2
Participant
0 Likes
2,375

Hello,

Is there a table function feature which allows accessing multiple rows of an internal table at once.

Eg: itab[ 3 to 10 ] should return all rows between index 3 and 10 both inclusive.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
2,058

Eventually use this workaround :

VALUE #( ( LINES OF itab FROM 3 TO 10 ) )

(see ABAP documentation of LINES OF)

Complete example:

TYPES ty_itab TYPE STANDARD TABLE OF i WITH EMPTY KEY.
DATA: itab  TYPE ty_itab,
      itab2 TYPE ty_itab.
itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ( 6 ) ( 7 ) ( 8 ) ( 9 ) ( 10 ) ( 11 ) ).
itab2 = VALUE #( ( LINES OF itab2 FROM 3 TO 10 ) ).
ASSERT itab2 = VALUE ty_itab( ( 3 ) ( 4 ) ( 5 ) ( 6 ) ( 7 ) ( 8 ) ( 9 ) ( 10 ) ).

Hello,

Is there a table function feature which allows accessing multiple rows of an internal table at once.

Eg: itab[ 3 to 10 ] should return all rows between index 3 and 10 both inclusive.

2 REPLIES 2
Read only

GK817
Active Contributor
0 Likes
2,058

Hi,

Not aware of table expression like you mentioned.

As an alternative, you can loop at table, then you have option to mention start index and end index in ‘loop at ......’ statement.

GK

Read only

Sandra_Rossi
Active Contributor
2,059

Eventually use this workaround :

VALUE #( ( LINES OF itab FROM 3 TO 10 ) )

(see ABAP documentation of LINES OF)

Complete example:

TYPES ty_itab TYPE STANDARD TABLE OF i WITH EMPTY KEY.
DATA: itab  TYPE ty_itab,
      itab2 TYPE ty_itab.
itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ( 6 ) ( 7 ) ( 8 ) ( 9 ) ( 10 ) ( 11 ) ).
itab2 = VALUE #( ( LINES OF itab2 FROM 3 TO 10 ) ).
ASSERT itab2 = VALUE ty_itab( ( 3 ) ( 4 ) ( 5 ) ( 6 ) ( 7 ) ( 8 ) ( 9 ) ( 10 ) ).