2009 Apr 23 1:12 PM
material norm date last modified
B2-SP HEAT 50.000 20090420
BF COKE 575.000 20090419
GROSS COKE 200.000 20090419
B2-SP HEAT 100.000 20090419
TWT 33.000 20090330
B7-SP HEAT 2.000 20090310
B1-SP HEAT 1.000 20090309
B7-SP HEAT 615.000 20090308
B2-SP HEAT 585.000 20090308
B1-SP HEAT 100.000 20090308
B3-SP HEAT 610.000 20090308
BF COKE 68.500 20090308
GROSS COKE 72.600 20090308
B8-SP HEAT 600.000 20090308
B9-SP HEAT 625.000 20090308
BX-SP HEAT 615.000 20090308
B9-SP HEAT 58.000 20090307
B1-SP HEAT 100.000 20090307
B6-SP HEAT 350.000 20090306
B2-SP HEAT 888.000 20090306
Like above there r numerous data in a table :
how will i select data into another internal table where material above is not repeated with latest modified date.please help.
material norm date last modified
B2-SP HEAT 50.000 20090420
BF COKE 575.000 20090419
GROSS COKE 200.000 20090419
B2-SP HEAT 100.000 20090419
TWT 33.000 20090330
B7-SP HEAT 2.000 20090310
B1-SP HEAT 1.000 20090309
B7-SP HEAT 615.000 20090308
B2-SP HEAT 585.000 20090308
B1-SP HEAT 100.000 20090308
B3-SP HEAT 610.000 20090308
BF COKE 68.500 20090308
GROSS COKE 72.600 20090308
B8-SP HEAT 600.000 20090308
B9-SP HEAT 625.000 20090308
BX-SP HEAT 615.000 20090308
B9-SP HEAT 58.000 20090307
B1-SP HEAT 100.000 20090307
B6-SP HEAT 350.000 20090306
B2-SP HEAT 888.000 20090306
Like above there r numerous data in a table :
how will i select data into another internal table where material above is not repeated with latest modified date.please help.
2009 Apr 23 1:29 PM
Hi,
1) Sort the internal table with respect to material and latest date
2) delete the records which you want by using delete internal table
2009 Apr 23 1:31 PM
Sort ur internal table by material last date .
itab2[] = itab[].
Loop at itab.
read table itab2 with key matnr = itab-date date = itab-date.
if sy-subrc eq 0.
delete itab2 from wa.
else.
continue.
endif,
endloop,
2009 Apr 23 1:36 PM
Hi Sonu,
Loop at itab1.
loop at itab2 where matnr = itab1-matnr.
delete itab2 index sy-tabix.
endloop.
endloop.
now itab1 has same records,
and itab2 has records who are not available in itab1 materials.
now move two tables data inot final internal table.
Regards,
Prabhudas
2009 Apr 23 1:42 PM
Hi,
First sort the table by material and last modified.
SORT itab BY material last_modified.
And then as you don't want same material that has been modified twice on the same day.. just delete those.
DELETE ADJACENT DUPLICATES COMPARING material last_modified.
Now you no need to pass the entries into some other internal table but can use the same itab as the duplicate entries are deleted already..
Hope this helps you...
2009 Apr 23 6:43 PM
you just have to sort and delete adjacent duplicate.
sort it_itab material last_modified.
delete adjacent duplicates comparing material last_modified.
Regards,
Lalit Mohan Gupta
2009 Apr 24 4:40 AM
hi,
First sort the internal table it_tab in ascending order of material and descending order for last_material.
Delete adjacent duplicates. This will keep the records with lates modified date for the material.
SORT it_tab BY matrial ASCENDING
date DESCENDING.
delete adjacent duplicates comparing material.
hope it helps.
2009 Apr 24 6:48 AM
Hi,
First sort the Internal Table with MATNR in assending order and DATE in descending order.
Then, use DELETE ADJACENT DUPLICATES FROM ITAB comparing MATNR DATE.
In this case, all the duplicates records of MATNR(sorted ascending order) and DATE (sorted in descending order, so the old records wil be in the bottom,) will be deleted. Only the latest updated records will be available in ITAB.
Then Move ITAB[] to ITAB2[].
Best Wishes,
Sai Prasad
2009 Apr 24 7:04 AM
Dear somu .
First sort the Internal Table with matnr.
Next, use DELETE ADJACENT DUPLICATES FROM ITAB comparing matnr lastmodified date.
I hope this is useful .
Regards ,
GJ
2009 Apr 24 7:26 AM
HI Sonu,
As u want the matnr not repeated with latest modified into another table,
First move itab1 to itab2.
sort itab2 by matnr ascending last modified descending.
delete adjacent duplicates from itab2 comapring matnr.
2009 Apr 24 7:54 AM
Hi Sonu,
You can use the following algorithm:
DATA: count type i.
SORT itab by date_last_modified material.
LOOP AT itab into wa.
CLEAR count.
LOOP AT itab INTO wa1 WHERE material = wa-material AND
date_last_modified = wa-date_last_modified.
count = count + 1.
ENDLOOP.
IF count = 1.
APPEND wa TO result_itab.
ENDIF.
ENDLOOP.
This logic works for sure.
Thanks and best regards
Anand.
Edited by: Anand Shankar on Apr 24, 2009 12:24 PM
Edited by: Anand Shankar on Apr 24, 2009 12:25 PM
2009 Apr 24 8:12 AM
Hi,
Create an internal table same as your current like Itab1 . Now process the loop for your current internal table [itab]. Take your value in another variable . and on change of matnr move the value in your itab1. eg
Loop at itab.
lmatnr = itab-matnr .
On change of itab-matnr.
itab1-matnr = lmatnr .
modify itab1.
clear lmatnr.
endon.
endloop.
Regards,
Himanshu
2009 Apr 24 8:21 AM
Hi,
You have to first SORT your internal table
according to the material field then use statement,
DELETE ADJACENT DUPLICATES FROM INTERNAL TABLE
By this all the unique entries will be left in the internal table.
Hope it helps
Regards
Mansi
2009 Apr 24 9:54 AM
sort it_tab by material ascending date_modified descending.
delete adjacent duplicates from it_tab."Now the it_tab has the unique and latest modified materials
2009 Apr 24 11:20 AM
Hi Sonu,
The main task is to move the contents of the one internal table to another with some condition.
First sort and delete the duplicate entries from the First Internal table like below :
sort it_tab by material ascending date_modified descending.
delete adjacent duplicates from it_tab.
Then move that Internal table contents to another internal table.
Define another internal table with the same structure as you have first internal table and then
Second Step :
it_itab1 = it_itab.
If you are using seperate Header line and Body then you can do like below :
it_itab1[] = it_itab[].This will fix the issue.
Please let me know if you need any further explonation.
Regards,
Kittu
Edited by: Kittu on Apr 24, 2009 12:21 PM