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: 

DELETE ITAB WHERE ....

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

9 REPLIES 9

former_member194669
Active Contributor
0 Kudos

Hi,


delete i_vbep where flag eq 'X'.

aRs

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


DELETE I_VBEP WHERE FLAG = 'X'.

Regards,

Ferry Lianto

Former Member
0 Kudos

delete i_vbep where flag eq 'X'.

Former Member
0 Kudos

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

0 Kudos

Some psuedo code.

loop at itab where flag = 'X'.

move vbep, posnr to temp_tab.

collect temp_tab.

endloop.

sort both tables by vbep and posnr.

loop at itab.

read temp tab with key ...

binary search.

if sy-subrc = 0.

delete itab.

endif.

endloop.

(Is VBEP the field name??)

Rob

0 Kudos

Hi,


i_vbep_1[] = i_vbep[].
delete i_vbep_1 where flag Ne 'X'.

Loop at i_vbep_1.
  delete i_vbep where vbeln eq i_vbep_1-vbeln
                  and posnr eq i_vbep_1-posnr.
endloop. 

aRs

0 Kudos

Rob

(Is VBEP the field name??)

That was a typo, i edited the original msg.

0 Kudos

SORT I_VBEP BY VBELN POSNR.

JTAB[] = I_VBEP[].

LOOP AT JTAB WHERE FLAG = 'X'.

DELETE I_VBEP WHERE VBELN = JTAB-VBELN

POSNR = JTAB-POSNR.

ENDLOOP.

Former Member
0 Kudos

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>