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: 

Regarding: Deleting adjacent duplicates

Former Member
0 Kudos

Hi Guys,

My Itab Looks like below.


PN   TKNUM  BRGEW  VOLUM TEMPB PRAT1
1       1122     30             5           01         
1       1122     25             4           02
2       1122     40             7           01          X
2       1122     50             8           01          X

I need to delete adjacent duplicates from the above table only where there is no 'X' in PRAT1.

My delete adjacent duplicates statement should work only for records which does not have PRAT1 value 'X'.

So my final ITAB1 should look like below


PN   TKNUM  BRGEW  VOLUM TEMPB PRAT1
1       1122     30             5           01         
2       1122     40             7           01          X
2       1122     50             8           01          X

Plz let me know.

Thanks,

Prasd.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Better if you can separate the entries into two internal tables and use

delete adjacent duplicates on the one which does not have PRAT1 = X entries ..

12 REPLIES 12

Former Member
0 Kudos

Hi,

Try this...

Delete adjacent duplicates from <int_table> comparing prat1 where prat1 <> 'X'.

Thanks and Regards,

Suresh

0 Kudos

Hi,

I have tried "Delete adjacent duplicates from <itab> where..."...

Sorry that it was not working...

You can use another solution....

Sort the internal table.

Then use a temporary work area...

Copy the first record of sorted internal table to the temporary work area <temp_wa>..

loop at itab into wa where prat1 <> 'X'.

if sy-tabix <> 1.

check the content of the workarea wa and the temp_wa. If both are equal then delete current record...

Else clear temp_wa and copy the content of wa to temp_wa.

endloop.

Hope this may help you...

Best Regards,

Suresh

Former Member
0 Kudos

On what basis you are deleting duplicates either on X or either on any field

Former Member
0 Kudos

Better if you can separate the entries into two internal tables and use

delete adjacent duplicates on the one which does not have PRAT1 = X entries ..

0 Kudos

Hi Srinivas,

I too have the same Idea,but thought there is some other procedure.

I will try and let you know.

Thanks,

Prasad.

Former Member
0 Kudos

Hi,

DELETE ADJACENT DUPLICATES FROM itab.

Try with using COMPARING FIELDS option

Regards,

jaya

former_member242255
Active Contributor
0 Kudos

move the data of itab into itemp

delete the records woth X and do the delete adjacent duplicates

and

delete the records without x in itab

then append these records of itemp to the itab .

this may be a lengthy process.but this should work...

Former Member
0 Kudos

Hi,

To delete comparing all fields:

sort itab by field1 field2 field3. "and so on for using all fields

delete adjacent duplicates from itab comparing all fields.

To delete comparing only one field:

sort itab by field1.

delete adjacent duplicates from itab comparing field1.

Regards,

Shalini

former_member222860
Active Contributor
0 Kudos

what's the field name that holds the value 'X'.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING prat1 where field1 = 'x'.

Former Member
0 Kudos

try this:

sort itab by pn tknum.
itab_temp[] = itab[].
delete itab_temp where prat1 = space.
delete itab where prat1 = 'X'.
delete adjacent duplicates from itab comparing pn tknum.
append lines of itab_temp into itab.

itab is the final table which the contains the rows you are looking for.

Former Member
0 Kudos

Hi,

Better read table with field prati....then delete it from table.

Former Member
0 Kudos

Thanks for your reply's Guys.

I have moved records with x into another table.

Did not do duplication for this records.

Appended this to another table along with duplication of another table .