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

display the date

Former Member
0 Likes
1,369

Good morning,

I'd like to display the date the particular material was counted on..... in case I have 2 count dates for the single material I should display the recent one. please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,344

suppose your itab contains

matnr date like this.[sequence is important here]

sort itab by matnr date descending.

loop at itab int watab.

at new matnr.

write : / watab-matnr, watab-date.

endat.

endloop.

regards

shiba dutta

10 REPLIES 10
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,344

Hi,

I think you can Sort the data by date and read the first record. This will be easy if you have the data in internal table else sort in the qury itself.

Regards,

Sesh

Read only

0 Likes
1,344

yes it is in the internal table

Read only

0 Likes
1,344

Hi ,

I if all the data is in internal table then sort the internal table by material numer and date descending.

So it would be SORT IT BY MATNR DATE DESCENDING.

So it sorts the material number and if a material has more than 1 date then the records will be arranged in descending order of date.

the you can use delete adjacent duplicates comparing matnr to delete all duplicte reords.

Regards

Arun

Read only

Former Member
0 Likes
1,344

You can compate the date using if condition.

if date1 > date2.

write:/ date1. "Recent date

endif.

Read only

0 Likes
1,344

thanks.... what's if I have only one date for that material

Read only

Former Member
0 Likes
1,344

Hi

In that case when you have two dates consider the time factor also .

Sort your table by date descending time descending.

Try this .

Please reward if useful.

Read only

Former Member
0 Likes
1,345

suppose your itab contains

matnr date like this.[sequence is important here]

sort itab by matnr date descending.

loop at itab int watab.

at new matnr.

write : / watab-matnr, watab-date.

endat.

endloop.

regards

shiba dutta

Read only

Former Member
0 Likes
1,344

sort itab1 by matnr ascending date1 by descending.

loop at itab1 into wa_itab1.

read table itab1 with key matnr = wa_itab1 binary search.

if sy-subrc = 0.

g_date = itab1-date1.

endif.

endloop.

Read only

Former Member
0 Likes
1,344

sort itab1 by matnr ascending date1 by descending.

loop at itab1 into wa_itab1.

read table itab1 with key matnr = wa_itab1 binary search.

if sy-subrc = 0.

g_date = itab1-date1.

endif.

endloop.

Read only

0 Likes
1,344

Thank you guys the problem is solved.