Application Development and Automation 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: 
Read only

Efficiency

Former Member
0 Likes
620

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)

5 REPLIES 5
Read only

former_member404244
Active Contributor
0 Likes
594

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

Read only

0 Likes
594

Instead of removing the second loop, is there any way to remove the read option?

keeping the output same.

Read only

0 Likes
594

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

Read only

Former Member
0 Likes
594

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

Read only

Former Member
0 Likes
594

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