2007 Oct 19 7:21 AM
Hi,
I have a code
LOOP AT I_VBRK_VBRP.
move sy-TABIX to vbrk_vbrp_indx.
move-corresponding i_vbrk_vbrp to w_vbrk_vbrp.
READ TABLE I_KONV WITH KEY KNUMV = I_VBRK_VBRP-KNUMV
KPOSN = I_VBRK_VBRP-POSNR
BINARY SEARCH.
IF SY-SUBRC NE 0.
DELETE I_VBRK_VBRP.
ELSE.
LOOP AT I_KONV WHERE KNUMV = I_VBRK_VBRP-KNUMV
AND KPOSN = I_VBRK_VBRP-POSNR.
IF I_VBRK_VBRP-KSCHL IS INITIAL
OR NOT RB_AG5 IS INITIAL.
MOVE I_KONV-KSCHL TO I_VBRK_VBRP-KSCHL.
MODIFY I_VBRK_VBRP index vbrk_vbrp_indx.
ELSE.
MOVE I_KONV-KSCHL TO W_VBRK_VBRP-KSCHL.
APPEND W_VBRK_VBRP.
CLEAR W_VBRK_VBRP.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
I want to merge the read operation in the second loop to make the operation more efficint.
Can anybody suggest me how to do?(without changing the output)
Hi,
try like this
LOOP AT I_VBRK_VBRP.
move sy-TABIX to vbrk_vbrp_indx.
move-corresponding i_vbrk_vbrp to w_vbrk_vbrp.
LOOP AT I_KONV WHERE KNUMV = I_VBRK_VBRP-KNUMV
AND KPOSN = I_VBRK_VBRP-POSNR.
IF I_VBRK_VBRP-KSCHL IS INITIAL
OR NOT RB_AG5 IS INITIAL.
MOVE I_KONV-KSCHL TO I_VBRK_VBRP-KSCHL.
MODIFY I_VBRK_VBRP index vbrk_vbrp_indx.
ELSE.
MOVE I_KONV-KSCHL TO W_VBRK_VBRP-KSCHL.
APPEND W_VBRK_VBRP.
CLEAR W_VBRK_VBRP.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
Regards,
NAGARAJ
2007 Oct 19 7:29 AM
Hi,
Instead of second loop try like this
read table I_KONV WHERE KNUMV = I_VBRK_VBRP-KNUMV
AND KPOSN = I_VBRK_VBRP-POSNR.
if sy-subrc eq 0.
IF I_VBRK_VBRP-KSCHL IS INITIAL
OR NOT RB_AG5 IS INITIAL.
MOVE I_KONV-KSCHL TO I_VBRK_VBRP-KSCHL.
MODIFY I_VBRK_VBRP index vbrk_vbrp_indx.
ELSE.
MOVE I_KONV-KSCHL TO W_VBRK_VBRP-KSCHL.
APPEND W_VBRK_VBRP.
CLEAR W_VBRK_VBRP.
ENDIF.
endif.
Reward if helpful.
reagrds,
Nagaraj
2007 Oct 19 7:52 AM
Instead of removing the second loop, is there any way to remove the read option?
keeping the output same.
2007 Oct 19 8:00 AM
Hi,
try like this
LOOP AT I_VBRK_VBRP.
move sy-TABIX to vbrk_vbrp_indx.
move-corresponding i_vbrk_vbrp to w_vbrk_vbrp.
LOOP AT I_KONV WHERE KNUMV = I_VBRK_VBRP-KNUMV
AND KPOSN = I_VBRK_VBRP-POSNR.
IF I_VBRK_VBRP-KSCHL IS INITIAL
OR NOT RB_AG5 IS INITIAL.
MOVE I_KONV-KSCHL TO I_VBRK_VBRP-KSCHL.
MODIFY I_VBRK_VBRP index vbrk_vbrp_indx.
ELSE.
MOVE I_KONV-KSCHL TO W_VBRK_VBRP-KSCHL.
APPEND W_VBRK_VBRP.
CLEAR W_VBRK_VBRP.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
Regards,
NAGARAJ
2007 Oct 19 7:36 AM
hi,
use like this.
read table I_KONV into <w_area> with key KNUMV = I_VBRK_VBRP-KNUMV
KPOSN = I_VBRK_VBRP-POSNR.
binary search.
if sy-subrc eq 0.
IF I_VBRK_VBRP-KSCHL IS INITIAL
OR NOT RB_AG5 IS INITIAL.
MOVE I_KONV-KSCHL TO I_VBRK_VBRP-KSCHL.
MODIFY I_VBRK_VBRP index vbrk_vbrp_indx.
ELSE.
MOVE I_KONV-KSCHL TO W_VBRK_VBRP-KSCHL.
APPEND W_VBRK_VBRP.
CLEAR W_VBRK_VBRP.
ENDIF.
endif.
<b><i>Reward points if useful</i></b>
Chandra
2007 Oct 19 7:58 AM
LOOP AT I_KONV WHERE KNUMV = I_VBRK_VBRP-KNUMV
in this code declare the internal table as SORTED TABLE instaed of standard table , this will improve performance
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |