Application Development 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: 

Please sugget me how to improve the performance for the logic.....

Former Member
0 Kudos

Hi All.

Please sugget me how to improve the performance for the logic as given below.

loop at i_vbep.

loop at i_z1234 where vbeln_va = i_vbep-vbeln

and posnr_va = i_vbep-posnr.

at end of zpd.

sum.

v_tot_quantity_kg = i_z1234-brgew.

endat.

loop at i_z5678 where zpd = i_z1234-zpd

and zld = i_z01234-zlegid.

at end of zpallid.

sum.

v_tot_quantity = i_z5678-zcpalqty.

endat.

clear i_mara.

read table i_mara with key matnr = i_z5678-zpmatnr

binary search.

if sy-subrc = 0.

perform convert_m2 using v_tot_quantity

i_z5678

i_mara.

modify table i_z5678.

endloop.

endloop.

4 REPLIES 4

Former Member
0 Kudos

What is the logic required? Is this piece working fine?

First try would be to sort the internal tables by keys.

ThomasZloch
Active Contributor
0 Kudos

former_member194613
Active Contributor
0 Kudos

loop at i_vbep.

loop at i_z1234 where vbeln_va = i_vbep-vbeln
and posnr_va = i_vbep-posnr.

The READ BINARY SEARCH solves only on part of the problems, the other is the LOOP WHERE

on standard tables.

Either use Sorted tables or optimize the loop on standard table, see here

Measurements on internal tables: Reads and Loops:

/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables

see section 3

Siegfried

Former Member
0 Kudos

Hi,

Can try following options:

1. Use internal table w/o header linei.e. use explicit work area. Better is to use field symbol.

2. Use read with binary search

3. You have 3 nested loop - check where is the performance bottleneck. If it is in the Read statement binary search will help you.

4. Check if you can avoid so many nested loop.