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

Read Data Based On Latest Document Change Date

Former Member
0 Likes
482

Dear all,

I would like to pull data based on latest date and print it out.

Now I having 2 internal table:

itab1 having info record no, vendor, material, and value

itab2 having info record no and info record change date

both info record no. came from different field.

How can I get the latest date in itab2 and pull out the data from itab1 based on the date? Can you please give me a sample code?

I know to get latest date is sort itab2 descending and read itab2 index 1, but how should I pull data from itab1 based on this?

Rewards point will be given for helpful answer. Thank you

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
449

Hello


sort itab1. sort itab2.
loop at itab2.
  at end of 'info record no'.
    read table itab1 with key 'info record no' = itab2-'info record no'.
    if sy-subrc = 0.
      write: itab1-'info record no',
             itab1-'vendor',
             itab1-'material',
             itab1-'value'.
    endif.
  endat.
endloop.

2 REPLIES 2
Read only

Former Member
0 Likes
450

Hello


sort itab1. sort itab2.
loop at itab2.
  at end of 'info record no'.
    read table itab1 with key 'info record no' = itab2-'info record no'.
    if sy-subrc = 0.
      write: itab1-'info record no',
             itab1-'vendor',
             itab1-'material',
             itab1-'value'.
    endif.
  endat.
endloop.

Read only

Former Member
0 Likes
449

Hi,

SORT itab1.

SORT itab2.

LOOP at itab1 into wa_itab1.

read table itab2 WITH KEY

'info record no' = wa_itab1'infozecord no'.

if sy-subrc = 0.

write : / itab2-'info record change date'.

endif.

ENDLOOP.

regards,

Bhupal.