‎2006 Nov 03 5:05 AM
when i am out of loop of an internaltable i have to go to print last record of an internal table.
can any body help me for this.
thanks $ regards
prahap
‎2006 Nov 03 5:09 AM
Hi Prathap
When you have made a loop continously, work area will have the last record. So you can use that orelse you can use below records for all cases.
<b>
DATA: l_lines TYPE I.
DESCRIBE TABLE <itab> LINE l_lines.
if l_lines > 0.
READ TABLE <itab> into <wa> index l_lines.
endif.</b>
Now <wa> will have the last record of the internal table.
Hope this helps.
Kind Regards
Eswar
‎2006 Nov 03 5:09 AM
sort itab by <fld> descending.
read table itab index 1.
write itab.
or
describe table itab lines fill.
read table itab index fill.
if sy-subrc = 0.
write itab.
endif.
Regards
- Gopi
‎2006 Nov 03 5:28 AM
Hi Prathap,
Use At last command.
Loop at itab into wa_itab.
.
.
.
.
.
at last.
move wa_itab-<field_name> to field.
end at.
endloop.
write field.
field is a varible( you have to declare) that contains the last record.
Regards,
Guru
*Mark helpfull answers
‎2006 Nov 03 10:16 AM
hi,
jus consider the following example
in this n gives the last record
report zodd_number_recs.
tables: zemp.
data : t1 type i value 1,
t2 type i value 0,
n type i.
data: begin of itab occurs 0,
empno like zemp-empno,
end of itab.
select empno from zemp into table itab .
loop at itab.
n = sy-tabix.
t1 = sy-tabix.
t2 = t1 mod 2.
if t2 <> 0.
write:/ itab-empno.
endif.
t1 = t1 + 2.
endloop.
write: / n.
‎2006 Nov 03 10:20 AM
Prathap,
another way is to by the use of work areas.
loop at itab into istab.
your loop processing.
endloop.
after the loop istab would have the details of last record.(make sure you dont use clear istab in the loop).