Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Checking if current pass in the loop is last pass..

Hello Gurus,

I want check if there exist any more record inside for an internal table insie the loop after the current record. If the current record in the loop is last then I want to execute a logic.

loop at it_tab.

if the record does not exist for the next pass (i.e current pass is the last pass)

"do some logic"

endif.

endloop.

How can check if current next record exist for the internal table when I am in current pass in the loop or if the current pass is last pass ?

Regards,

Rajesh.

Tags:
replied

Hi,

Use DESCRIBE statement to know the number of lines in that Internal Table,

Then Use

IF sy-tabix = 'a'.

Logic.

ENDIF.

Ex:-

DATA : a TYPE i.

DESCRIBE TABLE itab LINES a.

LOOP at itab.

IF sy-tabix = 'a'.

Logic.

ENDIF.

ENDLOOP.

Where a is the variable which has the total number of records value from DESCRIBE statement.

Regards

Bala Krishna

Edited by: Bala Krishna on Oct 17, 2008 12:11 AM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question