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

Re: How to delete the last record of a particular field

$
0
0

If there are multiple entries for an invoice ( > 2 ) and you want to delete only the last entry - Copy Gangadhar Ragula's code. Insert one more variable, lv_count ( See the sample code below ) . Else If you want to keep only the first invoice and delete the rest , then implement the solution proposed by Manish.

 

DATA : lv_count TYPE i.

 

SORT gt_final BY belnr. (If not sorted before)

 

LOOP AT gt_final INTO gs_final.

   lv_count = lv_count + 1.

 

   AT ENDOF gs_final-belnr.

      IF lv_count > 1.

       gs_final-del_flag = abap_true.  "(Add this field to gs_final structure).

      ENDIF.

   clear lv_count.

   ENDAT.

 

   MODIFY gt_final FROM gs_final INDEX sy-tabix.

 

  ENDLOOP.


DELETE gt_final where del_flag = 'X'.


Viewing all articles
Browse latest Browse all 8526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>