cancel
Showing results for 
Search instead for 
Did you mean: 

read last entry in a database table

Former Member
0 Kudos

Hi,

How to read a last entry in a database table

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

First get the data into an internal table, then

SORT the internal talbe in Descending order, then Read the table with INDEX 1 then you will get the last record

Regards

Sudheer

Former Member
0 Kudos

to get last record:

record with (key1 key2 key3) as the key fields in that order


select max ( key1 ) into l_key1 from table.

select max ( key2 ) into l_key2 from table where key1 = l_key1.

select max ( key3 ) into l_key3 from table  where key1 = l_key1 and key2 = l_key2.

select single * into record from table where where key1 = l_key1 and key2 = l_key2 and key3 = l_key3.

Similar logic if searching by other index fields.

Andrew

Former Member
0 Kudos

Hi,

1. Last means what ? It may mean,

the last entered, as per some date/time field in the table.

2. So its better to select all records first

in some internal table (for the same person number)

3. Then SORT ITAB field5 descending.

4. Read ITAB INDEX 1.

Regards,

Sankar