07-22-2008 10:14 AM
Hi all ,
I have requirement of having to take the latest creation date from the internal table .In the internal table i have multiple batch numbers for a particular plant and material number .I want to take one record for each material-batch combination for the given plant.So i have taken the field creation date as criteria .But how to take a single record if there are mutliple records having different batch numbers but same plant and material number .
data :itab_mchb TYPE STANDARD TABLE OF MCHB WITH HEADER LINE.
SORT itab_mchb DESCENDING BY ersda.
07-22-2008 10:25 AM
Hi,
You can use the following sample code:
data :itab_mchb TYPE STANDARD TABLE OF MCHB WITH HEADER LINE,
wa_mchb type mchb,
itab_mchb1 TYPE STANDARD TABLE OF MCHB WITH HEADER LINE.
SORT itab_mchb DESCENDING BY ersda descending.
loop at itab_mvhb.
move-corresponding itab_mvhb into wa_mchb.
at new matnr.
append wa_mchb to itab_mchb1.
endat.
endloop.
just check the structure of mchb.
Thanks and Regards,
Saurabh Chhatre
07-22-2008 10:16 AM
hi
u can use MIN and MAX funtion to get the smaaleest date on that field of ur table
Cheers
Snehi
07-22-2008 10:19 AM
can you please give a sample code for min and max functions .dont how to use it .
thanx in advance.
07-22-2008 10:19 AM
Hi,
After SORTING use INDEX to read data..
Link
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9eaa35c111d1829f0000e829fbfe/content.htm
Regards,
anirban
07-22-2008 10:20 AM
SORT itab_mchb DESCENDING BY matnr werks charg ersda DESCENDING.
delete adjacent dfuplicates from itab_mchb comparing matnr werks.
07-22-2008 10:25 AM
Hi,
You can use the following sample code:
data :itab_mchb TYPE STANDARD TABLE OF MCHB WITH HEADER LINE,
wa_mchb type mchb,
itab_mchb1 TYPE STANDARD TABLE OF MCHB WITH HEADER LINE.
SORT itab_mchb DESCENDING BY ersda descending.
loop at itab_mvhb.
move-corresponding itab_mvhb into wa_mchb.
at new matnr.
append wa_mchb to itab_mchb1.
endat.
endloop.
just check the structure of mchb.
Thanks and Regards,
Saurabh Chhatre
07-22-2008 10:27 AM
Dear Ambarish
usee as follows
SORT itab_mchb DESCENDING BY ersda.
read table itab_mchb INDEX sy-index INTO wa_mchb.
then you can find 1st record in wa_mchb.
wa_mchb should be same structure like itab_mchb.
Rewards if helpful.