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

Performance in Nested Loops

Former Member
0 Likes
924

Hii,

I have a strange problem on hand.

I have nested loops which contains a lot of records approx 50,000

I have used parallel cursor technique which uses to sort the tables beforehand.

When I use parallel cursor I get wrong results due to the fact I'm sorting tables.

Which other techniques do I have to make this nested loop faster.

What about Field Symbols.

Varun

5 REPLIES 5
Read only

sv_v
Explorer
0 Likes
881

Try using READ Statememnt where ever possible

Read only

Former Member
0 Likes
881

>

> Try using READ Statememnt where ever possible

There are possibilities of having multiple entries in both the tables.

I don't think read would suffice though let me check.

Read only

0 Likes
881

Hi,

Define inner loop table as sorted table with non unique key and apply where condition.

Both table have same data or not ?

Kind rgds

Ravi Lanjewar

Read only

asik_shameem
Active Contributor
0 Likes
881

Hi,

Parallel cursor is the best option for nested loop. It should work fine in all the cases. If you can post your code (Parallel cursor part) we could figure out.

Make sure, it is in the following way.

  SORT gt_likp BY vbeln.
  SORT gt_lips BY vbeln.

  LOOP AT gt_likp INTO gwa_likp.

    LOOP AT gt_lips INTO gwa_lips FROM gv_index.
      IF gwa_likp-vbeln NE gwa_lips-vbeln.
        gv_index = sy-tabix.
        EXIT.
      ENDIF.
      " Inner loop Coding Here
    ENDLOOP.

  ENDLOOP.

Field symbols do not help in your case.

Read only

Former Member
0 Likes
881

> Parallel cursor is the best option for nested loop. It sho

incorrect

Use a sorted table as the inner table, this is the way to go!

Otherwise you must program the optimization with BINARY SEARCH by yourself, it is one of the most frequent recommendations.

Stay away from nested cursor, it is complicated and not worth the effort.

Use ASSIGNING for the LOOPs, this is a small improvement of top.