‎2006 Aug 23 6:16 PM
hi SDNs,
i am facing problem with deleting records from the itab.
situation is :
There are 13 fields in my internal table. here i am getting multiple serial numbers (sernr). among the fields..
mblnr , budat, shkzg...
here i want latest document for each serial number. and duplicate serial numbers has to be deleted..
for these i have to sort by internal table by following fields:
mblnr, shkzg and budat in DESCENDING ORDER.
but my requirement won't fulfill i do that. it is not possible..
eg:
mblnr shkzg budat sernr
-
4 s 8 say a
2 s 7 say a
3 h 8 say a
1 s 5 say a
1 h 8 say b
2 s 8 say b
consider these are the conditions:,
so first based on budat (latest doc), i have to decrease. sothat i will get latest doc in the first line. and(if budats are same) then check for mblnr, same desc order. and take which is having heighest value. and based on records shkzg should be sorted in desc order..
so keep the first record as itis and delete (using delete adjacent compring <b>sernr</b>)
so that i will get the latest doc..
<b>this is my requirement. but i am unable to write code for this one, could any one help me out! what to do? </b>
thanking you
‎2006 Aug 23 6:40 PM
Hi Rama krishna,
Your requirement is to get latest document for each serial no based on BUDAT or MBLNR? As there can be multiple documents for one SERNR No for same date so you can not get latest document based on date.
You need to get latest document based on MBLNR no which is latest for each SERNR.
Sort ITAB on SERNR MBLNR IN DESCENDING ORDER.
Then use DELETE ADJACENT DUPLCIATES FROM ITAB COMPARING SERNR. This will delete duplicate SERNR which are found.
Since table will have latest MBLNR as first record for each SERNR.
before sort
mblnr shkzg budat sernr
-
1 s 8 say a
2 s 7 say a
3 h 8 say a
4 s 5 say a
1 h 8 say b
2 s 8 say b
after sort
mblnr shkzg budat sernr
-
4 s 8 say a
3 s 7 say a
2 h 8 say a
1 s 5 say a
2 h 8 say b
1 s 8 say b
Delete adjacent will give you output
4 s 8 say a
2 h 8 say b
Hope this will give your required result.
Please reward useful answers.
‎2006 Aug 24 2:57 AM
hi Sunil Sawaiker ,
thanks for reply...
here some times mblnr repeats and sometimes budat repeats..
in that cases what u said is always not correct...
is there any other method other than sort?
‎2006 Aug 24 5:27 AM
hi,
If shkzg , budat also changes, sort by those fields also.
sort itab by sernr mblnr descending
shkzg descending
budat descending.
delete adjacent duplicates from itab
comparing sernr mblnr shkzg budat.
Did this meet your requirement now?
Regards,
Sailaja.
‎2006 Aug 24 5:30 AM
Hello Ramakrishna,
Sort the table and use <b>DELETE ADJACENT DUPLICATES FROM ITAB COMPARING SERNR MBNLR BUDAT SHKZG.</b>
If useful reward.
Vasanth
‎2006 Aug 24 5:36 AM
IN UR INTERNAL TABLE PUT THE FIRST 4 FIELDS AS SERNR BUDAT SHKZG MBLNR...
SORT ITAB BY SERNR DESCENDING BUDAT DESCENDING SHKZG DESCENDING MBLNR DESCENDING.
DELETE ADJACENT DUPLICATES COMPARING SERNR .