Accounts Payable Rapid Mart Performance Issue

We are currently running the SAP AP Rapid Mart 3.2 and facing a performance issue on the SAP side for the data flows: DF_VendFinDocFactOpenDelta_SAP and DF_VendFinDocFactClearDelta_SAP.  These data flows pull from the same tables and one of them being BSEG which is a rather large table.
Has anyone found a means to pull data for these two dataflows within a reasonable amount of time?  I'm looking for a two hour or better abap run time for five years worth of data.

Hi Chuck,
I wish I could say that I have a solution. I ran nto the exact same problem a few months ago. Unfortunately we did not have enough time to come to a resolution of the issue, and then I moved on.
I would also love to hear anyone's suggestions regarding this issue.
BSEG is not a real table but a "virtual" table (like a view), so there are issues with how DI is able to pull data from BSEG.
Thanks

Similar Messages

  • Issues while executing Jobs - Rapid Mart Accounts Payable

    Hello,
    We are implementing A/c Payable  rapid marts at customer location.
    We installed dataservices and above it installed RM AP XI3.0.
    We successfully configured  source and target DS.
    When we validated the Jobs ,
    we faced the following error :
    [Query:SetLoadDateTime]
    Invalid mapping expression for column <SetLoadDateTime.EXCHANGE_TYPE_ID>. Additional information: <Cannot parse expression.
    Column <EXCHANGE_TYPE_ID> was not found in table <Effective_Date_1>. Please check the spelling of the referenced column and ensure such a column exists in the table.. (BODI-1112351)>. (BODI-1111081)
    [Query:SetLoadDateTime]
    Invalid mapping expression for column <SetLoadDateTime.FROM_CURRENCY_ID>. Additional information: <Cannot parse expression.
    Column <FROM_CURRENCY_ID> was not found in table <Effective_Date_1>. Please check the spelling of the referenced column and ensure such a column exists in the table.. (BODI-1112351)>. (BODI-1111081)
    [Query:SetLoadDateTime]
    Invalid mapping expression for column <SetLoadDateTime.TO_CURRENCY_ID>. Additional information: <Cannot parse expression.
    Column <TO_CURRENCY_ID> was not found in table <Effective_Date_1>. Please check the spelling of the referenced column and ensure such a column exists in the table.. (BODI-1112351)>. (BODI-1111081)
    and some more errors with same query SetLoadDateTime.
    We uploaded the file "fiscal_dates.dat"  in the SAP server "
    JUB02SAPJRD\BO_SHARE" ( which is used in DS setting )
    as mentioned in the Installation log.
    Would really appreciate any pointers wrt this issue.
    Thanks and regards,
    Vinay

    1. Can you check whether the System User ID with which Data Services try to fetch the auxillay files placed folder?
    2. How did you test the configurations? Have test run any job to test all the connectitivities required?

  • Performance Issue with BSIS(open accounting items)

    Hey All,
          I am having serious performance issue with a accrual report which gets all open GL items, and need some tips for optimization.
    The main issue is that I am accesing large tables like BSIS, BSEG, BSAS etc without proper indexes and that I am dealing with huge amounts of data.
    The select itself take a long time and after that as I have so much data overall execution is slow too.
    The select which concerns me the most is:
      SELECT zuonr hkont gjahr belnr buzei budat blart wrbtr shkzg xblnr waers bukrs
                 INTO TABLE i_bsis
                  FROM bsis
                  WHERE bukrs = '1000'
                  AND hkont in r_hkont   
                  AND budat <= p_lcdate
                  AND augdt = 0
                  AND augbl = space
                  AND gsber = c_ZRL1   
                  AND gjahr BETWEEN l_gjahr2 AND l_gjahr
                  AND ( blart = c_re      "Invoice
                  OR    blart = c_we      "Goods receipt
                  OR    blart = c_zc      "Invoice Cancels
                  OR    blart = c_kp ).   "Accounting offset
    I have seen other related threads, but was not that helpful.
    We already have a secondary index on bukrs hkont and budat, and i have checked in ST05 that it does use it. But inspite that it takes more than 15 hrs to complete(maybe because of huge data).
    Any Input is highly appreciated.
    Thanks

    Thank you Thomas for your inputs:
    You said that R_HKONT contains several ranges of account numbers. If these ranges cover a significant
    portion of the overall existing account numbers, then there is no really quick access possible via the
    BSIS primary key.
    Unfortunately R_HKONT contains all account numbers.
    As Rob said, your index on HKONT and BUDAT does not help much, since you are selecting "<=" on
    BUDAT. No chance of narrowing down that range?
    Will look into this.
    What about GSBER? Does the value in c_ZRL1 provide a rather small subset of the overall values? Then
    an index on BUKRS and GSBER might be helpful.
    ZRL1 does provide a decent selection . But I dont know if one more index is a good idea on overall
    system performance.
    I assume that the four document types are not very selective, so it probably does not pay off to
    investigate selecting on BKPF (there is an index involving BLART) and joining BSIS for the additional
    information. You still might want to look into it though.
    I did try to investigate this option too. Based on other threads related to BSIS and Robs Suggestion in
    those threads I tried this:
    SELECT bukrs belnr gjahr blart budat
      FROM bkpf INTO TABLE bkpf_l
            WHERE bukrs = c_pepsico
            AND bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z')
            AND blart IN ('RE', 'WE', 'ZC', 'KP')
            AND gjahr BETWEEN l_gjahr2 AND l_gjahr
            AND budat <= p_lcdate.
    SELECT zuonr hkont gjahr belnr buzei budat blart wrbtr shkzg xblnr waers bukrs
               FROM bsis INTO TABLE i_bsis FOR ALL ENTRIES IN bkpf_l
                         WHERE bukrs = bkpf_l-bukrs
                          AND  hkont IN r_hkont
                          AND  budat = bkpf_l-budat
                          AND  augdt = 0
                          AND  augbl = space
                          AND  gjahr = bkpf_l-gjahr
                          AND  belnr = bkpf_l-belnr
                          AND  blart = bkpf_l-blart
                          AND  gsber = c_zrl1.
    The improves the select on BSIS a lot, but the first select on BKPF kills it. Not sure if this would help
    improve performance.
    Also I was wondering whether it helps on refreshing the tabe statistics through DB20. The last refresh
    was done 7 months back. How frequently should we do this? Will it help?

  • SRKIM: R12: Accounts Payable Trial Balance issue troubleshoot

    Purpose
    R12 에서 AP Trial Balance Report 확인 시 데이터가 비정상적일 경우 check 해야 하는 내용에 대해 확인 해 보도록 한다.
    Question
    R12 에서 invoice 생성 후 gl 로 transfer 하였으나 ap trial balance report 의 데이터가 비정상적인 것으로 확인 된다.
    어떤 내용을 확인 해야 하는가.
    Answer
    1. APList Diagnostics Script 을 해당 invoice 에 대해 수행 하여 아래의 내용을 확인한다.
    - Accounting 이 생성되어 gl로 모두 transfer 되었는지 여부.
    - Accounting Date 가 Trial Balance Report 의 start date 와 as of date 안에 포함 되는지 여부
    2.위의 내용에 문제가 없다면 아래 sql 로 데이터를 확인 해 보도록 한다.
    select *
    from xla_trial_balances
    where source_entity_id in (
    select entity_id
    from xla.xla_transaction_entities xte
    where application_id = 200
    and (
    (entity_code = 'AP_INVOICES' and source_id_int_1 in (&invoice_id))
    OR
    applied_to_entity_id in (
    select entity_id
    from xla.xla_transaction_entities xte
    where application_id = 200
    and (
    (entity_code = 'AP_INVOICES' and source_id_int_1 in (&invoice_id))
    3.GL 에 실제 해당 데이터가 존재 하는지 아래 sql 로 확인 해 보도록 한다.
    SELECT distinct aeh.*
    FROM gl_je_lines gjl, GL_IMPORT_REFERENCES gir, gl_je_headers gjh, GL_JE_BATCHES gjb, XLA_AE_LINES
    ael,
    XLA_AE_HEADERS aeh, XLA_EVENTS aea, xla.xla_transaction_entities xte
    WHERE ael.gl_sl_link_id = gir.gl_sl_link_id
    and gjh.je_batch_id= gjb.je_batch_id
    and gjl.je_header_id = gjh.je_header_id
    and gjl.je_header_id = gir.je_header_id
    and gjl.je_line_num = gir.je_line_num
    AND gir.gl_sl_link_table in ('XLAJEL')
    and ael.gl_sl_link_table in ('XLAJEL')
    AND aea.application_id = 200
    AND aea.event_id = aeh.event_id
    AND aeh.ae_header_id = ael.ae_header_id
    AND gjb.je_batch_id = gir.je_batch_id
    and xte.application_id = 200
    and xte.entity_id = aea.entity_id
    and gjh.je_header_id = gir.je_header_id
    and gjh.je_source = 'Payables'
    and (
    (xte.entity_code = 'AP_PAYMENTS' and xte.source_id_int_1 = &check_id)
    OR
    (xte.entity_code = 'AP_INVOICES' and xte.source_id_int_1 = &invoice_id)
    SELECT distinct gjl.*
    FROM gl_je_lines gjl, GL_IMPORT_REFERENCES gir, gl_je_headers gjh, GL_JE_BATCHES gjb, XLA_AE_LINES
    ael,
    XLA_AE_HEADERS aeh, XLA_EVENTS aea, xla.xla_transaction_entities xte
    WHERE ael.gl_sl_link_id = gir.gl_sl_link_id
    and gjh.je_batch_id= gjb.je_batch_id
    and gjl.je_header_id = gjh.je_header_id
    and gjl.je_header_id = gir.je_header_id
    and gjl.je_line_num = gir.je_line_num
    AND gir.gl_sl_link_table in ('XLAJEL')
    and ael.gl_sl_link_table in ('XLAJEL')
    AND aea.application_id = 200
    AND aea.event_id = aeh.event_id
    AND aeh.ae_header_id = ael.ae_header_id
    AND gjb.je_batch_id = gir.je_batch_id
    and xte.application_id = 200
    and xte.entity_id = aea.entity_id
    and gjh.je_header_id = gir.je_header_id
    and gjh.je_source = 'Payables'
    and (
    (xte.entity_code = 'AP_PAYMENTS' and xte.source_id_int_1 = &check_id)
    OR
    (xte.entity_code = 'AP_INVOICES' and xte.source_id_int_1 = &invoice_id)
    4.위의 sql 을 통해 Trial Balance Table 의 데이타가 잘 못 생성 되었음이 확인 되면 해당 Trial balance table 의 데이타를 recreate 하는 작업을 수행 해야 한다.
    Reference
    Note. 553484.1 - THE R12 ACCOUNTS PAYABLE TRIAL BALANCE DATA IS
    INCORRECT/WRONG

    Follow the below steps and Run the Trial Blance and let me know if it helps.
    Thanks
    Girish
    How to Rebuild Trial Balance Data (repopulate XLA_TRIAL_BALANCES)
    1. Navigate: Payables Responsibility > Setup > Accounting Setups > Subledger Accounting Setups > Open Account Balances Listing Definitions
    2. Query up your Report Definition: select Defined By = Accounting Flexfield or Segment (whichever applies in your case), click “Go”
    3. Click on Update icon in the "Actions" column – the definition's update page opens.
    4. "Touch" the definition by simply clicking "Apply" button (without making any change).
    This should start the “Open Account Balances Data Manager” concurrent processes

  • Creating refunds in CR&B and issuing the check in Accounts Payable (ERP)

    Hi experts-
    I'm on an implementation project where ERP and CR&B are being put in place, both being on the same SAP instance/ box. The current refund process calls for generating refunds on the customers' contract accounts in CR&B and issuing the checks out of AP. The check memo field is to include the customer's name, Contract Account # ,and service address.
    Is there a standard SAP process to accommodate for this requirement? If not, what custom program or interface could satisfy the requirement?
    I'd like to hear if anyone has done anything similar and what successful approach was followed.
    Thanks,
    MD
    Moderator note - thread locked, no research - duplicate of Creating a refund request in CCS and printing that refund check FI-AP
    Edited by: William Eastman on Apr 26, 2011 5:24 PM

    1. Take List of all applied Invoices of the Payment
    2. Check the status of those invoices. Each one of them should be in status 'Accounted'
    3. If not,Identify the problem with the Invoice and Clear that. The problem may be Invoice adjustment(adj to Paid invoices allowed).
    4. Try running Create Accounting again.
    5. If the problem persists still, it conveys us that the Transactions were struck in loop and can be resolved only by using UPDATE command.
    6. Contact Oracle for Data fix
    Regards,
    Sridhar

  • Performance issues with the Vouchers index build in SES

    Hi All,
    We are currently performing an upgrade for: PS FSCM 9.1 to PS FSCM 9.2.
    As a part of the upgrade, Client wants Oracle SES to be deployed for some modules including, Purchasing, Payables (Vouchers)
    We are facing severe performance issues with the Vouchers index build. (Volume of data = approx. 8.5 million rows of data)
    The index creation process runs for over 5 days.
    Can you please share any information or issues that you may have faced on your project and how they were addressed?

    Check the following logs for errors:
    1.  The message log from the process scheduler
    2.  search_server1-diagnostic.log  in /search_server1/logs directory
    If the build is getting stuck while crawling then we typically have to increase the Java Heap size for the Weblogic instance for SES>

  • Performance Issue For Opening And Closing Balance In FBL1N/3N/5N

    Dear experts,
                        I Am Having Requirement to Bring Opening And Closing Balance In FBL1N, FBL3N, FBL5N.
    For This requirement I Used BADI : FI_ITEMS_CH_DATA~CHANGE_ITEMS, below is my Code For FBL1N, And I've Done the same For 3N/5N...With Related BAPI
    *   IF SY-TCODE = 'FBL1N'.
    *    LOOP AT ct_items INTO gs_items.
    *      CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    *        EXPORTING
    *          date      = gs_items-budat
    *          days      = '01'
    *          months    = '00'
    *          signum    = '-'
    *          years     = '00'
    *        IMPORTING
    *          calc_date = lv_date.
    *      CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
    *        EXPORTING
    *          companycode        = gs_items-bukrs
    *          vendor             = gs_items-konto
    *          keydate            = lv_date
    **   BALANCESPGLI       = ' '
    **   NOTEDITEMS         = ' '
    ** IMPORTING
    **   RETURN             =
    *        TABLES
    *          keybalance         =  lv_obal.
    *      CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
    *        EXPORTING
    *          companycode        = gs_items-bukrs
    *          vendor             = gs_items-konto
    *          keydate            = gs_items-budat
    **   BALANCESPGLI       = ' '
    **   NOTEDITEMS         = ' '
    ** IMPORTING
    **   RETURN             =
    *        TABLES
    *          keybalance         = lv_cbal
    *      READ TABLE lv_cbal INTO gs_cbal INDEX 1.
    *      gs_items-cbal = gs_cbal-lc_bal.
    *      READ TABLE lv_obal INTO gs_obal INDEX 1.
    *      gs_items-obal = gs_obal-lc_bal.
    *      MODIFY ct_items FROM gs_items TRANSPORTING obal cbal.
    *      CLEAR: gs_items,gs_obal,gs_cbal.
    *    ENDLOOP.
    *   ENDIF.
    So, Above Code Causing Me the Performance Issue, Kindly Suggest Me the Solution..
    Regards,
    uday.

    Hi Uday,
    I am sending you the code i used for the creation a Zreport based on FBL5N. Please check if it can of any help.
    *& Report  ZFBL5N                                                      *
    REPORT  zfbl5n_new  .
    TABLES : bsid,knc1,lfc1.
    TYPE-POOLS: slis.
    TYPES: BEGIN OF ty_bsid,
              bukrs TYPE bsid-bukrs,
              kunnr TYPE bsid-kunnr,
              belnr TYPE bsid-belnr,
              buzei TYPE bsid-buzei,
              bldat TYPE bsid-bldat,
              blart TYPE bsid-blart,
              bschl TYPE bsid-bschl,
              shkzg TYPE bsid-shkzg,
              dmbtr TYPE bsid-dmbtr,
              augdt TYPE bsid-augdt,
              augbl TYPE bsid-augbl,
              zuonr TYPE bsid-zuonr,
              sgtxt TYPE bsid-sgtxt,
              zfbdt TYPE bsid-zfbdt,
              zterm TYPE bsid-zterm,
              zbd1t TYPE bsid-zbd1t,
              zbd2t TYPE bsid-zbd2t,
              zbd3t TYPE bsid-zbd3t,
              kkber TYPE bsid-kkber,
              bstat TYPE bsid-bstat,
              umskz TYPE bsid-umskz,
            END OF ty_bsid.
    TYPES: BEGIN OF ty_bsik,
             bukrs TYPE bsik-bukrs,
              lifnr TYPE bsik-lifnr,
              belnr TYPE bsik-belnr,
              buzei TYPE bsik-buzei,
              bldat TYPE bsik-bldat,
              blart TYPE bsik-blart,
              bschl TYPE bsik-bschl,
              shkzg TYPE bsik-shkzg,
              dmbtr TYPE bsik-dmbtr,
              augdt TYPE bsik-augdt,
              augbl TYPE bsik-augbl,
              zuonr TYPE bsik-zuonr,
              sgtxt TYPE bsik-sgtxt,
               zfbdt TYPE bsik-zfbdt,
    *         KKBER TYPE bsik-kkber,
              zterm TYPE bsik-zterm,
               zbd1t TYPE bsik-zbd1t,
              zbd2t TYPE bsik-zbd2t,
              zbd3t TYPE bsik-zbd3t,
              bstat TYPE bsid-bstat,
              umskz TYPE bsid-umskz,
            END OF ty_bsik.
    TYPES: BEGIN OF ty_final,
              belnr TYPE bsid-belnr,
    *         buzei TYPE bsak-buzei,
              bldat TYPE bsid-bldat,
              blart TYPE bsid-blart,
              chq TYPE bsid-zuonr,
              debit TYPE bsid-dmbtr,
              credit TYPE bsid-dmbtr,
              txt TYPE bsid-sgtxt,
              date TYPE bsid-zfbdt,
              kkber TYPE bsid-kkber,
              zterm TYPE bsid-zterm,
              augbl TYPE bsid-augbl,
              augdt TYPE bsid-augdt,
              flag TYPE c,
            END OF ty_final.
    TYPES : BEGIN OF gs_openbal,
              bukrs TYPE bapi3007_2-comp_code,
              kunnr TYPE bapi3007_2-customer,
              dmbtr TYPE bapi3007_2-lc_amount,
             END OF gs_openbal.
    DATA: it_bsid TYPE STANDARD TABLE OF ty_bsid,
           it_bsik TYPE STANDARD TABLE OF ty_bsik,
           it_final TYPE STANDARD TABLE OF ty_final.
    DATA: wa_bsid TYPE ty_bsid,
           wa_bsik TYPE ty_bsik,
           wa_final TYPE ty_final.
    DATA: w_days TYPE t5a4a-dlydy,
           w_month TYPE t5a4a-dlymo,
           w_year TYPE t5a4a-dlyyr,
           w_date TYPE p0001-begda,
           w_name1 TYPE kna1-name1,
           w_ort01 TYPE kna1-ort01,
           w_lifnr TYPE kna1-lifnr,
           w_dmbtr1 TYPE bsid-dmbtr,
           w_dmbtr2 TYPE bsid-dmbtr,
           w_dmbtr3 TYPE bsad-dmbtr,
           w_dmbtr4 TYPE bsad-dmbtr,
           w_opbal TYPE bsid-dmbtr,
           w_credit TYPE bsik-dmbtr,
           w_debit TYPE bsik-dmbtr,
           w_clobal TYPE bsik-dmbtr,
           w_credit1 TYPE bsik-dmbtr,
           w_debit1 TYPE bsik-dmbtr,
           w_clobal1 TYPE bsik-dmbtr.
    DATA: ld_yrper LIKE rwcoom-fiscper,
           kunnr LIKE kna1-kunnr,
           x_norm TYPE c,
           x_park,
           x_apar,
           x_merk,
           ok_code(4),
           wa_x001 LIKE x001,
           return LIKE bapireturn,
           line_count LIKE sy-loopc,
           number_of_records TYPE i,
           xindex LIKE sy-tabix,
           open LIKE knc1-um01s,
           temp(20),
           close LIKE knc1-um01s,
           gjahr LIKE bsid-gjahr,
           period LIKE bkpf-monat,
           f(1),
           v_char(2),
           closec(20),
           openc(20),
           debit LIKE bapi3007_2-lc_amount,
           credit LIKE debit.
    DATA : v_dmbtr LIKE bsid-dmbtr.
    *DATA : tot_debit LIKE t_ar-debit,
    *       tot_credit LIKE t_ar-credit.
    DATA : t_kna1 LIKE kna1 OCCURS 1  WITH HEADER LINE,
            t_knb1 LIKE knb1 OCCURS 10 WITH HEADER LINE.
    DATA ibsid LIKE bsid OCCURS 0 WITH HEADER LINE.
    DATA ibsad LIKE bsad OCCURS 0 WITH HEADER LINE.
    DATA ibsik LIKE bsik OCCURS 0 WITH HEADER LINE.
    DATA ibsak LIKE bsak OCCURS 0 WITH HEADER LINE.
    DATA : it_fieldcat_alv   TYPE slis_t_fieldcat_alv,
            wa_fieldcat_alv     TYPE slis_fieldcat_alv,
            is_layout_alv  TYPE slis_layout_alv,
            wa_layout_alv  TYPE slis_layout_alv,
            it_list_top_of_page TYPE slis_t_listheader,
            it_events TYPE slis_t_event,
            wa_events TYPE LINE OF slis_t_event.
    DATA : BEGIN OF ibukrs OCCURS 0,
               bukrs LIKE t001-bukrs,
              END OF ibukrs.
    DATA : BEGIN OF ikunnr1 OCCURS 0,
              kunnr LIKE knc1-kunnr,
             END OF ikunnr1.
    DATA : BEGIN OF ikunnr OCCURS 0,
               kunnr LIKE knc1-kunnr,
               bukrs LIKE t001-bukrs,
               lifnr LIKE lfc1-lifnr,
              END OF ikunnr.
    DATA: it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    DATA:    r_bschl TYPE RANGE OF bschl,
              wa_bschl LIKE LINE OF r_bschl.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS : p_kunnr TYPE bsid-kunnr OBLIGATORY,
                  p_bukrs TYPE bsid-bukrs OBLIGATORY.
    SELECT-OPTIONS: so_budat FOR bsid-budat .
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS : p_normal AS CHECKBOX,
                  p_spl    AS CHECKBOX,
                  p_vendor AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK b2.
    PERFORM get_data.
    PERFORM process_data.
    *PERFORM calculate_openbal. " Commented by anish
    PERFORM calculate_open_bal.
    PERFORM calculate_closing_bal.
    PERFORM build_catalog_sort USING it_sort.
    PERFORM reuse_alv_events_get .
    PERFORM display_data.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_data .
       SELECT bukrs kunnr belnr buzei bldat blart bschl shkzg dmbtr augdt augbl zuonr sgtxt zfbdt zterm zbd1t zbd2t zbd3t kkber
         bstat umskz FROM bsid
         INTO TABLE it_bsid
         WHERE bukrs = p_bukrs
          AND kunnr = p_kunnr
          AND budat IN so_budat.
       SELECT bukrs kunnr belnr buzei bldat blart bschl shkzg dmbtr augdt augbl zuonr sgtxt zfbdt zterm zbd1t zbd2t zbd3t kkber
        bstat umskz FROM bsad
        APPENDING TABLE it_bsid
        WHERE bukrs = p_bukrs
         AND kunnr = p_kunnr
         AND budat IN so_budat.
       SELECT SINGLE name1 ort01 lifnr FROM kna1
         INTO (w_name1 , w_ort01 , w_lifnr)
         WHERE kunnr = p_kunnr.
       IF p_vendor IS NOT INITIAL.
         SELECT bukrs lifnr belnr buzei bldat blart bschl shkzg dmbtr augdt augbl zuonr sgtxt zfbdt zterm zbd1t zbd2t zbd3t
         bstat umskz   FROM bsik
         APPENDING TABLE it_bsik
         WHERE bukrs = p_bukrs
           AND lifnr = w_lifnr
           AND budat IN so_budat.
         SELECT bukrs lifnr belnr buzei bldat blart bschl shkzg dmbtr augdt augbl zuonr sgtxt zfbdt zterm zbd1t zbd2t zbd3t
         bstat umskz  FROM bsak
        APPENDING TABLE it_bsik
        WHERE bukrs = p_bukrs
          AND lifnr = w_lifnr
          AND budat IN so_budat.
       ENDIF.
       SORT it_bsid BY bschl.
       DELETE  it_bsid WHERE bschl = '04'.
       DELETE  it_bsid WHERE bschl = '07'.
       DELETE  it_bsid WHERE bschl = '17'.
       DELETE  it_bsid WHERE bschl = '34'.
       DELETE  it_bsid WHERE bschl = '27'.
       DELETE  it_bsid WHERE bschl = '37'.
       SORT it_bsik BY bschl.
       DELETE  it_bsik WHERE bschl = '04'.
       DELETE  it_bsik WHERE bschl = '07'.
       DELETE  it_bsik WHERE bschl = '17'.
       DELETE  it_bsik WHERE bschl = '34'.
       DELETE  it_bsik WHERE bschl = '27'.
       DELETE  it_bsik WHERE bschl = '37'.
    ENDFORM.                    " GET_DATA
    *&      Form  PROCESS_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM process_data .
       DATA:okay       TYPE c VALUE space.
       w_month = '00'.
       w_year = '00'.
       SORT it_bsid BY bldat .
       LOOP AT it_bsid INTO wa_bsid.
         PERFORM check_item_ok  USING p_normal
                                      p_spl
                                      p_vendor
    *                               x_park
                                      wa_bsid
                                CHANGING okay.
         CHECK okay = 'X'.
         wa_final-belnr = wa_bsid-belnr.
         wa_final-bldat = wa_bsid-bldat.
         wa_final-blart = wa_bsid-blart.
         wa_final-txt = wa_bsid-sgtxt.
         wa_final-kkber = wa_bsid-kkber.
         wa_final-zterm = wa_bsid-zterm.
         wa_final-augbl = wa_bsid-augbl.
         wa_final-augdt = wa_bsid-augdt.
         wa_final-flag = 'C'.
         IF wa_bsid-blart = 'DZ'.
           wa_final-chq = wa_bsid-zuonr.
         ENDIF.
         IF wa_bsid-shkzg = 'S'.
           wa_final-debit = wa_bsid-dmbtr.
         ELSEIF wa_bsid-shkzg = 'H'.
           wa_final-credit = wa_bsid-dmbtr.
         ENDIF.
         w_credit = w_credit + wa_final-credit.
         w_debit = w_debit + wa_final-debit.
    ****** Net due  date
         IF wa_bsid-zbd1t IS NOT INITIAL.
           w_days = wa_bsid-zbd1t.
         ELSEIF wa_bsid-zbd2t IS NOT INITIAL.
           w_days = wa_bsid-zbd2t.
         ELSEIF wa_bsid-zbd3t IS NOT INITIAL.
           w_days = wa_bsid-zbd3t.
         ENDIF.
         IF w_days IS INITIAL.
           wa_final-date = wa_bsid-zfbdt.
         ELSE.
           CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
             EXPORTING
               date      = wa_bsid-zfbdt
               days      = w_days
               months    = w_month
               signum    = '+'
               years     = w_year
             IMPORTING
               calc_date = w_date.
           wa_final-date = w_date.
         ENDIF.
         APPEND wa_final TO it_final.
         CLEAR: w_days , w_date , wa_final .
       ENDLOOP.
       IF it_bsik IS NOT INITIAL.
         CLEAR: w_days , w_date.
         SORT it_bsik BY bldat.
         LOOP AT it_bsik INTO wa_bsik.
           wa_final-belnr = wa_bsik-belnr.
           wa_final-bldat = wa_bsik-bldat.
           wa_final-blart = wa_bsik-blart.
           wa_final-txt = wa_bsik-sgtxt.
    *    wa_final-kkber = wa_bsik-kkber.
           wa_final-zterm = wa_bsik-zterm.
           wa_final-augbl = wa_bsik-augbl.
           wa_final-augdt = wa_bsik-augdt.
           wa_final-flag = 'V'.
           IF wa_bsik-blart = 'DZ'.
             wa_final-chq = wa_bsik-zuonr.
           ENDIF.
           IF wa_bsik-shkzg = 'S'.
             wa_final-debit = wa_bsik-dmbtr.
           ELSEIF wa_bsik-shkzg = 'H'.
             wa_final-credit = wa_bsik-dmbtr.
           ENDIF.
           w_credit1 = w_credit1 + wa_final-credit.
           w_debit1 = w_debit1 + wa_final-debit.
    *******  Net Due date
           IF wa_bsik-zbd1t IS NOT INITIAL.
             w_days = wa_bsik-zbd1t.
           ELSEIF wa_bsik-zbd2t IS NOT INITIAL.
             w_days = wa_bsik-zbd2t.
           ELSEIF wa_bsik-zbd3t IS NOT INITIAL.
             w_days = wa_bsik-zbd3t.
           ENDIF.
           IF w_days IS INITIAL.
             wa_final-date = wa_bsik-zfbdt.
           ELSE.
             CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
               EXPORTING
                 date      = wa_bsik-zfbdt
                 days      = w_days
                 months    = w_month
                 signum    = '+'
                 years     = w_year
               IMPORTING
                 calc_date = w_date.
           ENDIF.
           wa_final-date = w_date.
           APPEND wa_final TO it_final.
           CLEAR: wa_final.
         ENDLOOP.
       ENDIF.
    ENDFORM.                    " PROCESS_DATA
    *&      Form  DISPLAY_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_data .
       wa_fieldcat_alv-fieldname = 'BELNR'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-003.
       wa_fieldcat_alv-outputlen = '11'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'BLDAT'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-004.
       wa_fieldcat_alv-outputlen = '13'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'BLART'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-005.
       wa_fieldcat_alv-outputlen = '02'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'CHQ'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-006.
       wa_fieldcat_alv-outputlen = '09'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'DEBIT'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-007.
       wa_fieldcat_alv-outputlen = '15'.
       wa_fieldcat_alv-do_sum = 'X'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'CREDIT'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-008.
       wa_fieldcat_alv-outputlen = '15'.
       wa_fieldcat_alv-do_sum = 'X'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'TXT'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-009.
       wa_fieldcat_alv-outputlen = '50'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'DATE'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-010.
       wa_fieldcat_alv-outputlen = '12'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'KKBER'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-011.
       wa_fieldcat_alv-outputlen = '04'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'ZTERM'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-012.
       wa_fieldcat_alv-outputlen = '13'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'AUGBL'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-013.
       wa_fieldcat_alv-outputlen = '15'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'AUGDT'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-seltext_l = text-014.
       wa_fieldcat_alv-outputlen = '17'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       wa_fieldcat_alv-fieldname = 'FLAG'.
       wa_fieldcat_alv-tabname = 'IT_FINAL'.
       wa_fieldcat_alv-tech = 'X'.
       APPEND wa_fieldcat_alv TO it_fieldcat_alv.
       CLEAR wa_fieldcat_alv.
       CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program             = sy-repid
          is_layout                      = wa_layout_alv
          it_fieldcat                    = it_fieldcat_alv
    *   IT_EXCLUDING                   =
    *   IT_SPECIAL_GROUPS              =
          it_sort                        = it_sort
          it_events                      = it_events
          i_save                            = 'A'
         TABLES
           t_outtab                       = it_final
        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.
    *  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *    EXPORTING
    *      i_callback_program                = sy-repid
    *     i_callback_top_of_page            = 'TOP_OF_PAGE'
    *      is_layout                         = wa_layout_alv
    *      it_fieldcat                       = it_fieldcat_alv
    *      it_sort                           = it_sort
    ***   I_DEFAULT                         = 'X'
    **      i_save                            = 'A'
    ***   IT_EVENTS                         =
    *     TABLES
    *       t_outtab                          = it_final
    *    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.                    " DISPLAY_DATA
    *&      Form  TOP_OF_PAGE
    *       Header at top of page.
    FORM top_of_page.
       SKIP 1.
       WRITE: AT 35 'Account Statement from' , so_budat-low , 'to' , so_budat-high.
       SKIP 2.
       WRITE: AT /5 'CUSTOMER:' , p_kunnr.
       WRITE: AT 35 'Name:' , w_name1.
       WRITE: AT /5 'Company:' , p_bukrs.
       WRITE: AT 35 'City:' , w_ort01.
       SKIP 1.
       WRITE: AT /5 'Opening Balance as on' , so_budat-low , '   ' ,  w_opbal LEFT-JUSTIFIED.
       SKIP 2.
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  END_OF_PAGE
    *       Footer at End of page.
    FORM end_of_page.
       SKIP 2.
       IF so_budat-high IS NOT INITIAL.
         WRITE: AT 5 'Closing Balance as on' , so_budat-high , '   ' ,  w_clobal LEFT-JUSTIFIED.
       ELSE.
         WRITE: AT 5 'Closing Balance  ' , w_clobal LEFT-JUSTIFIED.
       ENDIF.
    ENDFORM.                    "end_of_page
    *&      Form  CALCULATE_OPENBAL
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM calculate_openbal .
       DATA:v_gjahr       TYPE bsid-gjahr.
       DATA: v_period LIKE  t009b-poper,v_monat LIKE t001-periv.
       CALL FUNCTION 'FI_PERIOD_DETERMINE'
              EXPORTING
                   i_budat        = so_budat-low
                   i_bukrs        = p_bukrs
    *           I_PERIV        = ' '
    *           I_GJAHR        = 0000
    *           I_MONAT        = 00
    *           X_XMO16        = ' '
              IMPORTING
                   e_gjahr        = v_gjahr
    *            e_monat        = v_monat
                   e_poper        = v_period.
       IF sy-subrc NE 0.
       ENDIF.
       DATA: f_date LIKE sy-datum.
       CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
         EXPORTING
           i_gjahr  = v_gjahr
           i_monmit = 00
           i_periv  = 'V3'
           i_poper  = v_period
         IMPORTING
           e_date   = f_date.
       period = v_period - 1.
       gjahr = v_gjahr.
       DATA wa_kna1 LIKE kna1.
       CALL FUNCTION 'READ_KNA1'
         EXPORTING
           xkunnr         = p_kunnr
         IMPORTING
           xkna1          = wa_kna1
         EXCEPTIONS
           key_incomplete = 1
           not_authorized = 2
           not_found      = 3
           OTHERS         = 4.
       IF sy-subrc <> 0.
         MESSAGE w023(zwww).
         CALL SCREEN 0010.
       ENDIF.
       MOVE-CORRESPONDING wa_kna1 TO t_kna1.
       APPEND t_kna1.
       SELECT kunnr FROM kna1 INTO TABLE ikunnr1
         WHERE kunnr = p_kunnr.
       SELECT bukrs FROM t001 INTO TABLE ibukrs
        FOR ALL ENTRIES IN t_knb1
        WHERE bukrs = t_knb1-bukrs.
       LOOP AT ikunnr1.
         LOOP AT ibukrs.
           ikunnr-kunnr = ikunnr1-kunnr.
           ikunnr-bukrs = ibukrs-bukrs.
           READ TABLE t_kna1 WITH  KEY kunnr = ikunnr1-kunnr.
           ikunnr-lifnr = t_kna1-lifnr.
           APPEND ikunnr.
         ENDLOOP.
       ENDLOOP.
       DELETE ikunnr WHERE bukrs NE p_bukrs.
       LOOP AT ikunnr.
         CLEAR: knc1,lfc1,f.
         IF NOT ( ikunnr-kunnr IS INITIAL ) AND NOT ( p_vendor IS INITIAL ).
           SELECT SINGLE * FROM lfc1
                  WHERE gjahr = gjahr AND bukrs = ikunnr-bukrs
                                      AND lifnr = ikunnr-lifnr.
         ENDIF.
         SELECT SINGLE * FROM knc1
           WHERE gjahr = gjahr AND bukrs = p_bukrs
                 AND kunnr = p_kunnr.
         IF sy-subrc = 0.
           CASE period .
             WHEN 12.
               open = knc1-umsav +
               knc1-um01s - knc1-um01h + knc1-um02s - knc1-um02h +
               knc1-um03s - knc1-um03h + knc1-um04s - knc1-um04h +
               knc1-um05s - knc1-um05h + knc1-um06s - knc1-um06h +
               knc1-um07s - knc1-um07h + knc1-um08s - knc1-um08h +
               knc1-um09s - knc1-um09h + knc1-um10s - knc1-um10h +
               knc1-um11s - knc1-um11h + knc1-um12s - knc1-um12h.
               IF NOT ( lfc1 IS INITIAL ).
                 open = open + lfc1-umsav +
                 lfc1-um01s - lfc1-um01h + lfc1-um02s - lfc1-um02h +
                 lfc1-um03s - lfc1-um03h + lfc1-um04s - lfc1-um04h +
                 lfc1-um05s - lfc1-um05h + lfc1-um06s - lfc1-um06h +
                 lfc1-um07s - lfc1-um07h + lfc1-um08s - lfc1-um08h +
                 lfc1-um09s - lfc1-um09h + lfc1-um10s - lfc1-um10h +
                 lfc1-um11s - lfc1-um11h + lfc1-um12s - lfc1-um12h.
               ENDIF.
             WHEN 11.
               open = knc1-umsav +
               knc1-um01s - knc1-um01h + knc1-um02s - knc1-um02h +
               knc1-um03s - knc1-um03h + knc1-um04s - knc1-um04h +
               knc1-um05s - knc1-um05h + knc1-um06s - knc1-um06h +
               knc1-um07s - knc1-um07h + knc1-um08s - knc1-um08h +
               knc1-um09s - knc1-um09h + knc1-um10s - knc1-um10h +
               knc1-um11s - knc1-um11h.
               IF NOT ( lfc1 IS INITIAL ) .
                 open = open + lfc1-umsav +
                 lfc1-um01s - lfc1-um01h + lfc1-um02s - lfc1-um02h +
                 lfc1-um03s - lfc1-um03h + lfc1-um04s - lfc1-um04h +
                 lfc1-um05s - lfc1-um05h + lfc1-um06s - lfc1-um06h +
                 lfc1-um07s - lfc1-um07h + lfc1-um08s - lfc1-um08h +
                 lfc1-um09s - lfc1-um09h + lfc1-um10s - lfc1-um10h +
                 lfc1-um11s - lfc1-um11h.
               ENDIF.
             WHEN 10.
               open = knc1-umsav +
               knc1-um01s - knc1-um01h + knc1-um02s - knc1-um02h +
               knc1-um03s - knc1-um03h + knc1-um04s - knc1-um04h +
               knc1-um05s - knc1-um05h + knc1-um06s - knc1-um06h +
               knc1-um07s - knc1-um07h + knc1-um08s - knc1-um08h +
               knc1-um09s - knc1-um09h + knc1-um10s - knc1-um10h .
               IF NOT ( lfc1 IS INITIAL ) .
                 open = open + lfc1-umsav +
                 lfc1-um01s - lfc1-um01h + lfc1-um02s - lfc1-um02h +
                 lfc1-um03s - lfc1-um03h + lfc1-um04s - lfc1-um04h +
                 lfc1-um05s - lfc1-um05h + lfc1-um06s - lfc1-um06h +
                 lfc1-um07s - lfc1-um07h + lfc1-um08s - lfc1-um08h +
                 lfc1-um09s - lfc1-um09h + lfc1-um10s - lfc1-um10h.
               ENDIF.
             WHEN 9.
               open = knc1-umsav +
               knc1-um01s - knc1-um01h + knc1-um02s - knc1-um02h +
               knc1-um03s - knc1-um03h + knc1-um04s - knc1-um04h +
               knc1-um05s - knc1-um05h + knc1-um06s - knc1-um06h +
               knc1-um07s - knc1-um07h + knc1-um08s - knc1-um08h +
               knc1-um09s - knc1-um09h .
               IF NOT ( lfc1 IS INITIAL ) .
                 open = open + lfc1-umsav +
                 lfc1-um01s - lfc1-um01h + lfc1-um02s - lfc1-um02h +
                 lfc1-um03s - lfc1-um03h + lfc1-um04s - lfc1-um04h +
                 lfc1-um05s - lfc1-um05h + lfc1-um06s - lfc1-um06h +
                 lfc1-um07s - lfc1-um07h + lfc1-um08s - lfc1-um08h +
                 lfc1-um09s - lfc1-um09h.
               ENDIF.
             WHEN 8.
               open = knc1-umsav +
               knc1-um01s - knc1-um01h + knc1-um02s - knc1-um02h +
               knc1-um03s - knc1-um03h + knc1-um04s - knc1-um04h +
               knc1-um05s - knc1-um05h + knc1-um06s - knc1-um06h +
               knc1-um07s - knc1-um07h + knc1-um08s - knc1-um08h.
               IF NOT ( lfc1 IS INITIAL ) .
                 open = open + lfc1-umsav +
                 lfc1-um01s - lfc1-um01h + lfc1-um02s - lfc1-um02h +
                 lfc1-um03s - lfc1-um03h + lfc1-um04s - lfc1-um04h +
                 lfc1-um05s - lfc1-um05h + lfc1-um06s - lfc1-um06h +
                 lfc1-um07s - lfc1-um07h + lfc1-um08s - lfc1-um08h .
               ENDIF.
             WHEN 7.
               open = knc1-umsav +
               knc1-um01s - knc1-um01h + knc1-um02s - knc1-um02h +
               knc1-um03s - knc1-um03h + knc1-um04s - knc1-um04h +
               knc1-um05s - knc1-um05h + knc1-um06s - knc1-um06h +
               knc1-um07s - knc1-um07h .
               IF NOT ( lfc1 IS INITIAL ) .
                 open = open + lfc1-umsav +
                 lfc1-um01s - lfc1-um01h + lfc1-um02s - lfc1-um02h +
                 lfc1-um03s - lfc1-um03h + lfc1-um04s - lfc1-um04h +
                 lfc1-um05s - lfc1-um

  • Performance issue in DB need help with analysing this ADDM report

    Hi,
    My environment:
    Os: RHEL5U3 / 11.1.0.7 64 bit / R12.1.1 64 bit
    Issue:
    Few days are am facing serious of performance problem in our Production instance. Normally the issue will occur 5 to 10 minutes occasionally per day. At the time of issue we not able to access the EBS application its taking time to load. But backend all the oracle, listener and apps services are up and running. No locks at table and session level. Cpu and memory usage is normal.
    We have monitored using "Enterprise Manager" for this issue and we found the wait session present more in Active session tab. At this time EBS application is not able access its loading too time. After some time the in Active session tab the wait session came normal and when we try to access the EBS application its working fine.
    We try to find the cause of the issue by running addm report. But am not able to understand what its says. Kindly suggests me
    ADDM Report for Task 'TASK_42656'
    Analysis Period
    AWR snapshot range from 14754 to 14755.
    Time period starts at 17-APR-12 11.00.22 AM
    Time period ends at 17-APR-12 12.00.33 PM
    Analysis Target
    Database 'PRD' with DB ID 1789440879.
    Database version 11.1.0.7.0.
    ADDM performed an analysis of instance PRD, numbered 1 and hosted at
    advgrpdb.advgroup.ae.
    Activity During the Analysis Period
    Total database time was 18674 seconds.
    The average number of active sessions was 5.17.
    Summary of Findings
    Description Active Sessions Recommendations
    Percent of Activity
    1 Top SQL by DB Time 3.43 | 66.33 5
    2 Buffer Busy 2.52 | 48.81 5
    3 Buffer Busy 1.39 | 26.81 2
    4 Log File Switches .91 | 17.56 1
    5 Buffer Busy .56 | 10.87 2
    6 Undersized SGA .38 | 7.37 1
    7 Commits and Rollbacks .28 | 5.42 1
    8 Undo I/O .18 | 3.53 0
    9 CPU Usage .13 | 2.57 1
    10 Top SQL By I/O .11 | 2.21 1
    Findings and Recommendations
    Finding 1: Top SQL by DB Time
    Impact is 3.43 active sessions, 66.33% of total activity.
    SQL statements consuming significant database time were found.
    Recommendation 1: SQL Tuning
    Estimated benefit is 1.59 active sessions, 30.8% of total activity.
    Action
    Investigate the SQL statement with SQL_ID "a49xsqhv0h31b" for possible
    performance improvements.
    Related Object
    SQL statement with SQL_ID a49xsqhv0h31b.
    SELECT R.Conc_Login_Id, R.Request_Id, R.Phase_Code, R.Status_Code,
    P.Application_ID, P.Concurrent_Program_ID, P.Concurrent_Program_Name,
    R.Enable_Trace, R.Restart, DECODE(R.Increment_Dates, 'Y', 'Y', 'N'),
    R.NLS_Compliant, R.OUTPUT_FILE_TYPE, E.Executable_Name,
    E.Execution_File_Name, A2.Basepath, DECODE(R.Stale, 'Y', 'C',
    P.Execution_Method_Code), P.Print_Flag, P.Execution_Options,
    DECODE(P.Srs_Flag, 'Y', 'Y', 'Q', 'Y', 'N'), P.Argument_Method_Code,
    R.Print_Style, R.Argument_Input_Method_Code, R.Queue_Method_Code,
    R.Responsibility_ID, R.Responsibility_Application_ID, R.Requested_By,
    R.Number_Of_Copies, R.Save_Output_Flag, R.Printer, R.Print_Group,
    R.Priority, U.User_Name, O.Oracle_Username,
    O.Encrypted_Oracle_Password, R.Cd_Id, A.Basepath,
    A.Application_Short_Name, TO_CHAR(R.Requested_Start_Date,'YYYY/MM/DD
    HH24:MI:SS'), R.Nls_Language, R.Nls_Territory,
    R.Nls_Numeric_Characters, DECODE(R.Parent_Request_ID, NULL, 0,
    R.Parent_Request_ID), R.Priority_Request_ID, R.Single_Thread_Flag,
    R.Has_Sub_Request, R.Is_Sub_Request, R.Req_Information,
    R.Description, R.Resubmit_Time, TO_CHAR(R.Resubmit_Interval),
    R.Resubmit_Interval_Type_Code, R.Resubmit_Interval_Unit_Code,
    TO_CHAR(R.Resubmit_End_Date,'YYYY/MM/DD HH24:MI:SS'),
    Decode(E.Execution_File_Name, NULL, 'N', Decode(E.Subroutine_Name,
    NULL, Decode(E.Execution_Method_Code, 'I', 'Y', 'J', 'Y', 'N'),
    'Y')), R.Argument1, R.Argument2, R.Argument3, R.Argument4,
    R.Argument5, R.Argument6, R.Argument7, R.Argument8, R.Argument9,
    R.Argument10, R.Argument11, R.Argument12, R.Argument13, R.Argument14,
    R.Argument15, R.Argument16, R.Argument17, R.Argument18, R.Argument19,
    R.Argument20, R.Argument21, R.Argument22, R.Argument23, R.Argument24,
    R.Argument25, X.Argument26, X.Argument27, X.Argument28, X.Argument29,
    X.Argument30, X.Argument31, X.Argument32, X.Argument33, X.Argument34,
    X.Argument35, X.Argument36, X.Argument37, X.Argument38, X.Argument39,
    X.Argument40, X.Argument41, X.Argument42, X.Argument43, X.Argument44,
    X.Argument45, X.Argument46, X.Argument47, X.Argument48, X.Argument49,
    X.Argument50, X.Argument51, X.Argument52, X.Argument53, X.Argument54,
    X.Argument55, X.Argument56, X.Argument57, X.Argument58, X.Argument59,
    X.Argument60, X.Argument61, X.Argument62, X.Argument63, X.Argument64,
    X.Argument65, X.Argument66, X.Argument67, X.Argument68, X.Argument69,
    X.Argument70, X.Argument71, X.Argument72, X.Argument73, X.Argument74,
    X.Argument75, X.Argument76, X.Argument77, X.Argument78, X.Argument79,
    X.Argument80, X.Argument81, X.Argument82, X.Argument83, X.Argument84,
    X.Argument85, X.Argument86, X.Argument87, X.Argument88, X.Argument89,
    X.Argument90, X.Argument91, X.Argument92, X.Argument93, X.Argument94,
    X.Argument95, X.Argument96, X.Argument97, X.Argument98, X.Argument99,
    X.Argument100, R.number_of_arguments, C.CD_Name,
    NVL(R.Security_Group_ID, 0), NVL(R.org_id, 0) FROM
    fnd_concurrent_requests R, fnd_concurrent_programs P, fnd_application
    A, fnd_user U, fnd_oracle_userid O, fnd_conflicts_domain C,
    fnd_concurrent_queues Q, fnd_application A2, fnd_executables E,
    fnd_conc_request_arguments X WHERE R.Status_code = 'I' And
    ((R.OPS_INSTANCE is null) or (R.OPS_INSTANCE = -1) or
    (R.OPS_INSTANCE =
    decode(:dcp_on,1,FND_CONC_GLOBAL.OPS_INST_NUM,R.OPS_INSTANCE))) And
    R.Request_ID = X.Request_ID(+) And R.Program_Application_Id =
    P.Application_Id(+) And R.Concurrent_Program_Id =
    P.Concurrent_Program_Id(+) And R.Program_Application_Id =
    A.Application_Id(+) And P.Executable_Application_Id =
    E.Application_Id(+) And P.Executable_Id =
    E.Executable_Id(+) And P.Executable_Application_Id =
    A2.Application_Id(+) And R.Requested_By = U.User_Id(+) And R.Cd_Id
    = C.Cd_Id(+) And R.Oracle_Id = O.Oracle_Id(+) And Q.Application_Id =
    :q_applid And Q.Concurrent_Queue_Id = :queue_id And (P.Enabled_Flag
    is NULL OR P.Enabled_Flag = 'Y') And R.Hold_Flag = 'N' And
    R.Requested_Start_Date <= Sysdate And ( R.Enforce_Seriality_Flag =
    'N' OR ( C.RunAlone_Flag = P.Run_Alone_Flag And (P.Run_Alone_Flag =
    'N' OR Not Exists (Select Null From Fnd_Concurrent_Requests Sr
    Where Sr.Status_Code In ('R', 'T') And Sr.Enforce_Seriality_Flag =
    'Y' And Sr.CD_id = C.CD_Id)))) And Q.Running_Processes <=
    Q.Max_Processes And R.Rowid = :reqname And
    ((P.Execution_Method_Code != 'S' OR
    (R.PROGRAM_APPLICATION_ID,R.CONCURRENT_PROGRAM_ID) IN
    ((0,98),(0,100),(0,31721),(0,31722),(0,31757))) AND
    ((R.PROGRAM_APPLICATION_ID,R.CONCURRENT_PROGRAM_ID) NOT IN
    ((510,40112),(510,40113),(510,41497),(510,41498),(530,41859),(530,418
    60),(535,41492),(535,41493),(535,41494)))) FOR UPDATE OF
    R.status_code NoWait
    Rationale
    SQL statement with SQL_ID "a49xsqhv0h31b" was executed 4686 times and
    had an average elapsed time of 1.2 seconds.
    Rationale
    Waiting for event "buffer busy waits" in wait class "Concurrency"
    accounted for 85% of the database time spent in processing the SQL
    statement with SQL_ID "a49xsqhv0h31b".
    Rationale
    Waiting for event "log file switch (checkpoint incomplete)" in wait
    class "Configuration" accounted for 9% of the database time spent in
    processing the SQL statement with SQL_ID "a49xsqhv0h31b".
    Recommendation 3: SQL Tuning
    Estimated benefit is .56 active sessions, 10.91% of total activity.
    Action
    Investigate the SQL statement with SQL_ID "5d7957yktf3nn" for possible
    performance improvements.
    Related Object
    SQL statement with SQL_ID 5d7957yktf3nn.
    UPDATE ICX_SESSIONS SET TIME_OUT = :B2 WHERE SESSION_ID = :B1
    Rationale
    SQL statement with SQL_ID "5d7957yktf3nn" was executed 266 times and had
    an average elapsed time of 7.6 seconds.
    Rationale
    Waiting for event "buffer busy waits" in wait class "Concurrency"
    accounted for 86% of the database time spent in processing the SQL
    statement with SQL_ID "5d7957yktf3nn".
    Rationale
    Waiting for event "log file switch (checkpoint incomplete)" in wait
    class "Configuration" accounted for 7% of the database time spent in
    processing the SQL statement with SQL_ID "5d7957yktf3nn".
    Finding 2: Buffer Busy
    Impact is 2.52 active sessions, 48.81% of total activity.
    Read and write contention on database blocks was consuming significant
    database time.
    Recommendation 1: Application Analysis
    Estimated benefit is 1.42 active sessions, 27.44% of total activity.
    Action
    Trace the cause of object contention due to SELECT statements in the
    application using the information provided.
    Related Object
    Database object with ID 34562.
    Rationale
    The SELECT statement with SQL_ID "a49xsqhv0h31b" was significantly
    affected by "buffer busy" waits.
    Related Object
    SQL statement with SQL_ID a49xsqhv0h31b.
    SELECT R.Conc_Login_Id, R.Request_Id, R.Phase_Code, R.Status_Code,
    P.Application_ID, P.Concurrent_Program_ID, P.Concurrent_Program_Name,
    R.Enable_Trace, R.Restart, DECODE(R.Increment_Dates, 'Y', 'Y', 'N'),
    R.NLS_Compliant, R.OUTPUT_FILE_TYPE, E.Executable_Name,
    E.Execution_File_Name, A2.Basepath, DECODE(R.Stale, 'Y', 'C',
    P.Execution_Method_Code), P.Print_Flag, P.Execution_Options,
    DECODE(P.Srs_Flag, 'Y', 'Y', 'Q', 'Y', 'N'), P.Argument_Method_Code,
    R.Print_Style, R.Argument_Input_Method_Code, R.Queue_Method_Code,
    R.Responsibility_ID, R.Responsibility_Application_ID, R.Requested_By,
    R.Number_Of_Copies, R.Save_Output_Flag, R.Printer, R.Print_Group,
    R.Priority, U.User_Name, O.Oracle_Username,
    O.Encrypted_Oracle_Password, R.Cd_Id, A.Basepath,
    A.Application_Short_Name, TO_CHAR(R.Requested_Start_Date,'YYYY/MM/DD
    HH24:MI:SS'), R.Nls_Language, R.Nls_Territory,
    R.Nls_Numeric_Characters, DECODE(R.Parent_Request_ID, NULL, 0,
    R.Parent_Request_ID), R.Priority_Request_ID, R.Single_Thread_Flag,
    R.Has_Sub_Request, R.Is_Sub_Request, R.Req_Information,
    R.Description, R.Resubmit_Time, TO_CHAR(R.Resubmit_Interval),
    R.Resubmit_Interval_Type_Code, R.Resubmit_Interval_Unit_Code,
    TO_CHAR(R.Resubmit_End_Date,'YYYY/MM/DD HH24:MI:SS'),
    Decode(E.Execution_File_Name, NULL, 'N', Decode(E.Subroutine_Name,
    NULL, Decode(E.Execution_Method_Code, 'I', 'Y', 'J', 'Y', 'N'),
    'Y')), R.Argument1, R.Argument2, R.Argument3, R.Argument4,
    R.Argument5, R.Argument6, R.Argument7, R.Argument8, R.Argument9,
    R.Argument10, R.Argument11, R.Argument12, R.Argument13, R.Argument14,
    R.Argument15, R.Argument16, R.Argument17, R.Argument18, R.Argument19,
    R.Argument20, R.Argument21, R.Argument22, R.Argument23, R.Argument24,
    R.Argument25, X.Argument26, X.Argument27, X.Argument28, X.Argument29,
    X.Argument30, X.Argument31, X.Argument32, X.Argument33, X.Argument34,
    X.Argument35, X.Argument36, X.Argument37, X.Argument38, X.Argument39,
    X.Argument40, X.Argument41, X.Argument42, X.Argument43, X.Argument44,
    X.Argument45, X.Argument46, X.Argument47, X.Argument48, X.Argument49,
    X.Argument50, X.Argument51, X.Argument52, X.Argument53, X.Argument54,
    X.Argument55, X.Argument56, X.Argument57, X.Argument58, X.Argument59,
    X.Argument60, X.Argument61, X.Argument62, X.Argument63, X.Argument64,
    X.Argument65, X.Argument66, X.Argument67, X.Argument68, X.Argument69,
    X.Argument70, X.Argument71, X.Argument72, X.Argument73, X.Argument74,
    X.Argument75, X.Argument76, X.Argument77, X.Argument78, X.Argument79,
    X.Argument80, X.Argument81, X.Argument82, X.Argument83, X.Argument84,
    X.Argument85, X.Argument86, X.Argument87, X.Argument88, X.Argument89,
    X.Argument90, X.Argument91, X.Argument92, X.Argument93, X.Argument94,
    X.Argument95, X.Argument96, X.Argument97, X.Argument98, X.Argument99,
    X.Argument100, R.number_of_arguments, C.CD_Name,
    NVL(R.Security_Group_ID, 0), NVL(R.org_id, 0) FROM
    fnd_concurrent_requests R, fnd_concurrent_programs P, fnd_application
    A, fnd_user U, fnd_oracle_userid O, fnd_conflicts_domain C,
    fnd_concurrent_queues Q, fnd_application A2, fnd_executables E,
    fnd_conc_request_arguments X WHERE R.Status_code = 'I' And
    ((R.OPS_INSTANCE is null) or (R.OPS_INSTANCE = -1) or
    (R.OPS_INSTANCE =
    decode(:dcp_on,1,FND_CONC_GLOBAL.OPS_INST_NUM,R.OPS_INSTANCE))) And
    R.Request_ID = X.Request_ID(+) And R.Program_Application_Id =
    P.Application_Id(+) And R.Concurrent_Program_Id =
    P.Concurrent_Program_Id(+) And R.Program_Application_Id =
    A.Application_Id(+) And P.Executable_Application_Id =
    E.Application_Id(+) And P.Executable_Id =
    E.Executable_Id(+) And P.Executable_Application_Id =
    A2.Application_Id(+) And R.Requested_By = U.User_Id(+) And R.Cd_Id
    = C.Cd_Id(+) And R.Oracle_Id = O.Oracle_Id(+) And Q.Application_Id =
    :q_applid And Q.Concurrent_Queue_Id = :queue_id And (P.Enabled_Flag
    is NULL OR P.Enabled_Flag = 'Y') And R.Hold_Flag = 'N' And
    R.Requested_Start_Date <= Sysdate And ( R.Enforce_Seriality_Flag =
    'N' OR ( C.RunAlone_Flag = P.Run_Alone_Flag And (P.Run_Alone_Flag =
    'N' OR Not Exists (Select Null From Fnd_Concurrent_Requests Sr
    Where Sr.Status_Code In ('R', 'T') And Sr.Enforce_Seriality_Flag =
    'Y' And Sr.CD_id = C.CD_Id)))) And Q.Running_Processes <=
    Q.Max_Processes And R.Rowid = :reqname And
    ((P.Execution_Method_Code != 'S' OR
    (R.PROGRAM_APPLICATION_ID,R.CONCURRENT_PROGRAM_ID) IN
    ((0,98),(0,100),(0,31721),(0,31722),(0,31757))) AND
    ((R.PROGRAM_APPLICATION_ID,R.CONCURRENT_PROGRAM_ID) NOT IN
    ((510,40112),(510,40113),(510,41497),(510,41498),(530,41859),(530,418
    60),(535,41492),(535,41493),(535,41494)))) FOR UPDATE OF
    R.status_code NoWait
    UPDATE ICX_SESSIONS SET LAST_CONNECT = SYSDATE WHERE SESSION_ID = :B1
    Recommendation 1: Schema Changes
    Estimated benefit is .03 active sessions, .62% of total activity.
    Action
    Consider rebuilding the TABLE "APPLSYS.FND_LOGIN_RESP_FORMS" with object
    ID 34651 using a higher value for PCTFREE.
    Related Object
    Database object with ID 34651.
    Rationale
    The UPDATE statement with SQL_ID "cqc5crhxxt36t" was significantly
    affected by "buffer busy" waits.
    Related Object
    SQL statement with SQL_ID cqc5crhxxt36t.
    UPDATE FND_LOGIN_RESP_FORMS FLRF SET END_TIME = SYSDATE WHERE
    FLRF.LOGIN_ID = :B2 AND FLRF.LOGIN_RESP_ID = :B1 AND FLRF.END_TIME IS
    NULL AND (FLRF.FORM_ID, FLRF.FORM_APPL_ID) = (SELECT F.FORM_ID,
    F.APPLICATION_ID FROM FND_FORM F, FND_APPLICATION A WHERE F.FORM_NAME
    = :B4 AND F.APPLICATION_ID = A.APPLICATION_ID AND
    A.APPLICATION_SHORT_NAME = :B3 )
    Symptoms That Led to the Finding:
    Wait class "Concurrency" was consuming significant database time.
    Impact is 2.53 active sessions, 48.87% of total activity.
    Finding 4: Log File Switches
    Impact is .91 active sessions, 17.56% of total activity.
    Log file switch operations were consuming significant database time while
    waiting for checkpoint completion.
    This problem can be caused by use of hot backup mode on tablespaces. DML to
    tablespaces in hot backup mode causes generation of additional redo.
    Recommendation 1: Database Configuration
    Estimated benefit is .91 active sessions, 17.56% of total activity.
    Action
    Verify whether incremental shipping was used for standby databases.
    Symptoms That Led to the Finding:
    Wait class "Configuration" was consuming significant database time.
    Impact is .91 active sessions, 17.63% of total activity.
    Finding 5: Buffer Busy
    Impact is .56 active sessions, 10.87% of total activity.
    A hot data block with concurrent read and write activity was found. The block
    belongs to segment "ICX.ICX_SESSIONS" and is block 243489 in file 36.
    Recommendation 1: Application Analysis
    Estimated benefit is .56 active sessions, 10.87% of total activity.
    Action
    Investigate application logic to find the cause of high concurrent read
    and write activity to the data present in this block.
    Related Object
    Database block with object number 37562, file number 36 and block
    number 243489.
    Rationale
    The SQL statement with SQL_ID "5d7957yktf3nn" spent significant time on
    "buffer busy" waits for the hot block.
    Related Object
    SQL statement with SQL_ID 5d7957yktf3nn.
    UPDATE ICX_SESSIONS SET TIME_OUT = :B2 WHERE SESSION_ID = :B1
    Rationale
    The SQL statement with SQL_ID "326up1aym56dd" spent significant time on
    "buffer busy" waits for the hot block.
    Related Object
    SQL statement with SQL_ID 326up1aym56dd.
    UPDATE ICX_SESSIONS SET LAST_CONNECT = SYSDATE WHERE SESSION_ID = :B1
    Recommendation 2: Schema Changes
    Estimated benefit is .56 active sessions, 10.87% of total activity.
    Action
    Consider rebuilding the TABLE "ICX.ICX_SESSIONS" with object ID 37562
    using a higher value for PCTFREE.
    Related Object
    Database object with ID 37562.
    Symptoms That Led to the Finding:
    Wait class "Concurrency" was consuming significant database time.
    Impact is 2.53 active sessions, 48.87% of total activity.
    Finding 6: Undersized SGA
    Impact is .38 active sessions, 7.37% of total activity.
    The SGA was inadequately sized, causing additional I/O or hard parses.
    The value of parameter "sga_target" was "4096 M" during the analysis period.
    Recommendation 1: Database Configuration
    Estimated benefit is .12 active sessions, 2.33% of total activity.
    Action
    Increase the size of the SGA by setting the parameter "sga_target" to
    4608 M.
    Symptoms That Led to the Finding:
    Wait class "User I/O" was consuming significant database time.
    Impact is .7 active sessions, 13.57% of total activity.
    Hard parsing of SQL statements was consuming significant database time.
    Impact is .13 active sessions, 2.51% of total activity.
    Contention for latches related to the shared pool was consuming
    significant database time.
    Impact is 0 active sessions, .03% of total activity.
    Wait class "Concurrency" was consuming significant database time.
    Impact is 2.53 active sessions, 48.87% of total activity.
    Finding 7: Commits and Rollbacks
    Impact is .28 active sessions, 5.42% of total activity.
    Waits on event "log file sync" while performing COMMIT and ROLLBACK operations
    were consuming significant database time.
    Recommendation 1: Host Configuration
    Estimated benefit is .28 active sessions, 5.42% of total activity.
    Action
    Investigate the possibility of improving the performance of I/O to the
    online redo log files.
    Rationale
    The average size of writes to the online redo log files was 163 K and
    the average time per write was 68 milliseconds.
    Symptoms That Led to the Finding:
    Wait class "Commit" was consuming significant database time.
    Impact is .28 active sessions, 5.42% of total activity.
    Finding 8: Undo I/O
    Impact is .18 active sessions, 3.53% of total activity.
    Undo I/O was a significant portion (26%) of the total database I/O.
    No recommendations are available.
    Symptoms That Led to the Finding:
    The throughput of the I/O subsystem was significantly lower than
    expected.
    Impact is .08 active sessions, 1.46% of total activity.
    Wait class "User I/O" was consuming significant database time.
    Impact is .7 active sessions, 13.57% of total activity.
    Finding 9: CPU Usage
    Impact is .13 active sessions, 2.57% of total activity.
    Time spent on the CPU by the instance was responsible for a substantial part
    of database time.
    Recommendation 1: SQL Tuning
    Estimated benefit is .13 active sessions, 2.57% of total activity.
    Finding 10: Top SQL By I/O
    Impact is .11 active sessions, 2.21% of total activity.
    Individual SQL statements responsible for significant user I/O wait were
    found.
    Recommendation 1: SQL Tuning
    Estimated benefit is .11 active sessions, 2.22% of total activity.
    Action
    Run SQL Tuning Advisor on the SQL statement with SQL_ID "b3pnc5yctv2z5".
    Related Object
    SQL statement with SQL_ID b3pnc5yctv2z5.
    INSERT INTO ZX_TRANSACTION_LINES_GT( APPLICATION_ID ,ENTITY_CODE
    ,EVENT_CLASS_CODE ,TRX_ID ,TRX_LEVEL_TYPE ,TRX_LINE_ID ,LINE_CLASS
    ,LINE_LEVEL_ACTION ,TRX_LINE_TYPE ,TRX_LINE_DATE
    ,LINE_AMT_INCLUDES_TAX_FLAG ,LINE_AMT ,TRX_LINE_QUANTITY ,UNIT_PRICE
    ,PRODUCT_ID ,PRODUCT_ORG_ID ,UOM_CODE ,PRODUCT_CODE ,SHIP_TO_PARTY_ID
    ,SHIP_FROM_PARTY_ID ,BILL_TO_PARTY_ID ,BILL_FROM_PARTY_ID
    ,SHIP_FROM_PARTY_SITE_ID ,BILL_FROM_PARTY_SITE_ID
    ,SHIP_TO_LOCATION_ID ,SHIP_FROM_LOCATION_ID ,BILL_TO_LOCATION_ID
    ,SHIP_THIRD_PTY_ACCT_ID ,SHIP_THIRD_PTY_ACCT_SITE_ID ,HISTORICAL_FLAG
    ,TRX_LINE_CURRENCY_CODE ,TRX_LINE_CURRENCY_CONV_DATE
    ,TRX_LINE_CURRENCY_CONV_RATE ,TRX_LINE_CURRENCY_CONV_TYPE
    ,TRX_LINE_MAU ,TRX_LINE_PRECISION ,HISTORICAL_TAX_CODE_ID
    ,TRX_BUSINESS_CATEGORY ,PRODUCT_CATEGORY ,PRODUCT_FISC_CLASSIFICATION
    ,LINE_INTENDED_USE ,PRODUCT_TYPE ,USER_DEFINED_FISC_CLASS
    ,ASSESSABLE_VALUE ,INPUT_TAX_CLASSIFICATION_CODE ,ACCOUNT_CCID
    ,BILL_THIRD_PTY_ACCT_ID ,BILL_THIRD_PTY_ACCT_SITE_ID ,TRX_LINE_NUMBER
    ,TRX_LINE_DESCRIPTION ,PRODUCT_DESCRIPTION ,USER_UPD_DET_FACTORS_FLAG
    ,DEFAULTING_ATTRIBUTE1 ) SELECT :B4 ,:B3 ,:B2
    ,PRL.REQUISITION_HEADER_ID ,:B1 ,PRL.REQUISITION_LINE_ID ,'INVOICE'
    ,NVL(PRL.TAX_ATTRIBUTE_UPDATE_CODE,'UPDATE') ,'ITEM'
    ,NVL(PRL.NEED_BY_DATE, SYSDATE) ,'N' ,NVL(PRL.AMOUNT,
    PRL.UNIT_PRICE*PRL.QUANTITY) ,PRL.QUANTITY ,PRL.UNIT_PRICE
    ,PRL.ITEM_ID ,(SELECT FSP.INVENTORY_ORGANIZATION_ID FROM
    FINANCIALS_SYSTEM_PARAMS_ALL FSP WHERE FSP.ORG_ID=PRL.ORG_ID)
    ,(SELECT MUM.UOM_CODE FROM MTL_UNITS_OF_MEASURE MUM WHERE
    MUM.UNIT_OF_MEASURE=PRL.UNIT_MEAS_LOOKUP_CODE) ,MSIB.SEGMENT1
    ,PRL.DESTINATION_ORGANIZATION_ID ,PV.PARTY_ID ,PRH.ORG_ID
    ,PV.PARTY_ID ,PVS.PARTY_SITE_ID ,PVS.PARTY_SITE_ID
    ,PRL.DELIVER_TO_LOCATION_ID ,(SELECT HZPS.LOCATION_ID FROM
    HZ_PARTY_SITES HZPS WHERE HZPS.PARTY_SITE_ID = PVS.PARTY_SITE_ID)
    ,(SELECT LOCATION_ID FROM HR_ALL_ORGANIZATION_UNITS WHERE
    ORGANIZATION_ID=PRH.ORG_ID) ,PRL.VENDOR_ID ,PRL.VENDOR_SITE_ID ,NULL
    ,NVL(PRL.CURRENCY_CODE, :B9 ) ,NVL2(PRL.CURRENCY_CODE, PRL.RATE_DATE,
    SYSDATE) ,NVL2(PRL.CURRENCY_CODE, PRL.RATE, :B8 )
    ,NVL2(PRL.CURRENCY_CODE, PRL.RATE_TYPE, :B7 )
    ,FC.MINIMUM_ACCOUNTABLE_UNIT ,NVL(FC.PRECISION, 2) ,NULL
    ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.TRX_BUSINESS_CATEGORY, NULL),
    NULL ) ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.PRODUCT_CATEGORY, NULL), NULL )
    ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.PRODUCT_FISC_CLASSIFICATION,
    NULL), NULL ) ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.LINE_INTENDED_USE, NULL), NULL )
    ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.PRODUCT_TYPE, NULL), NULL )
    ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.USER_DEFINED_FISC_CLASS, NULL),
    NULL ) ,DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.ASSESSABLE_VALUE, NULL), NULL )
    ,DECODE(:B6 , 'REQIMPORT', PRL.TAX_NAME,
    DECODE(PRL.TAX_ATTRIBUTE_UPDATE_CODE, 'CREATE',
    NVL2(PRL.PARENT_REQ_LINE_ID, ZXLDET.INPUT_TAX_CLASSIFICATION_CODE,
    NULL), NULL ) ) ,NVL((SELECT PRD.CODE_COMBINATION_ID FROM
    PO_REQ_DISTRIBUTIONS_ALL PRD WHERE PRD.REQUISITION_LINE_ID =
    PRL.REQUISITION_LINE_ID AND ROWNUM = 1), MSIB.EXPENSE_ACCOUNT )
    ,PV.VENDOR_ID ,PVS.VENDOR_SITE_ID ,PRL.LINE_NUM ,PRL.ITEM_DESCRIPTION
    ,PRL.ITEM_DESCRIPTION ,(SELECT 'Y' FROM DUAL WHERE :B6 = 'REQIMPORT'
    AND PRL.TAX_NAME IS NOT NULL) ,PRL.DESTINATION_ORGANIZATION_ID FROM
    PO_REQUISITION_HEADERS_ALL PRH, PO_REQUISITION_LINES_ALL PRL,
    ZX_LINES_DET_FACTORS ZXLDET, PO_VENDORS PV, PO_VENDOR_SITES_ALL PVS,
    MTL_SYSTEM_ITEMS_B MSIB, FND_CURRENCIES FC WHERE
    PRH.REQUISITION_HEADER_ID = :B5 AND PRH.REQUISITION_HEADER_ID =
    PRL.REQUISITION_HEADER_ID AND ZXLDET.APPLICATION_ID(+) = :B4 AND
    ZXLDET.ENTITY_CODE(+) = :B3 AND ZXLDET.EVENT_CLASS_CODE(+) = :B2 AND
    ZXLDET.TRX_LEVEL_TYPE(+) = :B1 AND ZXLDET.TRX_LINE_ID(+) =
    PRL.PARENT_REQ_LINE_ID AND PV.VENDOR_ID(+) = PRL.VENDOR_ID AND
    PVS.VENDOR_SITE_ID(+) = PRL.VENDOR_SITE_ID AND
    MSIB.INVENTORY_ITEM_ID(+) = PRL.ITEM_ID AND MSIB.ORGANIZATION_ID(+) =
    PRL.ORG_ID AND FC.CURRENCY_CODE(+) = PRL.CURRENCY_CODE AND
    NVL(PRL.MODIFIED_BY_AGENT_FLAG, 'N') = 'N' AND NVL(PRL.CANCEL_FLAG,
    'N') = 'N' AND NVL(PRL.CLOSED_CODE, 'OPEN') <> 'FINALLY CLOSED' AND
    PRL.LINE_LOCATION_ID IS NULL AND PRL.AT_SOURCING_FLAG IS NULL
    Rationale
    SQL statement with SQL_ID "b3pnc5yctv2z5" was executed 3 times and had
    an average elapsed time of 138 seconds.
    Rationale
    Average time spent in User I/O wait events per execution was 137
    seconds.
    Symptoms That Led to the Finding:
    Wait class "User I/O" was consuming significant database time.
    Impact is .7 active sessions, 13.57% of total activity.
    Additional Information
    Miscellaneous Information
    Wait class "Application" was not consuming significant database time.
    Wait class "Network" was not consuming significant database time.
    Session connect and disconnect calls were not consuming significant database
    time.
    The database's maintenance windows were active during 100% of the analysis
    period.
    Regards
    Athish

    Few days are am facing serious of performance problem in our Production instanceFor production issues, please log a SR.
    Was this working before? If yes, any changes been done recently?
    Do you have the statistics collected up to date?
    Please see these docs.
    AutoInvoice Performance Issue When Processing Tax [ID 1059275.1]
    R12 : System Hangs When Attempting To Save Blanket Release After Applying Patch 11817843 [ID 1333336.1]
    Thanks,
    Hussein

  • Performance issues when creating a Report / Query in Discoverer

    Hi forum,
    Hope you are can help, it involves a performance issues when creating a Report / Query.
    I have a Discoverer Report that currently takes less than 5 seconds to run. After I add a condition to bring back Batch Status that = ‘Posted’ we cancelled the query after reaching 20 minutes as this is way too long. If I remove the condition the query time goes back to less than 5 seconds.
    Please see attached the SQL Inspector Plan:
    Before Condition
    SELECT STATEMENT
    SORT GROUP BY
    VIEW SYS
    SORT GROUP BY
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    TABLE ACCESS BY INDEX ROWID GL.GL_CODE_COMBINATIONS
    AND-EQUAL
    INDEX RANGE SCAN GL.GL_CODE_COMBINATIONS_N2
    INDEX RANGE SCAN GL.GL_CODE_COMBINATIONS_N1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUES_N1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUE_SETS
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUE_SETS_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES_TL
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUES_TL_U1
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUE_NORM_HIER_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_LINES
    INDEX RANGE SCAN GL.GL_JE_LINES_N1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_HEADERS
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_DAILY_CONVERSION_TYPES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_SOURCES_TL
    INDEX UNIQUE SCAN GL.GL_JE_SOURCES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_CATEGORIES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    INDEX UNIQUE SCAN GL.GL_BUDGET_VERSIONS_U1
    INDEX UNIQUE SCAN GL.GL_ENCUMBRANCE_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_BATCHES
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_PERIODS
    INDEX RANGE SCAN GL.GL_PERIODS_U1
    After Condition
    SELECT STATEMENT
    SORT GROUP BY
    VIEW SYS
    SORT GROUP BY
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    TABLE ACCESS FULL GL.GL_JE_BATCHES
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_HEADERS
    INDEX RANGE SCAN GL.GL_JE_HEADERS_N1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_ENCUMBRANCE_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_DAILY_CONVERSION_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_BUDGET_VERSIONS_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_SOURCES_TL
    INDEX UNIQUE SCAN GL.GL_JE_SOURCES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_CATEGORIES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_LINES
    INDEX RANGE SCAN GL.GL_JE_LINES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_CODE_COMBINATIONS
    INDEX UNIQUE SCAN GL.GL_CODE_COMBINATIONS_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_PERIODS
    INDEX RANGE SCAN GL.GL_PERIODS_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUES_N1
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUE_NORM_HIER_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES_TL
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUES_TL_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUE_SETS
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUE_SETS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    Is there anything i can do in Discoverer Desktop / Administration to avoid this problem.
    Many thanks,
    Lance

    Hi Rod,
    I've tried the condition (Batch Status||'' = 'Posted') as you suggested, but the qeury time is still over 20 mins. To test i changed it to (Batch Status||'' = 'Unposted') and the query was returned within seconds again.
    I’ve been doing some more digging and have found the database view that is linked to the Journal Batches folder. See below.
    I think the problem is with the column using DECODE. When querying the column in TOAD the value of ‘P’ is returned. But in discoverer the condition is done on the value ‘Posted’. I’m not too sure how DECODE works, but think this could be the causing some sort of issue with Full Table Scans. How do we get around this?
    Lance
    DECODE( JOURNAL_BATCH1.STATUS,
    '+', 'Unable to validate or create CTA',
    '+*', 'Was unable to validate or create CTA',
    '-','Invalid or inactive rounding differences account in journal entry',
    '-*', 'Modified invalid or inactive rounding differences account in journal entry',
    '<', 'Showing sequence assignment failure',
    '<*', 'Was showing sequence assignment failure',
    '>', 'Showing cutoff rule violation',
    '>*', 'Was showing cutoff rule violation',
    'A', 'Journal batch failed funds reservation',
    'A*', 'Journal batch previously failed funds reservation',
    'AU', 'Showing batch with unopened period',
    'B', 'Showing batch control total violation',
    'B*', 'Was showing batch control total violation',
    'BF', 'Showing batch with frozen or inactive budget',
    'BU', 'Showing batch with unopened budget year',
    'C', 'Showing unopened reporting period',
    'C*', 'Was showing unopened reporting period',
    'D', 'Selected for posting to an unopened period',
    'D*', 'Was selected for posting to an unopened period',
    'E', 'Showing no journal entries for this batch',
    'E*', 'Was showing no journal entries for this batch',
    'EU', 'Showing batch with unopened encumbrance year',
    'F', 'Showing unopened reporting encumbrance year',
    'F*', 'Was showing unopened reporting encumbrance year',
    'G', 'Showing journal entry with invalid or inactive suspense account',
    'G*', 'Was showing journal entry with invalid or inactive suspense account',
    'H', 'Showing encumbrance journal entry with invalid or inactive reserve account',
    'H*', 'Was showing encumbrance journal entry with invalid or inactive reserve account',
    'I', 'In the process of being posted',
    'J', 'Showing journal control total violation',
    'J*', 'Was showing journal control total violation',
    'K', 'Showing unbalanced intercompany journal entry',
    'K*', 'Was showing unbalanced intercompany journal entry',
    'L', 'Showing unbalanced journal entry by account category',
    'L*', 'Was showing unbalanced journal entry by account category',
    'M', 'Showing multiple problems preventing posting of batch',
    'M*', 'Was showing multiple problems preventing posting of batch',
    'N', 'Journal produced error during intercompany balance processing',
    'N*', 'Journal produced error during intercompany balance processing',
    'O', 'Unable to convert amounts into reporting currency',
    'O*', 'Was unable to convert amounts into reporting currency',
    'P', 'Posted',
    'Q', 'Showing untaxed journal entry',
    'Q*', 'Was showing untaxed journal entry',
    'R', 'Showing unbalanced encumbrance entry without reserve account',
    'R*', 'Was showing unbalanced encumbrance entry without reserve account',
    'S', 'Already selected for posting',
    'T', 'Showing invalid period and conversion information for this batch',
    'T*', 'Was showing invalid period and conversion information for this batch',
    'U', 'Unposted',
    'V', 'Journal batch is unapproved',
    'V*', 'Journal batch was unapproved',
    'W', 'Showing an encumbrance journal entry with no encumbrance type',
    'W*', 'Was showing an encumbrance journal entry with no encumbrance type',
    'X', 'Showing an unbalanced journal entry but suspense not allowed',
    'X*', 'Was showing an unbalanced journal entry but suspense not allowed',
    'Z', 'Showing invalid journal entry lines or no journal entry lines',
    'Z*', 'Was showing invalid journal entry lines or no journal entry lines', NULL ),

  • Performance Issue in a ABAP Report

    Hi All,
    I am facing a big performance issue in a abap program which produce the cash flow details our group of company. This is the logic I used to develop the report. (It is a SAP Script)
    - First I am getting the closed customer payment records from the table BSAD ( eg: - Type 'DZ')
    - Then I am getting the correcponding invoices from the BSAD using the same BELNR ( eg :- Type <> 'DZ')
    - Then checking the GL Entry (BSIS) for the correspongding records which select in the second stage.
    - In a Z tabel I am keeping the account list by grouping   seperate section ( Eg: - Customer recipts, fixed assets...etc).
    I have done the same thing to get the open Item balances also.
    Report is correct and running perfectly, but my issue is it's takeing long time to process. Because of this I made this report to run as a background job. But still it is taking such a long time. ( For Eg: - If 1000 records selected from the first stage, it will take about more than onr hour to process, which is not good enough to run in a live environment)
    Pls advice me how to improve the preformance of this.

    Hi Ravi,
    I am sorry I had problem in my internet connection yesterday, because of that i couldn't reply u. Here is my code. I don't is there any way to send the code as a attachement since it is a little bit big one. I am going to paste that here any way.
    Here zcashflow_matrix is the "Z" table where I am going to keep my account details by grouping.
    REPORT ZCASH_FLOW.
    INCLUDE <%_LIST>.
    *       Author             Thanura .......                            *
    TYPES   :BEGIN OF ty_voucher1,
              kunnr LIKE bseg-kunnr,
              dmbtr LIKE bseg-dmbtr,
              belnr LIKE bseg-belnr,
              hkont LIKE bseg-hkont,
              shkzg LIKE bseg-shkzg,
              xblnr LIKE bsad-xblnr,
              budat LIKE bsad-bldat,
              blart LIKE bsad-blart,
              bldat LIKE bsad-bldat,
              lifnr LIKE bseg-lifnr,
              END OF ty_voucher1.
    DATA     :it_voucher1 TYPE STANDARD TABLE OF ty_voucher1 ,
               wa_voucher1 TYPE ty_voucher1.
    DATA    : it_voucher2 TYPE STANDARD TABLE OF ty_voucher1,
               wa_voucher2 TYPE ty_voucher1.
    DATA    : it_voucher3 TYPE STANDARD TABLE OF ty_voucher1,
               wa_voucher3 TYPE ty_voucher1.
    Data : w_ITCPO type ITCPO.
    Data : w_ITCPP type ITCPP.
    DATA : w_Rcptamt LIKE bseg-dmbtr,
            w_Netamt LIKE bseg-dmbtr,
            w_IntIncomeAmt LIKE bseg-dmbtr,
            w_IntIncome LIKE bseg-dmbtr,
            w_FixedAmt LIKE bseg-dmbtr,
            w_fixedasst LIKE bseg-dmbtr,
            w_Sundry LIKE bseg-dmbtr,
            w_SundryAmt LIKE bseg-dmbtr,
            w_SuppayAmt LIKE bseg-dmbtr,
            w_Suppay LIKE bseg-dmbtr,
            w_SuppayAmt1 LIKE bseg-dmbtr,
            w_Suppay1 LIKE bseg-dmbtr,
            w_DutyAmt LIKE bseg-dmbtr,
            w_Duty LIKE bseg-dmbtr,
            w_SalaryAmt LIKE bseg-dmbtr,
            w_Salary LIKE bseg-dmbtr,
            w_TaxAmt LIKE bseg-dmbtr,
            w_Tax LIKE bseg-dmbtr,
            w_TaxAmt1 LIKE bseg-dmbtr,
            w_Tax1 LIKE bseg-dmbtr,
            w_SellAmt LIKE bseg-dmbtr,
            w_Sell LIKE bseg-dmbtr,
            w_AdminAmt LIKE bseg-dmbtr,
            w_Admin LIKE bseg-dmbtr,
            w_loanAmt LIKE bseg-dmbtr,
            w_loan LIKE bseg-dmbtr,
            w_ManAmt LIKE bseg-dmbtr,
            w_Man LIKE bseg-dmbtr,
            w_CapitalAmt LIKE bseg-dmbtr,
            w_Capital LIKE bseg-dmbtr,
            w_GroupAmt LIKE bseg-dmbtr,
            w_Group LIKE bseg-dmbtr,
            w_IntAmt LIKE bseg-dmbtr,
            w_Int LIKE bseg-dmbtr,
            w_InterAmt LIKE bseg-dmbtr,
            w_Inter LIKE bseg-dmbtr,
            w_AdPayAmt LIKE bseg-dmbtr,
            w_AdPay LIKE bseg-dmbtr,
            w_GTotal LIKE bseg-dmbtr,
            W_COMPANYNAME like zcompany-copmname.
    DATA : w_ORcptamt LIKE bseg-dmbtr,
            w_ONetamt LIKE bseg-dmbtr,
            w_OIntIncomeAmt LIKE bseg-dmbtr,
            w_OIntIncome LIKE bseg-dmbtr,
            w_OFixedAmt LIKE bseg-dmbtr,
            w_Ofixedasst LIKE bseg-dmbtr,
            w_OSundry LIKE bseg-dmbtr,
            w_OSundryAmt LIKE bseg-dmbtr,
            w_OSuppayAmt LIKE bseg-dmbtr,
            w_OSuppay LIKE bseg-dmbtr,
            w_OSuppayAmt1 LIKE bseg-dmbtr,
            w_OSuppay1 LIKE bseg-dmbtr,
            w_ODutyAmt LIKE bseg-dmbtr,
            w_ODuty LIKE bseg-dmbtr,
            w_OSalaryAmt LIKE bseg-dmbtr,
            w_OSalary LIKE bseg-dmbtr,
            w_OTaxAmt LIKE bseg-dmbtr,
            w_OTax LIKE bseg-dmbtr,
            w_OTaxAmt1 LIKE bseg-dmbtr,
            w_OTax1 LIKE bseg-dmbtr,
            w_OSellAmt LIKE bseg-dmbtr,
            w_OSell LIKE bseg-dmbtr,
            w_OAdminAmt LIKE bseg-dmbtr,
            w_OAdmin LIKE bseg-dmbtr,
            w_OloanAmt LIKE bseg-dmbtr,
            w_Oloan LIKE bseg-dmbtr,
            w_OManAmt LIKE bseg-dmbtr,
            w_OMan LIKE bseg-dmbtr,
            w_OCapitalAmt LIKE bseg-dmbtr,
            w_OCapital LIKE bseg-dmbtr,
            w_OGroupAmt LIKE bseg-dmbtr,
            w_OGroup LIKE bseg-dmbtr,
            w_OIntAmt LIKE bseg-dmbtr,
            w_OInt LIKE bseg-dmbtr,
            w_OInterAmt LIKE bseg-dmbtr,
            w_OInter LIKE bseg-dmbtr,
            w_OAdPayAmt LIKE bseg-dmbtr,
            w_OAdPay LIKE bseg-dmbtr.
    DATA : w_NNetamt LIKE bseg-dmbtr,
            w_NIntIncome LIKE bseg-dmbtr,
            w_Nfixedasst LIKE bseg-dmbtr,
            w_NSundry LIKE bseg-dmbtr,
            w_NSuppay LIKE bseg-dmbtr,
            w_NSuppay1 LIKE bseg-dmbtr,
            w_NDuty LIKE bseg-dmbtr,
            w_NSalary LIKE bseg-dmbtr,
            w_NTax LIKE bseg-dmbtr,
            w_NTax1 LIKE bseg-dmbtr,
            w_NSell LIKE bseg-dmbtr,
            w_NAdmin LIKE bseg-dmbtr,
            w_Nloan LIKE bseg-dmbtr,
            w_NMan LIKE bseg-dmbtr,
            w_NCapital LIKE bseg-dmbtr,
            w_NGroup LIKE bseg-dmbtr,
            w_NInt LIKE bseg-dmbtr,
            w_NInter LIKE bseg-dmbtr,
            w_NAdPay LIKE bseg-dmbtr.
    RANGES : r_bwart FOR  bsad-blart.
    TABLES: bsad.
    *       Internal tables          Begin with IT_                       *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:      p_bukrs LIKE bsad-bukrs OBLIGATORY.
    SELECT-OPTIONS:  s_bldat FOR  bsad-bldat OBLIGATORY.
    * SELECT-OPTIONS:   s_hkont FOR bsad-hkont .
    PARAMETERS:      p_gjahr LIKE bkpf-gjahr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1 .
    * PARAMETERS : w_local   TYPE char1 RADIOBUTTON GROUP g1 DEFAULT 'X'. .
    * PARAMETERS : w_curr  TYPE char1 RADIOBUTTON GROUP g1 .
    w_ITCPO-TDNEWID = 'X'.
    *w_itcpo-tdgetotf   = 'X'.
    *opern form
       CALL FUNCTION 'OPEN_FORM'
        EXPORTING
    *        APPLICATION                       = 'TX'
    *        ARCHIVE_INDEX                     =
    *        ARCHIVE_PARAMS                    =
    *         DEVICE                            = 'PRINTER'
    *        DIALOG                            = ' '
          form                                 = 'ZCASHFLOW_FORM1'
    *        LANGUAGE                          = SY-LANGU
             OPTIONS                           = w_ITCPO
    *        MAIL_SENDER                       =
    *        MAIL_RECIPIENT                    =
    *        MAIL_APPL_OBJECT                  =
    *        RAW_DATA_INTERFACE                = '*'
    *        SPONUMIV                          =
    *      IMPORTING
    *        LANGUAGE                          =
    *        NEW_ARCHIVE_PARAMS                =
    *        RESULT                            =
    *      EXCEPTIONS
    *        CANCELED                          = 1
    *        DEVICE                            = 2
    *        FORM                              = 3
    *        OPTIONS                           = 4
    *        UNCLOSED                          = 5
    *        MAIL_OPTIONS                      = 6
    *        ARCHIVE_ERROR                     = 7
    *        INVALID_FAX_NUMBER                = 8
    *        MORE_PARAMS_NEEDED_IN_BATCH       = 9
    *        SPOOL_ERROR                       = 10
    *        CODEPAGE                          = 11
    *        OTHERS                            = 12
       IF sy-subrc <> 0.
    *   message id sy-msgid type sy-msgty number sy-msgno
    *           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       ENDIF.
    PERFORM select_data_closed.
    PERFORM select_data_open.
    * calculate the net figures
    w_NNetamt = w_Netamt + w_ONetamt.
    w_NIntIncome = w_IntIncome + w_OIntIncome.
    *w_NInCompRct = w_InCompRct + w_OInCompRct.
    w_NfixedAsst = w_fixedAsst + w_OfixedAsst.
    w_NSundry = w_Sundry + w_OSundry.
    w_NSuppay = w_Suppay + w_OSuppay.
    w_NSuppay1 = w_Suppay1 + w_OSuppay1.
    w_NDuty = w_Duty + w_ODuty.
    w_NSalary = w_Salary + w_OSalary.
    w_NTax = w_Tax + w_OTax.
    w_NTax1 = w_Tax1 + w_OTax1.
    w_NSell = w_Sell + w_OSell.
    w_NAdmin = w_Admin + w_OAdmin.
    w_NCapital = w_Capital + w_OCapital.
    w_Nloan = w_loan + w_Oloan.
    w_NMan = w_Man + w_OMan.
    w_NGroup = w_Group + w_OGroup.
    w_NInt = w_Int + w_OInt.
    w_NInter = w_Inter + w_OInter.
    w_NAdPay = w_AdPay + w_OAdPay.
    w_GTotal = ( w_NNetamt + w_NIntIncome + w_NfixedAsst + w_NSundry ) - (
    w_NSuppay + w_NSuppay1 + w_NDuty + w_NSalary + w_NTax + w_NTax1 +
    w_NSell + w_NAdmin + w_NCapital + w_Nloan + w_NMan + w_NGroup + w_NInt +
    w_NInter + w_NAdPay ).
    * Write the Main Account Balance
         CALL FUNCTION 'WRITE_FORM'
           EXPORTING
             element  = 'MAIN'
             function = 'SET'
             type     = 'BODY'
             window   = 'MAIN'.
         IF sy-subrc <> 0.
    **   message id sy-msgid type sy-msgty number sy-msgno
    **           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
         ENDIF.
    w_ITCPP-TDNEWID = 'X'.
       CALL FUNCTION 'CLOSE_FORM'
          IMPORTING
             RESULT                         = w_ITCPP
    *        RDI_RESULT                     =
    *      TABLES
    *        OTFDATA                        =
    *      EXCEPTIONS
    *        UNOPENED                       = 1
    *        BAD_PAGEFORMAT_FOR_PRINT       = 2
    *        SEND_ERROR                     = 3
    *        SPOOL_ERROR                    = 4
    *        CODEPAGE                       = 5
    *        OTHERS                         = 6
       IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    FORM select_data_closed.
       SELECT SINGLE copmname INTO w_companyname
          FROM zcompany
           WHERE  copcode = p_bukrs.
    * Select the receipts
       SELECT SUM( dmbtr ) AS dmbtr belnr kunnr hkont shkzg xblnr budat
    blart bldat
       INTO CORRESPONDING FIELDS OF TABLE it_voucher3
       FROM  bsad
       WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
               AND augdt IN s_bldat
               AND blart = 'DZ'
    *            AND blart = 'DZ' and shkzg = 'S'
               GROUP BY kunnr belnr hkont shkzg xblnr budat blart bldat.
       SORT it_voucher3 BY kunnr.
       LOOP AT it_voucher3 INTO wa_voucher3.
    * Select the invoices
         SELECT SUM( dmbtr ) AS dmbtr belnr kunnr hkont shkzg xblnr budat
    blart bldat
         INTO CORRESPONDING FIELDS OF TABLE it_voucher1
         FROM  bsad
         WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
                 AND augdt IN s_bldat
                 AND blart <> 'DZ' AND
                 augbl = wa_voucher3-belnr AND
                 kunnr = wa_voucher3-kunnr
                 GROUP BY belnr kunnr hkont shkzg xblnr budat blart bldat.
         LOOP AT it_voucher1 INTO wa_voucher1.
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_Rcptamt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX001' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_Rcptamt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX001' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Netamt = w_Netamt + w_Rcptamt.
                  continue.
                ENDIF.
           ELSE.
                 w_Netamt = w_Netamt + w_Rcptamt.
                 continue.
           ENDIF.
    * Interest Income
          SELECT SINGLE dmbtr FROM bsis INTO w_IntIncomeAmt WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX002' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_IntIncomeAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX002' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_IntIncome = w_IntIncome + w_IntIncomeAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_IntIncome = w_IntIncome + w_IntIncomeAmt.
                 continue.
           ENDIF.
    * Sale Of fixed Assets
          SELECT SINGLE dmbtr FROM bsis INTO w_FixedAmt WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX004' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_FixedAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX004' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_fixedasst = w_fixedasst + w_FixedAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_fixedasst = w_fixedasst + w_FixedAmt.
                 continue.
           ENDIF.
    * Gl Receipts ( Sundry Income)
          SELECT SINGLE dmbtr FROM bsis INTO w_SundryAmt WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX005' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_SundryAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX005' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Sundry = w_Sundry + w_SundryAmt.
                                continue.
                ENDIF.
           ELSE.
                 w_Sundry = w_Sundry + w_SundryAmt.
                              continue.
           ENDIF.
         ENDLOOP.
       ENDLOOP.
    *Out Flow
    r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'KZ'.
    APPEND r_bwart TO r_bwart.
    r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'VZ'.
    APPEND r_bwart TO r_bwart.
       SELECT SUM( dmbtr ) AS dmbtr belnr lifnr hkont shkzg xblnr budat
    blart bldat
       INTO CORRESPONDING FIELDS OF TABLE it_voucher3
       FROM  bsak
       WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
               AND augdt IN s_bldat
               AND blart IN  r_bwart
    *            AND blart = 'DZ' and shkzg = 'S'
               GROUP BY lifnr belnr hkont shkzg xblnr budat blart bldat.
       SORT it_voucher3 BY lifnr.
       LOOP AT it_voucher3 INTO wa_voucher3.
    * Select the invoices
         SELECT SUM( dmbtr ) AS dmbtr belnr lifnr hkont shkzg xblnr budat
    blart bldat
         INTO CORRESPONDING FIELDS OF TABLE it_voucher1
         FROM  bsak
         WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
                 AND augdt IN s_bldat
                 AND blart NOT IN r_bwart AND
                 augbl = wa_voucher3-belnr AND
                 lifnr = wa_voucher3-lifnr
                 GROUP BY belnr lifnr hkont shkzg xblnr budat blart bldat.
         LOOP AT it_voucher1 INTO wa_voucher1.
    * Supplier Payments  (LOCAL)
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_SupPayAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY001' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_SupPayAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY001' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_SupPay = w_SupPay + w_SupPayAmt.
                                continue.
                ENDIF.
           ELSE.
                 w_SupPay = w_SupPay + w_SupPayAmt.
                              continue.
           ENDIF.
    * supplier Payments  (Foreign )
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_SupPayAmt1 WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY002' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_SupPayAmt1  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY002' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_SupPay1 = w_SupPay1 + w_SupPayAmt1.
                  continue.
                ENDIF.
           ELSE.
                 w_SupPay1 = w_SupPay1 + w_SupPayAmt1.
                  continue.
           ENDIF.
    * duty/clearing expenses
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_DutyAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY003' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_DutyAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY003' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Duty = w_Duty + w_DutyAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Duty = w_Duty + w_DutyAmt.
                  continue.
           ENDIF.
    * Salary /EPF/ETF/MSPS/OVERTIME
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_SalaryAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY004' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_SalaryAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY004' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Salary = w_Salary + w_SalaryAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Salary = w_Salary + w_SalaryAmt.
                  continue.
           ENDIF.
    * Income Taxes
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_TaxAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY005' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_TaxAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY005' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Tax = w_Tax + w_TaxAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Tax = w_Tax + w_TaxAmt.
                  continue.
           ENDIF.
    * other taxes ( VAT: TT:Debit tax )
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_TaxAmt1 WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY006' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_TaxAmt1  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY006' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Tax1 = w_Tax1 + w_TaxAmt1.
                  continue.
                ENDIF.
           ELSE.
                 w_Tax1 = w_Tax1 + w_TaxAmt1.
                  continue.
           ENDIF.
    * Selling  & Promotional Costs
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_SellAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY007' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_SellAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY007' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Sell = w_Sell + w_SellAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Sell = w_Sell + w_SellAmt.
                  continue.
           ENDIF.
    * Admistration costs
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_AdminAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY008' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_AdminAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY008' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Admin = w_Admin + w_AdminAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Admin = w_Admin + w_AdminAmt.
                  continue.
           ENDIF.
    * Capital Expenditure
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_CapitalAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY009' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_CapitalAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY009' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Capital = w_Capital + w_CapitalAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Capital = w_Capital + w_CapitalAmt.
                  continue.
           ENDIF.
    * Loan repayments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_LoanAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY010' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_LoanAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY010' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Loan = w_Loan + w_LoanAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Loan = w_Loan + w_LoanAmt.
                  continue.
           ENDIF.
    * maangment fees
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_ManAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY011' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_ManAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY011' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Man = w_Man + w_ManAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Man = w_Man + w_ManAmt.
                  continue.
           ENDIF.
    * Group charges
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_GroupAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY012' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_GroupAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY012' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Group = w_Group + w_GroupAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Group = w_Group + w_GroupAmt.
                  continue.
           ENDIF.
    * Interest Payments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_IntAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY013' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_IntAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY013' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Int = w_Int + w_IntAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Int = w_Int + w_IntAmt.
                  continue.
           ENDIF.
    * Other Intercompany payments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_InterAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY014' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_InterAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY014' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Inter = w_Inter + w_InterAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Inter = w_Inter + w_InterAmt.
                  continue.
           ENDIF.
    * Advacnes/Prepayments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_AdPayAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY015' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_AdPayAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY015' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_AdPay = w_AdPay + w_AdPayAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_AdPay = w_AdPay + w_AdPayAmt.
                  continue.
           ENDIF.
         ENDLOOP.
       ENDLOOP.
    * Open Item Balances
    ENDFORM.                    " Select_Data
    FORM select_data_Open.
    *   SELECT SINGLE copmname INTO w_companyname
    *      FROM zcompany
    *       WHERE  copcode = p_bukrs.
    * Select the receipts
       SELECT SUM( dmbtr ) AS dmbtr belnr kunnr hkont shkzg xblnr budat
    blart bldat
       INTO CORRESPONDING FIELDS OF TABLE it_voucher3
       FROM  bsid
       WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
               AND augdt IN s_bldat
               AND blart = 'DZ'
    *            AND blart = 'DZ' and shkzg = 'S'
               GROUP BY kunnr belnr hkont shkzg xblnr budat blart bldat.
       SORT it_voucher3 BY kunnr.
       LOOP AT it_voucher3 INTO wa_voucher3.
    * Select the invoices
         SELECT SUM( dmbtr ) AS dmbtr belnr kunnr hkont shkzg xblnr budat
    blart bldat
         INTO CORRESPONDING FIELDS OF TABLE it_voucher1
         FROM  bsid
         WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
                 AND augdt IN s_bldat
                 AND blart <> 'DZ' AND
                 augbl = wa_voucher3-belnr AND
                 kunnr = wa_voucher3-kunnr
                 GROUP BY belnr kunnr hkont shkzg xblnr budat blart bldat.
         LOOP AT it_voucher1 INTO wa_voucher1.
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_ORcptamt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX001' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_ORcptamt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX001' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_ONetamt = w_ONetamt + w_ORcptamt.
                  continue.
                ENDIF.
           ELSE.
                 w_ONetamt = w_ONetamt + w_ORcptamt.
                  continue.
           ENDIF.
    * Interest Income
          SELECT SINGLE dmbtr FROM bsis INTO w_OIntIncomeAmt WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX002' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OIntIncomeAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX002' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OIntIncome = w_OIntIncome + w_OIntIncomeAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OIntIncome = w_OIntIncome + w_OIntIncomeAmt.
                  continue.
           ENDIF.
    * Sale Of fixed Assets
          SELECT SINGLE dmbtr FROM bsis INTO w_OFixedAmt WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX004' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OFixedAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX004' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_Ofixedasst = w_Ofixedasst + w_OFixedAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_Ofixedasst = w_Ofixedasst + w_OFixedAmt.
                  continue.
           ENDIF.
    * Gl Receipts ( Sundry Income)
          SELECT SINGLE dmbtr FROM bsis INTO w_OSundryAmt WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX005' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OSundryAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'XX005' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OSundry = w_OSundry + w_OSundryAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OSundry = w_OSundry + w_OSundryAmt.
                  continue.
           ENDIF.
         ENDLOOP.
       ENDLOOP.
    *Out Flow
    Clear r_bwart.
    refresh r_bwart.
    r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'KZ'.
    APPEND r_bwart TO r_bwart.
    r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'VZ'.
    APPEND r_bwart TO r_bwart.
       SELECT SUM( dmbtr ) AS dmbtr belnr lifnr hkont shkzg xblnr budat
    blart bldat
       INTO CORRESPONDING FIELDS OF TABLE it_voucher3
       FROM  bsik
       WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
               AND augdt IN s_bldat
               AND blart IN  r_bwart
    *            AND blart = 'DZ' and shkzg = 'S'
               GROUP BY lifnr belnr hkont shkzg xblnr budat blart bldat.
       SORT it_voucher3 BY lifnr.
       LOOP AT it_voucher3 INTO wa_voucher3.
    * Select the invoices
         SELECT SUM( dmbtr ) AS dmbtr belnr lifnr hkont shkzg xblnr budat
    blart bldat
         INTO CORRESPONDING FIELDS OF TABLE it_voucher1
         FROM  bsik
         WHERE   bukrs = p_bukrs AND gjahr = p_gjahr
                 AND augdt IN s_bldat
                 AND blart NOT IN r_bwart AND
                 augbl = wa_voucher3-belnr AND
                 lifnr = wa_voucher3-lifnr
                 GROUP BY belnr lifnr hkont shkzg xblnr budat blart bldat.
         LOOP AT it_voucher1 INTO wa_voucher1.
    * Supplier Payments  (LOCAL)
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OSupPayAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY001' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OSupPayAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY001' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OSupPay = w_OSupPay + w_OSupPayAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OSupPay = w_OSupPay + w_OSupPayAmt.
                  continue.
           ENDIF.
    * supplier Payments  (Foreign )
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OSupPayAmt1 WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY002' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OSupPayAmt1  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY002' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OSupPay1 = w_OSupPay1 + w_OSupPayAmt1.
                  continue.
                ENDIF.
           ELSE.
                 w_OSupPay1 = w_OSupPay1 + w_OSupPayAmt1.
                  continue.
           ENDIF.
    * duty/clearing expenses
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_ODutyAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY003' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_ODutyAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY003' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_ODuty = w_ODuty + w_ODutyAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_ODuty = w_ODuty + w_ODutyAmt.
                  continue.
           ENDIF.
    * Salary /EPF/ETF/MSPS/OVERTIME
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OSalaryAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY004' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OSalaryAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY004' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OSalary = w_OSalary + w_OSalaryAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OSalary = w_OSalary + w_OSalaryAmt.
                  continue.
           ENDIF.
    * Income Taxes
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OTaxAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY005' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OTaxAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY005' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OTax = w_OTax + w_OTaxAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OTax = w_OTax + w_OTaxAmt.
                  continue.
           ENDIF.
    * other taxes ( VAT: TT:Debit tax )
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OTaxAmt1 WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY006' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OTaxAmt1  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY006' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OTax1 = w_OTax1 + w_OTaxAmt1.
                  continue.
                ENDIF.
           ELSE.
                 w_OTax1 = w_OTax1 + w_OTaxAmt1.
                  continue.
           ENDIF.
    * Selling  & Promotional Costs
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OSellAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY007' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OSellAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY007' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OSell = w_OSell + w_OSellAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OSell = w_OSell + w_OSellAmt.
                  continue.
           ENDIF.
    * Admistration costs
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OAdminAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY008' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OAdminAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY008' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OAdmin = w_OAdmin + w_OAdminAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OAdmin = w_OAdmin + w_OAdminAmt.
                  continue.
           ENDIF.
    * Capital Expenditure
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OCapitalAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY009' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OCapitalAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY009' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OCapital = w_OCapital + w_OCapitalAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OCapital = w_OCapital + w_OCapitalAmt.
                  continue.
           ENDIF.
    * Loan repayments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OLoanAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY010' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OLoanAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY010' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OLoan = w_OLoan + w_OLoanAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OLoan = w_OLoan + w_OLoanAmt.
                  continue.
           ENDIF.
    * maangment fees
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OManAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY011' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OManAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY011' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OMan = w_OMan + w_OManAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OMan = w_OMan + w_OManAmt.
                  continue.
           ENDIF.
    * Group charges
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OGroupAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY012' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OGroupAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY012' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OGroup = w_OGroup + w_OGroupAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OGroup = w_OGroup + w_OGroupAmt.
                  continue.
           ENDIF.
    * Interest Payments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OIntAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY013' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OIntAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY013' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OInt = w_OInt + w_OIntAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OInt = w_OInt + w_OIntAmt.
                  continue.
           ENDIF.
    * Other Intercompany payments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OInterAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY014' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OInterAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY014' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OInter = w_OInter + w_OInterAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OInter = w_OInter + w_OInterAmt.
                  continue.
           ENDIF.
    * Advacnes/Prepayments
    *  Find the corresponding entry in the GL open
          SELECT SINGLE dmbtr FROM bsis INTO w_OAdPayAmt WHERE
    *           hkont = '0010003900' AND
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY015' ) AND  bukrs = p_bukrs  AND
                   gjahr = p_gjahr  AND
                   belnr = wa_voucher1-belnr.
           IF sy-subrc <> 0.
    * If the corresponding entry not found in GL open, look in the GL Closed
          SELECT SINGLE dmbtr FROM bsas INTO  w_OAdPayAmt  WHERE
               hkont IN ( select fglacc from zcashflow_matrix WHERE FCODE =
    'YY015' ) AND bukrs = p_bukrs  AND
                  gjahr = p_gjahr  AND
                  belnr = wa_voucher1-belnr.
                IF sy-subrc = 0.
                  w_OAdPay = w_OAdPay + w_OAdPayAmt.
                  continue.
                ENDIF.
           ELSE.
                 w_OAdPay = w_OAdPay + w_OAdPayAmt.
                  continue.
           ENDIF.
         ENDLOOP.
       ENDLOOP.
    ENDFORM.                    " Select_Data

  • Many-to-many performance issue

    I realize that many-to-many joins have been discussed before (yes, I looked through many threads), but I'm having a slight variation on the issue. Our data warehouse has been functioning for a couple of years now, but we're now experiencing a dramatic degradation in report performance. I'll tell you everything I know and what I've tried. My hope is that someone will have an idea that hasn't occurred to me yet.
    The troubling data links deal with accounts and account_types. Each transaction will have one account, but each account can have multiple account_types and each account_type is made up of multiple accounts. It ends up looking like this:
    Transaction_cube --< account_dimension >--< account_type_table
    Given the many-to-many relationship between account and account_type, this is the only architecture I could come up with that will maintain data integrity in the transaction cube.
    I know that this is the cause of the performance issues because the reports run normally when this is removed. The volume of data obviously increases over time, but the problem appeared very suddenly -- not a gradual degradation that one would expect from a volume issue. The cube is partitioned by year and we're a little below last year's growth.
    The other fact to throw in is that the account_type table did increase in size by an additional 30% when we first noticed the problem. However, the business was able to go back and remove half of the account_types (unused types) so now the table has fewer rows than it had before we noticed the problem (~15k rows in the account_type table).
    We have tried pinning the table so that it remain in memory, but that did not help. I tried creating a materialized view combining accounts and account_types with a similar lack of improvement. I've tried adding indexes, but there is still a full-table scan. All database objects are analyzed nightly after the data load is completed.
    I'm fresh out of ideas at this point. Any suggestions and/or ideas would be greatly appreciated.

    I've thought about that. What it would mean would be aprox. 20 additional columns for each of the different account_types. Unfortunately, that would also mean that all the reports that use the account_type would have to have a condition:
    WHERE acct_type1='Income Stmt." OR acct_type2='Income Stmt." OR ....
    Since the account_types are not set up in a hierarchy and there must be only one row for account, I'm not sure that this is a feasible solution.
    Thank you for the suggestion.

  • Performance issue showing read by other session Event

    Hi All,
    we are having a severe performance issue in my database when we are running batch jobs.
    This was a new database(11.2.0.2) and we are testing the performance by running some batch jobs. These batch jobs included some inserts and updates.
    I am seeing read by other session in top 5 timed events and cache buffers chains in Latch Miss Sources section.
    Please help me to solve this out.
    Inst Num Startup Time    Release     RAC
    1 27-Feb-12 09:03 11.2.0.2.0  NO
    Platform                         CPUs Cores Sockets Memory(GB)
    Linux x86 64-bit                    8     8       8      48.00           
    Snap Id      Snap Time      Sessions Curs/Sess
    Begin Snap:      5605 29-Feb-12 03:00:27        63       4.5
      End Snap:      5614 29-Feb-12 12:00:47        63       4.3
       Elapsed:              540.32 (mins)
       DB Time:            1,774.23 (mins)
    Cache Sizes                       Begin        End
    ~~~~~~~~~~~                  ---------- ----------
                   Buffer Cache:     1,952M     1,952M  Std Block Size:        16K
               Shared Pool Size:     1,024M     1,024M      Log Buffer:    18,868K
    Load Profile              Per Second    Per Transaction   Per Exec   Per Call
    ~~~~~~~~~~~~         ---------------    --------------- ---------- ----------
          DB Time(s):                3.3                0.8       0.02       0.05
           DB CPU(s):                1.1                0.3       0.01       0.02
           Redo size:           55,763.8           13,849.3
       Logical reads:           23,906.6            5,937.4
       Block changes:              325.7               80.9
      Physical reads:              665.6              165.3
    Physical writes:               40.4               10.0
          User calls:               60.7               15.1
              Parses:               10.6                2.6
         Hard parses:                1.1                0.3
    W/A MB processed:                0.6                0.2
              Logons:                0.1                0.0
            Executes:              151.2               37.6
           Rollbacks:                0.0                0.0
        Transactions:                4.0
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                Buffer Nowait %:   99.94       Redo NoWait %:  100.00
                Buffer  Hit   %:   97.90    In-memory Sort %:  100.00
                Library Hit   %:   98.06        Soft Parse %:   90.16
             Execute to Parse %:   92.96         Latch Hit %:  100.00
    Parse CPU to Parse Elapsd %:   76.71     % Non-Parse CPU:   98.57
    Shared Pool Statistics        Begin    End
                 Memory Usage %:   89.38   87.96
        % SQL with executions>1:   97.14   95.15
      % Memory for SQL w/exec>1:   96.05   92.46
    Top 5 Timed Foreground Events
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                               Avg
                                                              wait   % DB
    Event                                 Waits     Time(s)   (ms)   time Wait Class
    db file sequential read          14,092,706      65,613      5   61.6 User I/O
    DB CPU                                           34,819          32.7
    read by other session               308,534       1,260      4    1.2 User I/O
    direct path read                     97,454         987     10     .9 User I/O
    db file scattered read               71,870         910     13     .9 User I/O
    Host CPU (CPUs:    8 Cores:    8 Sockets:    8)
    ~~~~~~~~         Load Average
                   Begin       End     %User   %System      %WIO     %Idle
                    0.43      0.36      13.7       0.6       9.7      85.7
    Instance CPU
    ~~~~~~~~~~~~
                  % of total CPU for Instance:      13.5
                  % of busy  CPU for Instance:      94.2
      %DB time waiting for CPU - Resource Mgr:       0.0
    Memory Statistics
    ~~~~~~~~~~~~~~~~~                       Begin          End
                      Host Mem (MB):     49,152.0     49,152.0
                       SGA use (MB):      3,072.0      3,072.0
                       PGA use (MB):        506.5        629.1
        % Host Mem used for SGA+PGA:         7.28         7.53
    Time Model Statistics             
    -> Total time in database user-calls (DB Time): 106453.8s
    -> Statistics including the word "background" measure background process
       time, and so do not contribute to the DB time statistic
    -> Ordered by % or DB time desc, Statistic name
    Statistic Name                                       Time (s) % of DB Time
    sql execute elapsed time                            105,531.1         99.1
    DB CPU                                               34,818.8         32.7
    parse time elapsed                                      714.7           .7
    hard parse elapsed time                                 684.8           .6
    PL/SQL execution elapsed time                           161.9           .2
    PL/SQL compilation elapsed time                          44.2           .0
    connection management call elapsed time                  16.9           .0
    hard parse (sharing criteria) elapsed time               10.2           .0
    hard parse (bind mismatch) elapsed time                   9.4           .0
    sequence load elapsed time                                2.9           .0
    repeated bind elapsed time                                0.5           .0
    failed parse elapsed time                                 0.0           .0
    DB time                                             106,453.8
    background elapsed time                               1,753.9
    background cpu time                                      61.7
    Operating System Statistics        
    -> *TIME statistic values are diffed.
       All others display actual values.  End Value is displayed if different
    -> ordered by statistic type (CPU Use, Virtual Memory, Hardware Config), Name
    Statistic                                  Value        End Value
    BUSY_TIME                              3,704,415
    IDLE_TIME                             22,203,740
    IOWAIT_TIME                            2,517,864
    NICE_TIME                                      3
    SYS_TIME                                 145,696
    USER_TIME                              3,557,758
    LOAD                                           0                0
    RSRC_MGR_CPU_WAIT_TIME                         0
    VM_IN_BYTES                      358,813,045,760
    VM_OUT_BYTES                      29,514,830,848
    PHYSICAL_MEMORY_BYTES             51,539,607,552
    NUM_CPUS                                       8
    NUM_CPU_CORES                                  8
    NUM_CPU_SOCKETS                                8
    GLOBAL_RECEIVE_SIZE_MAX                4,194,304
    GLOBAL_SEND_SIZE_MAX                   1,048,586
    TCP_RECEIVE_SIZE_DEFAULT                  87,380
    TCP_RECEIVE_SIZE_MAX                   4,194,304
    TCP_RECEIVE_SIZE_MIN                       4,096
    TCP_SEND_SIZE_DEFAULT                     16,384
    TCP_SEND_SIZE_MAX                      4,194,304
    TCP_SEND_SIZE_MIN                          4,096
    Operating System Statistics -
    Snap Time           Load    %busy    %user     %sys    %idle  %iowait
    29-Feb 03:00:27      0.4      N/A      N/A      N/A      N/A      N/A
    29-Feb 04:00:35      1.4     11.9     11.2      0.6     88.1     14.3
    29-Feb 05:00:41      1.7     13.8     13.2      0.6     86.2     15.8
    29-Feb 06:00:48      1.5     14.0     13.5      0.6     86.0     12.3
    29-Feb 07:01:00      1.8     16.3     15.8      0.5     83.7     10.4
    29-Feb 08:00:12      2.6     23.2     22.5      0.6     76.8     12.6
    29-Feb 09:00:26      1.3     16.6     16.0      0.5     83.4      5.7
    29-Feb 10:00:33      1.2     13.8     13.3      0.5     86.2      2.0
    29-Feb 11:00:43      1.3     14.5     14.0      0.5     85.5      3.8
    29-Feb 12:00:47      0.4      4.9      4.2      0.7     95.1     10.6
    Foreground Wait Class              
    -> s  - second, ms - millisecond -    1000th of a second
    -> ordered by wait time desc, waits desc
    -> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
    -> Captured Time accounts for         97.9%  of Total DB time     106,453.79 (s)
    -> Total FG Wait Time:            69,415.64 (s)  DB CPU time:      34,818.79 (s)
                                                                      Avg
                                          %Time       Total Wait     wait
    Wait Class                      Waits -outs         Time (s)     (ms)  %DB time
    User I/O                   14,693,843     0           69,222        5      65.0
    DB CPU                                                34,819               32.7
    Commit                         40,629     0              119        3       0.1
    System I/O                     26,504     0               57        2       0.1
    Network                     1,945,010     0               11        0       0.0
    Other                         125,200    99                4        0       0.0
    Application                     2,673     0                2        1       0.0
    Concurrency                     3,059     0                1        0       0.0
    Configuration                      31    19                0       15       0.0
    Foreground Wait Events            
    -> s  - second, ms - millisecond -    1000th of a second
    -> Only events with Total Wait Time (s) >= .001 are shown
    -> ordered by wait time desc, waits desc (idle events last)
    -> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
                                                                 Avg
                                            %Time Total Wait    wait    Waits   % DB
    Event                             Waits -outs   Time (s)    (ms)     /txn   time
    db file sequential read      14,092,706     0     65,613       5    108.0   61.6
    read by other session           308,534     0      1,260       4      2.4    1.2
    direct path read                 97,454     0        987      10      0.7     .9
    db file scattered read           71,870     0        910      13      0.6     .9
    db file parallel read            35,001     0        372      11      0.3     .3
    log file sync                    40,629     0        119       3      0.3     .1
    control file sequential re       26,504     0         57       2      0.2     .1
    direct path read temp            14,499     0         49       3      0.1     .0
    direct path write temp            9,186     0         28       3      0.1     .0
    SQL*Net message to client     1,923,973     0          5       0     14.7     .0
    SQL*Net message from dblin        1,056     0          5       5      0.0     .0
    Disk file operations I/O          8,848     0          2       0      0.1     .0
    ASM file metadata operatio           36     0          2      54      0.0     .0
    SQL*Net break/reset to cli        2,636     0          1       1      0.0     .0
    ADR block file read                 472     0          1       1      0.0     .0
    os thread startup                     8     0          1      74      0.0     .0
    SQL*Net more data to clien       17,656     0          1       0      0.1     .0
    asynch descriptor resize        123,852   100          0       0      0.9     .0
    local write wait                    110     0          0       4      0.0     .0
    utl_file I/O                     55,635     0          0       0      0.4     .0
    log file switch (private s            8     0          0      52      0.0     .0
    cursor: pin S wait on X               2     0          0     142      0.0     .0
    enq: KO - fast object chec           13     0          0      20      0.0     .0
    PX Deq: Slave Session Stat          248     0          0       1      0.0     .0
    enq: RO - fast object reus           18     0          0      11      0.0     .0
    latch: cache buffers chain        2,511     0          0       0      0.0     .0
    latch: shared pool                  195     0          0       1      0.0     .0
    CSS initialization                   12     0          0       8      0.0     .0
    PX qref latch                        54   100          0       2      0.0     .0
    SQL*Net more data from cli          995     0          0       0      0.0     .0
    SQL*Net more data from dbl          300     0          0       0      0.0     .0
    kksfbc child completion               1   100          0      56      0.0     .0
    library cache: mutex X              244     0          0       0      0.0     .0
    PX Deq: Signal ACK RSG              124     0          0       0      0.0     .0
    undo segment extension                6   100          0       7      0.0     .0
    PX Deq: Signal ACK EXT              124     0          0       0      0.0     .0
    library cache load lock               3     0          0       9      0.0     .0
    ADR block file write                 45     0          0       1      0.0     .0
    CSS operation: action                12     0          0       2      0.0     .0
    reliable message                     28     0          0       1      0.0     .0
    CSS operation: query                 72     0          0       0      0.0     .0
    latch: row cache objects             14     0          0       1      0.0     .0
    enq: SQ - contention                 17     0          0       0      0.0     .0
    latch free                           32     0          0       0      0.0     .0
    buffer busy waits                    52     0          0       0      0.0     .0
    enq: PS - contention                 16     0          0       0      0.0     .0
    enq: TX - row lock content            6     0          0       1      0.0     .0
    SQL*Net message to dblink         1,018     0          0       0      0.0     .0
    cursor: pin S                        23     0          0       0      0.0     .0
    latch: cache buffers lru c            8     0          0       0      0.0     .0
    SQL*Net message from clien    1,923,970     0    944,508     491     14.7
    jobq slave wait                  66,732   100     33,334     500      0.5
    Streams AQ: waiting for me        6,481   100     32,412    5001      0.0
    wait for unread message on       32,858    98     32,411     986      0.3
    PX Deq: Execution Msg             1,448     0        190     131      0.0
    PX Deq: Execute Reply             1,196     0         74      62      0.0
    HS message to agent                 228     0          4      19      0.0
    single-task message                  42     0          4      97      0.0
    PX Deq Credit: send blkd            904     0          2       3      0.0
    PX Deq Credit: need buffer          205     0          1       3      0.0
    Foreground Wait Events            
    -> s  - second, ms - millisecond -    1000th of a second
    -> Only events with Total Wait Time (s) >= .001 are shown
    -> ordered by wait time desc, waits desc (idle events last)
    -> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
                                                                 Avg
                                            %Time Total Wait    wait    Waits   % DB
    Event                             Waits -outs   Time (s)    (ms)     /txn   time
    PX Deq: Table Q Normal            4,291     0          1       0      0.0
    PX Deq: Join ACK                    124     0          0       1      0.0
    PX Deq: Parse Reply                 124     0          0       0      0.0
    KSV master wait                     256     0          0       0      0.0
    Latch Miss Sources                
    -> only latches with sleeps are shown
    -> ordered by name, sleeps desc
                                                         NoWait              Waiter
    Latch Name               Where                       Misses     Sleeps   Sleeps
    ASM map operation freeli kffmTranslate2                   0          2        0
    DML lock allocation      ktadmc                           0          2        0
    FOB s.o list latch       ksfd_allfob                      0          2        2
    In memory undo latch     ktiFlushMe                       0          5        0
    In memory undo latch     ktichg: child                    0          3        0
    PC and Classifier lists  No latch                         0          6        0
    Real-time plan statistic keswxAddNewPlanEntry             0         20       20
    SQL memory manager worka qesmmIRegisterWorkArea:1         0          1        1
    active service list      kswslogon: session logout        0         23       12
    active service list      kswssetsvc: PX session swi       0          6        1
    active service list      kswsite: service iterator        0          1        0
    archive process latch    kcrrgpll                         0          3        3
    cache buffers chains     kcbgtcr_2                        0      1,746      573
    cache buffers chains     kcbgtcr: fast path (cr pin       0      1,024    2,126
    cache buffers chains     kcbgcur_2                        0         60        8
    cache buffers chains     kcbchg1: kslbegin: bufs no       0         16        3
    cache buffers chains     kcbgtcr: fast path               0         14       20
    cache buffers chains     kcbzibmlt: multi-block rea       0         10        0
    cache buffers chains     kcbrls_2                         0          9       53
    cache buffers chains     kcbgtcr: kslbegin shared         0          8        1
    cache buffers chains     kcbrls_1                         0          7       84
    cache buffers chains     kcbgtcr: kslbegin excl           0          6       14
    cache buffers chains     kcbnew: new latch again          0          6        0
    cache buffers chains     kcbzgb: scan from tail. no       0          6        0
    cache buffers chains     kcbzwb                           0          5        8
    cache buffers chains     kcbgcur: fast path (shr)         0          3        0
    cache buffers chains     kcbget: pin buffer               0          3        0
    cache buffers chains     kcbzhngcbk2_1                    0          1        0
    cache buffers lru chain  kcbzgws                          0         19        0
    cache buffers lru chain  kcbo_link_q                      0          3        0
    call allocation          ksuxds                           0         14       10
    call allocation          ksudlp: top call                 0          2        3
    enqueue hash chains      ksqgtl3                          0          2        1
    enqueue hash chains      ksqrcl                           0          1        2
    enqueues                 ksqgel: create enqueue           0          1        0
    object queue header oper kcbo_unlink_q                    0          5        2
    object queue header oper kcbo_sw_buf                      0          2        0
    object queue header oper kcbo_link_q                      0          1        2
    object queue header oper kcbo_switch_cq                   0          1        2
    object queue header oper kcbo_switch_mq_bg                0          1        4
    parallel query alloc buf kxfpbalo                         0          1        1
    process allocation       ksucrp:1                         0          2        0
    process queue reference  kxfpqrsnd                        0          1        0
    qmn task queue latch     kwqmnmvtsks: delay to read       0          1        0
    redo allocation          kcrfw_redo_gen: redo alloc       0         17        0
    row cache objects        kqreqd: reget                    0          6        0
    row cache objects        kqrpre: find obj                 0          6       13
    row cache objects        kqrso                            0          2        0
    row cache objects        kqreqd                           0          1        2
    row cache objects        kqrpre: init complete            0          1        1
    shared pool              kghalo                           0        199      106
    shared pool              kghupr1                          0         39      109
    shared pool              kghfre                           0         18       19
    shared pool              kghalp                           0          7       29
    space background task la ktsj_grab_task                   0         21       27
    Mutex Sleep Summary                
    -> ordered by number of sleeps desc
                                                                             Wait
    Mutex Type            Location                               Sleeps    Time (ms)
    Library Cache         kglhdgn2 106                              338           12
    Library Cache         kgllkc1   57                              259           10
    Library Cache         kgllkdl1  85                              123           21
    Cursor Pin            kkslce [KKSCHLPIN2]                        70          286
    Library Cache         kglget2   2                                31            1
    Library Cache         kglhdgn1  62                               31            2
    Library Cache         kglpin1   4                                26            1
    Library Cache         kglpnal1  90                               18            0
    Library Cache         kglpndl1  95                               15            2
    Library Cache         kgllldl2 112                                6            0
    Library Cache         kglini1   32                                1            0
              -------------------------------------------------------------Thanks in advance.

    Hi,
    Thanks for reply.
    I provided one hour report.
    Inst Num Startup Time    Release     RAC
    1 27-Feb-12 09:03 11.2.0.2.0  NO
      Platform                         CPUs Cores Sockets Memory(GB)
    Linux x86 64-bit                    8     8       8      48.00
                  Snap Id      Snap Time      Sessions Curs/Sess
    Begin Snap:      5606 29-Feb-12 04:00:35        63       3.7
      End Snap:      5607 29-Feb-12 05:00:41        63       3.6
       Elapsed:               60.11 (mins)
       DB Time:              382.67 (mins)
    Cache Sizes                       Begin        End
    ~~~~~~~~~~~                  ---------- ----------
                   Buffer Cache:     1,952M     1,952M  Std Block Size:        16K
               Shared Pool Size:     1,024M     1,024M      Log Buffer:    18,868K
    Load Profile              Per Second    Per Transaction   Per Exec   Per Call
    ~~~~~~~~~~~~         ---------------    --------------- ---------- ----------
          DB Time(s):                6.4                0.8       0.03       0.03
           DB CPU(s):                1.0                0.1       0.00       0.00
           Redo size:           84,539.3           10,425.6
       Logical reads:           23,345.6            2,879.1
       Block changes:              386.5               47.7
      Physical reads:            1,605.0              197.9
    Physical writes:                7.1                0.9
          User calls:              233.9               28.9
              Parses:                4.0                0.5
         Hard parses:                0.1                0.0
    W/A MB processed:                0.1                0.0
              Logons:                0.1                0.0
            Executes:              210.9               26.0
           Rollbacks:                0.0                0.0
        Transactions:                8.1
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                Buffer Nowait %:   99.62       Redo NoWait %:  100.00
                Buffer  Hit   %:   95.57    In-memory Sort %:  100.00
                Library Hit   %:   99.90        Soft Parse %:   98.68
             Execute to Parse %:   98.10         Latch Hit %:   99.99
    Parse CPU to Parse Elapsd %:   32.08     % Non-Parse CPU:   99.90
    Shared Pool Statistics        Begin    End
                 Memory Usage %:   89.25   89.45
        % SQL with executions>1:   96.79   97.52
      % Memory for SQL w/exec>1:   95.67   96.56
    Top 5 Timed Foreground Events
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                               Avg
                                                              wait   % DB
    Event                                 Waits     Time(s)   (ms)   time Wait Class
    db file sequential read           3,054,464      17,002      6   74.0 User I/O
    DB CPU                                            3,748          16.3
    read by other session               199,603         796      4    3.5 User I/O
    direct path read                     46,301         439      9    1.9 User I/O
    db file scattered read               21,113         269     13    1.2 User I/O
    Host CPU (CPUs:    8 Cores:    8 Sockets:    8)
    ~~~~~~~~         Load Average
                   Begin       End     %User   %System      %WIO     %Idle
                    1.45      1.67      13.2       0.6      15.8      86.2
    Instance CPU
    ~~~~~~~~~~~~
                  % of total CPU for Instance:      13.0
                  % of busy  CPU for Instance:      94.7
      %DB time waiting for CPU - Resource Mgr:       0.0
    Memory Statistics
    ~~~~~~~~~~~~~~~~~                       Begin          End
                      Host Mem (MB):     49,152.0     49,152.0
                       SGA use (MB):      3,072.0      3,072.0
                       PGA use (MB):        513.5        467.7
        % Host Mem used for SGA+PGA:         7.29         7.20
    Time Model Statistics            
    -> Total time in database user-calls (DB Time): 22960.5s
    -> Statistics including the word "background" measure background process
       time, and so do not contribute to the DB time statistic
    -> Ordered by % or DB time desc, Statistic name
    Statistic Name                                       Time (s) % of DB Time
    sql execute elapsed time                             22,835.9         99.5
    DB CPU                                                3,748.4         16.3
    parse time elapsed                                       15.4           .1
    hard parse elapsed time                                  14.3           .1
    PL/SQL execution elapsed time                             7.5           .0
    PL/SQL compilation elapsed time                           6.0           .0
    connection management call elapsed time                   1.6           .0
    sequence load elapsed time                                0.4           .0
    hard parse (sharing criteria) elapsed time                0.0           .0
    repeated bind elapsed time                                0.0           .0
    failed parse elapsed time                                 0.0           .0
    DB time                                              22,960.5
    background elapsed time                                 238.1
    background cpu time                                       4.9
    Operating System Statistics        
    -> *TIME statistic values are diffed.
       All others display actual values.  End Value is displayed if different
    -> ordered by statistic type (CPU Use, Virtual Memory, Hardware Config), Name
    Statistic                                  Value        End Value
    BUSY_TIME                                396,506
    IDLE_TIME                              2,483,725
    IOWAIT_TIME                              455,495
    NICE_TIME                                      0
    SYS_TIME                                  16,163
    USER_TIME                                380,052
    LOAD                                           1                2
    RSRC_MGR_CPU_WAIT_TIME                         0
    VM_IN_BYTES                       95,646,943,232
    VM_OUT_BYTES                       1,686,059,008
    PHYSICAL_MEMORY_BYTES             51,539,607,552
    NUM_CPUS                                       8
    NUM_CPU_CORES                                  8
    NUM_CPU_SOCKETS                                8
    GLOBAL_RECEIVE_SIZE_MAX                4,194,304
    GLOBAL_SEND_SIZE_MAX                   1,048,586
    TCP_RECEIVE_SIZE_DEFAULT                  87,380
    TCP_RECEIVE_SIZE_MAX                   4,194,304
    TCP_RECEIVE_SIZE_MIN                       4,096
    TCP_SEND_SIZE_DEFAULT                     16,384
    TCP_SEND_SIZE_MAX                      4,194,304
    TCP_SEND_SIZE_MIN                          4,096
    Operating System Statistics -
    Snap Time           Load    %busy    %user     %sys    %idle  %iowait
    29-Feb 04:00:35      1.4      N/A      N/A      N/A      N/A      N/A
    29-Feb 05:00:41      1.7     13.8     13.2      0.6     86.2     15.8
    Foreground Wait Class              
    -> s  - second, ms - millisecond -    1000th of a second
    -> ordered by wait time desc, waits desc
    -> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
    -> Captured Time accounts for         97.6%  of Total DB time      22,960.46 (s)
    -> Total FG Wait Time:            18,651.75 (s)  DB CPU time:       3,748.35 (s)
                                                                      Avg
                                          %Time       Total Wait     wait
    Wait Class                      Waits -outs         Time (s)     (ms)  %DB time
    User I/O                    3,327,253     0           18,576        6      80.9
    DB CPU                                                 3,748               16.3
    Commit                         23,882     0               69        3       0.3
    System I/O                      1,035     0                3        3       0.0
    Network                       842,393     0                2        0       0.0
    Other                          10,120    99                0        0       0.0
    Configuration                       3     0                0       58       0.0
    Application                       264     0                0        1       0.0
    Concurrency                     1,482     0                0        0       0.0
    Foreground Wait Events            
    -> s  - second, ms - millisecond -    1000th of a second
    -> Only events with Total Wait Time (s) >= .001 are shown
    -> ordered by wait time desc, waits desc (idle events last)
    -> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
                                                                 Avg
                                            %Time Total Wait    wait    Waits   % DB
    Event                             Waits -outs   Time (s)    (ms)     /txn   time
    db file sequential read       3,054,464     0     17,002       6    104.5   74.0
    read by other session           199,603     0        796       4      6.8    3.5
    direct path read                 46,301     0        439       9      1.6    1.9
    db file scattered read           21,113     0        269      13      0.7    1.2
    log file sync                    23,882     0         69       3      0.8     .3
    db file parallel read             4,727     0         68      14      0.2     .3
    control file sequential re        1,035     0          3       3      0.0     .0
    SQL*Net message to client       840,792     0          2       0     28.8     .0
    direct path read temp                95     0          2      18      0.0     .0
    local write wait                     79     0          0       4      0.0     .0
    Disk file operations I/O            870     0          0       0      0.0     .0
    ASM file metadata operatio            4     0          0      50      0.0     .0
    log file switch (private s            3     0          0      58      0.0     .0
    ADR block file read                  36     0          0       3      0.0     .0
    enq: RO - fast object reus            5     0          0      16      0.0     .0
    latch: cache buffers chain        1,465     0          0       0      0.1     .0
    SQL*Net break/reset to cli          256     0          0       0      0.0     .0
    asynch descriptor resize         10,059   100          0       0      0.3     .0
    SQL*Net more data to clien        1,510     0          0       0      0.1     .0
    enq: KO - fast object chec            3     0          0       8      0.0     .0
    SQL*Net more data from cli           91     0          0       0      0.0     .0
    latch: shared pool                   14     0          0       0      0.0     .0
    ADR block file write                  5     0          0       1      0.0     .0
    reliable message                      8     0          0       0      0.0     .0
    direct path write temp                1     0          0       2      0.0     .0
    SQL*Net message from clien      840,794     0     68,885      82     28.8
    jobq slave wait                   7,365   100      3,679     499      0.3
    Streams AQ: waiting for me          721   100      3,605    5000      0.0
    wait for unread message on        3,648    98      3,603     988      0.1
    KSV master wait                      20     0          0       0      0.0
    Background Wait Events            
    -> ordered by wait time desc, waits desc (idle events last)
    -> Only events with Total Wait Time (s) >= .001 are shown
    -> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
                                                                 Avg
                                            %Time Total Wait    wait    Waits   % bg
    Event                             Waits -outs   Time (s)    (ms)     /txn   time
    log file parallel write          29,353     0         83       3      1.0   34.8
    db file parallel write            5,753     0         17       3      0.2    6.9
    db file sequential read           1,638     0         15       9      0.1    6.1
    control file sequential re        5,142     0         13       2      0.2    5.4
    os thread startup                   140     0          8      58      0.0    3.4
    control file parallel writ        1,440     0          8       6      0.0    3.4
    log file sequential read            304     0          8      26      0.0    3.3
    db file scattered read              214     0          2       9      0.0     .8
    ASM file metadata operatio        1,199     0          1       1      0.0     .3
    direct path write                    35     0          0       6      0.0     .1
    direct path read                     41     0          0       5      0.0     .1
    kfk: async disk IO                    6     0          0       9      0.0     .0
    Disk file operations I/O          1,266     0          0       0      0.0     .0
    ADR block file read                  16     0          0       2      0.0     .0
    read by other session                 3     0          0       8      0.0     .0
    Log archive I/O                       2     0          0      10      0.0     .0
    log file sync                         3     0          0       5      0.0     .0
    asynch descriptor resize            341   100          0       0      0.0     .0
    CSS initialization                    1     0          0       6      0.0     .0
    log file single write                 4     0          0       1      0.0     .0
    latch: redo allocation                3     0          0       1      0.0     .0
    ADR block file write                  5     0          0       1      0.0     .0
    LGWR wait for redo copy              45     0          0       0      0.0     .0
    CSS operation: query                  6     0          0       0      0.0     .0
    CSS operation: action                 1     0          0       1      0.0     .0
    SQL*Net message to client           420     0          0       0      0.0     .0
    rdbms ipc message                47,816    39     61,046    1277      1.6
    DIAG idle wait                    7,200   100      7,200    1000      0.2
    Space Manager: slave idle         1,146    98      5,674    4951      0.0
    class slave wait                    284     0      3,983   14026      0.0
    dispatcher timer                     61   100      3,660   60006      0.0
    Streams AQ: qmn coordinato          258    50      3,613   14003      0.0
    Streams AQ: qmn slave idle          130     0      3,613   27789      0.0
    Streams AQ: waiting for ti            7    71      3,608  515430      0.0
    wait for unread message on        3,605   100      3,606    1000      0.1
    pmon timer                        1,201   100      3,604    3001      0.0
    smon timer                           15    73      3,603  240207      0.0
    ASM background timer                754     0      3,602    4777      0.0
    shared server idle wait             120   100      3,601   30006      0.0
    SQL*Net message from clien          554     0          4       7      0.0
    KSV master wait                     101     0          0       2      0.0
    Wait Event Histogram              
    -> Units for Total Waits column: K is 1000, M is 1000000, G is 1000000000
    -> % of Waits: value of .0 indicates value was <.05%; value of null is truly 0
    -> % of Waits: column heading of <=1s is truly <1024ms, >1s is truly >=1024ms
    -> Ordered by Event (idle events last)
                                                        % of Waits
                               Total
    Event                      Waits  <1ms  <2ms  <4ms  <8ms <16ms <32ms  <=1s   >1s
    ADR block file read           52  73.1   1.9   9.6  13.5               1.9
    ADR block file write          10 100.0
    ADR file lock                 12 100.0
    ARCH wait for archivelog l     3 100.0
    ASM file metadata operatio  1203  97.3    .5    .7    .3    .2          .9
    CSS initialization             1                   100.0
    CSS operation: action          1       100.0
    CSS operation: query           6  83.3  16.7
    Disk file operations I/O    2118  95.4   4.5    .1
    LGWR wait for redo copy       45 100.0
    Log archive I/O                2                         100.0
    SQL*Net break/reset to cli   256  99.6    .4
    SQL*Net message to client  839.9 100.0    .0
    SQL*Net more data from cli    91 100.0
    SQL*Net more data to clien  1503 100.0
    asynch descriptor resize   10.4K 100.0
    buffer busy waits              2 100.0
    control file parallel writ  1440   5.7  35.1  24.0  16.3  12.0   5.5   1.5
    control file sequential re  6177  69.4   7.5   5.9   8.1   7.1   1.7    .3
    db file parallel read       4727   1.7   3.2   3.2  10.1  46.6  33.3   1.8
    db file parallel write      5755  42.3  21.3  18.6  11.2   4.6   1.4    .5
    db file scattered read     21.5K   8.4   4.3  11.9  18.9  26.3  25.3   4.9
    db file sequential read    3053.  28.7  15.1  11.1  17.9  21.5   5.4    .3    .0
    direct path read           46.3K   9.9   8.8  18.5  21.7  22.8  15.7   2.7
    direct path read temp         95               9.5   9.5  23.2  49.5   8.4
    direct path write             35  11.4  31.4  17.1  22.9  11.4   2.9   2.9
    direct path write temp         1       100.0
    enq: KO - fast object chec     3                    66.7  33.3
    enq: RO - fast object reus     5  20.0              20.0  20.0  20.0  20.0
    kfk: async disk IO             6  50.0  16.7              16.7        16.7
    latch free                     3 100.0
    latch: cache buffers chain  1465 100.0
    latch: cache buffers lru c     1 100.0
    latch: object queue header     2 100.0
    latch: redo allocation         3  33.3  33.3  33.3
    latch: row cache objects       2 100.0
    latch: shared pool            15  93.3   6.7
    local write wait              79        35.4  34.2  21.5   8.9
    log file parallel write    29.4K  47.8  21.7  11.9   9.9   6.8   1.6    .3
    log file sequential read     304   6.3   3.0   3.6  10.2  23.4  24.3  29.3
    log file single write          4  25.0  75.0
    log file switch (private s     3                                     100.0
    log file sync              23.9K  40.9  28.0  12.9   9.7   6.7   1.5    .3
    os thread startup            140                                     100.0
    read by other session      199.6  37.1  19.9  12.9  13.1  13.8   3.1    .2
    reliable message               8 100.0
    ASM background timer         755   2.9    .4    .1    .1    .3    .1    .3  95.8
    DIAG idle wait              7196                                     100.0
    KSV master wait              121  88.4   2.5   3.3   2.5    .8    .8   1.7
    SQL*Net message from clien 840.1  97.1   1.8    .5    .2    .2    .1    .0    .1
    Space Manager: slave idle   1147    .1                                  .5  99.4
    Streams AQ: qmn coordinato   258  49.6                .4                    50.0
    Streams AQ: qmn slave idle   130    .8                                      99.2
    Streams AQ: waiting for me   721                                           100.0
    Streams AQ: waiting for ti     7  28.6                                42.9  28.6
    class slave wait             283  39.9   2.5   2.5   3.5   4.9   9.2  15.2  22.3
    dispatcher timer              60                                           100.0
    jobq slave wait             7360    .0    .0    .0                    99.9
    pmon timer                  1201                                           100.0
    rdbms ipc message          47.8K   2.7  31.6  17.4   1.1   1.1    .9  20.9  24.3
    Wait Event Histogram               DB/Inst: I2KPROD/I2KPROD  Snaps: 5606-5607
    -> Units for Total Waits column: K is 1000, M is 1000000, G is 1000000000
    -> % of Waits: value of .0 indicates value was <.05%; value of null is truly 0
    -> % of Waits: column heading of <=1s is truly <1024ms, >1s is truly >=1024ms
    -> Ordered by Event (idle events last)
                                                        % of Waits
                               Total
    Event                      Waits  <1ms  <2ms  <4ms  <8ms <16ms <32ms  <=1s   >1s
    shared server idle wait      120                                           100.0
    smon timer                    16                                       6.3  93.8
    wait for unread message on  7250                                  .1  99.9
    Latch Miss Sources                
    -> only latches with sleeps are shown
    -> ordered by name, sleeps desc
                                                         NoWait              Waiter
    Latch Name               Where                       Misses     Sleeps   Sleeps
    In memory undo latch     ktichg: child                    0          1        0
    active service list      kswslogon: session logout        0          2        0
    cache buffers chains     kcbgtcr_2                        0      1,123      483
    cache buffers chains     kcbgtcr: fast path (cr pin       0        496    1,131
    cache buffers chains     kcbrls_2                         0          5        6
    cache buffers chains     kcbgcur_2                        0          4        0
    cache buffers chains     kcbgtcr: fast path               0          3        1
    cache buffers chains     kcbzwb                           0          2        4
    cache buffers chains     kcbchg1: kslbegin: bufs no       0          1        0
    cache buffers chains     kcbnew: new latch again          0          1        0
    cache buffers chains     kcbrls_1                         0          1        6
    cache buffers chains     kcbzgb: scan from tail. no       0          1        0
    cache buffers lru chain  kcbzgws                          0          1        0
    object queue header oper kcbo_switch_cq                   0          1        0
    object queue header oper kcbo_switch_mq_bg                0          1        2
    redo allocation          kcrfw_redo_gen: redo alloc       0          3        0
    row cache objects        kqrpre: find obj                 0          1        1
    row cache objects        kqrso                            0          1        0
    shared pool              kghalo                           0         13        3
    shared pool              kghupr1                          0          4       15
    shared pool              kghalp                           0          1        0
    space background task la ktsj_grab_task                   0          2        2
              -------------------------------------------------------------

  • Performance issue with two unbanalnced hierarchies in a single report

    Hi All
    We are facing the performance issue with one of the report which houses two unbalanced hierarchies (having 18 levels) - skipped & ragged. Basically its a part of OBIAPPS financila analytics .
    The query is below :
    Could anyone let me know how to improve the performane. Any parameter that should be looked at while using unbalanced hierarchies.
    WITH SAWITH0
    AS ( SELECT SUM (T91707.OTHER_LOC_AMT) AS c1,
    MAX (T314768.HIER2_CODE) AS c2,
    MAX (T314768.HIER3_CODE) AS c3,
    MAX (T314768.HIER4_CODE) AS c4,
    MAX (T314768.HIER5_CODE) AS c5,
    MAX (T314768.HIER6_CODE) AS c6,
    MAX (T314768.HIER7_CODE) AS c7,
    MAX (T314768.HIER8_CODE) AS c8,
    MAX (T314768.HIER9_CODE) AS c9,
    MAX (T314768.HIER10_CODE) AS c10,
    MAX (T314768.HIER11_CODE) AS c11,
    MAX (T314768.HIER12_CODE) AS c12,
    MAX (T314768.HIER13_CODE) AS c13,
    MAX (T314768.HIER14_CODE) AS c14,
    MAX (T314768.HIER15_CODE) AS c15,
    MAX (T314768.HIER16_CODE) AS c16,
    MAX (T314768.HIER17_CODE) AS c17,
    MAX (T314768.HIER18_CODE) AS c18,
    MAX (T314768.HIER19_CODE) AS c19,
    MAX (T314768.HIER20_CODE) AS c20,
    T314768.HIER1_NAME AS c21,
    T314768.HIER1_CODE AS c22,
    T314914.HIER1_NAME AS c24,
    T314914.HIER10_NAME AS c25,
    T314914.HIER11_NAME AS c26,
    T314914.HIER12_NAME AS c27,
    T314914.HIER13_NAME AS c28,
    T314914.HIER14_NAME AS c29,
    T314914.HIER15_NAME AS c30,
    T314914.HIER16_NAME AS c31,
    T314914.HIER17_NAME AS c32,
    T314914.HIER18_NAME AS c33,
    T314914.HIER19_NAME AS c34,
    T314914.HIER2_NAME AS c35,
    T314914.HIER20_NAME AS c36,
    T314914.HIER3_NAME AS c37,
    T314914.HIER4_NAME AS c38,
    T314914.HIER5_NAME AS c39,
    T314914.HIER6_NAME AS c40,
    T314914.HIER7_NAME AS c41,
    T314914.HIER8_NAME AS c42,
    T314914.HIER9_NAME AS c43,
    T314914.HIER20_CODE AS c44,
    T314914.HIER1_CODE AS c45,
    T314914.HIER10_CODE AS c46,
    T314914.HIER11_CODE AS c47,
    T314914.HIER12_CODE AS c48,
    T314914.HIER13_CODE AS c49,
    T314914.HIER14_CODE AS c50,
    T314914.HIER15_CODE AS c51,
    T314914.HIER16_CODE AS c52,
    T314914.HIER17_CODE AS c53,
    T314914.HIER18_CODE AS c54,
    T314914.HIER19_CODE AS c55,
    T314914.HIER2_CODE AS c56,
    T314914.HIER3_CODE AS c57,
    T314914.HIER4_CODE AS c58,
    T314914.HIER5_CODE AS c59,
    T314914.HIER6_CODE AS c60,
    T314914.HIER7_CODE AS c61,
    T314914.HIER8_CODE AS c62,
    T314914.HIER9_CODE AS c63
    FROM W_HIERARCHY_D T314768 /* Dim_W_HIERARCHY_D_Segment11 */
    W_GL_SEGMENT_D T315677 /* Dim_W_GL_SEGMENT_D_Segment11 */
    W_HIERARCHY_D T314914 /* Dim_W_HIERARCHY_D_Segment13 */
    W_GL_SEGMENT_D T315731 /* Dim_W_GL_SEGMENT_D_Segment13 */
    W_GL_ACCOUNT_D T91397 /* Dim_W_GL_ACCOUNT_D */
    W_GL_OTHER_F T91707 /* Fact_W_GL_OTHER_F */
    WHERE ( T91397.ROW_WID = T91707.GL_ACCOUNT_WID
    AND T91397.ACCOUNT_SEG11_CODE = T315677.SEGMENT_VAL_CODE
    AND T91397.ACCOUNT_SEG13_CODE = T315731.SEGMENT_VAL_CODE
    AND T91397.ACCOUNT_SEG11_ATTRIB = T315677.SEGMENT_LOV_ID
    AND T91397.ACCOUNT_SEG13_ATTRIB = T315731.SEGMENT_LOV_ID
    AND T314768.HIER_CODE = T315677.SEGMENT_LOV_ID
    AND T314768.HIER_NAME = T315677.SEGMENT_LOV_NAME
    AND T314768.HIERARCHY_ID = T315677.SEGMENT_VAL_CODE
    AND T314914.HIER_CODE = T315731.SEGMENT_LOV_ID
    AND T314914.HIER_NAME = T315731.SEGMENT_LOV_NAME
    AND T314914.HIERARCHY_ID = T315731.SEGMENT_VAL_CODE
    AND T315677.SEGMENT_LOV_NAME =
    'Responsibility_Centre_Functional'
    AND T315677.SEGMENT_LOV_ID = 1000163
    AND T315731.SEGMENT_LOV_NAME = 'Account_Master'
    AND T315731.SEGMENT_LOV_ID = 1000165
    AND ( T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER11_CODE IS NULL)
    AND (T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER12_CODE IS NULL)
    AND ( T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER8_CODE IS NULL)
    AND ( T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER9_CODE IS NULL)
    AND ( T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER10_CODE IS NULL)
    AND ( T314914.HIER1_CODE IN ('ALL_LI')
    OR T314914.HIER2_CODE IN ('S000000001')
    OR T314914.HIER3_CODE IN ('S000005150')
    OR T314914.HIER4_CODE IN ('S000005151')
    OR T314914.HIER5_CODE IN ('S000005153')
    OR T314914.HIER6_CODE IN ('S000005154')
    OR T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022'))
    AND ( T314914.HIER2_CODE IN ('S000000001')
    OR T314914.HIER3_CODE IN ('S000005150')
    OR T314914.HIER4_CODE IN ('S000005151')
    OR T314914.HIER5_CODE IN ('S000005153')
    OR T314914.HIER6_CODE IN ('S000005154')
    OR T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER2_CODE IS NULL)
    AND ( T314914.HIER3_CODE IN ('S000005150')
    OR T314914.HIER4_CODE IN ('S000005151')
    OR T314914.HIER5_CODE IN ('S000005153')
    OR T314914.HIER6_CODE IN ('S000005154')
    OR T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER3_CODE IS NULL)
    AND ( T314914.HIER4_CODE IN ('S000005151')
    OR T314914.HIER5_CODE IN ('S000005153')
    OR T314914.HIER6_CODE IN ('S000005154')
    OR T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER4_CODE IS NULL)
    AND ( T314914.HIER5_CODE IN ('S000005153')
    OR T314914.HIER6_CODE IN ('S000005154')
    OR T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER5_CODE IS NULL)
    AND ( T314914.HIER6_CODE IN ('S000005154')
    OR T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER6_CODE IS NULL)
    AND ( T314914.HIER7_CODE IN ('S000005062')
    OR T314914.HIER8_CODE IN ('S000005160')
    OR T314914.HIER9_CODE IN ('S000000187')
    OR T314914.HIER10_CODE IN ('S526003000')
    OR T314914.HIER11_CODE IN ('S526002012')
    OR T314914.HIER12_CODE IN ('S000001022')
    OR T314914.HIER7_CODE IS NULL)
    AND T314768.HIER1_CODE IS NOT NULL
    AND T314914.HIER20_CODE IS NOT NULL
    AND T314914.HIER13_CODE IS NULL
    AND T314914.HIER14_CODE IS NULL
    AND T314914.HIER15_CODE IS NULL
    AND T314914.HIER16_CODE IS NULL
    AND T314914.HIER17_CODE IS NULL
    AND T314914.HIER18_CODE IS NULL
    AND T314914.HIER19_CODE IS NULL)
    GROUP BY T314768.HIER1_CODE,
    T314768.HIER1_NAME,
    T314914.HIER1_CODE,
    T314914.HIER1_NAME,
    T314914.HIER2_CODE,
    T314914.HIER2_NAME,
    T314914.HIER3_CODE,
    T314914.HIER3_NAME,
    T314914.HIER4_CODE,
    T314914.HIER4_NAME,
    T314914.HIER5_CODE,
    T314914.HIER5_NAME,
    T314914.HIER6_CODE,
    T314914.HIER6_NAME,
    T314914.HIER7_CODE,
    T314914.HIER7_NAME,
    T314914.HIER8_CODE,
    T314914.HIER8_NAME,
    T314914.HIER9_CODE,
    T314914.HIER9_NAME,
    T314914.HIER10_CODE,
    T314914.HIER10_NAME,
    T314914.HIER11_CODE,
    T314914.HIER11_NAME,
    T314914.HIER12_CODE,
    T314914.HIER12_NAME,
    T314914.HIER13_CODE,
    T314914.HIER13_NAME,
    T314914.HIER14_CODE,
    T314914.HIER14_NAME,
    T314914.HIER15_CODE,
    T314914.HIER15_NAME,
    T314914.HIER16_CODE,
    T314914.HIER16_NAME,
    T314914.HIER17_CODE,
    T314914.HIER17_NAME,
    T314914.HIER18_CODE,
    T314914.HIER18_NAME,
    T314914.HIER19_CODE,
    T314914.HIER19_NAME,
    T314914.HIER20_CODE,
    T314914.HIER20_NAME),
    SAWITH1
    AS (SELECT SUM (D1.c1) OVER () AS c1,
    MAX (D1.c2) OVER (PARTITION BY D1.c22) AS c2,
    MAX (D1.c3) OVER (PARTITION BY D1.c22) AS c3,
    MAX (D1.c4) OVER (PARTITION BY D1.c22) AS c4,
    MAX (D1.c5) OVER (PARTITION BY D1.c22) AS c5,
    MAX (D1.c6) OVER (PARTITION BY D1.c22) AS c6,
    MAX (D1.c7) OVER (PARTITION BY D1.c22) AS c7,
    MAX (D1.c8) OVER (PARTITION BY D1.c22) AS c8,
    MAX (D1.c9) OVER (PARTITION BY D1.c22) AS c9,
    MAX (D1.c10) OVER (PARTITION BY D1.c22) AS c10,
    MAX (D1.c11) OVER (PARTITION BY D1.c22) AS c11,
    MAX (D1.c12) OVER (PARTITION BY D1.c22) AS c12,
    MAX (D1.c13) OVER (PARTITION BY D1.c22) AS c13,
    MAX (D1.c14) OVER (PARTITION BY D1.c22) AS c14,
    MAX (D1.c15) OVER (PARTITION BY D1.c22) AS c15,
    MAX (D1.c16) OVER (PARTITION BY D1.c22) AS c16,
    MAX (D1.c17) OVER (PARTITION BY D1.c22) AS c17,
    MAX (D1.c18) OVER (PARTITION BY D1.c22) AS c18,
    MAX (D1.c19) OVER (PARTITION BY D1.c22) AS c19,
    MAX (D1.c20) OVER (PARTITION BY D1.c22) AS c20,
    D1.c21 AS c21,
    D1.c22 AS c22,
    SUM (
    D1.c1)
    OVER (
    PARTITION BY D1.c46,
    D1.c47,
    D1.c48,
    D1.c49,
    D1.c50,
    D1.c51,
    D1.c52,
    D1.c53,
    D1.c54,
    D1.c55,
    D1.c45,
    D1.c44,
    D1.c56,
    D1.c57,
    D1.c58,
    D1.c59,
    D1.c60,
    D1.c61,
    D1.c62,
    D1.c63,
    D1.c22)
    AS c23,
    D1.c24 AS c24,
    D1.c25 AS c25,
    D1.c26 AS c26,
    D1.c27 AS c27,
    D1.c28 AS c28,
    D1.c29 AS c29,
    D1.c30 AS c30,
    D1.c31 AS c31,
    D1.c32 AS c32,
    D1.c33 AS c33,
    D1.c34 AS c34,
    D1.c35 AS c35,
    D1.c36 AS c36,
    D1.c37 AS c37,
    D1.c38 AS c38,
    D1.c39 AS c39,
    D1.c40 AS c40,
    D1.c41 AS c41,
    D1.c42 AS c42,
    D1.c43 AS c43,
    D1.c44 AS c44,
    D1.c45 AS c45,
    D1.c46 AS c46,
    D1.c47 AS c47,
    D1.c48 AS c48,
    D1.c49 AS c49,
    D1.c50 AS c50,
    D1.c51 AS c51,
    D1.c52 AS c52,
    D1.c53 AS c53,
    D1.c54 AS c54,
    D1.c55 AS c55,
    D1.c56 AS c56,
    D1.c57 AS c57,
    D1.c58 AS c58,
    D1.c59 AS c59,
    D1.c60 AS c60,
    D1.c61 AS c61,
    D1.c62 AS c62,
    D1.c63 AS c63
    FROM SAWITH0 D1)
    SELECT DISTINCT
    38 AS c1,
    D1.c24 AS c2,
    D1.c25 AS c3,
    D1.c26 AS c4,
    D1.c27 AS c5,
    D1.c28 AS c6,
    D1.c29 AS c7,
    D1.c30 AS c8,
    D1.c31 AS c9,
    D1.c32 AS c10,
    D1.c33 AS c11,
    D1.c34 AS c12,
    D1.c35 AS c13,
    D1.c36 AS c14,
    D1.c37 AS c15,
    D1.c38 AS c16,
    D1.c39 AS c17,
    D1.c40 AS c18,
    D1.c41 AS c19,
    D1.c42 AS c20,
    D1.c43 AS c21,
    D1.c21 AS c22,
    NULL AS c23,
    NULL AS c24,
    NULL AS c25,
    NULL AS c26,
    NULL AS c27,
    NULL AS c28,
    NULL AS c29,
    NULL AS c30,
    NULL AS c31,
    NULL AS c32,
    NULL AS c33,
    NULL AS c34,
    NULL AS c35,
    NULL AS c36,
    NULL AS c37,
    NULL AS c38,
    NULL AS c39,
    NULL AS c40,
    NULL AS c41,
    D1.c44 AS c42,
    D1.c45 AS c43,
    D1.c46 AS c44,
    D1.c47 AS c45,
    D1.c48 AS c46,
    D1.c49 AS c47,
    D1.c50 AS c48,
    D1.c51 AS c49,
    D1.c52 AS c50,
    D1.c53 AS c51,
    D1.c54 AS c52,
    D1.c55 AS c53,
    D1.c56 AS c54,
    D1.c57 AS c55,
    D1.c58 AS c56,
    D1.c59 AS c57,
    D1.c60 AS c58,
    D1.c61 AS c59,
    D1.c62 AS c60,
    D1.c63 AS c61,
    NULL AS c62,
    D1.c22 AS c63,
    NULL AS c64,
    NULL AS c65,
    NULL AS c66,
    NULL AS c67,
    NULL AS c68,
    NULL AS c69,
    NULL AS c70,
    NULL AS c71,
    NULL AS c72,
    NULL AS c73,
    NULL AS c74,
    NULL AS c75,
    NULL AS c76,
    NULL AS c77,
    NULL AS c78,
    NULL AS c79,
    NULL AS c80,
    NULL AS c81,
    D1.c23 AS c82,
    CASE WHEN 1 = 1 THEN 1 ELSE 0 END AS c83,
    CASE
    WHEN D1.c2 IS NULL
    AND D1.c3 IS NULL
    AND D1.c4 IS NULL
    AND D1.c5 IS NULL
    AND D1.c6 IS NULL
    AND D1.c7 IS NULL
    AND D1.c8 IS NULL
    AND D1.c9 IS NULL
    AND D1.c10 IS NULL
    AND D1.c11 IS NULL
    AND D1.c12 IS NULL
    AND D1.c13 IS NULL
    AND D1.c14 IS NULL
    AND D1.c15 IS NULL
    AND D1.c16 IS NULL
    AND D1.c17 IS NULL
    AND D1.c18 IS NULL
    AND D1.c19 IS NULL
    AND D1.c20 IS NULL
    THEN
    1
    ELSE
    0
    END
    AS c84
    FROM SAWITH1 D1
    WHERE ( D1.c44 IS NOT NULL
    AND D1.c50 IS NULL
    AND D1.c49 IS NULL
    AND D1.c22 IS NOT NULL
    AND D1.c51 IS NULL
    AND D1.c52 IS NULL
    AND D1.c53 IS NULL
    AND D1.c54 IS NULL
    AND D1.c55 IS NULL)
    /* Formatted on 12/17/2012 7:49:44 PM (QP5 v5.139.911.3011) */
    WITH OBICOMMON0
    AS (SELECT T156337.ROW_WID AS c2,
    T156337.MCAL_PERIOD_WID AS c3,
    ROW_NUMBER ()
    OVER (PARTITION BY T156337.MCAL_PERIOD_WID
    ORDER BY T156337.MCAL_PERIOD_WID DESC)
    AS c4,
    T156337.MCAL_PERIOD_NAME AS c5,
    T156337.MCAL_PER_NAME_YEAR AS c6
    FROM W_MCAL_DAY_D T156337 /* Dim_W_MCAL_DAY_D_Fiscal_Day */
    WHERE (T156337.MCAL_CAL_NAME = 'Accounting')),
    SAWITH0
    AS (SELECT CASE
    WHEN CASE D1.c4 WHEN 1 THEN D1.c2 ELSE NULL END
    IS NOT NULL
    THEN
    RANK ()
    OVER (
    ORDER BY
    CASE D1.c4 WHEN 1 THEN D1.c2 ELSE NULL END ASC NULLS LAST)
    END
    AS c1,
    D1.c2 AS c2,
    D1.c3 AS c3
    FROM OBICOMMON0 D1),
    SAWITH1
    AS (SELECT DISTINCT
    MIN (D1.c1) OVER (PARTITION BY D1.c3) AS c1, D1.c2 AS c2
    FROM SAWITH0 D1),
    SAWITH2
    AS (SELECT CASE
    WHEN CASE D1.c4 WHEN 1 THEN D1.c2 ELSE NULL END
    IS NOT NULL
    THEN
    RANK ()
    OVER (
    ORDER BY
    CASE D1.c4 WHEN 1 THEN D1.c2 ELSE NULL END ASC NULLS LAST)
    END
    AS c1,
    D1.c3 AS c2,
    D1.c5 AS c3,
    D1.c6 AS c4
    FROM OBICOMMON0 D1),
    SAWITH3 AS (SELECT DISTINCT MIN (D1.c1) OVER (PARTITION BY D1.c2) AS c1,
    D1.c2 AS c2,
    D1.c3 AS c3,
    D1.c4 AS c4
    FROM SAWITH2 D1),
    SAWITH4
    AS ( SELECT SUM (T91707.TD_OTHER_REP_AMT) AS c1,
    T314914.HIER1_NAME AS c2,
    D2.c3 AS c3,
    T314914.HIER1_CODE AS c4,
    D2.c2 AS c5
    FROM W_HIERARCHY_D T314914 /* Dim_W_HIERARCHY_D_Segment13 */
    W_GL_SEGMENT_D T315731 /* Dim_W_GL_SEGMENT_D_Segment13 */
    W_GL_ACCOUNT_D T91397 /* Dim_W_GL_ACCOUNT_D */
    W_GL_OTHER_F T91707 /* Fact_W_GL_OTHER_F */
    SAWITH1 D4,
    SAWITH3 D2
    WHERE ( T314914.HIER_CODE = T315731.SEGMENT_LOV_ID
    AND T314914.HIER_NAME = T315731.SEGMENT_LOV_NAME
    AND T91397.ROW_WID = T91707.GL_ACCOUNT_WID
    AND T91707.ACCT_PERIOD_END_DT_WID = D4.c2
    AND T314914.HIERARCHY_ID = T315731.SEGMENT_VAL_CODE
    AND T91397.ACCOUNT_SEG13_CODE = T315731.SEGMENT_VAL_CODE
    AND T91397.ACCOUNT_SEG13_ATTRIB = T315731.SEGMENT_LOV_ID
    AND T315731.SEGMENT_LOV_NAME =
    'Account_Retail_Distribution'
    AND T315731.SEGMENT_LOV_ID = 1000165
    AND D2.c1 = D4.c1
    AND (D2.c4 IN ('2011', '2012')))
    GROUP BY T314914.HIER1_CODE,
    T314914.HIER1_NAME,
    D2.c2,
    D2.c3)
    SELECT D1.c1 AS c1,
    D1.c2 AS c2,
    D1.c3 AS c3,
    D1.c4 AS c4,
    D1.c5 AS c5,
    D1.c6 AS c6
    FROM ( SELECT DISTINCT 0 AS c1,
    D1.c2 AS c2,
    D1.c3 AS c3,
    D1.c4 AS c4,
    D1.c1 AS c5,
    D1.c5 AS c6
    FROM SAWITH4 D1
    ORDER BY c2 NULLS FIRST, c4 NULLS FIRST, c3) D1
    WHERE ROWNUM <= 65001

    Hello Gurus, Experts
    Any help/tips here ...

  • Creating a Vendor and Accounts Payable  Invoice

    Hello Everyone,
    At the moment we are using transaction FK01 or XK01 to create a Vendor on the SAP system. We want the process of "Creating a Vendor" and "Creating Accounts Payable Invoice" to be available on Portal which allows us to automate some part of our business process.
    Could anyone suggest me a proper approach for this requirements. I would appreciate your help. It is a bit urg*nt.
    Regards,
    PG.

    I would check in SE37 to see if there is any other BAPIs. Alternatively you could debug the transaction in R/3 to see which function modules it uses. It's possible that there is no BAPI, but there is a non RFC function module for creating a vendor. In that case, you can create a "wrapper" for it, ie your own function module that is rfc enabled and that simpley forwards the call internally to the function module that creates the vendor.
    I would also search the ABAP forums to find out if there are any function modules that provide this operation. If you don't find any threads you can try posting a question. It's best to post questions concerning BAPIs and function modules in the ABAP forums (or related forums).
    Failing all this or if none of the above fits your requirements, you could create your own BAPI to perform this operation. But 9/10 there is a standard function module to perform most operations. Don't worry if it's not rfc enabled like a BAPI, just create a wrapper around it.
    Cheers,
    Dion

  • Accounts payable: Reconciliation field(s)

    Dear all,
    I have posted the same thread in the Materials Management forum as I am not sure where it belongs. As I am not very familiar with vendor payments, I hope you can help me with this question.
    As per our accounts payable department, when they send a check to a vendor, they need to reference the payment with the bill of lading number.
    But the bill of lading is not available in the payments standard transaction: F110. So I was wondering: which field(s) (which are printed on the check) are usually used by vendors for payments reconcialiation?
    Thanks,
    Annabelle

    Hi Annabelle,
       When you enter an invoice with reference to a purchase order, the system suggests data from the purchase order and the goods receipts against the PO (for example, vendor, material, quantity still to be invoiced, expected amount per item, and terms of payment). You can overwrite these default values if the invoice actually submitted by the vendor contains other values. The system checks whether your input is allowed. In doing so, it may issue warning or error messages.
    You can also assign the invoice items to a purchase order using the number of the delivery note or bill of lading, provided that these numbers were entered at the time of goods receipt.
    With Regards
    Srinivas

Maybe you are looking for

  • Restricting employee to avail the casual leave in a quarter

    Hi Experts, I would like to know where is the setting in Time Management for restricting the no. of days to be availed in quarter for a casual leave i.e. employee should not avail more than 3 casual leaves in a quarter. Regards Santosh Rajam

  • Weblogic server 10.0 MP2 version compatibility with EJB3.0

    Is it ok to use EJB3.0 in 10.0 MP2 ? Are there any pitfalls or problems with EJB3.0 implementation with webloigc 10.0 MP2 version? Currently we are using weblogic 10.0 MP2 version and planning to use EJB3.0 for one of our projects. Do we still need t

  • Using Photoshop CS5 with Production Premium CS4

    I have a 32 bit system and at least 2 programs in PP CS5 that I would use the most (Premiere & After Effects) require a 64 bit system.  Photoshop apparently doesn't.  Will Photoshop CS5 (and Bridge that comes with it) work with PP CS4?

  • Naming problem

    Hello, Just wondering if anyone can help me, I have come across an annoying problem in my code and i dont know how to fix it :S Basically I have a load of movie clips that I am containing in the library and loading onto the stage via the addChild();

  • HT4847 How can I delete an iCloud backup of a device that has been wiped and sold?

    I have wiped my old iPhone and it has already been repurposed. How can I delete its backup from iCloud now?