08-05-2008 10:18 AM
Hi All,
I have some data in an internal table as below:
10344 5/6/08 12.20
10344 6/6/08 12.30
10344 7/6/08 12.40
10345 1/2/08 01.20
10345 2/2/08 01.30
I want to modify the entries of the same internal table to be as follows:
10344 7/6/08 12.40
10345 2/2/08 01.30
how can i do it with monimum coding?
08-05-2008 11:08 AM
Hello Rakesh,
use DELETE ADJACENT DUPLICATES on first field
e.g.:
SORT <itab> BY <field1>.
DELETE ADJACENT DUPLICATES FROM <itab> COMPARING <field1>.
Regards
Indu
08-05-2008 11:09 AM
Hi,
Field1 Field2 Field3
10344 5/6/08 12.20
10344 6/6/08 12.30
10344 7/6/08 12.40
10345 1/2/08 01.20
10345 2/2/08 01.30
If you want to modify the specific record as below:
10344 7/6/08 12.40
10345 2/2/08 01.30
If the field1 and Field2 are unique the you can perform read and modify the specific record otherwise modify within loop.
Ex:
Read table ITAB with key field1 = '10344' field3 = '12.40'.
if sy-subrc eq 0.
itab-field1 = '10345'.
itab-field2 = '2/2/08'.
itab-field3 = ' 01.30'.
MODIFY ITAB index sy-tabix.
endif.
08-05-2008 11:10 AM
sort itab by filed1 field3.
delete adjacent duplicates from itab comparing field1.
this will solve ur purpose....
08-05-2008 11:10 AM
Rakesh,
here am assuming about your internal table as
Field1 Field2 Field3
10344 5/6/08 12.20
10344 6/6/08 12.30
10344 7/6/08 12.40
10345 1/2/08 01.20
10345 2/2/08 01.30
sort itab by field1 field3 by decending.
DELETE ADJACENT DUPLICATES FROM itab COMPARING field1.
Amit.
08-05-2008 11:11 AM
Hi
Try this...
SORT ITAB BY <KEY_FIELD> ASCENDING <DATE_FIELD> DESCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING <FIELD_NAME>
Hope it helps.
Murthy
08-05-2008 11:11 AM
There are veriety of methods but try to use this one and get back.
Sort it_data by <first_field>
Delete Adjacent Duplicates FROM it_data
rgds
rajesh
08-05-2008 11:11 AM
First sort descending by 1st and 2nd fields.
And then delete adjacent duplicates comparing 1st field.
Regards,
Aparna Gaikwad
08-05-2008 11:38 AM
hi.
better to create another internal table. and use following logic:
loop at itab1.
at end of field1.
itab2-field1 = itab-field1.
pass other fields also.
append itab2.
endat.
endloop.
hope this will help u.