Wednesday, November 18, 2020

What is Parallel Cursor in SAP ABAP ? How to increase Performance using Parallel Cursor?

 Parallel Cursor Algorith- Parallel cursor is a technique to increase performance of ABAP Programs .

Suppose in Any program you have to use nested loop i.e loop inside loop , and if we use nested loop in  ABAP report it will take lot of time .So to avoid that we use Parallel Cursor .

Verdict: Use the parallel cursor method whenever there is a need to process data in a nested loop.

In Parallel cursor we avoid where clause and set sy-tabix instead of where clause .

Program Without Parallel Cursor Algorithm .

LOOP AT IT_MARA INTO WA_MARA.

  LOOP AT IT_MVKE INTO WA_MVKE WHERE MATNR = WA_MARA-MATNR.

    WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MVKE-VKORG, WA_MVKE-VTWEG.

  ENDLOOP.

ENDLOOP.

Program With Parallel Cursor Algorithm .

DATA V_INDEX TYPE SY-TABIX.

LOOP AT IT_MARA INTO WA_MARA.

  READ TABLE IT_MVKE INTO WA_MVKE WITH KEY MATNR = WA_MARA-MATNR BINARY SEARCH.

  IF SY-SUBRC = 0.

    V_INDEX = SY-TABIX.

    LOOP AT IT_MVKE INTO WA_MVKE FROM V_INDEX. "Avoiding Where Clause

      IF WA_MVKE-MATNR <> WA_MARA-MATNR.

        EXIT.

      ENDIF.

      WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MVKE-VKORG, WA_MVKE-VTWEG.

    ENDLOOP.

  ENDIF.

  CLEAR: WA_MARA, WA_MVKE.

ENDLOOP.



No comments:

Post a Comment

Procure to PAY Cycle

  SAP Tcodes in Procure to Pay ( P2P ): In the Procure-to-Pay (P2P) process in SAP ECC several transaction codes (T-codes) are commonly used...