2013 May 18 7:51 PM
DELETE ITAB WHERE segnam = 'ZCREEXT' OR
segnam = 'E1LFA1M' OR
segnam = 'E1LFB1M' OR
segnam = 'E1LFA1M' OR
segnam = 'E1LFA1B' OR
segnam = 'E1LFA1A' OR
segnam = 'E1LFA1H' OR
segnam = 'E1LFA1L' OR
segnam = 'E1LFB1M' OR
segnam = 'E1LFBWM' OR
segnam = 'E1LFB5M' OR
segnam = 'E1LFB1H' OR
segnam = 'E1LFB1L'.
Now my question is Would this Statement would delete the segments available in Table ITAB as provided in the Condition.
Now in my code it is deleting the segments present in table ITAB as mentioned in the where clause. But i think it should only delete whichever the condition holds true..
Pls guide me whether this statement is correct or will it falter somewhere.
DELETE ITAB WHERE segnam = 'ZCREEXT' OR
segnam = 'E1LFA1M' OR
segnam = 'E1LFB1M' OR
segnam = 'E1LFA1M' OR
segnam = 'E1LFA1B' OR
segnam = 'E1LFA1A' OR
segnam = 'E1LFA1H' OR
segnam = 'E1LFA1L' OR
segnam = 'E1LFB1M' OR
segnam = 'E1LFBWM' OR
segnam = 'E1LFB5M' OR
segnam = 'E1LFB1H' OR
segnam = 'E1LFB1L'.
Now my question is Would this Statement would delete the segments available in Table ITAB as provided in the Condition.
Now in my code it is deleting the segments present in table ITAB as mentioned in the where clause. But i think it should only delete whichever the condition holds true..
Pls guide me whether this statement is correct or will it falter somewhere.
2013 May 19 9:04 AM
If segnam is 'ZCREEXT', the record will be deleted.
If segnam is 'E1LFA1M' the record will be deleted
If segnam is 'E1LFB1M' the record will be deleted.
...
etc.
...
What's the problem? The DELETE statement removes exactly those records where the condition holds true. Perhaps your understanding of the condition is incorrect? What are you expecting?
2013 Jun 02 9:24 PM
Thanks for the reply..
I was of understanding that OR means that any of the conditions would work not both.
so nevertheless ur reply sorted out my confusion. thanks alot
2013 Jun 03 10:29 AM
2013 May 19 9:38 AM
Hi Rajat,
The records from the itab will be deleted for any of the condition you have specified since you are using 'OR'. There may be chances of multiple deletion of records. If segnam matches any of 'ZCREEXT' or
'E1LFA1M' or 'E1LFB1M' or 'E1LFA1M', the record will be deleted.
2013 May 19 9:42 AM
DATA: BEGIN OF ITAB OCCURS 0,
sno type i,
segnam type c LENGTH 7, "Plant+ material
END OF ITAB.
itab-SNO = 1.
ITAB-segnam = 'ZCREEXT'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 2.
ITAB-segnam = 'E1LFA1M'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 3.
ITAB-segnam = 'E1LFB1M'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 4.
ITAB-segnam = 'E1LFA1B'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 5.
ITAB-segnam = 'E1LFA1M'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 6.
ITAB-segnam = 'E1LFA1A'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 7.
ITAB-segnam = 'E1LFA1H'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 8.
ITAB-segnam = 'E1LFA1L'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 9.
ITAB-segnam = 'E1LFB1M'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 10.
ITAB-segnam = 'E1LFBWM'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 11.
ITAB-segnam = 'E1LFB5M'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 12.
ITAB-segnam = 'E1LFB1H'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 13.
ITAB-segnam = 'E1LFB1L'.
APPEND ITAB.
CLEAR ITAB.
itab-SNO = 14.
ITAB-segnam = 'ABCDE'.
APPEND ITAB.
CLEAR ITAB.
DELETE ITAB WHERE segnam = 'ZCREEXT' OR
segnam = 'E1LFA1M' OR
segnam = 'E1LFB1M' OR
segnam = 'E1LFA1M' OR "no need to repeat
segnam = 'E1LFA1B' OR
segnam = 'E1LFA1A' OR
segnam = 'E1LFA1H' OR
segnam = 'E1LFA1L' OR
segnam = 'E1LFB1M' OR
segnam = 'E1LFBWM' OR
segnam = 'E1LFB5M' OR
segnam = 'E1LFB1H' OR
segnam = 'E1LFB1L'.
LOOP AT ITAB.
WRITE😕 ITAB-SEGNAM.
ENDLOOP.
YOUR REUSLT WILL BE ABCDE.
2013 May 20 2:17 PM
What do you exactly expect, you only post a statement for deletion, and then you ask us if it does what it is intended to do ?
If the statement doesn't work as you expected you wrongly code it, but as long as you don't write your exact requirement; guessing it is difficult/hazardous, try to write your requirement in plain logical English...
Regards,
Raymond