‎2006 Sep 13 2:50 PM
Hello friends,
I want to delete some rows from an internal table based on a where condition depending on another internal table.
DELETE it_knvp
FOR ALL ENTRIES IN it_vbpa
WHERE kunnr = it_vbpa-kunnr.
In the above code both the internal tables have kunnr.
But the above code is not correct.
Any advice.
Shejal Shetty.
‎2006 Sep 13 2:57 PM
then use RANGES.
RANGES : R_KUNNR FOR KNA1-KUNNR.
R_KUNNR-SIGN = 'I'.
R_KUNNR-OPTION = 'EQ'.
LOOP AT it_vbpa.
R_KUNNR-LOW = it_vbpa-KUNNR.
APPEND R_KUNNR.
ENDLOOP.
IF you want to delete IT_KNVP records based on IT_VBPA,
1. if record exists in IT_VBPA then if you want to delete IT_KNVP also,then do
<b>DELETE IT_KNVP WHERE KUNNR IN R_KUNNR.</b>
2. IF you want to delete entries from IT_KNVP where KUNNR not in IT_VBPA,then
<b> DELETE IT_VBPA WHERE KUNNR <u>NOT</u> IN R_KUNNR.</b>
regards
srikanth
Message was edited by: Srikanth Kidambi
‎2006 Sep 13 2:53 PM
hi
chk this code.
*it_knvp should be occurs 0 with header line
loop at it_knvp.
read table it_vbpa with key kunnr = it_knvp-kunnr.
if sy-subrc = 0 .
DELETE TABLE it_knvp FROM it_knvp.
endif.
endloop.
rgds
anver
if helped pls mark points
‎2006 Sep 13 2:55 PM
Thanks Anversha,
I am looking for a way to do it without using the loop statement.
Thanks again,
Shejal.
‎2006 Sep 13 2:58 PM
hi shejal,
for all entries is not possible in DELETE syntax.
thats y i went for loop.
since it is an internal table, there will not be nay performance issue.
rgds
anver
‎2006 Sep 13 2:54 PM
Hi Shejal,
Try this:
loop at it_vbpa.
delete it_knvp where kunnr = it_vbpa-kunnr.
endloop.
Regards,
Vivek
‎2006 Sep 13 2:56 PM
hi,
do this way ..
loop at it_vbpa.
read table it_vbpa where< Conditions>
if sy-subrc = 0.
delete it_vbpa
endif
endloop.
‎2006 Sep 13 2:57 PM
then use RANGES.
RANGES : R_KUNNR FOR KNA1-KUNNR.
R_KUNNR-SIGN = 'I'.
R_KUNNR-OPTION = 'EQ'.
LOOP AT it_vbpa.
R_KUNNR-LOW = it_vbpa-KUNNR.
APPEND R_KUNNR.
ENDLOOP.
IF you want to delete IT_KNVP records based on IT_VBPA,
1. if record exists in IT_VBPA then if you want to delete IT_KNVP also,then do
<b>DELETE IT_KNVP WHERE KUNNR IN R_KUNNR.</b>
2. IF you want to delete entries from IT_KNVP where KUNNR not in IT_VBPA,then
<b> DELETE IT_VBPA WHERE KUNNR <u>NOT</u> IN R_KUNNR.</b>
regards
srikanth
Message was edited by: Srikanth Kidambi
‎2006 Sep 13 3:01 PM
i dont know the way to work in delete
with "FOR ALL ENTRIES "
i work like this
loop at [first internal table]
read [second table] with key if kunner = kunner
if sy-subrc = 0 .
delete second table index sy-tabix
endif.
endloop
‎2006 Sep 13 3:05 PM
Thanks Everyone for all the advice and suggestions.
Shejal Shetty.