2007 Jun 12 5:47 AM
Dear Friends,
My i_bkpf internal table has approx. 3 lakh records another table i_del has 2 lakh records. I have to delete these 2 lakh records of i_del from i_bkpf.
I'd written the following piece of code for the same but it takes hell lot of time and ultimately I encounter a timeout.
Kindly have a look at the following code and suggest how can I improve it.
**********************
sort i_bkpf by belnr.
sort i_del by belnr.
loop at i_del.
DELETE I_BKPF WHERE BELNR = I_DEL-BELNR AND
GJAHR = I_DEL-GJAHR AND
BUKRS = I_DEL-BUKRS.
ENDLOOP.
**********************
Regards,
Alok.
2007 Jun 12 5:55 AM
sort i_del by belnr gjahr bukrs.
loop at i_bkpf.
v_tabix = sy-tabix.
read table i_del with key belnr = i_bkpf-belnr
gjahr = i_bkpf-gjahr
bukrs = i_bkpf-bukrs
binary search.
if sy-subrc eq 0.
delete i_bkpf index v_tabix.
endif.
endloop.
aRs
Dear Friends,
My i_bkpf internal table has approx. 3 lakh records another table i_del has 2 lakh records. I have to delete these 2 lakh records of i_del from i_bkpf.
I'd written the following piece of code for the same but it takes hell lot of time and ultimately I encounter a timeout.
Kindly have a look at the following code and suggest how can I improve it.
**********************
sort i_bkpf by belnr.
sort i_del by belnr.
loop at i_del.
DELETE I_BKPF WHERE BELNR = I_DEL-BELNR AND
GJAHR = I_DEL-GJAHR AND
BUKRS = I_DEL-BUKRS.
ENDLOOP.
**********************
Regards,
Alok.
2007 Jun 12 5:51 AM
hi Alok,
Try to Include all the primary keys in the where condition and sort by these fields.
REgards,
Santosh
2007 Jun 12 5:52 AM
hi,
try like this,
sort i_bkpf by belnr.
sort i_del by belnr.
loop at i_bkpf.
DELETE adjacent duplicates of I_BKPF WHERE BELNR = I_DEL-BELNR AND GJAHR = I_DEL-GJAHR AND BUKRS = I_DEL-BUKRS.
ENDLOOP.
if helpful reward some points.
with regards,
suresh.
2007 Jun 12 5:53 AM
Hi
do like this
sort i_bkpf by bukrs belnr gjahr.
sort i_del by bukrs belnr gjahr.
loop at i_del.
read table I_BKPF With key BUKRS = I_DEL-BUKRS
BELNR = I_DEL-BELNR
GJAHR = I_DEL-GJAHR
binary search.
if sy-subrc = 0.
delete i_bkpf index sy-tabix.
endif..
ENDLOOP.
<b>Reward points for useful Answers</b>
Regards
Anji
2007 Jun 12 5:55 AM
sort i_del by belnr gjahr bukrs.
loop at i_bkpf.
v_tabix = sy-tabix.
read table i_del with key belnr = i_bkpf-belnr
gjahr = i_bkpf-gjahr
bukrs = i_bkpf-bukrs
binary search.
if sy-subrc eq 0.
delete i_bkpf index v_tabix.
endif.
endloop.
aRs
2007 Jun 12 5:55 AM
<b>sort i_bkpf by belnr GJAHR BUKRS.</b>
sort i_del by belnr.
loop at i_del.
DELETE I_BKPF WHERE BELNR = I_DEL-BELNR AND
GJAHR = I_DEL-GJAHR AND
BUKRS = I_DEL-BUKRS.
ENDLOOP.
2007 Jun 12 5:56 AM
hi
I think u can do like this. :
loop at i_del.
if i_del is not initial.
loop at i_bkpf where <conditions>
if sy-subrc = 0.
delete i_bkpf index sy-tabix.
endif.
endloop.
endif.
endloop.
hope it helps ....
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |