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

Last changed record

Former Member
0 Likes
1,438

Hi,

I have a small query. I use the changeddocument_read to fetch the changes on SORT field on LFA1.

I get all the values in internal table.Could you please tell me how to fetch the last changed record ?

When i use SORT itab by date descending time descending , it works like date ascending and time descending.

I need to fetch the last changed using UDATE and UTIME latest value.

Can you help.

Thanks

AS

4 REPLIES 4
Read only

Former Member
0 Likes
1,266

Hi AS

It`s weird, SORT itab BY udate DESCENDING utime DESCENDING. should works fine.

Please past your code here, then we can further check.

regards,

Archer

Read only

mayur_priyan
Active Participant
0 Likes
1,266

DATA : lt_lfa1 TYPE STANDARD TABLE OF lfa1,

       wa_lfa1 TYPE lfa1.

SELECT * FROM lfa1 UP TO 30 ROWS  INTO TABLE lt_lfa1.

IF NOT lt_lfa1[] IS INITIAL.

SORT lt_lfa1 by UPDAT DESCENDING UPTIM DESCENDING.

LOOP AT lt_lfa1 INTO wa_lfa1.

WRITE/ wa_lfa1-LIFNR, wa_lfa1-UPDAT, wa_lfa1-uptim.

ENDLOOP.

ENDIF.

Read only

VijayaKrishnaG
Active Contributor
0 Likes
1,266

Hi Swarna,

If you are trying to fetch latest record (last changed, can be newly added Vendor) from LFA1 irrespective to LIFNR, you can use following select statement:

SELECT SINGLE LIFNR MAX( UPDAT ) MAX( UPTIM ) FROM LFA1 INTO LS_LFA1

  WHERE LIFNR = P_LIFNR

  GROUP BY LIFNR UPDAT UPTIM.

Otherwise, if you are looking for the latest change in a log of particular vendor, you should fetch data from tables like CDHDR CDPOS.

To get the log,

Pass OBJCETCLASS as 'KRED', OBJECTID as <LIFNR> (with leading zeros) and TCODE as 'XK02'.

To get the log details,

Get the CHANGENR field from above statement and pass that to CDPOS. You will get detailed log.

Regards,

Vijay

Read only

vinodkumar_thangavel
Participant
0 Likes
1,266

Hi ,

Try to use Sort syntax as SORT itab by date descending and time descending.

Regards,

Vinodkumar.