07-14-2008 6:36 PM
Hi All,
I have two internal table. in one internal table all data are available. now i want last record on first internal table and store in second internal table.... so give me some logic or sample code......
Thanks
zeni
07-14-2008 6:44 PM
Hi Zeni,
Try the following:
First find the number of records in the first internal table itab1 using
DESCRIBE TABLE itab1 LINES w_lines.
Now read the first internal table :
read table itab1 index w_lines.
Now append the record from itab1 to itab2.
append fs_itab1 to itab2.
Hope this helps you.
Regards,
Chandra Sekhar
Edited by: Chandrasekhar Gandla on Jul 14, 2008 7:48 PM
07-14-2008 6:38 PM
Hi,
describe table itab1 lines ws_lines.
read table itab1 into ws_itab1 index ws_lines.
ws_itab2 = ws_itab1.
append ws_itab2 to itab2.
Regards,
Subramanian
07-14-2008 6:39 PM
lets have itab1 as the internal table
DATA: N TYPE I.
DESCRIBE TABLE ITAB1 LINES N.
read table itab1 index N.
this will read the last row of itab1...
Hope this helps
Cheers
Kothand
07-14-2008 6:43 PM
Use DESCRIBE TABLE itab LINES n statment, which is return no of lines 'n' in internal table.
Use 'READ' statment with index 'n'. will get the last record in first internal table and append that record to second internal table.
Regards,
Soujanya
07-14-2008 6:44 PM
Hi Zeni,
Try the following:
First find the number of records in the first internal table itab1 using
DESCRIBE TABLE itab1 LINES w_lines.
Now read the first internal table :
read table itab1 index w_lines.
Now append the record from itab1 to itab2.
append fs_itab1 to itab2.
Hope this helps you.
Regards,
Chandra Sekhar
Edited by: Chandrasekhar Gandla on Jul 14, 2008 7:48 PM
07-14-2008 6:57 PM
Hi All,
Thanks i solved my problem.........
i assign point also......
Thanks
zeni
07-20-2013 6:10 AM
get the latest record from an internal table.
if you are using function module RH_READ_INFTY_1001 then <itab
> will always contain all the records betweebn specified period (taken from selection screen), but to retrieve the latest, sort the records by ENDDA and you will get it on top, then use INDEX 1 for that record only, and store the record in a <work_area>, finally get that record from <work_area> to <itab> it self. thats way your <itab> will hold only latest record.(you can store <work_area> in <work_area_2> and then pass the record in to <itab>
or, you can store the <work_area> to a different <itab_2>).
call function RH_READ_INFTY_1001
tables
i1001 = it_hrp1001
sort it_hrp1001 by endda descending.
read table it_hrp1001 into wa_hrp1001 INDEX 1.
refresh it_hrp1001.
append wa_hrp1001 to it_hrp1001.
07-22-2013 6:41 AM
Hi Zenithi,
Please refer the below code.
DATA : lv_line TYPE i.
DESCRIBE TABLE itab1 INTO lv_line.
READ TABLE itab1 ASSIGNING <fs_itab1> INDEX lv_line.
APPEND <fs_itab1> TO itab2.
Hope this will work..
Thanks,
Supratik
07-22-2013 1:40 PM
Thanks to all...even i was having same requirement.
its working perfactly..
10-03-2014 4:55 AM
BTW - In more recent ABAP versions, you can do this to get the last record:
read table itab1 index lines( itab1 ).
10-03-2014 11:31 AM
Hi Matt,
How about this : wa = itab[ lines( itab ) ].
I have not checked the above yet, but for ex: wa = itab[ 4 ] works.
🙂
Kesav
11-18-2020 4:05 PM
Indeed this works on modern ABAP 7.4 or greater.
DATA(wa) = itab[ lines( itab ) ].