Performance tuning of this report

Hello friends iam attaching my report give the performance tuning for this report to avoid nested endloops. how to do without using nested endloops.
give me the reply urgent.
REPORT  ZDEMO9          NO STANDARD PAGE HEADING
                        LINE-SIZE 250
                        LINE-COUNT 22(3).                             .
            TABLES DECLARATION                    *
TABLES : MARA,              "general material data
         MAKT,              "material description
         MARC,              "plant data for material
         VBAP,              "sales document for item data
         EKKO,              "purchasing document header
         EKPO,              "purchasing document item
         KNA1.              "customer master details
            INTERNAL TABLE DECLARATION             *
DATA : BEGIN OF T_MARA OCCURS 0,
       MATNR LIKE MARA-MATNR,
       MTART LIKE MARA-MTART,
       MEINS LIKE MARA-MEINS,
       END OF T_MARA.
DATA : BEGIN OF T_MAKT OCCURS 0,
       MATNR LIKE MAKT-MATNR,
       MAKTX LIKE MAKT-MAKTX,
       SPRAS LIKE MAKT-SPRAS,
       END OF T_MAKT.
DATA : BEGIN OF T_MARC OCCURS 0,
       MATNR LIKE MARC-MATNR,
       WERKS LIKE MARC-WERKS,
       END OF T_MARC.
DATA : BEGIN OF T_KNA1 OCCURS 0,
       KUNNR LIKE KNA1-KUNNR,
       NAME1 LIKE KNA1-NAME1,
       LAND1 LIKE KNA1-LAND1,
       END OF T_KNA1.
DATA : BEGIN OF T_VBAP OCCURS 0,
       MATNR LIKE VBAP-MATNR,
       POSNR LIKE VBAP-POSNR,
       MATKL LIKE VBAP-MATKL,
       VBELN LIKE VBAP-VBELN,
       END OF T_VBAP.
DATA : BEGIN OF T_EKPO OCCURS 0,
       EBELN LIKE EKPO-EBELN,
       EBELP LIKE EKPO-EBELP,
       BUKRS LIKE EKPO-BUKRS,
       WERKS LIKE EKPO-WERKS,
       LGORT LIKE EKPO-LGORT,
       MATNR LIKE EKPO-MATNR,
       MANDT LIKE EKPO-MANDT,
       END OF T_EKPO.
                 FINAL INTERNAL TABLE                *
DATA : BEGIN OF T_FINAL OCCURS 0,
       MATNR LIKE MARA-MATNR,
       MTART LIKE MARA-MTART,
       MEINS LIKE MARA-MEINS,
       WERKS LIKE MARC-WERKS,
       MAKTX LIKE MAKT-MAKTX,
       SPRAS LIKE MAKT-SPRAS,
       VBELN LIKE VBAP-VBELN,
       POSNR LIKE VBAP-POSNR,
       MATKL LIKE VBAP-MATKL,
       EBELN LIKE EKPO-EBELN,
       EBELP LIKE EKPO-EBELP,
       BUKRS LIKE EKPO-BUKRS,
       KUNNR LIKE KNA1-KUNNR,
       LAND1 LIKE KNA1-LAND1,
       NAME1 LIKE KNA1-NAME1,
       LGORT LIKE EKPO-LGORT,
       END OF T_FINAL.
*DATA: BEGIN OF V_matnr OCCURS 0,
       matnr LIKE mara-matnr,
     END OF t_matnr.
data:
      a(32) type c.
a = 'IBT000000000000000001000000000000000050'.
                   SELECTION SCREEN                         *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_BUKRS FOR EKPO-BUKRS,
                 S_KUNNR FOR KNA1-KUNNR,
                 S_WERKS FOR MARC-WERKS,
                 S_MATNR FOR MARA-MATNR obligatory.
SELECTION-SCREEN END OF BLOCK B1.
                 START OF SELECTION                           *
START-OF-SELECTION.
  SELECT MATNR mtart meins
          FROM MARA
          INTO CORRESPONDING FIELDS OF TABLE T_MARA
          WHERE MATNR IN S_MATNR.
  SELECT MATNR WERKS
          FROM MARC
          INTO CORRESPONDING FIELDS OF TABLE T_MARC
          FOR ALL ENTRIES IN T_MARA
          WHERE MATNR = T_MARA-MATNR
          and werks in s_werks.
  select  matnr maktx spras
        from makt
        into corresponding fields of table t_makt
        for all entries in t_mara
        where matnr = t_mara-matnr
        and spras = sy-langu.
  select matnr posnr matkl vbeln
         from vbap
         into corresponding fields of table t_vbap
         for all entries in t_mara
         where matnr = t_mara-matnr.
select matnr werks bukrs ebeln ebelp lgort
         from ekpo
         into corresponding fields of table t_ekpo
         for all entries in t_mara
         where matnr = t_mara-matnr
         and werks in s_werks.
  LOOP AT T_MARA.
    MOVE T_MARA-matnr TO T_FINAL-matnr.
    move t_mara-mtart to t_final-mtart.
    move t_mara-meins to t_final-meins.
    loop at t_marc where matnr eq t_mara-matnr.
      move t_marc-werks to t_final-werks.
      loop at t_makt.
        move t_makt-maktx to t_final-maktx.
        move t_makt-spras to t_final-spras.
        loop at t_vbap.
          move t_vbap-posnr to t_final-posnr.
          move t_vbap-matkl to t_final-matkl.
          move t_vbap-vbeln to t_final-vbeln.
        loop at t_ekpo.
        move t_ekpo-bukrs to t_final-bukrs.
        move t_ekpo-ebeln to t_final-ebeln.
        move t_ekpo-ebelp to t_final-ebelp.
        move t_ekpo-lgort to t_final-lgort.
          append t_final.
        endloop.
      endloop.
    endloop.
  endloop.
  endloop.
  SELECT werks KUNNR LAND1 NAME1
  INTO CORRESPONDING FIELDS OF TABLE T_KNA1
  FROM KNA1.
WHERE WERKS in s_werks.
  loop at t_kna1.
    move t_kna1-kunnr to t_final-kunnr.
    move t_kna1-name1 to t_final-name1.
    move t_kna1-land1 to t_final-land1.
    append t_final.
  endloop.
  "endloop.
  loop at t_final.
    write :   4 t_final-matnr,
             20 t_final-mtart,
             28 t_final-meins,
             46 t_final-werks,
             58 t_final-maktx,
             71 t_final-spras,
             78 t_final-posnr,
            100 t_final-matkl,
            115 t_final-vbeln,
            130 t_final-kunnr,
            142 t_final-name1,
            156 t_final-land1,
            168 t_final-bukrs,
            190 t_final-ebeln,
            205 t_final-ebelp,
            208 t_final-lgort.
  endloop.
              TOP-OF-PAGE                       *
top-of-page.
  uline.
  write : /60 'G E N E R A L   D E T A I L S' COLOR 2 INVERSE OFF.
  ULINE.
  write :/ SY-VLINE,    'MATERIAL'       COLOR 4, "12 SY-VLINE,
        13 SY-VLINE,    'IND SECTOR',
        28 SY-VLINE,    'UNITS',
        43 SY-VLINE,    'PLANT',
        55 SY-VLINE,    'MAT DESC',
        68 SY-VLINE,    'LANGU',
        70 SY-VLINE,    'SALES DOC ITEM',
        95 SY-VLINE,    'MAT GROUP',
       110 SY-VLINE,    'SALES DOC',
       125 SY-VLINE,    'CUST ID',
       140 SY-VLINE,    'NAME',
       155 SY-VLINE,    'COUNTRY',
       165 sy-vline,    'company code',
       205 sy-vline,    'storge loc'.

*& Report  YTESTCHA                                                    *
REPORT ytestcha  NO STANDARD PAGE HEADING
LINE-SIZE 250
LINE-COUNT 22(3). .
TABLES DECLARATION *
TABLES : mara, "general material data
makt, "material description
marc, "plant data for material
vbap, "sales document for item data
ekko, "purchasing document header
ekpo, "purchasing document item
kna1. "customer master details
INTERNAL TABLE DECLARATION *
*DECLARE TYPES FIRST AND THE INTERNAL TABLES
*DONT USE MATNR LIKE MARA-MATNR ,INSTEAD USE MARA TYPE MATNR WHERE MATNR
*IS THE DATA ELEMENT FOR FIELD MATNR.
TYPES: BEGIN OF ty_mara,
         matnr TYPE matnr,
         mtart TYPE mtart,
         meins TYPE meins,
         kunnr TYPE wettb,
       END OF ty_mara.
TYPES: BEGIN OF ty_makt,
        matnr TYPE matnr,
        maktx TYPE maktx,
        spras TYPE spras,
       END OF ty_makt.
TYPES: BEGIN OF ty_marc,
        matnr TYPE matnr,
        werks TYPE werks_d,
        END OF ty_marc.
TYPES : BEGIN OF ty_kna1,
          kunnr TYPE kunnr,
          name1 TYPE name1_gp,
          land1 TYPE land1_gp,
          END OF ty_kna1.
TYPES: BEGIN OF ty_vbap,
         matnr TYPE matnr,
         posnr TYPE posnr_va,
         matkl TYPE matkl,
         vbeln TYPE vbeln_va,
         END OF ty_vbap.
TYPES: BEGIN OF ty_ekpo,
         ebeln TYPE ebeln,
         ebelp TYPE ebelp,
         bukrs TYPE bukrs,
         werks TYPE werks_d,
         lgort TYPE lgort_d,
         matnr TYPE matnr,
         mandt TYPE mandt,
        END OF ty_ekpo.
DATA:t_mara TYPE TABLE OF ty_mara WITH HEADER LINE,
     t_makt TYPE TABLE OF ty_makt WITH HEADER LINE,
     t_marc TYPE TABLE OF ty_marc WITH HEADER LINE,
     t_kna1 TYPE TABLE OF ty_kna1 WITH HEADER LINE,
     t_vbap TYPE TABLE OF ty_vbap WITH HEADER LINE,
     t_ekpo TYPE TABLE OF ty_ekpo WITH HEADER LINE.
FINAL INTERNAL TABLE *
TYPES: BEGIN OF ty_final,
     matnr TYPE matnr,
     mtart TYPE mtart,
     meins TYPE meins,
     werks TYPE werks_d,
     maktx TYPE maktx,
     spras TYPE spras,
     vbeln TYPE vbeln_va,
     posnr TYPE posnr_va,
     matkl TYPE matkl,
     ebeln TYPE ebeln,
     ebelp TYPE ebelp,
     bukrs TYPE bukrs,
     kunnr TYPE kunnr,
     land1 TYPE land1_gp,
     name1 TYPE name1_gp,
     lgort TYPE lgort_d,
     END OF ty_final.
DATA : t_final TYPE TABLE OF ty_final WITH HEADER LINE.
*DATA: BEGIN OF V_matnr OCCURS 0,
matnr LIKE mara-matnr,
END OF t_matnr.
DATA:
a(32) TYPE c.
a = 'IBT000000000000000001000000000000000050'.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_bukrs FOR ekpo-bukrs,
                 s_kunnr FOR kna1-kunnr,
                 s_werks FOR marc-werks,
                 s_matnr FOR mara-matnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START OF SELECTION *
START-OF-SELECTION.
*USE SUBROUTINES
*get data
  PERFORM get_data.
*populate final table
  PERFORM populate_final_table.
END-OF-SELECTION.
*display output
  PERFORM display_output.
TOP-OF-PAGE *
TOP-OF-PAGE.
  ULINE.
  WRITE : /60 'G E N E R A L D E T A I L S' COLOR 2 INVERSE OFF.
  ULINE.
  WRITE :/ sy-vline, 'MATERIAL' COLOR 4, "12 SY-VLINE,
  13 sy-vline, 'IND SECTOR',
  28 sy-vline, 'UNITS',
  43 sy-vline, 'PLANT',
  55 sy-vline, 'MAT DESC',
  68 sy-vline, 'LANGU',
  70 sy-vline, 'SALES DOC ITEM',
  95 sy-vline, 'MAT GROUP',
  110 sy-vline, 'SALES DOC',
  125 sy-vline, 'CUST ID',
  140 sy-vline, 'NAME',
  155 sy-vline, 'COUNTRY',
  165 sy-vline, 'company code',
  205 sy-vline, 'storge loc'.
*&      Form  GET_DATA
      text
-->  p1        text
<--  p2        text
*TRY TO CLEAR AND REFRESH TABLES BEFORE SELECT
FORM get_data .
  CLEAR t_mara.
  REFRESH t_mara.
  SELECT matnr
         mtart
         meins
         kunnr
         FROM mara
         INTO TABLE t_mara
         WHERE matnr IN s_matnr.
  IF NOT t_mara[] IS INITIAL.
    CLEAR t_marc.
    REFRESH t_marc.
    SELECT matnr
           werks
           FROM marc
           INTO TABLE t_marc
           FOR ALL ENTRIES IN t_mara
           WHERE matnr = t_mara-matnr
                 AND werks IN s_werks.
    CLEAR t_makt.
    REFRESH t_makt.
    SELECT matnr
           maktx
           spras
           FROM makt
           INTO TABLE t_makt
           FOR ALL ENTRIES IN t_mara
           WHERE matnr = t_mara-matnr
           AND spras = sy-langu.
    CLEAR t_vbap.
    REFRESH t_vbap.
    SELECT matnr
           posnr
           matkl
           vbeln
           FROM vbap
           INTO TABLE t_vbap
           FOR ALL ENTRIES IN t_mara
           WHERE matnr = t_mara-matnr.
    CLEAR t_ekpo.
    REFRESH t_ekpo.
    SELECT ebeln
           ebelp
           bukrs
           werks
           lgort
           matnr
           mandt
           FROM ekpo
           INTO TABLE t_ekpo
           FOR ALL ENTRIES IN t_mara
           WHERE matnr = t_mara-matnr
           AND werks IN s_werks.
  ENDIF.
  CLEAR t_kna1.
  REFRESH t_kna1.
  SELECT kunnr
         land1
         name1
         INTO  TABLE t_kna1
         FROM kna1.
WHERE WERKS in s_werks.
ENDFORM.                    " GET_DATA
*&      Form  POPULATE_FINAL_TABLE
      text
-->  p1        text
<--  p2        text
FORM populate_final_table .
*AVOID LOOPS AND TRY  TO USE READ
  CLEAR t_final.
  REFRESH t_final.
  LOOP AT t_mara.
    MOVE t_mara-matnr TO t_final-matnr.
    MOVE t_mara-mtart TO t_final-mtart.
    MOVE t_mara-meins TO t_final-meins.
    READ TABLE t_marc WITH KEY matnr = t_mara-matnr.
    MOVE t_marc-werks TO t_final-werks.
    READ TABLE t_makt WITH KEY matnr = t_mara-matnr.
    MOVE t_makt-maktx TO t_final-maktx.
    MOVE t_makt-spras TO t_final-spras.
    READ TABLE t_vbap WITH KEY matnr = t_mara-matnr.
    MOVE t_vbap-posnr TO t_final-posnr.
    MOVE t_vbap-matkl TO t_final-matkl.
    MOVE t_vbap-vbeln TO t_final-vbeln.
    READ TABLE t_ekpo WITH KEY matnr = t_mara-matnr.
    MOVE t_ekpo-bukrs TO t_final-bukrs.
    MOVE t_ekpo-ebeln TO t_final-ebeln.
    MOVE t_ekpo-ebelp TO t_final-ebelp.
    MOVE t_ekpo-lgort TO t_final-lgort.
    READ TABLE t_kna1 WITH KEY kunnr  = t_mara-kunnr.
    MOVE t_kna1-kunnr TO t_final-kunnr.
    MOVE t_kna1-name1 TO t_final-name1.
    MOVE t_kna1-land1 TO t_final-land1.
    APPEND t_final.
    CLEAR :t_final,t_mara,t_marc,t_makt,t_ekpo,t_vbap.
  ENDLOOP.
ENDFORM.                    " POPULATE_FINAL_TABLE
*&      Form  DISPLAY_OUTPUT
      text
-->  p1        text
<--  p2        text
FORM display_output .
  LOOP AT t_final.
    WRITE : 4 t_final-matnr,
    20 t_final-mtart,
    28 t_final-meins,
    46 t_final-werks,
    58 t_final-maktx,
    71 t_final-spras,
    78 t_final-posnr,
    100 t_final-matkl,
    115 t_final-vbeln,
    130 t_final-kunnr,
    142 t_final-name1,
    156 t_final-land1,
    168 t_final-bukrs,
    190 t_final-ebeln,
    205 t_final-ebelp,
    208 t_final-lgort.
  ENDLOOP.
ENDFORM.                    " DISPLAY_OUTPUT

Similar Messages

  • Performance Tuning for Concurrent Reports

    Hi,
    Can you help me with Performance Tuning for Concurrent Reports/Requests ?
    It was running fine but suddenly running slow.
    Request Name : Participation Process: Compensation program

    What is your application release?
    Please see if (Performance Issues With Participation Process: Compensation Workbench [ID 389979.1]) is applicable.
    To enable trace/debug, please see (FAQ: Common Tracing Techniques within the Oracle Applications 11i/R12 [ID 296559.1] -- 5. How does one enable trace for a concurrent program INCLUDING bind variables and waits?).
    Thanks,
    Hussein

  • Performance Tuning of webi report BO4.0

    Hi ,
    I have report which has two data providers in 1st Data Provider i have 10 objects and in 2nd Data provider i have 3 objects the issue is performance report is taking 6 minutes to run.
    Please help me out how we can increase the performance at Query Level.
    Thanks
    Siva

    Hi
    There are various levels to which you have to check to improve the performance of reports could be at connection levels, query, database etc.
    some of them you can try
    1. check array fetch size in relational connection parameters, deactivating array fetch size can increase the efficiency of retrieving your data, but slows server performance.
    2. Setting options for the default list of values in business layer and data foundation layer
    Automatic refresh - If this is selected, the list of values is automatically refreshed each time the
    list is called. This can have an effect on performance each time the list of values is refreshed. You should disable this option if the list of values returns a large number of values.
    3. set query stripping (Optimize query with Query Stripping in Web Intelligence - Business Intelligence (BusinessObjects) - SCN Wiki)
    4. also check Performance Tuning Methods in BO
    Regards,
    Raghava

  • Performance Tuning for OBIEE Reports

    Hi Experts,
    I had a requirement for which i have to end up building a snowflakt model in Physical layer i.e. One Dimension table with Three snowflake tables(Materialized views).
    The key point is the Dimension table is used in most of the OOTB reports.
    so all the reports use other three snowflakes tables in the Join conditions due to which the reports take longer time than ever like 10 mints.
    can anyone suggest good performance tuning tips to tune the reports.
    i created some indices on Materialized view columns and and on dimension table columns.
    i created the Materialized views with cache Enabled and refreshes only once in 24 hours etc
    is there anything i have to improve performance or have to consider re-designing the Physical layer without snowflake
    Please Provide valuable suggestions and comments
    Thank You
    Kumar

    Kumar,
    Most of the Performance Tuning should be done at the Back End , So calculate all the aggregates in the Repository it self and Create a Fast Refresh for MV and you can also do one thing you can schedule an IBOT to run the report every 1 hour or some thing so that the report data will be cached and when the user runs the report the BI Server extracts the data from Cache
    Hope that helps
    ~Srix

  • Performance tuning of this code.

    Hello Friends,
    Following is the piece of Code.. can some one please help me to optimise the code.
    I want to do performance tuning on the same.
    Any inputs on this would be valuable to me .
    Thanking you all in anticipation.
    << Unformatted code removed >>
    Edited by: Jitesh Pamnani on Apr 7, 2009 10:09 AM
    Edited by: Jitesh Pamnani on Apr 7, 2009 10:09 AM
    Edited by: Rob Burbank on Apr 7, 2009 11:05 AM

    please read,
    SQL trace:
    /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    for the first part, without SQL Trace it does not make much sense, to check your select statements.
    I guess that one or several are slow. But there are too many.
    Second part, use sorted tables or binary search!!!!!
    Your coding is highly nonlinear, not only quadratic but even cubic!!!!
    Read here for table types and runtimes
    Measurements on internal tables: Reads and Loops:
    /people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
    Read here about nonlinearity:
    Nonlinearity: The problem and background
    /people/siegfried.boes/blog/2007/02/12/performance-problems-caused-by-nonlinear-coding
    Read here for measuring:
    SE30
    /people/siegfried.boes/blog/2007/11/13/the-abap-runtime-trace-se30--quick-and-easy
    Z_SE30_COMPARE
    /people/siegfried.boes/blog/2008/01/15/a-tool-to-compare-runtime-measurements-zse30compare
    Nonlinearity Check
    /people/siegfried.boes/blog/2008/01/24/nonlinearity-check-using-the-zse30compare
    If you do ot all I assume that your coding can becomes faster by factors 10 ... 100 or even more.
    Siegfried

  • Performance tuning of a report.

    hello all,
              I have been assigned a report to improve the performance.Initially after studying the report i found that all the data was fetched by using select * from... query,hence i changed the query by selectin the particular feilds from the tables.the tables used in my report r bsid and bsad majorly..after these changes there was not much of a diff in the performance,after tracing the report thru st05 it was realized that the select for bsad is taking the max time to fetch..as bsad is a huge table and has huge amount of data..is ther any way i can reduce this time..by using indexes n all..can u please provide me with an example to reduce the time taken for fetchin data from bsid and bsad..
    thanks and regards,
    seema.

    hello again,
    SELECT
          KUNNR
          UMSKZ
          AUGDT
          AUGBL
          ZUONR
          GJAHR
          BELNR
          BUZEI
          BUDAT
          BLDAT
          WAERS
          XBLNR
          BLART
          MONAT
          BSCHL
          SHKZG
          GSBER
          DMBTR
          SGTXT
          AUFNR
          HKONT
          ZFBDT
          ZTERM
          SKNTO
          REBZG
          MANSP
          MSCHL
          MADAT
          MANST
          MABER
          MWSK1
          VBELN
          XREF1
          XREF2
          KKBER
          EMPFB
          PRCTR
          XREF3
          QSSKZ
          BUPLA
        FROM   BSAD
        INTO   CORRESPONDING FIELDS OF TABLE T_BSID_TEMP
        WHERE  KUNNR IN S_KUNNR
        and    BUKRS = P_BUKRS
        AND    AUGDT GT S_BUDAT-HIGH
        AND    GSBER IN S_GSBER
        AND    BUDAT IN S_BUDAT
    AND    BLDAT IN S_BLDAT
        AND    KKBER IN S_KKBER
        AND    XREF1 IN  s_wERKS                                
        AND    UMSKZ NOT IN ('B', 'G')
        AND    BSTAT NOT IN ('S').
    if this is my select qury and these r the selection criteria in the wher condition how could i modify the query for better performance,
    Regards,
    seema.

  • Performance Tuning for a report

    Hi,
    We have developed a program which updates 2 fields namely Reorder Point and Rounding Value on the MRP1 tab in TCode MM03.
    To update the fields, we are using the BAPI BAPI_MATERIAL_SAVEDATA.
    The problem is that when we upload the data using a txt file, the program takes a very long time. Recently when we uploaded a file containing 2,00,000 records, it took 27 hours. Below is the main portion of the code (have ommitted the open data set etc). Please help us fine tune this, so that we can upload these 2,00,000 records in 2-3 hours.
    select matnr from mara into table t_mara.
    select werks from t001w into corresponding fields of table t_t001w .
    select matnr werks from marc into corresponding fields of table t_marc.
    loop at str_table into wa_table.
    if not wa_table-partnumber is initial.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
         INPUT         =  wa_table-partnumber
         IMPORTING
        OUTPUT        = wa_table-partnumber
    endif.
    clear wa_message.
    read table t_mara into wa_mara with key matnr = wa_table-partnumber.
    if sy-subrc is not initial.
    concatenate 'material ' wa_table-partnumber ' doesnot exists'
    into wa_message.
    append wa_message to t_message.
    endif.
    read table t_t001w into wa_t001w with key werks = wa_table-HostLocID.
      if sy-subrc is not initial.
      concatenate 'plant ' wa_table-HostLocID  ' doesnot exists' into
      wa_message.
      append wa_message to t_message.
      else.
      case wa_t001w-werks.
    when 'DE40'
    or  'DE42'
    or  'DE44'
    or  'CN61'
    or  'US62'
    or  'SG70'
    or  'FI40'
    read table t_marc into wa_marc with key matnr = wa_table-partnumber
                                            werks = wa_table-HostLocID.
    if sy-subrc is not initial.
    concatenate 'material' wa_table-partnumber  ' not extended to plant'
    wa_table-HostLocID  into  wa_message.
    append wa_message to t_message.
    endif.
    when others.
    concatenate 'plant ' wa_table-HostLocID ' not allowed'
      into wa_message.
    append wa_message to t_message.
    endcase.
    endif.
        if wa_message is initial.
          data: wa_headdata type BAPIMATHEAD,
          wa_PLANTDATA type BAPI_MARC,
          wa_PLANTDATAx type BAPI_MARCX.
          wa_headdata-MATERIAL = wa_table-PartNumber.
          wa_PLANTDATA-plant = wa_table-HostLocID.
          wa_PLANTDATAX-plant = wa_table-HostLocID.
          wa_PLANTDATA-REORDER_PT = wa_table-ROP.
          wa_PLANTDATAX-REORDER_PT = 'X'.
          wa_plantdata-ROUND_VAL = wa_table-EOQ.
          wa_plantdatax-round_val =  'X'.
          CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
            EXPORTING
              HEADDATA                   = wa_headdata
             PLANTDATA                  = wa_PLANTDATA
             PLANTDATAX                 = wa_PLANTDATAX
          IMPORTING
             RETURN                     =  t_bapiret
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    write t_bapiret-message.
    endif.
    clear: wa_mara, wa_t001w, wa_marc.
    endloop.
    loop at t_message into wa_message.
    write wa_message.
    endloop.
    Thanks in advance.
    Peter
    Edited by: kishan P on Sep 17, 2010 4:50 PM

    Hi Peter,
    I would suggest few changes in your code. Please refer below procedure to optimize the code.
    Steps:
               Please run SE30 run time analysis and find out if ABAP code or Database fetch is taking time.
               Please run extended program check or code inspector to remove any errors and warnings.
               Few code changes that i would suggest in your code
              For select query from t001w & marc remove the corresponding clause as this also reduces the performance. ( For this you can define an Internal table with only the required fields in the order they are specified in the table and execute a select query to fetch these fields)
              Also put an initial check if str_table[] is not initial before you execute the loop.
              where ever you have used read table. Please sort these tables and use binary search.
              Please clear the work areas after every append statment.
              As i dont have a sap system handy. i would also check if my importing parameters for the bapi structure is a table. Incase its a table i would directly pass all the records to this table and then pass it to the bapi. Rather than looping every records and updating it.
    Hope this helps to resolve your problem.
    Have a nice day
    Thanks

  • Performance tuning on this code

    Hi guys,
    This piece of coding is taking ages to execute, any idea how can i fine tune it?
      SELECT vbeln vbtyp_n vbtyp_v vbelv
          INTO TABLE lt_vbfa1 FROM vbfa
          FOR ALL ENTRIES IN lt_vbrp
          WHERE vbeln = lt_vbrp-vbeln
            AND vbtyp_n IN ('N','S')
            AND vbtyp_v IN ('M','P','O').
    Thanks in advance!

    Table VBFA (sales document flow) is to be used to find preceding documents, like cancelation invoices for an invoice.
    Here original documents are to be found for a preceding document. Then it's better not to use table VBFA because its key is original document number. Then try to use VBRP-VGBEL (preceding document) or VBRP-AUBEL (preceding sales order). Here something like:
    SELECT vbrk~vbeln vbrk~vbtyp vbrp~vgtyp vbrp~vgbel
    INTO TABLE lt_vbfa1
    FROM vbrk INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
    FOR ALL ENTRIES IN lt_vbrp
    WHERE vbrk~vbeln = lt_vbrp-vbeln
    AND   vbrp~posnr = lt_vbrp-posnr
    AND   vbrk~vbtyp IN ('N','S')
    AND   vbrp~vgtyp IN ('M','P','O').
    Regards Jack

  • Oracle Memory Issue/ performance tuning

    I have Oracle 9i running on Window 2003 server. 2 GB memory is allocated to Oralce DB( even though server has 14GB memory)
    Recently, the oracle process has been slow.. running query
    I ran the window task manager. Here is the numbers that I see
    Mem usage: 556660k
    page Faults: 1075029451
    VM size: 1174544 K
    I am not sure how to analyze this data. why the page fault is so huge. and Mem usage is half of VM size?
    How can I do the performance tuning on this box?

    I'm having a similar issue with Oracle 10g R2 64-bit on Windows 2003 x64. Performance on complicated queries is abysmal because [I think] most of the SGA is sitting in a page file, even though there is plenty of physical RAM to be had. Performance on simple queries is probably bad also, but it's not really noticable. Anyway, page faults skyrocket when I hit the "go" button on big queries. Our legacy system runs our test queries in about 5 minutes, but the new system takes at least 30 if not 60. The new system has 24 gigs of RAM, but at this point, I'm only allocating 1 gig to the SGA and 1/2 gig to the PGA. Windows reports oracle.exe has 418,000K in RAM and 1,282,000K in the page file (I rounded a bit). When I had the PGA set to 10 gigs, the page usage jumped to over 8 gigs.
    I tried adding ORA_LPENABLE=1 to the registry, but this issue seems to be independent. Interestingly, the amount of RAM taken by oracle.exe goes down a bit (to around 150,000K) when I do this. I also added "everyone" to the security area "lock pages in memory", but again, this is probably unrelated.
    I did an OS datafile copy and cloned the database to a 32-bit windows machine (I had to invalidate and recompile all objects to get this to work), and this 32-bit test machine now has the same problem.
    Any ideas?

  • I want to do 1Z0-054 11g Performance Tuning

    I want to do 1Z0-054 11g Performance Tuning
    for this first needed 1Z0-007 or 1Z0-047 or 1Z0-051, then 1Z0-052 & 1Z0-054
    1) Which should be best in 1Z0-007 or 1Z0-047 or 1Z0-051
    2) Recommended books... where will get course materials.
    Thanks
    Harsh

    857317 wrote:
    I want to do 1Z0-054 11g Performance Tuning
    for this first needed 1Z0-007 or 1Z0-047 or 1Z0-051, then 1Z0-052 & 1Z0-054
    1) Which should be best in 1Z0-007 or 1Z0-047 or 1Z0-051
    2) Recommended books... where will get course materials.
    Thanks
    HarshI always think it is useful to be precise about these things:
    You can take the exam +1Z0-054 11g Performance Tuning+ whenever you like. Simply book it, turn up and take it.
    In the event you pass you've passed the exam!!! If you don't it is an expensive re-take.
    However .....
    While you;ve passed the exam you would not be a 'Oracle Database 11g Performance Tuning Certified Expert ' until Oracle confirms to you that certification, and Oracle you have identified all the requriements wht Oracle have detailed here:-
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=287
    This indicates one of two additional pre-requisites to the exam pass:-
    : Either (1) : A prior DBA 11g Certification.
    : Or (2): Verification of your attendance to the Oracle Univerisity Oracle Database 11g: Performance Tuning training course.
    Above you have sort of indicated the 11g DBA OCP credential requirements (omitting the mandatory training requirement) ( http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=198)
    The journey to 'Oracle Database 11g Performance Tuning Certified Expert ' is a long one, and i suggest most people should look at the basics first. Begin by becoming familiar with http://certification.oracle.com.
    If you wish to continue I would consider focusing on 1z0-051 as a first exam or possilby attempting to find suitable workforce development programme training (assuming oracle univerisity is too expensive). Please be aware IMHO Oracle are not responsible for WDP institutes and I suspect some are very bad.
    https://workforce.oracle.com/pls/wdp/new_home.main

  • Can anyone plz tell me the steps for performance tuning.

    hello friends
    what is performance tuning?
    can anyone plz tell me the steps for performance tuning.

    Hi Kishore, this will help u.
    Following are the different tools provided by SAP for performance analysis of an ABAP object
    Run time analysis transaction SE30
    This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
    SQL Trace transaction ST05
    The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
    The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
    The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.
    To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.
    Need for performance tuning
    In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the “given deadlines”.
    Often due to this pressure of schedules and deliveries, the main focus of making a efficient program takes a back seat. An efficient ABAP program is one which delivers the required output to the user in a finite time as per the complexity of the program, rather than hearing the comment “I put the program to run, have my lunch and come back to check the results”.
    Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus increasing the productivity of the user, and in turn keeping the user and the management happy.
    This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and syntax of ABAP programming.
    Use of selection criteria
    Instead of selecting all the data and doing the processing during the selection, it is advisable to restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code.
    Not recommended
    Select * from zflight.
    Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
    Endselect.
    Recommended
    Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
    Endselect.
    One more point to be noted here is of the select *. Often this is a lazy coding practice. When a programmer gives select * even if one or two fields are to be selected, this can significantly slow the program and put unnecessary load on the entire system. When the application server sends this request to the database server, and the database server has to pass on the entire structure for each row back to the application server. This consumes both CPU and networking resources, especially for large structures.
    Thus it is advisable to select only those fields that are needed, so that the database server passes only a small amount of data back.
    Also it is advisable to avoid selecting the data fields into local variables as this also puts unnecessary load on the server. Instead attempt must be made to select the fields into an internal table.
    Use of aggregate functions
    Use the already provided aggregate functions, instead of finding out the minimum/maximum values using ABAP code.
    Not recommended
    Maxnu = 0.
    Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
    Check zflight-fligh > maxnu.
    Maxnu = zflight-fligh.
    Endselect.
    Recommended
    Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.
    The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
    Use of Views instead of base tables
    Many times ABAP programmers deal with base tables and nested selects. Instead it is always advisable to see whether there is any view provided by SAP on those base tables, so that the data can be filtered out directly, rather than specially coding for it.
    Not recommended
    Select * from zcntry where cntry like ‘IN%’.
    Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
    Endselect.
    Recommended
    Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
    Endselect.
    Check this links
    http://www.sapdevelopment.co.uk/perform/performhome.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
    kindly reward if found helpful.
    cheers,
    Hema.

  • Need clear steps for doing performance tuning on SQL Server 2008 R2 (DB Engine, Reporting Services and Integration Services)

    We have to inverstigate about a reporting solution where things are getting slow (may be material, database design, network matters).
    I have red a lot in MSDN and some books about performance tuning on SQL Server 2008 R2 (or other) but frankly, I feel a little lost in all that stuff
    I'am looking for practical steps in order to do the tuning. Someone had like a recipe for that : a success story...
    My (brain storm) Methodology should follow these steps:
     Resource bottlenecks: CPU, memory, and I/O bottlenecks
     tempdb bottlenecks
     A slow-running user query : Missing indexes, statistics,...
     Use performance counters : there are many, can one give us the list of the most important
    how to do fine tuning about SQL Server configuration
    SSRS, SSIS configuration ? 
    And do the recommandations.
    Thanks
    "there is no Royal Road to Mathematics, in other words, that I have only a very small head and must live with it..."
    Edsger W. Dijkstra

    Hello,
    There is no clear defined step which can be categorized as step by step to performance tuning.Your first goal is to find out cause or drill down to factor causing slowness of SQL server it can be poorly written query ,missing indexes,outdated stats.RAM crunch
    CPU crunch so on and so forth.
    I generally refer to below doc for SQL server tuning
    http://technet.microsoft.com/en-us/library/dd672789(v=sql.100).aspx
    For SSIS tuning i refer below doc.
    http://technet.microsoft.com/library/Cc966529#ECAA
    http://msdn.microsoft.com/en-us/library/ms137622(v=sql.105).aspx
    When I face issue i generally look at wait stats ,wait stats give you idea about on what resource query was waiting.
    --By Jonathan KehayiasSELECT TOP 10
    wait_type ,
    max_wait_time_ms wait_time_ms ,
    signal_wait_time_ms ,
    wait_time_ms - signal_wait_time_ms AS resource_wait_time_ms ,
    100.0 * wait_time_ms / SUM(wait_time_ms) OVER ( )
    AS percent_total_waits ,
    100.0 * signal_wait_time_ms / SUM(signal_wait_time_ms) OVER ( )
    AS percent_total_signal_waits ,
    100.0 * ( wait_time_ms - signal_wait_time_ms )
    / SUM(wait_time_ms) OVER ( ) AS percent_total_resource_waits
    FROM sys.dm_os_wait_stats
    WHERE wait_time_ms > 0 -- remove zero wait_time
    AND wait_type NOT IN -- filter out additional irrelevant waits
    ( 'SLEEP_TASK', 'BROKER_TASK_STOP', 'BROKER_TO_FLUSH',
    'SQLTRACE_BUFFER_FLUSH','CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT',
    'LAZYWRITER_SLEEP', 'SLEEP_SYSTEMTASK', 'SLEEP_BPOOL_FLUSH',
    'BROKER_EVENTHANDLER', 'XE_DISPATCHER_WAIT', 'FT_IFTSHC_MUTEX',
    'CHECKPOINT_QUEUE', 'FT_IFTS_SCHEDULER_IDLE_WAIT',
    'BROKER_TRANSMITTER', 'FT_IFTSHC_MUTEX', 'KSOURCE_WAKEUP',
    'LAZYWRITER_SLEEP', 'LOGMGR_QUEUE', 'ONDEMAND_TASK_QUEUE',
    'REQUEST_FOR_DEADLOCK_SEARCH', 'XE_TIMER_EVENT', 'BAD_PAGE_PROCESS',
    'DBMIRROR_EVENTS_QUEUE', 'BROKER_RECEIVE_WAITFOR',
    'PREEMPTIVE_OS_GETPROCADDRESS', 'PREEMPTIVE_OS_AUTHENTICATIONOPS',
    'WAITFOR', 'DISPATCHER_QUEUE_SEMAPHORE', 'XE_DISPATCHER_JOIN',
    'RESOURCE_QUEUE' )
    ORDER BY wait_time_ms DESC
    use below link to analyze wait stats
    http://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
    HTH
    PS: for reporting services you can post in SSRS forum
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Plz increase performance of this report

    hi all
    i want to know how can i improve the performance of my report.
    the code is given below and it takes so much time on production even for single record
    plz help
    HERE COMES THE CODE
    *& Report  ZGRSTATUS
    REPORT  ZGRSTATUS.
    TYPE-POOLS slis.
    TABLES: mseg, qamb, mkpf, rseg.
    DATA : BEGIN OF itab OCCURS 0,
           mblnr LIKE mseg-mblnr,
           zeile LIKE mseg-zeile,
           uom LIKE mseg-erfme,
           matnr LIKE mseg-matnr,
           recqty LIKE mseg-erfmg,
           qcins LIKE mseg-insmk,               "INSPECTION SIGN
           ebeln LIKE mseg-ebeln,
           ebelp LIKE mseg-ebelp,
           lifnr LIKE mseg-lifnr,
           budat LIKE mkpf-budat,
           txz01 LIKE ekpo-txz01,
           name1 LIKE lfa1-name1,
           accqty LIKE mseg-erfmg,
           rejqty LIKE mseg-erfmg,
           belnr LIKE rseg-belnr,
           dqty LIKE mseg-menge,
           cqty LIKE mseg-menge,
           qcdat like mkpf-budat,
           miro_budat like rbkp-budat,
           accuom like mseg-erfme,
           rejuom like mseg-erfme,
           qcstat like mseg-insmk,
           acstat(1) type c,
           crnote(1) type c,
           END OF itab.
    DATA : BEGIN OF itab1 OCCURS 0,
           mblnr LIKE mseg-mblnr,
           zeile LIKE mseg-zeile,
           mjahr LIKE mseg-mjahr,
           prueflos like qamb-prueflos,
           END OF itab1.
    DATA: BEGIN OF imiro OCCURS 0,
          belnr LIKE rseg-belnr,
          lfbnr LIKE rseg-lfbnr,              "DOCMENT NO SAME AS MBLRN
          shkzg LIKE rseg-shkzg,              "DEBIT CREDIT SIGN
          menge LIKE rseg-menge,
          ebeln LIKE rseg-ebeln,
          ebelp LIKE rseg-ebelp,
          budat LIKE rbkp-budat,
          END OF imiro.
    data: begin of iins occurs 0,             "NEW INTERNAL TABLE DECLARED for inspection lot numbers
          mblnr like mseg-mblnr,
          zeile like mseg-zeile,
          prueflos like qamb-prueflos,
          mjahr like qamb-mjahr,
          end of iins.
    ****************************CODE FOR SELECTION SCREEN****************************
    selection-screen begin of block par1 WITH FRAME TITLE TEXT-001.
    PARAMETERS : plant LIKE mseg-werks OBLIGATORY DEFAULT 'MFPL'.
    PARAMETERS: year LIKE mseg-mjahr OBLIGATORY DEFAULT '2007'.
    SELECT-OPTIONS : grno FOR mseg-mblnr,
                     grdate FOR mkpf-budat,
                     vendor FOR mseg-lifnr,
                     item for mseg-matnr.
    SELECTION-SCREEN END OF BLOCK par1.
    ***************************END OF CODE FOR SELECTION SCREEN**********************
    *************************FETCHING OF GR INFORMATION FROM MSEG AND MKPF*************************
    SELECT amblnr zeile aerfme amatnr aerfmg ainsmk aebeln aebelp alifnr bbudat ctxz01 d~name1
    FROM mseg AS a
    INNER JOIN mkpf AS b ON amblnr = bmblnr AND amjahr = bmjahr
    INNER JOIN ekpo AS c ON aebeln = cebeln AND aebelp = cebelp
    INNER JOIN lfa1 as d ON dlifnr = alifnr
    INTO TABLE itab
    WHERE awerks = plant AND amblnr IN grno AND bwart = '101' AND a~mjahr = year
    AND btcode2 = 'MIGO_GR' AND bbudat IN grdate AND alifnr IN vendor and amatnr IN item.
    *************************END OF RETERIEVEL***************************************
    if sy-subrc <> 0.
      Message 'NO RECORD FOUND' type 'E'.
    endif.
    *******************************SELECTING THE INSPECTED DOC NUMBERS AND CORROSPONDING INSPECTION LOT********************************
    select mblnr zeile mjahr prueflos
    from qamb into table itab1  for all entries in itab where mblnr = itab-mblnr and zeile = itab-zeile.
    **********************************END OF SELECTING THE INSPECTED DOC. NUMBERS & INSPECTION LOTS************************************
    **************************SELECTING THE DOC NO FOR ACCEPTED AND REJECTED QTY ACCORDING TO INSPECTION LOT***************************
    select mblnr zeile prueflos mjahr into table iins from qamb
      for all entries in itab1 where prueflos = itab1-prueflos and mblnr <> itab1-mblnr.
    **************************END OF SELECTING ACCEPTED AND REJECTED QTY DOCUMENTS****************************************************
    **********************************SELECTING THE DEBIT AND CREDIT QTY FOR THE MIRO TCODE*******************************************
    SELECT abelnr lfbnr shkzg menge ebeln ebelp bbudat INTO table imiro
        FROM rseg as a
        inner join rbkp as b on abelnr = bbelnr
        for all entries in itab where a~lfbnr = itab-mblnr.
    DATA : v_qcidoc LIKE qamb-prueflos,
           v_qcdoc LIKE mseg-mblnr,
           v_qcdoc1 LIKE mseg-zeile,
           v_qty LIKE mseg-menge,
           v_bwart LIKE mseg-bwart,
           v_name1 LIKE lfa1-name1,
           v_budat like mkpf-budat,
           v_newrejqty like mseg-menge,
           v_newaccqty like mseg-menge,
           CMPACCQTY LIKE MSEG-MENGE,
           CMPREJQTY LIKE MSEG-MENGE,
           aa TYPE c.
    data: begin of iartab occurs 0,
          mblnr like mseg-mblnr,
          bwart like mseg-bwart,
          qty like mseg-menge,
          erfme like mseg-erfme,
          zeile like mseg-zeile,
          budat like mkpf-budat,
          end of iartab.
    clear iartab.
    refresh iartab.
    ****************************************table for accept and reject qty************************************
    SELECT a~mblnr bwart erfmg erfme zeile budat into table iartab
      FROM mseg as a
      inner join mkpf as b on amblnr = bmblnr
      for all entries in iins
      WHERE amblnr = iins-mblnr AND azeile = iins-zeile AND xauto <> 'X' AND a~mjahr = iins-mjahr.
    ******************************************END OF ACCEPT AND REJECTED QTY.***********************************
    LOOP AT itab.
    clear: itab-accuom, itab-rejuom.
    SELECT SINGLE name1 FROM lfa1 INTO itab-name1 WHERE lifnr = itab-lifnr.
         **********************GETTING THE ACCEPTED AND REJECTED QTY FROM MSEG FOR ALL RECORDS OF ITAB*********************
      IF itab-qcins = 'X'.
      clear v_qcidoc.
      clear: v_bwart, v_qty, v_budat.
      read table itab1 with key mblnr = itab-mblnr zeile = itab-zeile.
        if sy-subrc = 0.
          v_qcidoc = itab1-prueflos.
        endif.
       LOOP AT itab1 where prueflos = v_qcidoc and mblnr <> itab-mblnr .
         LOOP AT iins where prueflos = v_qcidoc. " and mblnr <> itab-mblnr .
          v_qty = 0.
         SELECT single bwart erfmg budat
           INTO (v_bwart, v_qty, v_budat)
           FROM mseg as a
           inner join mkpf as b on amblnr = bmblnr
           WHERE amblnr = itab1-mblnr AND azeile = itab1-zeile AND xauto <> 'X' AND a~mjahr = itab1-mjahr.
           WHERE amblnr = iins-mblnr AND azeile = iins-zeile AND xauto <> 'X' AND a~mjahr = iins-mjahr.
          read table iartab with key mblnr = iins-mblnr zeile = iins-zeile.
          if sy-subrc = 0.
            v_bwart = iartab-bwart.
            v_qty = iartab-qty.
            v_budat = iartab-budat.
          endif.
          IF v_bwart = '321'.
            v_newaccqty = v_newaccqty + v_qty.
            itab-accqty = v_newaccqty.
            itab-qcdat = v_budat.
            itab-accuom = iartab-erfme.
          ELSEIF v_bwart = '122'.
            itab-qcdat = v_budat.
            v_newrejqty = v_newrejqty + v_qty.
            itab-rejqty = v_newrejqty.
            itab-rejuom = iartab-erfme.
          ENDIF.
        ENDLOOP.        "*********END OF LOOP FOR ITAB1**************
            clear: v_newaccqty, v_newrejqty.
      ENDIF.    "**********END OF MAIN ENDIF***********************
             *****************END OF CODE FOR ACCEPTED AND REJECTED QTY************************************
         ****************************GETTING DEBIT AND CREDIT QTY******************************************
      LOOP AT imiro WHERE lfbnr = itab-mblnr AND ebeln = itab-ebeln AND ebelp = itab-ebelp.
        ITAB-MIRO_BUDAT = IMIRO-BUDAT.
        itab-belnr = imiro-belnr.
        IF imiro-shkzg = 'S'.
          itab-dqty = imiro-menge.
        ELSEIF imiro-shkzg = 'H'.
          itab-cqty = imiro-menge.
        ENDIF.
      ENDLOOP.
         *****************************END OF CODE FOR DEBIT AND CREDIT QTY*******************************
      data v_sumqty like mseg-menge.
      CLEAR V_SUMQTY.
      if itab-qcins = 'X'.
      clear: cmpaccqty, cmprejqty.
      cmpaccqty = itab-accqty.
      cmprejqty = itab-rejqty.
        IF ITAB-UOM <> ITAB-ACCUOM AND ITAB-ACCUOM <> SPACE.
          CALL FUNCTION 'ZCONVERT_UOM_QTY'
           EXPORTING
             P_FR_UOM       = ITAB-UOM
             P_TO_UOM       = ITAB-ACCUOM
             P_QTY          = ITAB-ACCQTY
           IMPORTING
             P_RETVAL       = CMPACCQTY.
         ELSEIF ITAB-UOM <> ITAB-REJUOM AND ITAB-REJUOM <> SPACE.
           CALL FUNCTION 'ZCONVERT_UOM_QTY'
             EXPORTING
               P_FR_UOM       = ITAB-UOM
               P_TO_UOM       = ITAB-REJUOM
               P_QTY          = ITAB-REJQTY
             IMPORTING
               P_RETVAL       = CMPREJQTY.
         ENDIF.
        v_sumqty = CMPACCQTY + CMPREJQTY.
        if ( v_sumqty = itab-recqty ).
          itab-qcstat = 'C'.
          modify itab.
        ELSE.
          ITAB-QCSTAT = 'P'.
        endif.
      ELSE.
        ITAB-QCSTAT = 'C'.
      endif.
    IF ITAB-QCSTAT = 'C'.
      IF ITAB-DQTY = ITAB-RECQTY.
        ITAB-ACSTAT = 'C'.
      ELSE.
        ITAB-ACSTAT = 'P'.
      ENDIF.
    ELSEIF ITAB-QCSTAT = 'P'.
      IF ITAB-RECQTY = ITAB-DQTY.
        ITAB-ACSTAT = 'O'.
      ENDIF.
    ENDIF.
    IF ITAB-REJQTY > 0.
      IF ITAB-ACSTAT = 'C' AND ITAB-REJQTY > ITAB-CQTY.
        ITAB-CRNOTE = 'P'.
      ELSEIF ITAB-ACSTAT = 'C' AND ITAB-REJQTY < ITAB-CQTY.
        ITAB-CRNOTE = 'W'.
      ELSEIF ITAB-ACSTAT = 'C' AND ITAB-REJQTY = ITAB-CQTY.
        ITAB-CRNOTE = 'C'.
      ENDIF.
    ELSE.
      ITAB-CRNOTE = 'N'.
    ENDIF.
    MODIFY itab.
    ENDLOOP.    "*********************************************"END OF MAINT LOOP FOR ITAB.***********************
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE slis_fieldcat_alv,
          wa_layout TYPE slis_layout_alv.
    PERFORM f_layout.
    PERFORM f_fieldcat.
    PERFORM display.
    *&      Form  F_LAYOUT
          text
    FORM f_layout.
      wa_layout-colwidth_optimize = 'X'.
      wa_layout-no_subchoice = 'X'.
      wa_layout-zebra = 'X'.
    ENDFORM.                    "F_LAYOUT
    *&      Form  F_FIELDCAT
          text
    FORM f_fieldcat.
      DATA wa_col TYPE i VALUE 1.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'GR. NO'.
      wa_fieldcat-fieldname = 'MBLNR'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'GR DATE'.
      wa_fieldcat-fieldname = 'BUDAT'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'PO NO'.
      wa_fieldcat-fieldname = 'EBELN'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'PARTY ID'.
      wa_fieldcat-fieldname = 'LIFNR'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'PARTY NAME'.
      wa_fieldcat-fieldname = 'NAME1'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-outputlen = '18'.
      wa_fieldcat-seltext_l = 'ITEM ID'.
      wa_fieldcat-fieldname = 'MATNR'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'DESCRIPTION'.
      wa_fieldcat-fieldname = 'TXZ01'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'UOM'.
      wa_fieldcat-fieldname = 'UOM'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'INS REQ'.
      wa_fieldcat-fieldname = 'QCINS'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'GR QTY'.
      wa_fieldcat-fieldname = 'RECQTY'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'QC DATE'.
      wa_fieldcat-fieldname = 'QCDAT'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'ACC QTY'.
      wa_fieldcat-fieldname = 'ACCQTY'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'ACC UOM'.
      wa_fieldcat-fieldname = 'ACCUOM'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'REJ QTY'.
      wa_fieldcat-fieldname = 'REJQTY'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'REJ UOM'.
      wa_fieldcat-fieldname = 'REJUOM'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'MIRO NO'.
      wa_fieldcat-fieldname = 'BELNR'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'MIRO DATE'.
      wa_fieldcat-fieldname = 'MIRO_BUDAT'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'DB.QTY'.
      wa_fieldcat-fieldname = 'DQTY'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-no_zero = 'X'.
      wa_fieldcat-seltext_l = 'CR.QTY'.
      wa_fieldcat-fieldname = 'CQTY'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'QC STATUS'.
      wa_fieldcat-fieldname = 'QCSTAT'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat to it_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'A/C STATUS'.
      wa_fieldcat-fieldname = 'ACSTAT'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat to it_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-col_pos = wa_col + 1.
      wa_fieldcat-seltext_l = 'CR NOTE STATUS'.
      wa_fieldcat-fieldname = 'CRNOTE'.
      wa_fieldcat-tabname = itab.
      APPEND wa_fieldcat to it_fieldcat.
      clear wa_fieldcat.
    ENDFORM.                    "F_FIELDCAT
    *&      Form  DISPLAY
          text
    FORM display.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          is_layout          = wa_layout
          I_CALLBACK_USER_COMMAND  = 'HANDLE_USER_COMMAND'
          it_fieldcat        = it_fieldcat
        TABLES
          t_outtab           = itab.
    ENDFORM.                    "DISPLAY
    FORM HANDLE_USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                 RS_SELFIELD TYPE SLIS_SELFIELD.
       CASE R_UCOMM.
        WHEN '&IC1'.
        clear itab-ebeln.
          IF RS_SELFIELD-FIELDNAME = 'EBELN'.
            READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
            SET PARAMETER ID 'BES' FIELD ITAB-EBELN.
            call transaction 'ME23N' AND SKIP FIRST SCREEN.
            CLEAR RS_SELFIELD.
          ELSEIF RS_SELFIELD-FIELDNAME = 'MBLNR'.
            READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
            SET PARAMETER ID 'MBN' FIELD ITAB-MBLNR.
            SET PARAMETER ID 'MJA' FIELD year.
            call transaction 'MIGO' AND SKIP FIRST SCREEN.
            CLEAR RS_SELFIELD.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "HANDLE_USER_COMMAND

    Ways of Performance Tuning
    1.     Selection Criteria
    2.     Select Statements
    •     Select Queries
    •     SQL Interface
    •     Aggregate Functions
    •     For all Entries
    Select Over more than one internal table
    Selection Criteria
    1.     Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement. 
    2.     Select with selection list.
    SELECT * FROM SBOOK INTO SBOOK_WA.
      CHECK: SBOOK_WA-CARRID = 'LH' AND
             SBOOK_WA-CONNID = '0400'.
    ENDSELECT.
    The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list
    SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
      WHERE SBOOK_WA-CARRID = 'LH' AND
                  SBOOK_WA-CONNID = '0400'.
    Select Statements   Select Queries
    1.     Avoid nested selects
    SELECT * FROM EKKO INTO EKKO_WA.
      SELECT * FROM EKAN INTO EKAN_WA
          WHERE EBELN = EKKO_WA-EBELN.
      ENDSELECT.
    ENDSELECT.
    The above code can be much more optimized by the code written below.
    SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
        FROM EKKO AS P INNER JOIN EKAN AS F
          ON PEBELN = FEBELN.
    Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.
    2.     Select all the records in a single shot using into table clause of select statement rather than to use Append statements.
    SELECT * FROM SBOOK INTO SBOOK_WA.
      CHECK: SBOOK_WA-CARRID = 'LH' AND
             SBOOK_WA-CONNID = '0400'.
    ENDSELECT.
    The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table
    SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
      WHERE SBOOK_WA-CARRID = 'LH' AND
                  SBOOK_WA-CONNID = '0400'.
    3.     When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
    To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
    4.     For testing existence, use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit. 
    SELECT * FROM SBOOK INTO SBOOK_WA
      UP TO 1 ROWS
      WHERE CARRID = 'LH'.
    ENDSELECT.
    The above code is more optimized as compared to the code mentioned below for testing existence of a record.
    SELECT * FROM SBOOK INTO SBOOK_WA
        WHERE CARRID = 'LH'.
      EXIT.
    ENDSELECT.
    5.     Use Select Single if all primary key fields are supplied in the Where condition .
    If all primary key fields are supplied in the Where conditions you can even use Select Single.
    Select Single requires one communication with the database system, whereas Select-Endselect needs two.
    Select Statements SQL Interface
    1.     Use column updates instead of single-row updates
    to update your database tables.
    SELECT * FROM SFLIGHT INTO SFLIGHT_WA.
      SFLIGHT_WA-SEATSOCC =
        SFLIGHT_WA-SEATSOCC - 1.
      UPDATE SFLIGHT FROM SFLIGHT_WA.
    ENDSELECT.
    The above mentioned code can be more optimized by using the following code
    UPDATE SFLIGHT
           SET SEATSOCC = SEATSOCC - 1.
    2.     For all frequently used Select statements, try to use an index.
    SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
      WHERE CARRID = 'LH'
        AND CONNID = '0400'.
    ENDSELECT.
    The above mentioned code can be more optimized by using the following code
    SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
      WHERE MANDT IN ( SELECT MANDT FROM T000 )
        AND CARRID = 'LH'
        AND CONNID = '0400'.
    ENDSELECT.
    3.     Using buffered tables improves the performance considerably.
    Bypassing the buffer increases the network considerably
    SELECT SINGLE * FROM T100 INTO T100_WA
      BYPASSING BUFFER
      WHERE     SPRSL = 'D'
            AND ARBGB = '00'
            AND MSGNR = '999'.
    The above mentioned code can be more optimized by using the following code
    SELECT SINGLE * FROM T100  INTO T100_WA
      WHERE     SPRSL = 'D'
            AND ARBGB = '00'
            AND MSGNR = '999'.
    Select Statements  Aggregate Functions
    •     If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.
    Some of the Aggregate functions allowed in SAP are  MAX, MIN, AVG, SUM, COUNT, COUNT( * )
    Consider the following extract.
                Maxno = 0.
                Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
                 Check zflight-fligh > maxno.
                 Maxno = zflight-fligh.
                Endselect.
    The  above mentioned code can be much more optimized by using the following code.
    Select max( fligh ) from zflight into maxno where airln = ‘LF’ and cntry = ‘IN’.
    Select Statements  For All Entries
    •     The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
         The plus
    •     Large amount of data
    •     Mixing processing and reading of data
    •     Fast internal reprocessing of data
    •     Fast
         The Minus
    •     Difficult to program/understand
    •     Memory could be critical (use FREE or PACKAGE size)
    Points to be must considered FOR ALL ENTRIES
    •     Check that data is present in the driver table
    •     Sorting the driver table
    •     Removing duplicates from the driver table
    Consider the following piece of extract
              Loop at int_cntry.
      Select single * from zfligh into int_fligh
      where cntry = int_cntry-cntry.
      Append int_fligh.
                          Endloop.
    The above mentioned can be more optimized by using the following code.
    Sort int_cntry by cntry.
    Delete adjacent duplicates from int_cntry.
    If NOT int_cntry[] is INITIAL.
                Select * from zfligh appending table int_fligh
                For all entries in int_cntry
                Where cntry = int_cntry-cntry.
    Endif.
    Select Statements Select Over more than one Internal table
    1.     Its better to use a views instead of nested Select statements.
    SELECT * FROM DD01L INTO DD01L_WA
      WHERE DOMNAME LIKE 'CHAR%'
            AND AS4LOCAL = 'A'.
      SELECT SINGLE * FROM DD01T INTO DD01T_WA
        WHERE   DOMNAME    = DD01L_WA-DOMNAME
            AND AS4LOCAL   = 'A'
            AND AS4VERS    = DD01L_WA-AS4VERS
            AND DDLANGUAGE = SY-LANGU.
    ENDSELECT.
    The above code can be more optimized by extracting all the data from view DD01V_WA
    SELECT * FROM DD01V INTO  DD01V_WA
      WHERE DOMNAME LIKE 'CHAR%'
            AND DDLANGUAGE = SY-LANGU.
    ENDSELECT
    2.     To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.
    SELECT * FROM EKKO INTO EKKO_WA.
      SELECT * FROM EKAN INTO EKAN_WA
          WHERE EBELN = EKKO_WA-EBELN.
      ENDSELECT.
    ENDSELECT.
    The above code can be much more optimized by the code written below.
    SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
        FROM EKKO AS P INNER JOIN EKAN AS F
          ON PEBELN = FEBELN.
    3.     Instead of using nested Select loops it is often better to use subqueries.
    SELECT * FROM SPFLI
      INTO TABLE T_SPFLI
      WHERE CITYFROM = 'FRANKFURT'
        AND CITYTO = 'NEW YORK'.
    SELECT * FROM SFLIGHT AS F
        INTO SFLIGHT_WA
        FOR ALL ENTRIES IN T_SPFLI
        WHERE SEATSOCC < F~SEATSMAX
          AND CARRID = T_SPFLI-CARRID
          AND CONNID = T_SPFLI-CONNID
          AND FLDATE BETWEEN '19990101' AND '19990331'.
    ENDSELECT.
    The above mentioned code can be even more optimized by using subqueries instead of for all entries.
    SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA
        WHERE SEATSOCC < F~SEATSMAX
          AND EXISTS ( SELECT * FROM SPFLI
                         WHERE CARRID = F~CARRID
                           AND CONNID = F~CONNID
                           AND CITYFROM = 'FRANKFURT'
                           AND CITYTO = 'NEW YORK' )
          AND FLDATE BETWEEN '19990101' AND '19990331'.
    ENDSELECT.
    1.     Table operations should be done using explicit work areas rather than via header lines.
    READ TABLE ITAB INTO WA WITH KEY K = 'X‘ BINARY SEARCH.
    IS MUCH FASTER THAN USING
    READ TABLE ITAB INTO WA WITH KEY K = 'X'.
    If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).
    2.     Always try to use binary search instead of linear search. But don’t forget to sort your internal table before that.
    READ TABLE ITAB INTO WA WITH KEY K = 'X'. IS FASTER THAN USING
    READ TABLE ITAB INTO WA WITH KEY (NAME) = 'X'.
    3.     A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime.
    4.     A binary search using secondary index takes considerably less time.
    5.     LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally.
    LOOP AT ITAB INTO WA WHERE K = 'X'.
    ENDLOOP.
    The above code is much faster than using
    LOOP AT ITAB INTO WA.
      CHECK WA-K = 'X'.
    ENDLOOP.
    6.     Modifying selected components using “ MODIFY itab …TRANSPORTING f1 f2.. “ accelerates the task of updating  a line of an internal table.
    WA-DATE = SY-DATUM.
    MODIFY ITAB FROM WA INDEX 1 TRANSPORTING DATE.
    The above code is more optimized as compared to
    WA-DATE = SY-DATUM.
    MODIFY ITAB FROM WA INDEX 1.
    7.     Accessing the table entries directly in a "LOOP ... ASSIGNING ..." accelerates the task of updating a set of lines of an internal table considerably
    Modifying selected components only makes the program faster as compared to Modifying all lines completely.
    e.g,
    LOOP AT ITAB ASSIGNING <WA>.
      I = SY-TABIX MOD 2.
      IF I = 0.
        <WA>-FLAG = 'X'.
      ENDIF.
    ENDLOOP.
    The above code works faster as compared to
    LOOP AT ITAB INTO WA.
      I = SY-TABIX MOD 2.
      IF I = 0.
        WA-FLAG = 'X'.
        MODIFY ITAB FROM WA.
      ENDIF.
    ENDLOOP.
    8.    If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.
    LOOP AT ITAB1 INTO WA1.
      READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.
      IF SY-SUBRC = 0.
        ADD: WA1-VAL1 TO WA2-VAL1,
             WA1-VAL2 TO WA2-VAL2.
        MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.
      ELSE.
        INSERT WA1 INTO ITAB2 INDEX SY-TABIX.
      ENDIF.
    ENDLOOP.
    The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by
    LOOP AT ITAB1 INTO WA.
      COLLECT WA INTO ITAB2.
    ENDLOOP.
    SORT ITAB2 BY K.
    COLLECT, however, uses a hash algorithm and is therefore independent
    of the number of entries (i.e. O(1)) .
    9.    "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to “ LOOP-APPEND-ENDLOOP.”
    APPEND LINES OF ITAB1 TO ITAB2.
    This is more optimized as compared to
    LOOP AT ITAB1 INTO WA.
      APPEND WA TO ITAB2.
    ENDLOOP.
    10.   “DELETE ADJACENT DUPLICATES“ accelerates the task of deleting duplicate entries considerably as compared to “ READ-LOOP-DELETE-ENDLOOP”.
    DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.
    This is much more optimized as compared to
    READ TABLE ITAB INDEX 1 INTO PREV_LINE.
    LOOP AT ITAB FROM 2 INTO WA.
      IF WA = PREV_LINE.
        DELETE ITAB.
      ELSE.
        PREV_LINE = WA.
      ENDIF.
    ENDLOOP.
    11.   "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to “  DO -DELETE-ENDDO”.
    DELETE ITAB FROM 450 TO 550.
    This is much more optimized as compared to
    DO 101 TIMES.
      DELETE ITAB INDEX 450.
    ENDDO.
    12.   Copying internal tables by using “ITAB2[ ] = ITAB1[ ]” as compared to “LOOP-APPEND-ENDLOOP”.
    ITAB2[] = ITAB1[].
    This is much more optimized as compared to
    REFRESH ITAB2.
    LOOP AT ITAB1 INTO WA.
      APPEND WA TO ITAB2.
    ENDLOOP.
    13.   Specify the sort key as restrictively as possible to run the program faster.
    “SORT ITAB BY K.” makes the program runs faster as compared to “SORT ITAB.”
    Internal Tables         contd…
    Hashed and Sorted tables
    1.     For single read access hashed tables are more optimized as compared to sorted tables.
    2.      For partial sequential access sorted tables are more optimized as compared to hashed tables
    Hashed And Sorted Tables
    Point # 1
    Consider the following example where HTAB is a hashed table and STAB is a sorted table
    DO 250 TIMES.
      N = 4 * SY-INDEX.
      READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
      IF SY-SUBRC = 0.
      ENDIF.
    ENDDO.
    This runs faster for single read access as compared to the following same code for sorted table
    DO 250 TIMES.
      N = 4 * SY-INDEX.
      READ TABLE STAB INTO WA WITH TABLE KEY K = N.
      IF SY-SUBRC = 0.
      ENDIF.
    ENDDO.
    Point # 2
    Similarly for Partial Sequential access the STAB runs faster as compared to HTAB
    LOOP AT STAB INTO WA WHERE K = SUBKEY.
    ENDLOOP.
    This runs faster as compared to
    LOOP AT HTAB INTO WA WHERE K = SUBKEY.
    ENDLOOP.

  • U0095     Vendor performance report this report gives performance of supplier to se

    Vendor performance report this report gives performance of supplier to send an order to customer

    Kiran,
    The functionality you are asking sounds like standard functionality. Doesn't make sense to custom develop the same.
    Make sure you search and confirm that standard reports are NOT available for the same.
    Regards,
    Ravi
    Note : please mark the helpful answers

  • Report running for long time & performance tuning

    Hi All,
    (1). WebI report is running for long time.so what are the steps i need to check for it ?
    (2). Can you tell me about performance tuning in BO ?
    please help me.....
    Thanks
    Kumar

    (1). WebI report is running for long time.so what are the steps i need to check for it ?
    The first step is to see if the problem lies in the query on the data source or in webi itself. Depending on the data source there are different ways to extract the query and try to run it against the database. Which source does your report uses?
    (2). Can you tell me about performance tuning in BO ?
    I would recommend to start by reading the administrator's guide. There is a section about how to improve performance.
    Regards,
    Stratos

Maybe you are looking for

  • Sharepoint Designer 2010 and Visio 2013

    I am testing out Visio Professional 2013. I can import a VWI file from Sharepoint Designer 2010 and I can export a VWI file from Visio. But when I try to import the VWI file created in Visio 2013 into sharpoint Designer 2010 it appears to work, as I

  • CC 2014 2.2 on Mac unstable and constantly giving program error message

    This is the least stable version of PS I've ever used on a Mac. It feels like Painter ten years ago. With files over a certain size - it seems like over a medium numbers of layers - I constantly get the stupid error where it can't save the file "beca

  • EBXML IN SAP XI

    Hello Forum,            Can anyone guide me about the use of EBXML, in sap xi, how they are handled and whats the scope of it. Can we handle it at the adapter level, i have seen a pdf on 3rd party adapter. Any other Guides or have anyone worked with

  • Delta in BW after R/3 archiving

    Hello, following question: Currently we are thinking about R/3 archiving (with archiving objects). R/3 and BW are connected. In R/3 we want to archive e.g. year 2000 and 2001. In BW are all line items from 2000 - today. What will happen after a R/3 a

  • Contacting Adobe Directly for Support Questions

    Does anyone have an email address for direct Adobe Lightroom Support? The web site seems designed to prevent such contact at all costs.