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

fatch last inserted record in ztable

Former Member
0 Likes
939

hi all,

any buddy can tell me how can i get last inserted record from my ztable.

hi all,

any buddy can tell me how can i get last inserted record from my ztable.

6 REPLIES 6
Read only

Former Member
0 Likes
870

DESCRIBE TABLE itab LINES SY-TFILL.

READ TABLE itab INDEX SY-TFILL.

Thanks,

Srinivas

Read only

rajasekhar_matukumalli3
Active Participant
0 Likes
870

Hi,

If your requirement is to read the last record from the Ztable

SELECT SINGLE * FROM ZTABLE INTO WA_ZTABLE ORDER BY KEY FIELDS DESCENDING.

Regards,

Raj

Read only

0 Likes
870

Hi,

I think this wont work .....

Ex: table has (considering first two cols as PK's)

000123 AA 124

000123 AB 124

000123 AC 124

000123 BA 124

000123 BB 124

000123 BC 124

000123 LH 124

Now i am inserting 000123 BD 124

=> Records will be arranged as

000123 AA 124

000123 AB 124

000123 AC 124

000123 BA 124

000123 BB 124

000123 BC 124

000123 BD 124

000123 LH 124

How will yur query works ? Please clarify ....

Read only

0 Likes
870

You can add timestamp field in your table ... like we have record creation field in sales document tables..

Then you can read based on max time stamp field..

Enjoy SAP.

Pankaj Singh

Read only

Former Member
0 Likes
870

READ TABLE itab INDEX SY-TFILL..

this will give you the data record last inserted.

thanks...

Read only

vinod_vemuru2
Active Contributor
0 Likes
870

Hi Jitendra,

U must have date and time stamp field in ur ztable to achieve this. First get the records from the table and sort by descending time stamp. Now READ the internal table with INDEX 1. I think this is the only way as per my knowledge. Dont forget to update the timestamp when u create the record

in Ztable:-)

Thanks,

Vinod.