‎2009 Dec 11 11:59 AM
hi,
how to fetch last record from database table.
plz reply earliest.
Regards,
Jyotsna
Moderator message - Please search before asking - post locked
Edited by: Rob Burbank on Dec 11, 2009 9:44 AM
‎2009 Dec 11 12:03 PM
Hello,
Select single * from <table> order by <keyfield> desc.
Thanks
manish
‎2009 Dec 11 12:10 PM
must be something with select..i tried but wasn't able to find...
selecting in descending order might not work...
select all the data..
describe the internal table.
and then read with index.
hope it helps
regards
Yadesh
‎2009 Dec 11 12:15 PM
Hi Jyotsana,
Do as below :-
SELECT single FIELD1 FIELD2 from table into TABLE ITAB WHERE FIELD1 = 'VALUE'.
ENDSELECT.
LOOP AT ITAB into WA.
Do nothing....
ENDLOOP.
Here WA will be having the last record.
Regards
Abhii
‎2009 Dec 11 12:22 PM
abhi,
just imagine the table to be BSEG or FAGLFLEXA... then what would be performance of the code ?
any ways,
jyotsna, first check if you have a pattern to follow like if the primary key field have a increasing number range or it would be great if you find a date field which stores the inserted date or some thing..
you can select max or that field or order by descending using select single.
or get all data.. sort in descending order.(again you need some criteria like date).
read the first entry. using read itab index 1