Skip to Content
author's profile photo Former Member
Former Member

DELETE ITAB WHERE ....

I want to delete items that have flag as X. So in this case all records would be deleted from i_vbep.

VBELN		POSNR	FLAG	ETENR		MBDAT
0000000001	000010	  X       0001		09/06/2007
0000000001	000020	         0001		09/06/2007
0000000001	000020	   X      0002		09/07/2007
0000000002	000020	         0001		09/06/2007
0000000002	000020	   X      0002		09/08/2007
0000000002	000030	         0001		09/06/2007
0000000002	000030	   X      0002		09/10/2007

Message was edited by:

Megan Flores

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 06:19 PM

    This will only delete those records with flag as X but I need the item removed.

    So if you look at the data: 3rd record has flag X item 0002. So that item should be deleted which means 2nd & 3rd row and not just the 3rd row.

    Message was edited by:

    Megan Flores

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 06:14 PM

    delete i_vbep where flag eq 'X'.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2007 at 06:10 PM

    Hi,

    delete i_vbep where flag eq 'X'.
    
    

    aRs

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2007 at 06:13 PM

    Hi,

    Please try this.

    DELETE I_VBEP WHERE FLAG = 'X'.
    

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 07:04 PM

    Megan, find the logic below.

    *--Types Declaration
      TYPES :
      BEGIN OF typ_itab,
      vbep(10)	TYPE 	c	,
      posnr(6)	TYPE 	c	,
      flag(1)	TYPE 	c	,
      etenr(4)	TYPE 	c	,
      mbdat(10)	TYPE 	c	,
      END OF typ_itab,
      typ_itab_tab TYPE STANDARD TABLE OF typ_itab.
    
    *--Int table Declaration
      DATA : it_itab_temp  TYPE typ_itab_tab  WITH HEADER LINE, "To hold the Initial data
             it_itab_final TYPE typ_itab_tab  WITH HEADER LINE, "To hold the final results
    
        it_itab_final[] = it_itab_temp[] .
    
    
      LOOP AT it_itab_temp WHERE flag EQ 'X'.
      
    *--Delete based on Item number & Order
        LOOP AT it_itab_final WHERE  vbep  EQ it_itab_temp-vbep AND
                                     posnr EQ it_itab_temp-posnr.
    
          DELETE it_itab_final.
    
        ENDLOOP..
    
      ENDLOOP.
    
    *--it_itab_final will have the final set of records
      BREAK-POINT.
    
    

    <b>AS</b>

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.