Application Development 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: 

last entry entered in the table should come first

Former Member
0 Kudos

Hi all,

I have created a table and when I enter the data,The last entered data should display first.

I tried it by sorting the primary key field but the data entered in this field may not be in some order.so this is not woking.

Please help me what I can do for this .It is very urgent and Plz try to help me soon.

Thanks a million.........in advance..

Regards,

Akanksha

5 REPLIES 5

Former Member
0 Kudos

Hi,

You can read the contents into an internal table and get the last one. But this may cause performance problems if your table is too large.

DATA itab LIKE TABLE OF ztable.

SELECT *
 FROM ztable
 INTO TABLE itab.

DATA lines TYPE i.

DESCRIBE TABLE itab LINES lines.

READ TABLE itab INDEX lines.

WRITE : itab.

Regards,

Wenceslaus.

Former Member
0 Kudos

Hi,

Enter the data into an internal table.

describe table itable lines i.

while i not equal to 0

insert data

i = i - 1.

endwhile.

Regards,

Smitha.

claus_wallacher
Active Participant
0 Kudos

If you talk about a standard internal table, just fill the table using

INSERT <value> INTO int_tab INDEX 1.

Then your last entry is always on top of your internal table.

Regards,

Claus

0 Kudos

Hi,

use <b>READ TABLE itab INDEX v_line.</b>

Regards,

Santosh

vinod_gunaware2
Active Contributor
0 Kudos

U have to take two more field date and time(i.e. last change)

so that u can get last record depending upon that fields.

U can update that field using table maitiance.

regards

vinod