‎2007 Apr 19 5:32 AM
Hi,
I want to read the last record in the Database Table. How to write such an select statement.I don't want to use Internal tables for this purpose. Is there any way.
regards,
Navneeth.K
‎2007 Apr 19 5:49 AM
Hi,
Please take a look at my example below.
tables: vbak.
select vbeln erdat
from vbak up to 1 rows
into (vbak-vbeln, vbak-erdat)
order by erdat descending.
write: vbak-vbeln, vbak-erdat.
In my example above, it gets the last record from VBAK table according to the date. Hope this helps...
P.S. Please award points if it helps...
‎2007 Apr 19 5:38 AM
hi
try this
<b>DESCRIBE TABLE i_mvke LINES ws_lines.
READ TABLE i_mvke INTO wa_mvke INDEX ws_lines.</b>
You will have a latest record in wa_mvke
regards
ravish
<b>plz reward points if helpful</b>
‎2007 Apr 19 5:42 AM
Hi Ravish,
I dont want to use any internal tables , is there any other way.
regards,
Navneeth.K
‎2007 Apr 19 5:45 AM
Hi Navneeth,
Try this query
SELECT * FROM <tablename> LIMIT < last row number in the table>,-1.
Regards,
ANusha
‎2007 Apr 19 5:47 AM
Hi,
As SAP uses internal tables to manipulate the data, i dont think you can directly get the last record from database table directly.
You can get the number of records directly using count(*) or getting sy-dbcnt.
Sandeep
‎2007 Apr 19 5:49 AM
Hi,
Please take a look at my example below.
tables: vbak.
select vbeln erdat
from vbak up to 1 rows
into (vbak-vbeln, vbak-erdat)
order by erdat descending.
write: vbak-vbeln, vbak-erdat.
In my example above, it gets the last record from VBAK table according to the date. Hope this helps...
P.S. Please award points if it helps...