use of parallel cursor

3
Use of Parallel Cursor method: The most common performance problem that occurs in ABAP programs is because of huge number of records in the internal table. where condition that is used in inner loops expend a significant amount of processing time. The idea is to avoid where conditions in the inner loops by maintaining the loop indexes manually. Parallel Cursor is a technique to increase the performance of the program when there are nested loops. Code for nested loops Conventional LOOP AT lt_eabpl INTO lwa_eabpl . * Calculated total SPA amount at CA level. LOOP AT lt_tmp INTO lwa_tmp WHERE vkont = lwa_eabpl - vkont . IF lwa_tmp - betrwbillprop IS NOT INITIAL . lv_total = lv_total + lwa_tmp - betrwbillprop . ELSE . lv_total = lv_total + lwa_tmp - betrw . ENDIF . ENDLOOP . MOVE : lwa_tmp - vkont TO gwa_output - vkont , lwa_tmp - erdat TO gwa_output - erdat , lv_total TO gwa_output - betrwbillprop . APPEND gwa_output TO gt_output . CLEAR : lv_total . ENDLOOP .

Upload: altruism-r-if

Post on 14-Dec-2015

213 views

Category:

Documents


0 download

DESCRIPTION

Use of Parallel Cursor

TRANSCRIPT

Page 1: Use of Parallel Cursor

Use of Parallel Cursor method:

The most common performance problem that occurs in ABAP programs is because of huge number of records in the internal table.

where condition that is used in inner loops expend a significant amount of processing time.

The idea is to avoid where conditions in the inner loops by maintaining the loop indexes manually.

Parallel Cursor is a technique to increase the performance of the program when there are nested loops.

Code for nested loops Conventional

      LOOP AT lt_eabpl INTO lwa_eabpl.*     Calculated total SPA amount at CA level.        LOOP AT lt_tmp INTO lwa_tmp WHERE vkont = lwa_eabpl-vkont.          IF lwa_tmp-betrwbillprop IS NOT INITIAL.            lv_total = lv_total + lwa_tmp-betrwbillprop.          ELSE.            lv_total = lv_total + lwa_tmp-betrw.          ENDIF.        ENDLOOP.        MOVE:   lwa_tmp-vkont TO gwa_output-vkont,                lwa_tmp-erdat TO gwa_output-erdat,                lv_total      TO gwa_output-betrwbillprop.        APPEND  gwa_output TO  gt_output.        CLEAR: lv_total.

      ENDLOOP.

Page 2: Use of Parallel Cursor

Code sample: Parallel Cursor method

      LOOP AT lt_eabpl INTO lwa_eabpl.        READ TABLE lt_tmp INTO lwa_tmp WITH KEY vkont = lwa_eabpl-vkont BINARY SEARCH.        IF sy-subrc = 0.          lv_tmp_index = sy-tabix.          LOOP AT lt_tmp INTO lwa_tmp FROM lv_tmp_index.            IF lwa_tmp-vkont <> lwa_eabpl-vkont.              EXIT.            ENDIF.          IF lwa_tmp-betrwbillprop IS NOT INITIAL.            lv_total = lv_total + lwa_tmp-betrwbillprop.          ELSE.            lv_total = lv_total + lwa_tmp-betrw.          ENDIF.          ENDLOOP.        ENDIF.        gwa_output-vkont          = lwa_tmp-vkont.        gwa_output-erdat          = lwa_tmp-erdat.        gwa_output-betrwbillprop  = lv_total.        APPEND  gwa_output TO  gt_output.        CLEAR: lv_total.

      ENDLOOP.