Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8667

Re: How to remove dupliate rows with condition?

$
0
0

Hi Caroline,

 

Check the code below. I think you are trying to delete the records based on the count.

I considered the below conditions.

-> if one record exists for each SAPPOSITION with OBSOLETE = space -> you are not deleting

-> in case of more than one record for Each SAPPOSITION you are applying the condition OBSOLETE = 'SPACE'.

 

Check the code below.


IT_TEST[] is your internal table holding the specified records.

 

sort it_test[] by sap_position ob_begin.

*Move the entries into temporary table for validation of records


it_temp[] = it_test[].


loop at it_temp into wa_test.
   clear l_index.
   l_index = sy-tabix.


* Parllel cursor


   loop at it_test into wa_temp from l_index.

     at end of sap_position.
      if it_temp1[] is initial.
         exit.
       else.


*if more than one record and obsolete is space- then delete
         delete it_test
                where sap_position = wa_temp-sap_position and
                         obsolete = ' '.
         refresh : it_temp1[].
         exit.
       endif.
     endat.
   append wa_temp to it_temp1.
   clear wa_temp.
   endloop.
endloop.

 

Thanks,

Kiran


Viewing all articles
Browse latest Browse all 8667

Trending Articles