Application Development 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: 

Looping internal table only till one row..

Former Member
0 Kudos

H1,

I want to loop at internal table just for first line.

Loop at IT_TABLE

:

:

ENDLOOP

How do I do this in above command?

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you just want to read the internal table first line,


READ TABLE ITAB index 1.

If you must do a LOOP. Try this.



Loop at IT_TABLE
if sy-tabix > 1.
exit.
endif.
...
ENDLOOP

REgards,

Rich HEilman

4 REPLIES 4

Former Member
0 Kudos

Loop at it_table index 1.

Endloop.

0 Kudos

Sorry it is "read it_table index 1".

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you just want to read the internal table first line,


READ TABLE ITAB index 1.

If you must do a LOOP. Try this.



Loop at IT_TABLE
if sy-tabix > 1.
exit.
endif.
...
ENDLOOP

REgards,

Rich HEilman

Former Member
0 Kudos

The best way is to read the table index 1. You could also:

LOOP AT itab.
  EXIT.
ENDLOOP.

The first record will be in the header area.

Rob