Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Delete entries

Former Member
0 Kudos

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?

8 REPLIES 8

Former Member
0 Kudos

Hello Rakesh,

use DELETE ADJACENT DUPLICATES on first field

e.g.:

SORT <itab> BY <field1>.

DELETE ADJACENT DUPLICATES FROM <itab> COMPARING <field1>.

Regards

Indu

Former Member
0 Kudos

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.

former_member195383
Active Contributor
0 Kudos

sort itab by filed1 field3.

delete adjacent duplicates from itab comparing field1.

this will solve ur purpose....

former_member181995
Active Contributor
0 Kudos

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.

former_member787646
Contributor
0 Kudos

Hi

Try this...

SORT ITAB BY <KEY_FIELD> ASCENDING <DATE_FIELD> DESCENDING.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING <FIELD_NAME>

Hope it helps.

Murthy

Former Member
0 Kudos

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

Former Member
0 Kudos

First sort descending by 1st and 2nd fields.

And then delete adjacent duplicates comparing 1st field.

Regards,

Aparna Gaikwad

Former Member
0 Kudos

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.