Application Development and Automation 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: 
Read only

Delete entries

Former Member
0 Likes
915

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
Read only

Former Member
0 Likes
887

Hello Rakesh,

use DELETE ADJACENT DUPLICATES on first field

e.g.:

SORT <itab> BY <field1>.

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

Regards

Indu

Read only

Former Member
0 Likes
887

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.

Read only

former_member195383
Active Contributor
0 Likes
887

sort itab by filed1 field3.

delete adjacent duplicates from itab comparing field1.

this will solve ur purpose....

Read only

Former Member
0 Likes
887

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.

Read only

former_member787646
Contributor
0 Likes
887

Hi

Try this...

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

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING <FIELD_NAME>

Hope it helps.

Murthy

Read only

Former Member
0 Likes
887

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

Read only

Former Member
0 Likes
887

First sort descending by 1st and 2nd fields.

And then delete adjacent duplicates comparing 1st field.

Regards,

Aparna Gaikwad

Read only

Former Member
0 Likes
887

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.