‎2007 Jul 09 4:23 PM
Hello.
I have a internal table with some fields, and many fiels are repeat. I would delete the fields that are repeat, but not all the fields of this record.
Example:
Code Name Price Date Num
10 X 20 12-10 9
10 X 20 15-10 12
15 R 14 14-10 8
15 R 14 12-10 5
and i would....
10 X 20 12-10 9
15-10 12
15 R 15 14-10 8
12-10 5
Thanks!!!!
‎2007 Jul 09 4:47 PM
Hi,
Please try this.
data: string_old(5),
string_new(5).
sort itab.
loop at itab.
at first.
move: itab-code(2) to string_old(2),
itab-name(1) to string_old+2(1),
itab-price(2) to string_old+3(2).
continue.
endat.
move: itab-code(2) to string_new(2),
itab-name(1) to string_new+2(1),
itab-price(2) to string_new+3(2).
if string_old = string_new.
move: spaces to itab-code(2),
spaces to itab-name(1),
spaces to itab-price(2).
modify itab.
endif.
string_old = string_new.
endloop.
Regards,
Ferry Lianto
‎2007 Jul 09 4:28 PM
Hi,
Please try to sort the internal table and use delete adjacent duplicate entries statement.
Syntax:
DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
[COMPARING <f1> <f 2> ...
|ALL FIELDS].
Regards,
Ferry Lianto
‎2007 Jul 09 4:32 PM
No, becase delete adjecent delete all the record, and only want to delete the three first fields of the record......
‎2007 Jul 09 4:38 PM
Try to mention first three fields in delete adjacent.
sort itab by field1 field2 field3.
DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
COMPARING field1 field2 field3.
Now it should work.
Thanks
Seshu
Message was edited by:
Seshu Maramreddy
‎2007 Jul 09 4:38 PM
Hi,
Try like this:
Delete Adjacent Duplicates From Itab.
Regards,
Bhaskar
‎2007 Jul 09 4:47 PM
Hi
What do you really mean with DELETE?
It can't delete the fields, but it can clear or don't write their value:
SORT ITAB BY CODE NAME PRICE.
DATA: _NEW.
LOOP AT ITAB.
_NEW = SPACE.
AT NEW PRICE.
_NEW = 'X'.
ENDAT.
IF _NEW = 'X'.
WRITE: / ITAB-CODE, ITAB-NAME, ITAB-PRICE, ITAB-<FIELD>........
ELSE.
WRITE: / ITAB-<FIELD>........
ENDIF.
ENDLOOP.The field PRICE has to be define as CHAR field
Max
‎2007 Jul 09 4:47 PM
Hi,
Please try this.
data: string_old(5),
string_new(5).
sort itab.
loop at itab.
at first.
move: itab-code(2) to string_old(2),
itab-name(1) to string_old+2(1),
itab-price(2) to string_old+3(2).
continue.
endat.
move: itab-code(2) to string_new(2),
itab-name(1) to string_new+2(1),
itab-price(2) to string_new+3(2).
if string_old = string_new.
move: spaces to itab-code(2),
spaces to itab-name(1),
spaces to itab-price(2).
modify itab.
endif.
string_old = string_new.
endloop.
Regards,
Ferry Lianto