Please help me how to improve the performance of this query further.

Hi All,
Please help me how to improve the performance of this query further.
Thanks.

Hi,
this is not your first SQL tuning request in this community -- you really should learn how to obtain performance diagnostics.
The information you posted is not nearly enough to even start troubleshooting the query -- you haven't specified elapsed time, I/O, or the actual number of rows the query returns.
The only piece of information we have is saying that your query executes within a second. If we believe this, then your query doesn't need tuning. If we don't, then we throw it away
and we're left with nothing.
Start by reading this blog post: Kyle Hailey » Power of DISPLAY_CURSOR
and applying this knowledge to your case.
Best regards,
  Nikolay

Similar Messages

  • HI All, How to improve the performance in given query?

    HI All,
    How to improve the performance in given query?
    Query is..
    PARAMETERS : p_vbeln type lips-vbeln.
    DATA : par_charg TYPE LIPS-CHARG,
    par_werks TYPE LIPS-WERKS,
    PAR_MBLNR TYPE MSEG-MBLNR .
    SELECT SINGLE charg
    werks
    INTO (par_charg, par_werks)
    FROM lips
    WHERE vbeln = p_vbeln.
    IF par_charg IS NOT INITIAL.
    SELECT single max( mblnr )
    INTO par_mblnr
    FROM mseg
    WHERE bwart EQ '101'
    AND werks EQ par_werks (index on werks only)
    AND charg EQ par_charg.
    ENDIF.
    Regards
    Steve

    Hi steve,
    Can't you use the material in your query (and not only the batch)?
    I am assuming your system has an index MSEG~M by MANDT + MATNR + WERKS (+ other fields). Depending on your system (how many different materials you have), this will probably speed up the query considerably.
    Anyway, in our system we ended up by creating an index by CHARG, but leave as a last option, only if selecting by matnr and werks is not good enough for your scenario.
    Hope this helps,
    Rui Dantas

  • How to improve the performance of this code

    Hi gurus
    code is given below with LDB
    this code look big but most of lines are commented
    plz help its urgent
    thanks in advance
    *& Report  ZSALES_RECON
    REPORT  ZSALES_RECON.
    TYPE-POOLS : SLIS.
    nodes: bseg , bkpf.
    data : begin of zbseg occurs 0,
    kunnr like bseg-kunnr,
    *lifnr like bseg-lifnr,
    dmbtr like bseg-dmbtr,
    *shkzg like bseg-shkzg,
    *gsber like bseg-gsber,
    bschl like bseg-bschl,
    *sgtxt like bseg-sgtxt,
    total like bseg-dmbtr,
    hkont like bseg-hkont,
    BUDAT LIKE Bkpf-BUDAT,
    belnr LIKE BSEG-belnr,
    cash like bseg-dmbtr,
    credit like bseg-dmbtr,
    abn_voucher like bseg-dmbtr,
    barista_voucher like bseg-dmbtr,
    accor like bseg-dmbtr,
    sodexho like bseg-dmbtr,
    gift like bseg-dmbtr,
    corp like bseg-dmbtr,
    card like bseg-dmbtr,
    miscellaneous like bseg-dmbtr,
    werks like bseg-werks,
    gjahr like bseg-gjahr,
    SR_NO TYPE I,
    shkzg like bseg-shkzg,
          end of zbseg,
          TP_TBL_DATA like ZBSEG.
        DATA  : idx TYPE sy-tabix.
    Report data to be shown.
    data: it_data like ZBSEG.
    Heading of the report.
    data: t_heading type slis_t_listheader.
    AT SELECTION-SCREEN.
    get bkpf.
    START-OF-SELECTION.
    data : sum_mis like bseg-dmbtr,
           sum_abn like bseg-dmbtr,
           sum_cash like bseg-dmbtr,
           sum_credit like bseg-dmbtr,
           sum_card like bseg-dmbtr,
           sum_barista_voucher like bseg-dmbtr,
           sum_accor like bseg-dmbtr,
           sum_sodexho like bseg-dmbtr,
           sum_gift like bseg-dmbtr,
           sum_corp like bseg-dmbtr.
    data : wa1_total like bseg-dmbtr.
    data : wa_belnr like bseg-belnr,
           wa_kunnr like bseg-kunnr,
           wa_werks like bseg-werks,
           belnr1 like bseg-belnr,
           wa_sr_no type i.
    GET BSEG.
    data : wa like line of zbseg.
    data : count type i,
           count1 type i.
    move-corresponding bseg to zbseg.
    *idx = sy-tabix.
    on change of zbseg-belnr.
    wa_kunnr = zbseg-kunnr.
    wa_kunnr = wa_kunnr+6(4).
    select single werks into wa_werks from bseg where belnr = zbseg-belnr
    and kunnr = '' and gjahr = zbseg-gjahr.
    if wa_kunnr = wa_werks.
    if zbseg-bschl <> '01'.
    clear: sum_mis,wa1_total,sum_abn,sum_cash,sum_credit,sum_card,
    sum_barista_voucher,sum_accor,sum_sodexho,sum_gift,sum_corp.
    wa-BUDAT = BKPF-BUDAT.
    wa-bschl = zbseg-bschl.
    wa-hkont = zbseg-hkont.
    wa-belnr = zbseg-belnr.
    wa_belnr = wa-belnr.
    wa-shkzg = zbseg-shkzg.
    wa-kunnr = zbseg-kunnr.
    count = wa-sr_no.
    *wa-sr_no = count + 1.
    idx = idx + 1.
    append wa to zbseg.
    **count = wa-sr_no.
    *wa-sr_no = wa-sr_no + 1.
    clear wa-total.
    endif.
    endif.
    endon.
    *clear : wa1_total.
    if wa_belnr = zbseg-belnr.
    loop at zbseg into wa.
    wa-total = wa1_total.
    wa-bschl = zbseg-bschl.
    wa-hkont = zbseg-hkont.
    count = sy-tabix.
    wa-sr_no = count.
    count1 = count.
    *wa_sr_no = count.
    modify zbseg from wa transporting sr_no.
    IF wa-bschl eq  '40' and wa-hkont eq '0024013020'.
    if sy-tabix = 1.
    wa-cash  = zbseg-dmbtr.
    sum_cash = sum_cash + wa-cash.
    wa-cash = sum_cash.
    modify zbseg index idx from wa transporting cash.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060010'.
       if sy-tabix = 1.
    wa-credit  = zbseg-dmbtr.
    sum_credit = sum_credit + wa-credit.
    wa-credit = sum_credit.
    modify zbseg index idx from wa transporting credit.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060015'.
    if sy-tabix = 1.
    wa-abn_voucher  = zbseg-dmbtr.
    sum_abn = sum_abn + wa-abn_voucher.
    wa-abn_voucher = sum_abn.
    modify zbseg index idx from wa transporting abn_voucher.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060017'.
    if sy-tabix = 1.
    wa-barista_voucher  = zbseg-dmbtr.
    sum_barista_voucher = sum_barista_voucher + wa-barista_voucher.
    wa-barista_voucher = sum_barista_voucher.
    modify zbseg  index idx from wa transporting barista_voucher.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060020'.
    if sy-tabix = 1.
    wa-sodexho  = zbseg-dmbtr.
    sum_sodexho = sum_sodexho + wa-sodexho.
    wa-sodexho = sum_sodexho.
    modify zbseg index idx from wa transporting sodexho.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026060030'.
    if sy-tabix = 1.
    wa-accor  = zbseg-dmbtr.
    sum_accor = sum_accor + wa-accor.
    wa-accor = sum_accor.
    modify zbseg  index idx from wa transporting accor.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026070040'.
    if sy-tabix = 1.
    wa-gift  = zbseg-dmbtr.
    sum_gift = sum_gift + wa-gift.
    wa-gift = sum_gift.
    modify zbseg index idx from wa transporting gift.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026060070'.
    if sy-tabix = 1.
    wa-card  = zbseg-dmbtr.
    sum_card = sum_card + wa-card.
    wa-card = sum_card.
    modify zbseg index idx from wa transporting card.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026060018'.
    if sy-tabix = 1.
    wa-corp  = zbseg-dmbtr.
    sum_corp = sum_corp + wa-corp.
    wa-corp = sum_corp.
    modify zbseg index idx from wa transporting corp.
    endif.
    endif.
    *IF wa-bschl eq  '11' .
    *wa-total  = zbseg-dmbtr.
    *modify zbseg index idx from wa transporting total.
    *endif.
    IF wa-bschl EQ  '40'  or wa-bschl = '01' .
    if sy-tabix = 1.
    wa-total = zbseg-dmbtr.
    wa1_total = wa1_total + wa-total.
    wa-total = wa1_total.
    *if idx = 2.
    *modify zbseg index 1 from wa transporting total.
    *else.
    modify zbseg  index idx from wa transporting total.
    *endif.
    endif.
    endif.
    *IF zbseg-TOTAL NE zbseg-DMBTR.
    IF wa-BSCHL NE '11' AND wa-BSCHL NE '40'. "AND wa-BSCHL NE '01'.
    if sy-tabix = 1.
    if wa-shkzg = 'S'.
    wa-miscellaneous = - wa-miscellaneous.
    endif.
    wa-miscellaneous =  ZBSEG-DMBTR.
    sum_mis = sum_mis + wa-miscellaneous.
    wa-miscellaneous = sum_mis.
    modify zbseg index idx from wa transporting miscellaneous.
    endif.
    ENDIF.
    *wa1-miscellaneous = wa-miscellaneous.
    *modify zbseg index idx from wa.
    *ENDIF.
    *append wa to zbseg.
    *clear:zbseg-dmbtr.
    endloop.
    endif.
    *****endif.
    *****endon.
    *ENDFORM.
    *append zbseg.
    *endloop.
    End-of-selection.
      perform build_alv using zbseg t_heading.
    *&      Form  build_alv
          Builds and display the ALV Grid.
    form build_alv using t_data
    *tp_tbl_data
                         t_heading  type slis_t_listheader.
    ALV required data objects.
    data: w_title   type lvc_title,
          w_repid   type syrepid,
          w_comm    type slis_formname,
          w_status  type slis_formname,
          x_layout  type slis_layout_alv,
          t_event    type slis_t_event,
          t_fieldcat type slis_t_fieldcat_alv,
          t_sort     type slis_t_sortinfo_alv.
    refresh t_fieldcat.
    refresh t_event.
    refresh t_sort.
    clear x_layout.
    clear w_title.
    Field Catalog
      perform set_fieldcat2 using:
    1 'SR_NO' 'SR_NO' 'BKPF' '5' space  space  'SR NO'  space  space space
    space space space space space t_fieldcat ,
    2 'BELNR' 'BELNR' 'BKPF' '10' space  space  'Document No'  space  space
    space space space space space space t_fieldcat ,
    3 'BUDAT' 'BUDAT' 'BKPF' '10' space  space  'Document Date'  space
    space space space space space space space t_fieldcat ,
    4 'KUNNR' space space  space space  space  'Site'  space  space
    space space space space space space t_fieldcat ,
    5 'TOTAL' space 'BSEG' space space  space  'Total'  space  space space
    space space space space 'X' t_fieldcat ,
    6 'CASH' 'CASH' 'BSEG' space space  space  'Cash Sales'
      space  space space space space space space 'X' t_fieldcat ,
    7 'CREDIT' 'CREDIT' 'BSEG' space space  space  'Credit Card'
    space space space space space space space 'X' t_fieldcat ,
    8 'ABN_VOUCHER' space 'BSEG' space space  space  'ABN Voucher'  space
    space
    space space space space space 'X' t_fieldcat ,
    9 'BARISTA_VOUCHER' space 'BSEG' '15' space  space  'BARISTA Voucher'
    space  space
    space space space space space 'X' t_fieldcat ,
    10 'CORP' 'CORP' 'BSEG' space space  space  'ABN Corp'  space  space
    space space space space space 'X' t_fieldcat ,
    11 'SODEXHO' 'SODEXHO' 'BSEG' space space  space  'Sodexho'  space
    space space space space space space 'X' t_fieldcat ,
    12 'ACCOR' 'ACCOR' 'BSEG' space space  space  'Accor'
    space  space space space space space space 'X' t_fieldcat ,
    13 'GIFT' 'GIFT' 'BSEG' space space  space  'Gift Coupon'
    space  space space space space space space 'X' t_fieldcat ,
    14 'CARD' 'CARD' 'BSEG' space space  space  'Diners Card'  space
    space space space space space space 'X' t_fieldcat ,
    15 'MISCELLANEOUS' space 'BKPF' '18' space  space
    'Miscellaneous Income' space space space space space space space 'X'
    t_fieldcat .
    *14 'KBETR' 'KBETR' 'KONP' '10' space  space  'Tax %age'  space  space
    *space space space space space space t_fieldcat ,
    *15 'MWSKZ1' 'MWSKZ1' 'RBKP' space space  space  'Tax Type'  space
    *space
    space space space space space space t_fieldcat ,
    *16 'AMT' 'AMT' 'RBKP' space space  space  'Amount Payable'  space
    *space
    space space space space space 'X' t_fieldcat ,
    *17 'WERKS' 'SITE' 'RSEG' space space  space  'State'  space  space
    *space space space space space space t_fieldcat .
    *18 'GSBER' 'GSBER' 'RBKP' space space  space  'Business Area'  space
    *space space space space space space space t_fieldcat .
    Layout
    x_layout-zebra = 'X'.
    Top of page heading
      perform set_top_page_heading using t_heading t_event.
    Events
      perform set_events using t_event.
    GUI Status
      w_status = ''.
      w_repid = sy-repid.
    Title
    w_title = <<If you want to set a title for
                the ALV, please, uncomment and edit this line>>.
    User commands
      w_comm   = 'USER_COMMAND'.
    Order
    Example
    PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
    Displays the ALV grid
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program       = w_repid
          it_fieldcat              = t_fieldcat
          is_layout                = x_layout
          it_sort                  = t_sort
          i_callback_pf_status_set = w_status
          i_callback_user_command  = w_comm
          i_save                   = 'X'
          it_events                = t_event
          i_grid_title             = w_title
        tables
          t_outtab                 = zbseg
         t_data
        exceptions
          program_error            = 1
          others                   = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " build_alv.
    *&      Form  set_top_page_heading
          Creates the report headings.
    form set_top_page_heading using t_heading type slis_t_listheader
                                    t_events  type slis_t_event.
    data: x_heading type slis_listheader,
          x_event   type line of slis_t_event.
    Report title
      clear t_heading[].
      clear x_heading.
      x_heading-typ = 'H'.
      x_heading-info = 'SALES RECONCILIATION REPORT'(001).
      append x_heading to t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-form = 'TOP_OF_PAGE'.
      append x_event to t_events.
    endform.
    *&      Form  set_events
          Sets the events for ALV.
          The TOP_OF_PAGE event is alredy being registered in
          the set_top_page_heading subroutine.
    form set_events using t_events type slis_t_event.
    data: x_event   type line of slis_t_event.
    Example
    clear x_event.
    x_event-name = .
    x_event-form = .
    append x_event to t_event.
    endform.
    *&      Form  set_order
          Adds an entry to the order table.
    FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
                         t_sort TYPE slis_t_sortinfo_alv.
      DATA: x_sort TYPE slis_sortinfo_alv.
      CLEAR x_sort.
      x_sort-fieldname = p_fieldname.
      x_sort-tabname   = p_tabname.
      x_sort-up = p_up.
      x_sort-down = p_down.
      x_sort-subtot = p_subtot.
      APPEND x_sort TO t_sort.
    ENDFORM.                    "set_order
    *&      Form  set_fieldcat2
          Adds an entry to the field catalog.
       p_colpos: Column position.
       p_fieldname: Field of internal table which is being described by
    *            this record of the field catalog.
       p_ref_fieldname: (Optional) Table field / data element which
    *                describes the properties of the field.
    *                If this field is not given, it is copied from
    *                the fieldname.
       p_ref_tabname: (Optional) Table which holds the field referenced
    *              by <<p_ref_fieldname>>.
                      If this is not given, the parameter
                      <<p_ref_fieldname>> references a data element.
       p_outputlen: (Optional) Column width.
       p_noout: (Optional) If set to 'X', states that the field is not
    *           showed initially. If so, the field has to be
                included in the report at runtime using the display
                options.
       p_seltext_m: (Optional) Medium label to be used as column header.
       p_seltext_l: (Optional) Long label to be used as column header.
       p_seltext_s: (Optional) Small label to be used as column header.
       p_reptext_ddic: (Optional) Extra small (heading) label to be
    *                used as column header.
       p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
                  whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
                  or REPTEXT_DDIC as text for column header.
       p_hotspot: (Optional) If set to 'X', this field will be used
    *             as a hotspot area for cursor, alolowing the user
    *          to click on the field.
       p_showasicon: (Optional) If set to 'X', this field will be shown
                     as an icon and the contents of the field will set
    *             which icon to show.
       p_checkbox: (Optional) If set to 'X', this field will be shown
                   as a checkbox.
       p_edit: (Optional) If set to 'X', this field will be editable.
       p_dosum: (Optional) If set to 'X', this field will be summed
                (aggregation function) according to the grouping set
                by the order functions.
       t_fieldcat: Table which contains the whole fieldcat.
    FORM set_fieldcat2 USING
          p_colpos p_fieldname p_ref_fieldname p_ref_tabname
          p_outputlen p_noout
          p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
          p_hotspot p_showasicon p_checkbox p_edit
          p_dosum
          t_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
      wa_fieldcat-no_out = p_noout.
      wa_fieldcat-hotspot = p_hotspot.
      wa_fieldcat-checkbox = p_checkbox.
      wa_fieldcat-icon = p_showasicon.
      wa_fieldcat-do_sum = p_dosum.
    Set reference fieldname, tablenam and rollname.
    If p_ref_tabname is not given, the ref_fieldname given
       is a data element.
    If p_ref_tabname is given, the ref_fieldname given is a
       field of a table.
    In case ref_fieldname is not given,
       it is copied from the fieldname.
      IF p_ref_tabname IS INITIAL.
        wa_fieldcat-rollname =   p_ref_fieldname.
      ELSE.
        wa_fieldcat-ref_tabname = p_ref_tabname.
        IF p_ref_fieldname EQ space.
          wa_fieldcat-ref_fieldname =   wa_fieldcat-fieldname.
        ELSE.
          wa_fieldcat-ref_fieldname =   p_ref_fieldname.
        ENDIF.
      ENDIF.
    Set output length.
      IF NOT p_outputlen IS INITIAL.
        wa_fieldcat-outputlen = p_outputlen.
      ENDIF.
    Set text headers.
      IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
      ENDIF.
      IF NOT p_seltext_l IS INITIAL.
        wa_fieldcat-seltext_l = p_seltext_l.
      ENDIF.
      IF NOT p_seltext_s IS INITIAL.
        wa_fieldcat-seltext_s = p_seltext_s.
      ENDIF.
      IF NOT p_reptext_ddic IS INITIAL.
        wa_fieldcat-reptext_ddic = p_reptext_ddic.
      ENDIF.
      IF NOT p_ddictxt IS INITIAL.
        wa_fieldcat-ddictxt = p_ddictxt.
      ENDIF.
    Set as editable or not.
      IF NOT p_edit IS INITIAL.
        wa_fieldcat-input     = 'X'.
        wa_fieldcat-edit     = 'X'.
      ENDIF.
      APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                   "set_fieldcat2
    ======================== Subroutines called by ALV ================
    *&      Form  top_of_page
          Called on top_of_page ALV event.
          Prints the heading.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
        i_logo             = <<If you want to set a logo, please,
                             uncomment and edit this line>>
          it_list_commentary = t_heading.
    endform.                    " alv_top_of_page
    *&      Form  user_command
          Called on user_command ALV event.
          Executes custom commands.
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
    Example Code
    Executes a command considering the sy-ucomm.
    CASE r_ucomm.
       WHEN '&IC1'.
         Set your "double click action" response here.
         Example code: Create and display a status message.
         DATA: w_msg TYPE string,
               w_row(4) TYPE n.
         w_row = rs_selfield-tabindex.
         CONCATENATE 'You have clicked row' w_row
                     'field' rs_selfield-fieldname
                     'with value' rs_selfield-value
                     INTO w_msg SEPARATED BY space.
         MESSAGE w_msg TYPE 'S'.
    ENDCASE.
    End of example code.
    endform.                    "user_command
    *********************************ldb code start from here *************************************************************
         DATABASE PROGRAM OF LOGICAL DATABASE ZBRM_3
      top-include and nxxx-include are generated automatically
      Do NOT change their names manually!!!
    *include DBZBRM_3TOP . " header
    *include DBZBRM_3NXXX . " all system routines
    include DBZBRM_3F001 . " user defined include
    PROGRAM SAPDBZBRM_3 DEFINING DATABASE ZBRM_3.
    TABLES:
        BKPF,
        BSEG.
    Hilfsfelder
    DATA:
       BR_SBUKRS LIKE BKPF-BUKRS,
        BR_SBELNR LIKE BKPF-BELNR,
        BR_SGJAHR LIKE BKPF-GJAHR,
        BR_SBUDAT LIKE BKPF-BUDAT,
        BR_SGSBER LIKE BSEG-GSBER.
       BR_SBUZEI LIKE BSEG-BUZEI,
       BR_SEBELN LIKE BSEG-EBELN,
       BR_SEBELP LIKE BSEG-EBELP,
       BR_SZEKKN LIKE BSEG-ZEKKN.
    working areas for the authority check                     "n435991
    for the company code                                      "n435991
    *TYPES : BEGIN OF STYPE_BUKRS,                               "n435991
             BUKRS              LIKE  T001-BUKRS,              "n435991
             WAERS              LIKE  T001-WAERS,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_BUKRS.                                 "n435991
                                                               "n435991
    *DATA : G_S_BUKRS             TYPE  STYPE_BUKRS,             "n435991
          G_T_BUKRS             TYPE  STYPE_BUKRS   OCCURS 0.  "n435991
                                                               "n435991
    for the document type                                     "n435991
    *TYPES : BEGIN OF STYPE_BLART,                               "n435991
             BLART              LIKE  BKPF-BLART,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_BLART.                                 "n435991
                                                               "n435991
    *DATA : G_S_BLART             TYPE  STYPE_BLART,             "n435991
          G_T_BLART             TYPE  STYPE_BLART   OCCURS 0.  "n435991
                                                               "n435991
    for the business area                                     "n435991
    *TYPES : BEGIN OF STYPE_GSBER,                               "n435991
             GSBER              LIKE  BSEG-GSBER,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_GSBER.                                 "n435991
                                                               "n435991
    *DATA : G_S_GSBER             TYPE  STYPE_GSBER,             "n435991
          G_T_GSBER             TYPE  STYPE_GSBER   OCCURS 0.  "n435991
                                                               "n435991
    for the purchasing organization                           "n435991
    *TYPES : BEGIN OF STYPE_EKORG,                               "n435991
             EKORG              LIKE  EKKO-EKORG,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_EKORG.                                 "n435991
                                                               "n435991
    *DATA : G_S_EKORG             TYPE  STYPE_EKORG,             "n435991
          G_T_EKORG             TYPE  STYPE_EKORG   OCCURS 0.  "n435991
                                                               "n435991
    for the plant                                             "n435991
    *TYPES : BEGIN OF STYPE_WERKS,                               "n435991
             WERKS              LIKE  EKPO-WERKS,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_WERKS.                                 "n435991
                                                               "n435991
    *DATA : G_S_WERKS             TYPE  STYPE_WERKS,             "n435991
          G_T_WERKS             TYPE  STYPE_WERKS   OCCURS 0.  "n435991
                                                               "n435991
    *DATA : G_F_TABIX             LIKE   SY-TABIX.               "n435991
                                                               "n435991
    working tables for array database access                  "n934526
    *types : begin of stype_key,                                 "n934526
             bukrs              type  bkpf-bukrs,              "n934526
             belnr              type  bkpf-belnr,              "n934526
             gjahr              type  bkpf-gjahr,              "n934526
           end of stype_key,                                   "n934526
                                                               "n934526
           stab_key             type  standard table of        "n934526
                                      stype_key                "n934526
                                      with default key.        "n934526
    Initialwerte setzen
    FORM INIT.
    ENDFORM.
    Selection Screen: Process before output
    FORM PBO.
    ENDFORM.
    Selection Screen: Process after input
    FORM PAI USING FNAME MARK.
      CHECK MARK = SPACE.
    ENDFORM.
    Lesen BKPF und Uebergabe an den Selektionsreport
    FORM PUT_BKPF.
    define locla working areas                                "n934526
    data : l_t_key             type  stab_key,                "n934526
            l_t_key_block       type  stab_key,                "n934526
            l_t_bkpf            type  standard table of bkpf.  "n934526
                                                               "n934526
    ----------------------------------------------------------"n934526
                                                                "n934526
    database seletion improved                                "n934526
    at first read all FI doc keys into a lean table           "n934526
    data: wa like bkpf-belnr.
      SELECT * FROM BKPF
    where budat in br_budat
          AND GJAHR EQ BR_GJAHR-LOW
          AND BLART = 'RV'.
         AND BLART IN BR_BLAR                               "n934526
                                                                "n934526
    check sy-subrc is initial.                                "n934526
                                                               "n934526
    then process the found FI doc keys in small blocks        "n934526
    do.                                                       "n934526
       if  l_t_key[] is initial.                               "n934526
         exit.        " no more keys -> leave this DO loop     "n934526
       endif.                                                  "n934526
                                                               "n934526
      form small blocks with 100 FI docs each                 "n934526
       refresh                  l_t_key_block.                 "n934526
       append lines of l_t_key  from 1 to 100                  "n934526
                                to  l_t_key_block.             "n934526
       delete l_t_key           from 1 to 100.                 "n934526
                                                               "n934526
      read the complete FI doc headers for the block          "n934526
       SELECT *                 FROM BKPF                      "n934526
         into  corresponding fields of table l_t_bkpf          "n934526
           for all entries in l_t_key_block                    "n934526
             WHERE BUKRS = l_t_key_block-BUKRS                 "n934526
               AND BELNR = l_t_key_block-BELNR                 "n934526
               AND GJAHR = l_t_key_block-GJAHR.                "n934526
                                                               "n934526
      provide the complete structure for the PUT              "n934526
       loop at l_t_bkpf         into  bkpf.                    "n934526
        process this company code  : authority and read T001  "n934526
         PERFORM                F1000_COMPANY_CODE.            "n934526
                                                               "n934526
        go on if the first authority check was successful     "n934526
         CHECK : G_S_BUKRS-RETCODE IS INITIAL.                 "n934526
                                                               "n934526
        set the currency key and save the keys                "n934526
         MOVE : G_S_BUKRS-WAERS TO  T001-WAERS,                "n934526
                BKPF-BUKRS      TO  BR_SBUKRS,                 "n934526
               MOVE  BKPF-BELNR       TO  BR_SBELNR.
               MOVE  BKPF-GJAHR      TO  BR_SGJAHR .               "n934526
                BKPF-GJAHR      TO  BR_SGJAHR.                 "n934526
          PUT                    BKPF.                          "n934526
       endloop.                                                "n934526
    enddo.                                                    "n934526
    ENDSELECT.
    ENDFORM.
    Lesen BSEG und Uebergabe an den Selektionsreport
    FORM PUT_BSEG.
    define local working areas                                "n934526
      data : l_t_bseg            type  standard table of bseg.  "n934526
                                                                "n934526
    ----------------------------------------------------------"n934526
    BR_SGSBER = BR_GSBER-LOW.
                                                                "n934526
      SELECT * FROM BSEG                                        "n934526
          WHERE  BELNR EQ BR_SBELNR
          AND GJAHR EQ BR_SGJAHR
          AND GSBER EQ BR_SGSBER.
    check sy-subrc is initial.                                "n934526
                                                                "n934526
    loop at l_t_bseg           into  bseg.                    "n934526
       MOVE BSEG-BUZEI TO BR_SBUZEI.
       MOVE BSEG-EBELN TO BR_SEBELN.
       MOVE BSEG-EBELP TO BR_SEBELP.
       MOVE BSEG-ZEKKN TO BR_SZEKKN.
        PUT BSEG.
      endSELECT.                                                  "n934526
    ENDFORM.
    "n435991
          FORM AUTHORITYCHECK_BKPF                            "n435991
    "n435991
                                                                "n435991
    *FORM AUTHORITYCHECK_BKPF.                                   "n435991
                                                                "n435991
    the authority-check for the company code was successful;  "n435991
    check authority for the document type here                "n435991
                                                                "n435991
    does the buffer contain this document type ?              "n435991
    READ  TABLE  G_T_BLART     INTO  G_S_BLART                "n435991
            WITH  KEY  BLART = BKPF-BLART  BINARY SEARCH.      "n435991
                                                               "n435991
    CASE  SY-SUBRC.                                           "n435991
       WHEN  0.       "document type is known                  "n435991
                                                               "n435991
       WHEN  4.       "docment type is new --> insert          "n435991
         MOVE  SY-TABIX         TO  G_F_TABIX.                 "n435991
         PERFORM                F1200_CREATE_BLART_ENTRY.      "n435991
         INSERT  G_S_BLART      INTO  G_T_BLART                "n435991
                                INDEX  G_F_TABIX.              "n435991
                                                               "n435991
       WHEN  8.       "document type is new --> append         "n435991
         PERFORM                F1200_CREATE_BLART_ENTRY.      "n435991
         APPEND  G_S_BLART      TO  G_T_BLART.                 "n435991
    ENDCASE.                                                  "n435991
                                                               "n435991
    set the return code                                       "n435991
    MOVE  G_S_BLART-RETCODE    TO  SY-SUBRC.                  "n435991
                                                               "n435991
    *ENDFORM.                     "authoritycheck_bkpf           "n435991
                                                               "n435991
    "n435991
          FORM AUTHORITYCHECK_BSEG                            "n435991
    "n435991
                                                                "n435991
    *FORM AUTHORITYCHECK_BSEG.                                   "n435991
                                                               "n435991
    does the buffer contain this document type ?              "n435991
    READ  TABLE  G_T_GSBER     INTO  G_S_GSBER                "n435991
            WITH  KEY  GSBER = BSEG-GSBER  BINARY SEARCH.      "n435991
                                                               "n435991
    CASE  SY-SUBRC.                                           "n435991
       WHEN  0.       "business area is known                  "n435991
                                                               "n435991
       WHEN  4.       "business area is new --> insert         "n435991
         MOVE  SY-TABIX         TO  G_F_TABIX.                 "n435991
         PERFORM                F1300_CREATE_GSBER_ENTRY.      "n435991
         INSERT  G_S_GSBER      INTO  G_T_GSBER                "n435991
                                INDEX  G_F_TABIX.              "n435991
                                                               "n435991
       WHEN  8.       "business area is new --> append         "n435991
         PERFORM                F1300_CREATE_GSBER_ENTRY.      "n435991
         APPEND  G_S_GSBER      TO  G_T_GSBER.                 "n435991
    ENDCASE.                                                  "n435991
                                                               "n435991
    set the return code                                       "n435991
    MOVE  G_S_GSBER-RETCODE    TO  SY-SUBRC.                  "n435991
                                                               "n435991
    *ENDFORM.                     "authoritycheck_bseg           "n435991
                                                               "n435991

    ABAP provides few tools to analyse the perfomance of the objects, which was developed by us.
    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
    by using this tool we can analyse the perfomance issues related to DATABASE calls.
    Perfomance Techniques for improve the perfomance of the object.
    1) ABAP/4 programs can take a very long time to execute, and can make other processes have to wait before executing. Here are some tips to speed up your programs and reduce the load your programs put on the system:
    2) Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that optimization technique REALLY helps unless you test it out.
    3) Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
    4) Generally, try to reduce I/O first, then memory, then CPU activity. I/O operations that read/write to hard disk are always the most expensive operations. Memory, if not controlled, may have to be written to swap space on the hard disk, which therefore increases your I/O read/writes to disk. CPU activity can be reduced by careful program design, and by using commands such as SUM (SQL) and COLLECT (ABAP/4).
    5) Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
    6) Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space.
    Use as many table keys as possible in the WHERE part of your select statements.
    7)Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
    8) Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
    9) Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
    10) Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
    11) Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access.
    12) If the number of records you are reading is constantly growing, you may be able to break it into chunks of relatively constant size. For instance, if you have to read all records from 1991 to present, you can break it into quarters, and read all records one quarter at a time. This will reduce I/O operations. Test extensively with GET RUN TIME when using this method.
    13) Know how to use the 'collect' command. It can be very efficient.
    14) Use the SELECT SINGLE command whenever possible.
    15) Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
    Some tips:
    1) Use joins where possible as redundant data is not fetched.
    2) Use select single where ever possible.
    3) Calling methods of a global class is faster than calling function modules.
    4) Use constants instead of literals
    5) Use WHILE instead of a DO-EXIT-ENDDO.
    6) Unnecessary MOVEs should be avoided by using the explicit work area operations
    see the follwing links for a brief insifght into performance tuning,
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
    1. Debuggerhttp://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    2. Run Time Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
    3. SQL trace
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
    4. CATT - Computer Aided Testing Too
    http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
    5. Test Workbench
    http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
    6. Coverage Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
    7. Runtime Monitor
    http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
    8. Memory Inspector
    http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
    9. ECATT - Extended Computer Aided testing tool.
    http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
    Performance tuning for Data Selection Statement
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm

  • Improving the performance of this query

    Hi, Do you see any change we could do on this to improve its performance, pls, I appreciate you taking few minutes to help with analysing and tuining it
    select hoc.hoc_id,
    hoc.mstr_key_id,
    address.DISP_NME,
    blck.st_blck_id,
    blck.mstr_key_id as blck_mstr_key,
    bldg.BLDG_ID,
    hoc.BLDG_KEY_ID,
    address.OCPD_IND,
    address.TP_TYPE_CDE,
    '' as cmbcNumber,
    '' as tpSiteNumber,
    case
    when address.cmbc_id is not null then amsowner.ams_038_direct_connect.GetMobilierForCMB(address.cmbc_id)
    when address.lbc_id is not null and address.cmbc_id is null then amsowner.ams_038_direct_connect.GetMobilierForLBC(address.lbc_id)
    END as Mobilier,
    choice.cnsmr_chce_ind,
    hoc.SRT_IND,
    hoc.DLVRY_IND,
    case valRES_STAT_CDE
    when 123444 then hoc.cse_sprtn_wdth
    when 123555 then hoc_pend.cse_sprtn_wdth
    when 123666 then hoc_pend.cse_sprtn_wdth
    end as cse_sprtn_wdth,
    case valRES_STAT_CDE
    when 123444 then hoc.admail_color_id
    when 123555 then hoc.admail_color_id
    when 123666 then hoc_pend.admail_color_id
    end as admail_color_id,
    case valRES_STAT_CDE
    when 123444 then hoc.tieout
    when 123555 then hoc_pend.tieout
    when 123666 then hoc_pend.tieout
    end as tieout,
    hoc.callr_Ind,
    hoc.PCKUP_ind,
    case
    when hldout.hld_out_id > 0 then 33
    else 34
    end as HLDOUT_IND,
    case valRES_STAT_CDE
    when 123444 then hoc.BREAKER_CARD_NUM
    when 123555 then hoc_pend.BREAKER_CARD_NUM
    when 123666 then hoc_pend.BREAKER_CARD_NUM
    end as BREAKER_CARD_IND,
    Case
    when valRES_STAT_CDE = 123444 and hoc.MP_ID is not null and hoc.MP_ID <> 0 then 33
    when valRES_STAT_CDE = 123555 and hoc_pend.MP_ID is not null and hoc_pend.MP_ID <> 0 then 33
    when valRES_STAT_CDE = 123666 and hoc_pend.MP_ID is not null and hoc_pend.MP_ID <> 0 then 33
    else 34 END as MP_IND,
    case
    when valRES_STAT_CDE = 123444 then hoc.LCRMS_SEQ_NUM
    when valRES_STAT_CDE = 123555 then hoc_pend.DEL_SEQ
    when valRES_STAT_CDE = 123666 then hoc_pend.DEL_SEQ
    END as DEL_SEQ,
    case
    when (hoc_type_cde = 154 and hoc.MP_ID is not null ) then (NVL(mp.SLCLRES_RATE , 0)+ NVL(mp.OSSDRES_RATE,0))
    when (hoc_type_cde = 154 and hoc.MP_ID is null ) then (NVL(asmt.SLCLRES_RATE , 0)+ NVL(asmt.OSSDRES_RATE,0))
    when (hoc_type_cde = 156 and hoc.MP_ID is not null )then (NVL(mp.SLCLCOM_RATE,0) + NVL(mp.OSSDCOM_RATE,0))
    when (hoc_type_cde = 156 and hoc.MP_ID is null ) then (NVL(asmt.SLCLCOM_RATE,0) + NVL(asmt.OSSDCOM_RATE,0))
    else 0
    END As AvgMail,
    Case
    when valRES_STAT_CDE = 123444 then hoc.drct_ind
    when valRES_STAT_CDE = 123555 then hoc_pend.drct_ind
    when valRES_STAT_CDE = 123666 then hoc_pend.drct_ind
    END as drct_ind,
    Case
    when pc.ldu_type_cde in (492, 564, 565, 566, 567 ) then 33
    else 34
    end as lvr_ind,
    hoc.A12_CARD_IND,
    hoc.DNC_CARD_IND,
    hoc.CARD_IND,
    hoc.FRCE_CARD_IND,
    hoc.EXTRA_CARD_NBR,
    hoc.TTL_HOC_CNT,
    --(select BSNS_NME_EN from occupant where occupant.ADDR_MAIL_ID = address.addr_id and occupant.prmry_ind = 33 and rownum <= 1 )as PRIMARY_BUS_NME_EN,
    --(select BSNS_NME_FR from occupant where occupant.ADDR_MAIL_ID = address.addr_id and occupant.prmry_ind = 33 and rownum <= 1 )as PRIMARY_BUS_NME_FR,
    blck.blck_seq,
    address.ADDR_NUM,
    address.ADDR_SFX_CDE,
    address.ADDR_STE_NUM,
    hoc.HOC_TYPE_CDE,
    hoc.CSE_SPRTN_GRP_ID,
    pc.pc_id As pc_id,
    pc.disp_nme as pc_disp_nme,
    hoc.bag_ind,
    hoc.CASETAG,
    occupant.BSNS_NME_EN as PRIMARY_BUS_NME_EN , occupant.BSNS_NME_FR as PRIMARY_BUS_NME_FR
    from amsowner.AMS_038_HOC hoc
    left join amsowner.ams_038_hoc_pndng hoc_pend
    on hoc.MSTR_KEY_ID = hoc_pend.MSTR_KEY_ID
    inner join amsowner.AMS_038_ST_BlCK blck
    on hoc.st_blck_key_id = blck.mstr_key_id
    inner join amsowner.postal_code pc
    on blck.pc_id = pc.pc_id
    left join amsowner.AMS_038_bldg bldg
    on hoc.BLDG_KEY_ID = bldg.MSTR_KEY_ID
    inner join amsowner.address address
    on address.addr_id = hoc.addr_mail_id
    inner join amsowner.addr_lctn_to_mail locToMail
    on locToMail.addr_mail_id = address.addr_id
    inner join amsowner.addr_chce choice
    on choice.addr_id = locToMail.addr_lctn_id
    left join occupant on (occupant.ADDR_MAIL_ID = address.addr_id and occupant.prmry_ind = 33)
    left join amsowner.ams_038_hld_out hldout
    on (hldout.mstr_key_id = hoc.mstr_key_id and hldout.end_dte is null)
    left join amsowner.ams_038_dm dm
    on dm.dm_id = blck.dm_id
    left join ams_038_assmt asmt
    on blck.pc_id = asmt.pc_id and asmt.dpt_cde_nme = valDpt_cde_nme and ((asmt.case_type_cde = 1220 and dm.a62_cse_ind = 33) or (asmt.case_type_cde = 1219 and dm.a62_cse_ind = 34))
    left join ams_038_mail_prfl mp
    on hoc.mp_id = mp.mp_id and ((mp.case_type_cde = 1220 and dm.a62_cse_ind = 33) or (mp.case_type_cde = 1219 and dm.a62_cse_ind = 34))
    where hoc.mstr_key_id = valMSTR_KEY_ID and blck.DPT_CDE_NME = valDpt_cde_nme and hoc.DPT_CDE_NME = valDpt_cde_nme and blck.RSTRCTR_STAT_CDE = restCode;
    Thanks a lot :)

    Hi and welcome to the forum.
    I appreciate you taking few minutes to help with analysing and tuining itUnfortunatly it's not that simple.
    We would need some more input here, like:
    - database version
    - optimizer settings
    - execution plans
    -etc..
    Tuning is a complex matter, since many parameters come into play here.
    If you want some useful responses then see:
    [When your query takes too long...|http://forums.oracle.com/forums/thread.jspa?messageID=3299435]
    [How to post a SQLStatement tuning request|http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]
    to understand what information would also be very useful to us (and, if needed, have your DBA participating in this as well).

  • Is There any way to improve the performance on this code

    Hi all can any one tell me how to improve the performance of this below code.
    Actually i need to calculate opening balance of gl account so instead of using bseg am using bsis
    So is there any way to improve this code performance.
    Any help would be appreciated.
    REPORT  ZTEMP5 NO STANDARD PAGE HEADING LINE-SIZE 190.
    data: begin of collect occurs 0,
           MONAT TYPE MONAT,
           HKONT TYPE HKONT,
           BELNR TYPE BELNR_D,
           BUDAT TYPE BUDAT,
           WRBTR TYPE WRBTR,
           SHKZG TYPE SHKZG,
           SGTXT TYPE SGTXT,
           AUFNR TYPE AUFNR_NEU,
           TOT   LIKE BSIS-WRBTR,
    end of collect.
    TYPES: BEGIN OF TY_BSIS,
           MONAT TYPE MONAT,
           HKONT TYPE HKONT,
           BELNR TYPE BELNR_D,
           BUDAT TYPE BUDAT,
           WRBTR TYPE WRBTR,
           SHKZG TYPE SHKZG,
           SGTXT TYPE SGTXT,
           AUFNR TYPE AUFNR_NEU,
    END OF TY_BSIS.
    DATA: IT_BSIS TYPE TABLE OF TY_BSIS,
          WA_BSIS TYPE TY_BSIS.
    DATA: TOT TYPE WRBTR,
          SUMA TYPE WRBTR,
          VALUE TYPE WRBTR,
          VALUE1 TYPE WRBTR.
    SELECTION-SCREEN: BEGIN OF BLOCK B1.
    PARAMETERS:  S_HKONT LIKE WA_BSIS-HKONT DEFAULT '0001460002' .
    SELECT-OPTIONS: S_BUDAT FOR WA_BSIS-BUDAT,
                    S_AUFNR FOR WA_BSIS-AUFNR DEFAULT '200020',
                    S_BELNR FOR WA_BSIS-BELNR.
    SELECTION-SCREEN: END OF BLOCK B1.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF SCREEN-NAME = 'S_HKONT'.
          SCREEN-INPUT = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    START-OF-SELECTION.
      SELECT MONAT
             HKONT
             BELNR
             BUDAT
             WRBTR
             SHKZG
             SGTXT
             AUFNR
             FROM BSIS
             INTO TABLE IT_BSIS
             WHERE HKONT EQ S_HKONT
             AND   BELNR IN S_BELNR
             AND   BUDAT IN S_BUDAT
             AND   AUFNR IN S_AUFNR.
    *  if sy-subrc <> 0.
    *    message 'No Data' type 'I'.
    *  endif.
      SELECT SUM( WRBTR )
             FROM BSIS
             INTO COLLECT-TOT
             WHERE HKONT EQ S_HKONT
             AND BUDAT < S_BUDAT-LOW
             AND AUFNR IN S_AUFNR.
    END-OF-SELECTION.
      CLEAR: S_BUDAT, S_AUFNR, S_BELNR, S_HKONT.
      LOOP AT IT_BSIS INTO WA_BSIS.
    IF wa_bsis-SHKZG = 'H'.
       wa_bsis-WRBTR = 0 - wa_bsis-WRBTR.
    ENDIF.
        collect-MONAT  = wa_bsis-monat.
        collect-HKONT  = wa_bsis-hkont.
        collect-BELNR  = wa_bsis-belnr.
        collect-BUDAT  = wa_bsis-budat.
        collect-WRBTR  = wa_bsis-wrbtr.
        collect-SHKZG  = wa_bsis-shkzg.
        collect-SGTXT  = wa_bsis-sgtxt.
        collect-AUFNR  = wa_bsis-aufnr.
        collect collect into  collect.
        CLEAR: COLLECT, WA_BSIS.
      ENDLOOP.
      LOOP AT COLLECT.
        AT end of HKONT.
          WRITE:/65 'OpeningBalance',
                 85  collect-tot.
          skip 1.
        ENDAT.
        WRITE:/06 COLLECT-BELNR,
               22 COLLECT-BUDAT,
               32 COLLECT-WRBTR,
               54 COLLECT-SGTXT.
        AT end of MONAT.
          SUM.
          WRITE:/ COLLECT-MONAT COLOR 1.
          WRITE:32 COLLECT-WRBTR COLOR 1.
          VALUE = COLLECT-WRBTR.
          SKIP 1.
        ENDAT.
        VALUE1 = COLLECT-TOT +  VALUE.
        AT end of MONAT.
          WRITE:85 VALUE1.
        ENDAT.
      endloop.
      CLEAR: COLLECT, SUMA, VALUE, VALUE1.
    TOP-OF-PAGE.
      WRITE:/06 'Doc No',
             22 'Post Date',
             39 'Amount',
             54 'Text'.
    Moderator message : See the Sticky threads (related for performance tuning) in this forum. Thread locked.
    Edited by: Vinod Kumar on Oct 13, 2011 11:12 AM

    Hi Ben,
    both BSIS selects would become faster if you can add Company Code BUKRS as 1st field of WHERE clause, because it's the 1st field of primary key and HKONT is the 2nd field of primary key.
    If you have no table index with HKONT as 1st field it's a full database access.
    If possible, try to add BUKRS as 1st field of WHERE clause, otherwise ask for an additional BSIS index at your basis team.
    Regards,
    Klaus

  • How to improve the performance in AM level

    Hi,
    I am using Jdeveloper 11.1.1.2.0 and weblogic server 10.3.2.
    How to improve the performance in AM level.
    Actually i have approx 10 lacs Data but when search the record then it is taking more time.
    I have following the link..
    http://www.gebs.ro/blog/oracle/adf-view-object-performance-tuning-analysis/
    but there is no effect in the performance level for seaching.
    So please help me ..
    Thanks
    Anup

    Hi Timo,
    In search page,i m giving empId and click on search button then to execute query it is taking more time.I have override the VOImpl executeQuery(). then it is taking more time
    @Override
    public void executeQuery() {
    setNamedWhereClauseParam("bind_draft", "D");
    setNamedWhereClauseParam("bind_complete","%");
    setNamedWhereClauseParam("bind_reject","%");
    setNamedWhereClauseParam("bind_approve","A");
    setNamedWhereClauseParam("bind_review","R");
    super.executeQuery();
    this method super.executeQuery() is calling and after 5 minutes heap space is comming on cosole as well as page also.
    Thanks
    Anup

  • How to improve the performance of adobe forms

    Hi,
    Please give me some suggestions as to how to improve the performance of adobe form?
    Right now when I' am doing user events it is working fine for first 6 or 7 user events. From the next
    one it is hanging.
    I read about Wizard form design approach, how to use the same here.
    Thanks,
    Aravind

    Hi Otto,
    The form is created using HCM forms and processes. I' am performing user events in the form.
    User events will doa round trip, in which form data will be sent to backend SAP system. Processing will
    happen on the ABAP side and result will appear on the form. First 6 or 7 user events works correctly,
    the result is appearing on the form. Around 8 or 9th one, the wait symbol appears and the form is not
    re-rendered. The form is of size 6 pages. The issue is not coming with form of size 1 page.
    I was reading ways to improve performance during re-rendering given below.
    http://www.adobe.com/devnet/livecycle/articles/DynamicInteractiveFormPerformance.pdf
    It talks about wizard form design approach. But in SFP transaction, I am not seeing any kind of wizard.
    Let me know if you need further details.
    Thanks,
    Aravind

  • How to Improve the performance in Variable Selection Screen.

    Hi,
    In Query Level we have Variable " User entry Defalt Valu". User want select particular value when he press "F4" it's take hours time how to improve the performance in Varaible Selection Screen.
    Thanks in Advance.
    Regards,
    Venkat.

    Dear Venkat.
    You please try the following steps:
    1. Say the InfoObject is 0EMPLOYEE against which you have created the variable, which user is trying to select value against, when they execute the report.
    2. Goto RSA1-> InfoObject tab-> Select InfoObject 0EMPLOYEE.
    3. Selcet the following options:
       Query Execution Filter Val. Selectn  -  'Only Posted Value for Navigation'
       Filter Value Repr. At Query Exec. -      'Selector Box Without Values'
    Please let me know if there is any more issue. Feel free to raise further concern
    Thnx,
    Sukdev K

  • How to improve the performance of the abap program

    hi all,
    I have created an abap program. And it taking long time since the number of records are more. And can anyone let me know how to improve the performance of my abap program.
    Using se30 and st05 transaction.
    can anyone help me out step by step
    regds
    haritha

    Hi Haritha,
    ->Run Any program using SE30 (performance analysis)
    Note: Click on the Tips & Tricks button from SE30 to get performance improving tips.
    Using this you can improve the performance by analyzing your code part by part.
    ->To turn runtim analysis on within ABAP code insert the following code
    SET RUN TIME ANALYZER ON.
    ->To turn runtim analysis off within ABAP code insert the following code
    SET RUN TIME ANALYZER OFF.
    ->Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
    ->Avoid for all entries in JOINS
    ->Try to avoid joins and use FOR ALL ENTRIES.
    ->Try to restrict the joins to 1 level only ie only for tables
    ->Avoid using Select *.
    ->Avoid having multiple Selects from the same table in the same object.
    ->Try to minimize the number of variables to save memory.
    ->The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
    ->Avoid creation of index as far as possible
    ->Avoid operators like <>, > , < & like % in where clause conditions
    ->Avoid select/select single statements in loops.
    ->Try to use 'binary search' in READ internal table. -->Ensure table is sorted before using BINARY SEARCH.
    ->Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
    ->Avoid using ORDER BY in selects
    ->Avoid Nested Selects
    ->Avoid Nested Loops of Internal Tables
    ->Try to use FIELD SYMBOLS.
    ->Try to avoid into Corresponding Fields of
    ->Avoid using Select Distinct, Use DELETE ADJACENT
    Check the following Links
    Re: performance tuning
    Re: Performance tuning of program
    http://www.sapgenie.com/abap/performance.htm
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    check the below link
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
    See the following link if it's any help:
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    Check also http://service.sap.com/performance
    and
    books like
    http://www.sap-press.com/product.cfm?account=&product=H951
    http://www.sap-press.com/product.cfm?account=&product=H973
    http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
    Performance tuning for Data Selection Statement
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
    Debugger
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    http://www.cba.nau.edu/haney-j/CIS497/Assignments/Debugging.doc
    http://help.sap.com/saphelp_erp2005/helpdata/en/b3/d322540c3beb4ba53795784eebb680/frameset.htm
    Run Time Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
    SQL trace
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
    CATT - Computer Aided Testing Too
    http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
    Test Workbench
    http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
    Coverage Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
    Runtime Monitor
    http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
    Memory Inspector
    http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
    ECATT - Extended Computer Aided testing tool.
    http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
    Just refer to these links...
    performance
    Performance
    Performance Guide
    performance issues...
    Performance Tuning
    Performance issues
    performance tuning
    performance tuning
    You can go to the transaction SE30 to have the runtime analysis of your program.Also try the transaction SCI , which is SAP Code Inspector.
    edited by,
    Naveenan

  • How to improve the performance of the query

    Hi,
    Help me by giving tips how to improve the performance of the query. Can I post the query?
    Suresh

    Below is the formatted query and no wonder it is taking lot of time. Will give you a list of issues soon after analyzing more. Till then understand the pitfalls yourself from this formatted query.
    SELECT rt.awb_number,
           ar.activity_id as task_id,
           t.assignee_org_unit_id,
           t.task_type_code,
           ar.request_id
    FROM activity_task ar,
         request_task rt,
         task t
    WHERE ar.activity_id =t.task_id
    AND ar.request_id = rt.request_id
    AND ar.complete_status != 'act.stat.closed'
    AND t.assignee_org_unit_id in (SELECT org_unit_id
                                   FROM org_unit
                                   WHERE org_unit_id in (SELECT oo.org_unit_id
                                                         FROM org_unit oo
                                                         WHERE oo.org_unit_id='3'
                                                         OR oo.parent_id ='3'
                                   OR parent_id in (SELECT oo.org_unit_id
                                                    FROM org_unit oo
                                                    WHERE oo.org_unit_id='3'
                                                    OR oo.parent_id ='3'
                                   AND has_queue=1
    AND ar.parent_task_id not in (SELECT tt.task_id
                                  FROM task tt
                                  WHERE tt.assignee_org_unit_id in (SELECT org_unit_id
                                                                    FROM org_unit
                                                                    WHERE org_unit_id in (SELECT oo.org_unit_id
                                                                                          FROM org_unit oo
                                                                                          WHERE oo.org_unit_id='3'
                                                                                          OR oo.parent_id ='3'
                                                                     OR parent_id in (SELECT oo.org_unit_id
                                                                                      FROM org_unit oo     
                                                                                      WHERE oo.org_unit_id='3'
                                                                                      OR oo.parent_id ='3'
                                                                     AND has_queue=1
    AND rt.awb_number is not null
    ORDER BY rt.awb_numberCheers
    Sarma.

  • Inner Join. How to improve the performance of inner join query

    Inner Join. How to improve the performance of inner join query.
    Query is :
    select f1~ablbelnr
             f1~gernr
             f1~equnr
             f1~zwnummer
             f1~adat
             f1~atim
             f1~v_zwstand
             f1~n_zwstand
             f1~aktiv
             f1~adatsoll
             f1~pruefzahl
             f1~ablstat
             f1~pruefpkt
             f1~popcode
             f1~erdat
             f1~istablart
             f2~anlage
             f2~ablesgr
             f2~abrdats
             f2~ableinh
                from eabl as f1
                inner join eablg as f2
                on f1ablbelnr = f2ablbelnr
                into corresponding fields of table it_list
                where f1~ablstat in s_mrstat
                %_HINTS ORACLE 'USE_NL (T_00 T_01) index(T_01 "EABLG~0")'.
    I wanted to modify the query, since its taking lot of time to load the data.
    Please suggest : -
    Treat this is very urgent.

    Hi Shyamal,
    In your program , you are using "into corresponding fields of ".
    Try not to use this addition in your select query.
    Instead, just use "into table it_list".
    As an example,
    Just give a normal query using "into corresponding fields of" in a program. Now go to se30 ( Runtime analysis), and give the program name and execute it .
    Now if you click on Analyze button , you can see, the analysis given for the query.The one given in "Red" line informs you that you need to find for alternate methods.
    On the other hand, if you are using "into table itab", it will give you an entirely different analysis.
    So try not to give "into corresponding fields" in your query.
    Regards,
    SP.

  • How to improve the performance of one program in one select query

    Hi,
    I am facing performance issue in one program. I have given some part of the code of the program.
    it is taking much time below select query. How to improve the performance.
    Quick response is highly appreciated.
    Program code
    DATA: BEGIN OF t_dels_tvpod OCCURS 100,
    vbeln LIKE tvpod-vbeln,
    posnr LIKE tvpod-posnr,
    lfimg_diff LIKE tvpod-lfimg_diff,
    calcu LIKE tvpod-calcu,
    podmg LIKE tvpod-podmg,
    uecha LIKE lips-uecha,
    pstyv LIKE lips-pstyv,
    xchar LIKE lips-xchar,
    grund LIKE tvpod-grund,
    END OF t_dels_tvpod,
    DATA: l_tabix LIKE sy-tabix,
    lt_dels_tvpod LIKE t_dels_tvpod OCCURS 10 WITH HEADER LINE,
    ls_dels_tvpod LIKE t_dels_tvpod.
    SELECT vbeln INTO TABLE lt_dels_tvpod FROM likp
    FOR ALL ENTRIES IN t_dels_tvpod
    WHERE vbeln = t_dels_tvpod-vbeln
    AND erdat IN s_erdat
    AND bldat IN s_bldat
    AND podat IN s_podat
    AND ernam IN s_ernam
    AND kunnr IN s_kunnr
    AND vkorg IN s_vkorg
    AND vstel IN s_vstel
    AND lfart NOT IN r_del_types_exclude.
    Waiting for quick response.
    Best regards,
    BDP

    Bansidhar,
    1) You need to add a check to make sure that internal table t_dels_tvpod (used in the FOR ALL ENTRIES clause) is not blank. If it is blank skip the SELECt statement.
    2)  Check the performance with and without clause 'AND lfart NOT IN r_del_types_exclude'. Sometimes NOT causes the select statement to not use the index. Instead of 'lfart NOT IN r_del_types_exclude' use 'lfart IN r_del_types_exclude' and build r_del_types_exclude by using r_del_types_exclude-sign = 'E' instead of 'I'.
    3) Make sure that the table used in the FOR ALL ENTRIES clause has unique delivery numbers.
    Try doing something like this.
    TYPES: BEGIN OF ty_del_types_exclude,
             sign(1)   TYPE c,
             option(2) TYPE c,
             low       TYPE likp-lfart,
             high      TYPE likp-lfart,
           END OF ty_del_types_exclude.
    DATA: w_del_types_exclude TYPE          ty_del_types_exclude,
          t_del_types_exclude TYPE TABLE OF ty_del_types_exclude,
          t_dels_tvpod_tmp    LIKE TABLE OF t_dels_tvpod        .
    IF NOT t_dels_tvpod[] IS INITIAL.
    * Assuming that I would like to exclude delivery types 'LP' and 'LPP'
      CLEAR w_del_types_exclude.
      REFRESH t_del_types_exclude.
      w_del_types_exclude-sign = 'E'.
      w_del_types_exclude-option = 'EQ'.
      w_del_types_exclude-low = 'LP'.
      APPEND w_del_types_exclude TO t_del_types_exclude.
      w_del_types_exclude-low = 'LPP'.
      APPEND w_del_types_exclude TO t_del_types_exclude.
      t_dels_tvpod_tmp[] = t_dels_tvpod[].
      SORT t_dels_tvpod_tmp BY vbeln.
      DELETE ADJACENT DUPLICATES FROM t_dels_tvpod_tmp
        COMPARING
          vbeln.
      SELECT vbeln
        FROM likp
        INTO TABLE lt_dels_tvpod
        FOR ALL ENTRIES IN t_dels_tvpod_tmp
        WHERE vbeln EQ t_dels_tvpod_tmp-vbeln
        AND erdat IN s_erdat
        AND bldat IN s_bldat
        AND podat IN s_podat
        AND ernam IN s_ernam
        AND kunnr IN s_kunnr
        AND vkorg IN s_vkorg
        AND vstel IN s_vstel
        AND lfart IN t_del_types_exclude.
    ENDIF.

  • Please help me how to take the "Spot Color" in illustrator?

    Hi,
    Please help me how to take the "spot color in illustrator CS" using vb script (or) java script.
    Regards,
    Prabudass E.

    Prabudass,<br /><br />If you are just wanting to see if the illustrator file uses spot colors - run the Delete Unused Panel items from the default actions. then view the swatch palette in small or large List View. The color names that have a square containing a gray circle (spot) to the right of their color names are spot colors. <br /><br />The following will get the spot color name of an existing swatch named "Color1" and change it to "Nicks Swatch" and will assign the CMYK values stated.<br /><br />if (app.documents.length > 0){<br />var swatches = app.activeDocument.spots;<br />for(i=0;i<swatches.length;i++){ var currSwatch = swatches[i]; if(currSwatch.name == "Color1")<br />{currSwatch.name = "Nicks Swatch";<br />     var newColor = new CMYKColor(); <br />     newColor.cyan = 35; newColor.magenta = 0; <br />     newColor.yellow = 50; <br />     newColor.black = 0; <br />     currSwatch.color = newColor; } }}<br /><br />When this script has run the swatch palette will not immediately reflect the changes to the swatch name until you double click on a swatch and click OK or Cancel in the Edit Swatch dialog.<br /><br />I hope that I have understood your question correctly and that these responses are helpful.<br /><br />Good Luck<br /><br />Nick

  • How to improve the performance of serialization/deserialization?

    Hi, Friends,
    I have a question about how to improve the performance of serialization/deserialization.
    When an object is serialized, the entire tree of objects rooted at the object is also serialized. When it is deserialized, the tree is reconstructed. For example, suppose a serializable Father object contains (a serializable field of) an array of Child objects. When a Father object is serialized, so is the array of Child objects.
    For the sake of performance consideration, when I need to deserialize a Father object, I don't want to deserialize any Child object. However, I should be able to know that Father object has children. I should also be able to deserialize any child of that Father object when necessary.
    Could you tell me how to achieve the above idea?
    Thanks.
    Youbin

    You could try something like this...
    import java.io.*;
    import java.util.*;
    class Child implements Serializable {
        int id;
        Child(int _id) { id=_id; }
        public String toString() { return String.valueOf(id); }
    class Father implements Serializable
        Child[] children = new Child[10];
        public Father() {
         Arrays.fill(children, new Child(1001));
        public void readObject(ObjectInputStream stream)
         throws IOException, ClassNotFoundException
         int numchildren = stream.readInt();
         for(int i=0; i<numchildren; i++)
             children[i] = (Child)stream.readObject();
         stream.close();
        public void writeObject(ObjectOutputStream stream) throws IOException
         stream.writeInt(children.length);
         for(int i=0; i<children.length; i++)
             stream.writeObject(children);
         stream.close();
    Child[] getChildren() { return children; }
    class FatherProxy
    int numchildren;
    String filename;
    public FatherProxy(String _filename) throws IOException
         filename = _filename;
         ObjectInputStream ois =
         new ObjectInputStream(new FileInputStream(filename));
         numchildren = ois.readInt();
         ois.close();
    int getNumChildren() { return numchildren; }
    Child[] getChildren() throws IOException, ClassNotFoundException
         ObjectInputStream ois =
         new ObjectInputStream(new FileInputStream(filename));
         Father f = (Father)ois.readObject();
         ois.close();     
         return f.getChildren();
    public class fatherref
    public static void main(String[] args) throws Exception
         // create the serialized file
         Father f = new Father();
         ObjectOutputStream oos =
         new ObjectOutputStream(new FileOutputStream("father.ser"));
         oos.writeObject(f);
         oos.close();
         // read in just what is needed -- numchildren
         FatherProxy fp = new FatherProxy("father.ser");
         System.out.println("numchildren: " + fp.getNumChildren());
         // do some processing
         // you need the rest -- children
         Child[] c = fp.getChildren();
         System.out.println("children:");
         for(int i=0; i<c.length; i++)
         System.out.println("i " + i + ": " + c[i]);

  • How to improve the performance of socket ?

    how to improve the performance of socket ?
    . allocation and deallocation of buffer ?

    No, that exception is thrown when the underlying
    socket (tcp/ip) implementation cannot reserve buffer
    space for new sockets afaik. I get it on windows
    machines when the concurrent connection load reaches
    17-18k connections. I do believe it's configurable
    though.And what happens if your max server load is 7-8 connections an hour and you never close the connections?

Maybe you are looking for

  • Error in Posting Travel Costs to FI/CO

    Hi Friends , I am working on a Business scenario on "Project with Resource Related Intercompany Billing". As a part of this scenario, one has to do time booking & travel expenses booking ( in CAT2) of a cross company employee. Then the time is transf

  • Changing MAC address at the boot time

    I want to call "ifconfig eth0 hw ether (...)" before dhcp client starts. Is there any place in the network scripts which already does it or should I add it anywhere I want?

  • Sense Code 30C00

    I am getting Sense Code 30C00 errors when I burn a DVD with Encore CS4 and Windows 7.  The DVD drivers are current and all Windows updates have been installed.

  • How to change password iPhoto

    I am new to Mac Book Pro so if you know the answer please remember K.I.S.S. as I don't know where to find all the drop down menus stuff like I did with Windows. Here is my problem: I have my password for this site and iCloud but I beieve I messed up

  • Installing Availability Agent CCMSPING

    Dear All, We are working on "Installing Availability Agent CCMSPING" on our system landscape.  We are facing an error " ccmsping: /lib/tls/libc.so.6 version 'GLIBC_2.3.4' not found (required by ccmsping)" We are using OS = RedHat LINUX We are not hav