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: 

EOF in internal table

Former Member
0 Kudos

as I can know when it is the EOF in an internal table

Thanks

11 REPLIES 11

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Do you mean, how to know when you are at the last record?

If you are using a LOOP. Then you can use the AT LAST statement in your loop.



report zrich_0001.

data: itab type table of string with header line.
data: xtab type string.

itab = 'String A'.  append itab.
itab = 'String B'.  append itab.
itab = 'String C'.  append itab.
itab = 'String D'.  append itab.


loop at itab.
xtab = itab.

  at last.
    write:/ xtab.
    write:/ 'this is the last record'.
  endat.

endloop.

Regards,

Rich Heilman

Better Sample

Message was edited by: Rich Heilman

0 Kudos

Thanks, this function I work myself

Former Member
0 Kudos

hii

use AT LAST.

OTHERWISE

<b>data: syindex type i.

Describe table itab lines syindex.

read table itab index syindex.</b>

this will count the number of records and this will give you last record .

otherwise

<b>Loop in ITab and

you get the count in sy-tabix</b>

with that sy-tabix count we can print the last record.

Reward points if helpful

revert back for more help .

regards

Naresh

0 Kudos

hi use

loop.

<b>AT LAST.

AT ENDOF.</b>

endloop.

Regards,

Santosh

Former Member
0 Kudos

Hi,

You can use AT LAST event in loop.

Loop at itab.

At Last.

Endloop.

Cheers,

Bujji

Former Member
0 Kudos

Hi,

U can find with the event at last...endat in loop.

Sreedhar

former_member181966
Active Contributor
0 Kudos

Also you can execute this command which returns you the lines

DESCRIBE TABLE itab LINES N

eof = n.

loop at itab.

if eof = sy-tabix.

***do something

endif.

endloop.

Hope this’ll give you idea!!

<b>P.S award the points.</b>

Good luck

Thanks

Saquib Khan

"Some are wise and some are otherwise"

.

0 Kudos

Thanks, this function I work myself

former_member188685
Active Contributor
0 Kudos

Hi,

you can do this way also...

data: len type i.

describe table itab lines len.

loop at itab.

if sy-tabix = len.
write: 'END of internal table reached'.
endif.

endloop.

Regards

vijay

former_member181962
Active Contributor
0 Kudos

Hi Angel,

describe table itab lines v_lines.

loop at itab.

if sy-tabix = v_lines.

write:/ 'End of internal table reached'.

endif.

endloop.

REgards,

ravi

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Welcome to SDN, Angel. Please make sure to mark your post as a question, and award points for any answers that might have been helpful. Thanks.

Regards,

Rich Heilman