Skip to main content

SAP ABAP : Parallel Cursor

 


*&---------------------------------------------------------------------*
*& Report Z_PARALEL_CURSOR
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_PARALEL_CURSOR.

DATA LT_BKPF TYPE TABLE OF BKPF,
       LT_BSEG TYPE TABLE OF BSEG,
       LS_BKPF TYPE BKPF,
       LS_BSEG TYPE BSEG.

DATA LV_TIME1               TYPE I,
       LV_TIME2               TYPE I,
       LV_TIME3               TYPE I,
       LV_TIME4               TYPE I,
       LV_RES_TIME_GN_PROCESS TYPE I,
       LV_RES_TIME_PA_PROCESS TYPE I,
       INDX                   TYPE I.

DATA LV_BKPF_RECS TYPE I.
DATA LV_BSEG_RECS TYPE I.

START-OF-SELECTION.

  SELECT FROM BKPF INTO TABLE LT_BKPF UP TO 10000 ROWS.
  SELECT FROM BSEG INTO TABLE LT_BSEG UP TO 10000 ROWS.

  DESCRIBE TABLE LT_BKPF LINES LV_BKPF_RECS.
  DESCRIBE TABLE LT_BSEG LINES LV_BSEG_RECS.

  GET RUN TIME FIELD LV_TIME1.
  LOOP AT LT_BKPF INTO LS_BKPF.
    LOOP AT LT_BSEG INTO LS_BSEG WHERE VBELN LS_BKPF-BELNR.

    ENDLOOP.
  ENDLOOP.

  GET RUN TIME FIELD LV_TIME2.

  LV_RES_TIME_GN_PROCESS LV_TIME2 LV_TIME1.

* APPLYING PARALLEL CURSOR TECHNIQUE
 SORT LT_BKPF BY BELNR.
 SORT LT_BSEG BY BELNR.

  GET RUN TIME FIELD LV_TIME3.
  LOOP AT LT_BKPF INTO LS_BKPF.
    READ TABLE LT_BSEG INTO LS_BSEG WITH  KEY BELNR LS_BKPF-BELNR BINARY SEARCH.
    IF SY-SUBRC 0.
      INDX SY-TABIX.
      LOOP AT LT_BSEG INTO LS_BSEG FROM INDX.
        IF LS_BSEG-BELNR <> LS_BKPF-BELNR.
          EXIT.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDLOOP.

  GET RUN TIME FIELD LV_TIME4.

  LV_RES_TIME_PA_PROCESS LV_TIME4 LV_TIME3.

  WRITE:'Total BKPF Rows = 'LV_BKPF_RECS.
  WRITE:'Total BSEG Rows = 'LV_BSEG_RECS.

  WRITE :'Nested loop Processing Time'LV_RES_TIME_GN_PROCESS.
  WRITE :'Parallel Cursor Processing Time'LV_RES_TIME_PA_PROCESS.

Comments

Popular posts from this blog

How to Create a REST API in SAP ABAP — Step-by-step Guide

How to Create a REST API in SAP ABAP — Step-by-step Guide Summary: This tutorial shows how to build a REST API in SAP ABAP by creating a handler class, configuring SICF service, registering endpoints with cl_rest_router , implementing endpoint logic (example GET method), and testing the API. Based on an internal implementation reference. Why expose REST APIs from SAP? REST APIs allow SAP systems to integrate with web, mobile, and external services using standard HTTP and JSON payloads. Implementing REST endpoints in ABAP provides secure, reusable, and maintainable integration points for modern applications. Prerequisites Access to an SAP system with authorization to create classes (SE24) and SICF services (SICF). Familiarity with ABAP object-oriented concepts and basic SAP transaction codes. ABAP classes CL_REST_RESOURCE , CL_REST_ROUTER and utilities like /UI2/CL_JSON . High-level overview (4 steps) Create an API handler class (e.g. ZCL_API_HANDLER ). R...

SAP ABAP - User Exit Set Batch Characteristic Value In MIGO Goods Receipt

Customer Exit  :  MBCFC004 ( EXIT_SAPMM07M_004) Set Up Customer Exit for Classification of User-Defined Characteristics You use SAP enhancement MBCFC004 EXIT_SAPMM07M_004, which contains function module exit EXIT_SAPMM07M_004 to classify user-defined characteristics automatically during goods movements in Inventory Management. This is only possible for characteristics which are not assigned values during quality inspection. Requirements 1. The class of the batch to be classified must be known.  This means that a class must be assigned either to the material or at least to one batch of this material. 2. The exit call must be activated for the respective movement type in activity Activate batch classification during goods movements in IM using indicator 'Extended classification' . Open tcode OMC...

IT Asset Management Dengan PHP MySQL

Pada postingan kali saya akan share sebuah aplikasi IT Asset management yang fungsinya untuk memonitoring semua Asset khusus IT, contohnya : Laptop/komputer , Printer, Router, Hardisk, dll. Dalam aplkasi ini kita bisa mengetahui Asset IT posisinya dimana dan digunakan oleh siapa. untuk data-data yang dibutuhkan antara lain : 1. data kategori asset dalam menu ini kita bisa meng-input jenis2 kategory asset : tambah kategori asset : 2. data department 3. data karyawan 4. data department per karyawan 5. data asset location  6. data satuan asset dan untuk transaksi yang ada dalam aplikasi ini adalah,  1. create asset, pada menu create asset ini kita akan mengalokasikan sebuah asset ke karyawan/personnel tampilannya seperti berikut: setelah klik tombol save akan muncul seperti dibawah : untuk melihat detail asset yang sudah dibuat tadi, kita bisa pilih...