Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Fetching latest records

Former Member
0 Likes
682

Hi All,

I want to fetch some records from a database table which are the latest entries. How can I fetch these records?

Regards,

Jeetu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
660

Hi,

Method 1:

1) check whether you have DATE field in your database table.

2) fetch all records into your internal table.

3) sort internal table by date descending.

4) you will get the latest records on top in your internal table.

Method 2:

If you want only latest 10 records from your internal table

data: begin of itab occurs 10,

Declare your fields here make sure that you have DATE field in your internal table.

end of itab.

Select <fields> from <database table> into itab.

append itab sorted by date.

endselect.

note: Date should be one of teh fields of itab.

Hi All,

I want to fetch some records from a database table which are the latest entries. How can I fetch these records?

Regards,

Jeetu

3 REPLIES 3
Read only

Former Member
0 Likes
660

hi first fetch all data into internl table than loop on itab and get latest records

you can use

loop at itab from 50.

.......

......

endloop.

it will fetch latest record from 50th record.

reward if useful

Read only

Former Member
0 Likes
660

hi,

do this way ...


* To fetch the latest record
select max( field ) from  <Table> into itab where <conditions>. 

Read only

Former Member
0 Likes
661

Hi,

Method 1:

1) check whether you have DATE field in your database table.

2) fetch all records into your internal table.

3) sort internal table by date descending.

4) you will get the latest records on top in your internal table.

Method 2:

If you want only latest 10 records from your internal table

data: begin of itab occurs 10,

Declare your fields here make sure that you have DATE field in your internal table.

end of itab.

Select <fields> from <database table> into itab.

append itab sorted by date.

endselect.

note: Date should be one of teh fields of itab.