03-13-2007 9:00 AM
Hello!
Can this following code work with this logic to determine the
youngest date ?
Regards
Ilhan
DATA it_hs TYPE ty_hsnr occurs 0 with header line.
DATA wa_hs TYPE ty_hsnr.
FORM hsnr_determine using mater type MATNR
changing nr type stawn.
select matnr valid stawn from /G2A/LDM_VL_MAT
into table it_hs WHERE
MATNR = mater .
<b>sort it_hs by VALID.</b>
read table it_hs INTO wa_hs INDEX 1 .
nr = wa_hs-STAWN.
ENDFORM.
03-13-2007 9:07 AM
sort it_hs by VALID
i dont know what u mean by youngest date ?
but
1.
sort it_hs by VALID
will give the old date ( previous date " -->before )
2.sort it_hs by VALID descending.
will give u the latest date ( recent used date )
03-13-2007 9:06 AM
Hi IIhan,
If you sort the internal table in ascending order with repect to the Valid date and read the first index, then it should return you data corresponding to oldest date.
If you sort the internal table in descending order with repect to the Valid date and read the first index, then it should return you data with the latest date.
Regards,
George
reward for all helpful tips
03-13-2007 9:07 AM
sort it_hs by VALID
i dont know what u mean by youngest date ?
but
1.
sort it_hs by VALID
will give the old date ( previous date " -->before )
2.sort it_hs by VALID descending.
will give u the latest date ( recent used date )
03-13-2007 9:13 AM
For Youngest / recent date you should use
SORT <itab> BY <Field> DESCENDING.
This will bring the row with largest date on the first row.
Now you can do a READ on the first row.
READ TABLE <itab> INDEX 1.
Hope it will help.
Vishal
03-13-2007 9:15 AM
Hi.....
if u write
<b>sort it_hs by VALID</b>
here first record will give u the oldest date.
and if u write
<b>sort it_hs by VALID descending </b>
here first record will give u the youngest date.
Reward points if useful......
Suresh......
03-13-2007 9:21 AM
Hi,
If u want the latest date then u must sort the table byu descending in addition this will give u the latest date if index is 1,other wise u have to read the valid from
the last index .
Regards,
Ravi
03-13-2007 9:43 AM
THOUGH SORT COMMAND WILL SORT IN ASCENDING ORDER BURT FOR YOUR REQUIREMENT YOU CAN ADD ASCENDING OPTION IN SORT ALSO.
sort it_hs by VALID ASCENDING.
read table it_hs INTO wa_hs INDEX 1 .
IT WILL GIVE YOU THE DATA WITH SMALLEST DATE.
REGARDS
SHIBA DUTTA