2008 Dec 03 8:37 AM
I have an Internal table, with columns Date, Material no(duplicates), Material Document No(unique).
I would like to pick only latest date record with material no, material document, then delete rest for the material no in the internal table.
Any Suggestion or logic using Internal table..
Edited by: Praba KN on Dec 3, 2008 9:37 AM
2008 Dec 03 8:46 AM
Here it is important column order. Use this like below:
data: begin of it occurs 0,
material type...
date type d,
doc type ...
end of it.
...
sort it by material date doc.
loop at it.
at new material. "gets the lates record from material
continue. "continue loop leaving this entry
endat.
delete it index sy-tabix. "delete all the others
endloop.
This should work
Marcin
2008 Dec 03 8:39 AM
Hi,
First sort your internal table on date field and then select the required fields.Thanks
2008 Dec 03 8:40 AM
hi,
Sort your internal table in descending order by date,and the rest of the fields, in this way you would get the latest date, and delete the remaining record,
Thanks..
2008 Dec 03 8:41 AM
Hi,
Sort the internal table with descending date and read the first recrod.
e.g.
SORT IT_TAB1 by DATS DESCENDING.
Read table it_tab1 index 1.
Hope this will help.
Regards,
Nitin.
2008 Dec 03 8:41 AM
Hi,
sort the internal table with material number , date and material doc then u can have to use control levels .. pick the last record and place in new internal table ..
do the same process to all the material once you completed then you can procedd with new internal table..
Hope Helpfull
Raghunath.S
2008 Dec 03 8:44 AM
2008 Dec 03 8:41 AM
2008 Dec 03 8:41 AM
Hi ,
Sort the internal table on date in decending order and then read the table index 1. this will give you the latest record.
Raj
2008 Dec 03 8:46 AM
Here it is important column order. Use this like below:
data: begin of it occurs 0,
material type...
date type d,
doc type ...
end of it.
...
sort it by material date doc.
loop at it.
at new material. "gets the lates record from material
continue. "continue loop leaving this entry
endat.
delete it index sy-tabix. "delete all the others
endloop.
This should work
Marcin
2008 Dec 03 9:05 AM
P:
With this method, i have 4 record with duplicate Material no, different date and materia no., result is zero.It deleted all the record.
111 1/2/2008 123
111 1/3/2008 132
111 2/3/2008 134
111 12/01/2008 135
I want only
111 12/01/2008 135
rest all needs to be delete in the internal table.
Any thoughts.
2008 Dec 03 9:10 AM
data: begin of it occurs 0,
material type...
date type d,
doc type ...
end of it.
...
sort it by material date doc.
after these steps using
DELETE ADJACENT DUPLICATES FROM it COMPARING material .
will be better than
loop at it.
at new material.
continue.
endat.
delete it index sy-tabix.
endloop.
2008 Dec 03 9:14 AM
Sorry I think it was due to wrong sorting condition. This code works fine (I checked). Only apply this logic.
data: begin of it occurs 0,
m type c,
d type d,
doc type i,
end of it.
it-m = 1.
it-d = '20080101'.
it-doc = 123.
append it.
it-m = 1.
it-d = '20080201'.
it-doc = 132.
append it.
it-m = 1.
it-d = '20080301'.
it-doc = 145.
append it.
sort it by m d DESCENDING doc .
loop at it.
at new m. "gets the lates record from material
continue. "continue loop leaving this entry
endat.
delete it index sy-tabix. "delete all the others
endloop.
Regards
Marcin
2008 Dec 03 9:19 AM