07-23-2007 12:55 PM
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
07-23-2007 1:00 PM
Use this code.
data v_lin type i.
describe table itab lines v_lin.
read table itab index v_lin.
07-23-2007 12:58 PM
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
07-23-2007 12:59 PM
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
07-23-2007 1:00 PM
Use this code.
data v_lin type i.
describe table itab lines v_lin.
read table itab index v_lin.
07-23-2007 1:02 PM
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
07-23-2007 1:07 PM
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
07-23-2007 1:07 PM
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.
07-23-2007 1:10 PM
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