Skip to Content
avatar image
Former Member

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 16, 2008 at 06:36 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2008 at 06:29 PM

    use AT LAST before endloop. read f1 help on how to use that

    Add comment
    10|10000 characters needed characters exceeded