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 issue with nested loop ?

0 Likes
480

Dear friends,

i have a strange issue and i am kind of at the end of the day with it, so i was very happy if one of you could have a look at it and do some improvements in performance ( this piece of code takes about 5 minutes for 100 datasets in i_tab_ztest. Your help will be awarded points immediately !

FORM do_find.

  DATA: idx TYPE sy-tabix.

  LOOP AT i_tab_ztest INTO w_tab_ztest.

    PERFORM progress_bar USING 'Analyse läuft...'(001) sy-tabix e.

    w_tab_result-ds1 = w_tab_ztest.
    w_tab_result-i1 = sy-tabix.
    w_tab_result-stufe = 0.

    insert w_tab_result into table i_tab_result.

    n = sy-tabix.
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE w_tab_ztest TO <dyn_field>.
      IF sy-subrc <> 0.
        EXIT.
      ELSE.
        i = sy-index.
        TRANSLATE <dyn_field> USING ' _-_/_._'.

        SPLIT <dyn_field> AT '_' INTO TABLE itab.

        LOOP AT itab.
          l = strlen( itab ).
          if l = 0.

          else.

            TRANSLATE itab TO UPPER CASE.
            PERFORM ersetzung USING itab CHANGING itab.

            LOOP AT l_str_id INTO w_str_id WHERE wort = itab
            AND feld = i.

              READ TABLE i_tab_ztest INTO w_tab_ztest2
              INDEX w_str_id-id.

              if n <> w_str_id-id.

                w_tab_result-ds1 = w_tab_ztest2.
                w_tab_result-i1 = n.
                w_tab_result-stufe = 1.

                insert w_tab_result into table i_tab_result.

              else.
              endif.

           ENDLOOP.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDDO.

  ENDLOOP.

ENDFORM.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
451

Hi

U should delete the routine for the message:

PERFORM progress_bar USING 'Analyse läuft...'(001) sy-tabix e.

Max

2 REPLIES 2
Read only

Former Member
0 Likes
452

Hi

U should delete the routine for the message:

PERFORM progress_bar USING 'Analyse läuft...'(001) sy-tabix e.

Max

Read only

Former Member
0 Likes
451

Check this:

/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops

Rob