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: 

how to find last row in itab?

Former Member
0 Kudos

hi experts,

How to find the last row or item in an itab.I am using if statement for which i have to check the last row and if it is the last row some set of statements should trigger.

thanks

mani

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use this code.

data v_lin type i.

describe table itab lines v_lin.

read table itab index v_lin.

7 REPLIES 7

Former Member
0 Kudos

Hi,

Get the number of records existed in itab using DESCRIBE and use READ staetement with index, you will get the last record of itab.

Describe table itab lines l_lines.

reasd table itab index l_lines.

Sudheer.A

Message was edited by:

sudheer Addepalli

0 Kudos

Hi,

Using DESCRIBE get the count if the lines in the ITAB and then compare it agisnt sy-tabix with in a LOOP.

DATA: line type I.

DESCRIBE TABLE itab LINES line.

if line = sy-tabix.

  • last line

endif.

Regards,

Sesh

Former Member
0 Kudos

Use this code.

data v_lin type i.

describe table itab lines v_lin.

read table itab index v_lin.

0 Kudos

describe table itab lines n

and read table itab index n

Message was edited by:

Madan Gopal Sharma

Message was edited by:

Madan Gopal Sharma

Former Member
0 Kudos

Hi,

Describe table lines <it finds the number of record in internal table>

code:data v_lin type i.

describe table itab lines v_lin

<Read table itab index no of lines.>

read table itab index v_lin.

Regards

Former Member
0 Kudos

hi,

DATA: line type I.

DESCRIBE TABLE itab LINES line.

if line = sy-tabix. //

statement[s].

endif.

describe statement gives the total no . of lines in the internal table. if line no = last line then give statements.

if helpful reward some points.

with regards,

Suresh Aluri.

raymond_giuseppi
Active Contributor
0 Kudos

Just, find the last record :

* Standard table
  DESCRIBE TABLE itab LINES n.
  READ TABLE itab INDEX n.

Check on the table with special work at last record :

* Loop
  LOOP AT itab.
    MOVE itab TO wa_itab.
    AT LAST.
* here wa_itab is the last record (itab is *****)
    ENDAT.
  ENDLOOP.

Regards