Query on Performance issues relating to a report

Hi Group,
I have an issue while running a report which was creating Business Partners for (both Company and the Contact person and as well as relationship b/w them).
This report was having BAPI( for creating Business Partners ) and also for creating relationships and the report was taking too much of response time.
I was thinking it to be the reason for calling BAPIs. But, I want to know from you that is that the real cause or it might be the other cause.
So please kindly let me know inputs from your side on this.
thanks in advance.
Regards,
Vishnu.

Hi
I think it's always better to use the provided standard fm's and bapi's to make changes to the data in the system instead of directly placing them in the tables.
One thing you can do is try to use parallel processing. E.g 10.000 BP's should be created. In that case schedule 4 jobs to create the Bp's instead of 1 job creating the whole lot.
Kind regards, Rob Dielemans

Similar Messages

  • 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 while opening the report

    HI,
    I am working BO XI R3.1.there is performance issue while opening the report in BO Solris Server but  on window server it is compratively fast.
    we have few reports which contains 5 fixed prompt 7 optional prompt.
    out of 5 fixed prompt 3 prompt is static (it contains 3 -4 record only )which is coming from materlied view.
    we have already use many thing for improve performance in report like-
    1) Index Awareness
    2) Aggregate Awareness
    3) Array fatch size-250
    3) Aray bind time -32767
    4) Login time out -600
    the issue is that before refresh opening the report iteslf taking time 1.30 min on BO solris server but same report taking time in BO window server 45 sec. even we  import on others BO solris server it is taking same time as per old solris server(1.30 min).
    when we close the trace in solris server than it is taking 1.15  sec time.it should not be intial phase it is not hitting more on database.so why it is taking that much time while opening the report.
    could you please guide us where exectly problem is there and how we can improve performance for opening the report.In case the problem related to solris server so what would be and how can we rectify.
    Incase any further input require for the same feel free to ask me.

    Hi Kumar,
    If this is happening with all the reports then this issue seems to be due to firewall or security settings of Solaris OS.
    Please try to lower down the security level in solaris and test for the issue.
    Regards,
    Chaitanya Deshpande

  • Performance issue in HR Payroll Report

    Hi Experts
    I having performance issue in HR payroll report
    My issue as follows
    I have selection period to select date range
    if I select start date & end date Which is giving EMP name, wage type,wage text, amount, etc
    whenever I excute it takes morethan one hour to get the resust
    my code is some wht like this
    loop at GT_REDIR where
    begda(start date) ge pnpbegda and
    endat(end date) le pnpendat and
    paytyp eq ''
    move gt-sqnr to  lv_sqnr
    call function PYXX_READ_PAYROLL_RESULT
    here i am passing pernr  and sequence number
    please give me some idea to fix this issue
    Thanks in Advance
    Gopinath Subramanyam

    Hi Jhings
    Thanks for Your immediate reply
    data is  coming from cluster table and also I am using Logical database
    I will post my code here soon
    Regards
    Gopinath subramayam

  • Performance issues -- related to printing

    Hi All,
    I am haviing production system performance issues related to printing. endusers are telling the printing is slow for almost printers. We are having more that 40 to 50 printers in landscape.
    As per my primary investigation I didnt find any issues in TSP01 & TSP02 tables. But I can see the table TST01 and TST03 table having many number of entries (more that lakh). I dont have idead about this table. Is ther eany thing related to this table where the print causes slowness or any other factors also makes this printing issue .. Please advice ..
    thanks in advance

    Hai,
    Check the below link...
    http://help.sap.com/saphelp_nw70/helpdata/en/c1/1cca3bdcd73743e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/fc/04ca3bb6f8c21de10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/86/1ccb3b560f194ce10000000a114084/content.htm
    TemSe cannot administer objects that require more than two gigabytes of storage space, regardless of whether the objects are stored in the database or in the file system. Spool requests of a size greater than two gigabytes must therefore be split into several smaller requests.
    It is enough if you perform the regular background jobs and Temse consistency checks for the tables.
    This will help in controlling the capacity problems.
    If you change the profile parameter rspo/store_location parameter value to 'G' this will make the performance better. The disadvantages are TemSe data must be backed up and restored separately from the database using operating system tools, In the event of problems, it can be difficult to restore consistency between the data held in files and the TemSeu2019s object management in the database. Also you have take care of the Hard disk requirements because in some cases, spool data may occupy several hundred megabytes of disk storage. If you use the G option, you must ensure that enough free disk space is available for spool data.
    Regards,
    Yoganand.V

  • 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

  • Performance issue with Hyperion Interactive Reporting  Report

    Hi,
    We created a report in Hyperion Interactive reporting using Hyperion Essbase as database connection file .
    Report performance was good in Interactive reporting Studio we don't have any problem in studio.
    when we open the report in Hyperion Workspace report performance is very very slow. We are using system 11.1.1.3
    Any suggestions to resolve performance issue will be really helpful.
    Thanks in advance
    Regards
    Vamsi

    Thank you so much, It is working fine when the report is in table structure (List Report. I mean insert a table and drag and drop the fact items and dimention items in to the table)
    The requirement is looks like that, it is not a pivot table. Now I want apply the different color or shadow for Item1 and Item 2 in all groups... Please help me.
    Total Fact Fact 1 fact 2 Fact 3 ......
    Group 1
    Item 1 Item 1 000 000 000 000 ...
    Item 2 Item2 000 000 000 000 ....
    Group 2
    Item 1 Item 1 000 000 000 000 ...
    Item 2 Item2 000 000 000 000 ....
    Group 3
    Item 1 Item 1 000 000 000 000
    Item 2 Item2 000 000 000 000
    Thanks and Regards,
    Murugan

  • Performance issues related to logging (ForceSingleTraceFile option)

    Dear SDN members,
    I have a question about logging.
    I like to place my logs/traces for every application in different log files. By doing this you have to set the ForceSingleTraceFile option to NO (in the config tool).
    But in a presentation of SAP, named SAP Web Application Server 6.40; SAP Logging and Tracing API, is stated:
    - All traces by default go to the default trace file.
         - Good for performance
              - On production systems, this is a must!!!
    - Hard to find your trace messages
    - Solution: Configure development systems to pipe traces and logs for applications to their own specific trace file
    But I want the logs/traces also by our customers (production systems) in separate files. So my question is:
    What are the performance issues we face, if we turn the ForceSingleTraceFile option to NO by our customers?
    and
    If we turn the ForceSingleTraceFile to NO will the logs/traces of the SAP applications also go to different files? If so, then I can imagine that it will be difficult to find the logs of the different SAP applications.
    I hope that someone can clarify the working of the ForceSingleTraceFile setting.
    Kind regards,
    Marinus Geuze

    Dear Marinus,
    The performance issues with extensive logging are related to high memory usage (for concatenation/generation of the messages which are written to the log files) and as result increased garbare collection frequency, as well as high disk I/O and CPU overhead for the actual logging.
    Writing to same trace file, if logging is extensive can become a bottleneck.
    Anyway it is not related to if you should write the logs to the default trace of a standard location. I believe that the recommendation in the documentation is just about using the standard logging APIs of the SAP Java Server, because they are well optimized.
    Best regards,
    Sylvia

  • Query giving performance issues.

    Hi All,
    Following query is giving performance issues. Query execution is taking around 11 minutes. Our client requirement is to get the data for the query in 30 sec to 1 min. Please suggest.
    SELECT
    DISTINCT r.rptid, p.product_id, p.vnd_dscr, p.vendor_cd, p.Firm_Cd, a.is_mm_sweep IsMoneyMarket
    FROM
    dev.ac_cube a,
    dev.rpt_master_rep_list_view r,
    dev.cur_ps_cube p
    WHERE a.repid = r.rep_id
    AND a.accountkey = p.accountkey
    AND p.product_id IS NOT NULL
    AND p.product_id != 'CASH'
    AND r.RPTID = '42817'
    Number of distinct records fetched by above query : 34445
    Number of records in dev.ac_cube table : 13.6 million
    Number of records in dev.cur_ps_cube table : 7 million
    Number of records in dev.rpt_master_rep_list_view for RPTID '42817' : 118354
    repid, product_id is indexed column in dev.ac_cube table. accountkey is primary key in dev.ac_cube table.
    rep_id is indexed column in base table on which dev.rpt_master_rep_list_view view is created

    The output is not complete as i expected. Have you followed the steps I have mentioned in my earlier post
    Also when posting output enclose between two {*code*} ...{*code*} (remove * within braces). It displays everything between the tags as proper formatted output otherwise its really hard to read and understand
    See sample below. However you need to get the session id, sql id, display_cursor output exactly in same way as mentioned in my previous post
    SQL> set arraysize 200 timing on serveroutput on linesize 200;
    SQL> set autotrace traceonly explain statistics;
    SQL> select level from dual  connect by level <= 10000;
    10000 rows selected.
    Elapsed: 00:00:00.09
    Execution Plan
    Plan hash value: 1236776825
    | Id  | Operation                    | Name | Rows  | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |      |     1 |     2   (0)| 00:00:01 |
    |   1 |  CONNECT BY WITHOUT FILTERING|      |       |            |          |
    |   2 |   FAST DUAL                  |      |     1 |     2   (0)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
              0  consistent gets
              0  physical reads
              0  redo size
          57406  bytes sent via SQL*Net to client
            919  bytes received via SQL*Net from client
             51  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
          10000  rows processed
    SQL>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SQL Query Having performance issues

    I need help on rewriting this query, I am having performance issues with the way it is now. I create a temporary table and query against it. Any help will be appreciated. Thanks, Antonio
    Here it is:
    create global temporary table pr_php_elig_tmp
    on commit preserve rows as
    SELECT UNIQUE A.SAK_PROV, A.CDE_SERVICE_LOC, a.sak_short
    FROM T_PR_PHP_ELIG A,
    T_PR_TYPE C
    WHERE C.SAK_PROV = A.SAK_PROV
    AND C.CDE_SERVICE_LOC = A.CDE_SERVICE_LOC
    AND C.CDE_PROV_TYPE not in ('01', '03', '08', '24', '27', '31')
    AND A.SAK_PROV_PGM not in (11, 13)
    AND A.DTE_END >= :il_current_date
    AND A.DTE_EFFECTIVE <= :il_prev_18_months
    AND NOT EXISTS (
    SELECT 'X'
    FROM T_PR_GRP_MBR T
    WHERE T.SAK_PROV = A.SAK_PROV
    AND T.CDE_SVC_LOC_MBR = A.CDE_SERVICE_LOC)
    AND NOT EXISTS (
    select a.sak_prov, a.cde_service_loc
    from t_pmp_svc_loc d
    where a.sak_prov = d.sak_prov
    and a.cde_service_loc = d.cde_service_loc
    and d.dte_end >= :il_current_date)
    ORDER BY A.SAK_PROV, A.CDE_SERVICE_LOC;
    select * from pr_php_elig_tmp
    minus
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_dntl_dtl temp01
                   WHERE temp01.sak_prov_perf = a.sak_prov
                   and temp01.cde_svc_loc_perf = a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
                   HAVING MAX(temp01.DTE_FIRST_SVC) >= :il_prev_18_months
                   OR NVL(MAX(temp01.DTE_FIRST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_dntl_hdr temp02
                   WHERE ( (temp02.prov_billing     = a.sak_prov
                   and temp02.cde_service_loc = a.cde_service_loc)
                   OR     (temp02.sak_prov_perf     = a.sak_prov
                   and temp02.cde_perf_svc_loc = a.cde_service_loc)
                   OR     (temp02.sak_prov_referring = a.sak_prov
                   and temp02.cde_svc_loc_ref_1 = a.cde_service_loc)
                   OR     (temp02.sak_prov_referring_2 = a.sak_prov
                   and temp02.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
                   HAVING MAX(temp02.DTE_FINAL)     >= :il_prev_18_months
                   OR NVL(MAX(temp02.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_phrm_hdr temp03
                   WHERE ( (temp03.prov_billing     = a.sak_prov and
                        temp03.cde_service_loc = a.cde_service_loc)
                   OR     (temp03.sak_prov_rendering = a.sak_prov and
                        temp03.cde_svc_loc_rend = a.cde_service_loc)
                   OR     (temp03.sak_presc_prov = a.sak_prov and
                        temp03.cde_svc_loc_presc = a.cde_service_loc)
                   OR     temp03.id_prov_prescrb = to_char(a.sak_prov) || a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
                   HAVING     MAX(temp03.DTE_FINAL) >= :il_prev_18_months
                   OR     NVL(MAX(temp03.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_phys_dtl temp04
              WHERE ( (temp04.sak_prov_perf     = a.sak_prov
                   and     temp04.cde_svc_loc_rend = a.cde_service_loc)
                   OR (temp04.sak_prov_referring = a.sak_prov
                   and     temp04.cde_svc_loc_ref_1 = a.cde_service_loc)
                   OR (temp04.sak_prov_referring_2 = a.sak_prov
                   and     temp04.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING     MAX(temp04.DTE_LAST_SVC)     >= :il_prev_18_months
                   OR     NVL(MAX(temp04.DTE_LAST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_phys_hdr temp05
              WHERE ( (temp05.prov_billing     = a.sak_prov
                   and     temp05.cde_service_loc     = a.cde_service_loc)
                   OR (temp05.sak_prov_perf     = a.sak_prov
                   and     temp05.cde_perf_svc_loc = a.cde_service_loc)
                   OR (temp05.sak_prov_referring = a.sak_prov
                   and     temp05.cde_svc_loc_ref_1 = a.cde_service_loc)
                   OR (temp05.sak_prov_referring_2 = a.sak_prov
                   and     temp05.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING     MAX(temp05.DTE_FINAL) >= :il_prev_18_months
                   OR     NVL(MAX(temp05.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_ub92_dtl temp06
              WHERE ( (temp06.sak_pr_other     = a.sak_prov
                   and     temp06.cde_scv_loc_other = a.cde_service_loc)
                   OR (temp06.sak_pr_other_2     = a.sak_prov
                   and     temp06.cde_svc_loc_other_2 = a.cde_service_loc)
                   OR (temp06.sak_pr_attend     = a.sak_prov
                   and     temp06.cde_svc_loc_attend = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING     MAX(temp06.DTE_LAST_SVC)     >= :il_prev_18_months
                   OR     NVL(MAX(temp06.DTE_LAST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_ub92_hdr temp07
              WHERE ( (temp07.prov_billing     = a.sak_prov
                   and     temp07.cde_service_loc     = a.cde_service_loc)
              OR (temp07.sak_pr_facility     = a.sak_prov
                   and     temp07.cde_svc_loc_fa     = a.cde_service_loc)
              OR (temp07.sak_pr_other     = a.sak_prov
                   and     temp07.cde_svc_loc_other = a.cde_service_loc)
              OR (temp07.sak_pr_other_2     = a.sak_prov
                   and     temp07.cde_svc_loc_other_2 = a.cde_service_loc)
              OR (temp07.sak_pr_attend     = a.sak_prov
                   and     temp07.cde_svc_loc_attend = a.cde_service_loc)
              OR     temp07.id_prov_attend     = to_char(a.sak_prov) || a.cde_service_loc
              OR     temp07.id_prov_other     = to_char(a.sak_prov) || a.cde_service_loc
              OR     temp07.id_prov_other_2     = to_char(a.sak_prov) || a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp07.DTE_FINAL)     >= :il_prev_18_months
                   OR     NVL(MAX(temp07.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_dntl_dtl temp08
              WHERE temp08.sak_prov_perf     = a.sak_prov
                   and temp08.cde_svc_loc_perf     = a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp08.DTE_FIRST_SVC) >= :il_prev_18_months
                   OR     NVL(MAX(temp08.DTE_FIRST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_dntl_hdr     temp09
              WHERE ( (temp09.prov_billing     = a.sak_prov
                   and     temp09.cde_service_loc     = a.cde_service_loc)
              OR (temp09.sak_prov_perf     = a.sak_prov
                   and     temp09.cde_perf_svc_loc = a.cde_service_loc)
              OR (temp09.sak_prov_referring = a.sak_prov
                   and     temp09.cde_svc_loc_ref_1 = a.cde_service_loc)
              OR (temp09.sak_prov_referring_2 = a.sak_prov
                   and     temp09.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp09.DTE_FINAL)     >= :il_prev_18_months
                   OR     NVL(MAX(temp09.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_pharm_hdr temp10
              WHERE ( (temp10.prov_billing     = a.sak_prov
                   and     temp10.cde_service_loc     = a.cde_service_loc)
              OR (temp10.sak_prov_rend     = a.sak_prov
                   and     temp10.cde_svc_loc_rend = a.cde_service_loc)
              OR (temp10.sak_presc_prov     = a.sak_prov
                   and     temp10.cde_svc_loc_presc = a.cde_service_loc)
              OR     temp10.id_prov_prescrb     = to_char(a.sak_prov) || a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp10.DTE_FINAL)     >= :il_prev_18_months
                   OR     NVL(MAX(temp10.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_phys_dtl temp11
              WHERE ( (temp11.sak_prov_perf     = a.sak_prov
                   and     temp11.cde_svc_loc_rend = a.cde_service_loc)
              OR (temp11.sak_prov_referring = a.sak_prov
                   and     temp11.cde_svc_loc_ref_1 = a.cde_service_loc)
              OR (temp11.sak_prov_referring_2 = a.sak_prov
                   and     temp11.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp11.DTE_LAST_SVC)     >= :il_prev_18_months
                   OR     NVL(MAX(temp11.DTE_LAST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_phys_hdr     temp12
              WHERE ( (temp12.prov_billing     = a.sak_prov
                   and     temp12.cde_service_loc     = a.cde_service_loc)
              OR (temp12.sak_prov_perf     = a.sak_prov
                   and     temp12.cde_perf_svc_loc = a.cde_service_loc)
              OR (temp12.sak_prov_referring = a.sak_prov
                   and     temp12.cde_svc_loc_ref_1 = a.cde_service_loc)
              OR (temp12.sak_prov_referring_2 = a.sak_prov
                   and     temp12.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp12.DTE_FINAL)     >= :il_prev_18_months
                   OR     NVL(MAX(temp12.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_ub92_dtl temp13
              WHERE ( (temp13.sak_pr_other     = a.sak_prov
                   and     temp13.cde_scv_loc_other = a.cde_service_loc)
                   OR (temp13.sak_pr_other_2     = a.sak_prov
                   and     temp13.cde_svc_loc_other_2 = a.cde_service_loc)
                   OR (temp13.sak_pr_attend     = a.sak_prov
                   and     temp13.cde_svc_loc_attend = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING     MAX(temp13.DTE_LAST_SVC)     >= :il_prev_18_months
                   OR     NVL(MAX(temp13.DTE_LAST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_ub92_hdr     temp14
              WHERE ( (temp14.prov_billing     = a.sak_prov
                   and     temp14.cde_service_loc     = a.cde_service_loc)
              OR (temp14.sak_pr_facility     = a.sak_prov
                   and     temp14.cde_svc_loc_fa     = a.cde_service_loc)
              OR (temp14.sak_pr_other_2     = a.sak_prov
                   and     temp14.cde_svc_loc_other_2 = a.cde_service_loc)
              OR (temp14.sak_pr_attend     = a.sak_prov
                   and     temp14.cde_svc_loc_attend = a.cde_service_loc)
              OR (temp14.sak_pr_other     = a.sak_prov
                   and     temp14.cde_svc_loc_other = a.cde_service_loc)
              OR     temp14.id_prov_attend     = to_char(a.sak_prov) || a.cde_service_loc
              OR     temp14.id_prov_other     = to_char(a.sak_prov) || a.cde_service_loc
              OR     temp14.id_prov_other_2     = to_char(a.sak_prov) || a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp14.DTE_FINAL)     >= :il_prev_18_months
                   OR     NVL(MAX(temp14.DTE_FINAL),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_dental_dtl temp15
              WHERE temp15.sak_prov_perf     = a.sak_prov
                   and temp15.cde_svc_loc_perf     = a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp15.DTE_FIRST_SVC) >= :il_prev_18_months
                   OR     NVL(MAX(temp15.DTE_FIRST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_dental_hdr temp16
              WHERE ( (temp16.sak_prov_perf     = a.sak_prov
                   and     temp16.cde_perf_svc_loc = a.cde_service_loc)
              OR (temp16.sak_prov_referring = a.sak_prov
                   and     temp16.cde_svc_loc_ref_1 = a.cde_service_loc)
              OR (temp16.sak_prov_referring_2 = a.sak_prov
                   and     temp16.cde_svc_loc_ref_2 = a.cde_service_loc)
              OR (temp16.prov_billing     = a.sak_prov
                   and     temp16.cde_service_loc     = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING ((MAX(temp16.DTE_LAST_SVC) >= :il_prev_18_months
                   OR     NVL(MAX(temp16.DTE_LAST_SVC),0) = 0)
                   and (MAX(temp16.DTE_BILLED) >= :il_prev_18_months
                   OR     NVL(MAX(temp16.DTE_BILLED),0) = 0) )
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_phrm_hdr temp17
              WHERE ( (temp17.prov_billing     = a.sak_prov
                   and     temp17.cde_service_loc     = a.cde_service_loc)
              OR (temp17.sak_prov_rend     = a.sak_prov
                   and     temp17.cde_svc_loc_rend = a.cde_service_loc)
              OR (temp17.sak_presc_prov     = a.sak_prov
                   and     temp17.cde_svc_loc_presc = a.cde_service_loc)
              OR     temp17.id_prov_prescrb     = to_char(a.sak_prov) || a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp17.DTE_BILLED)     >= :il_prev_18_months
                   OR     NVL(MAX(temp17.DTE_BILLED),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_phys_dtl temp18
              WHERE ( (temp18.sak_prov_perf     = a.sak_prov
                   and     temp18.cde_svc_loc_rend = a.cde_service_loc)
              OR (temp18.sak_prov_referring = a.sak_prov
                   and     temp18.cde_svc_loc_ref_1 = a.cde_service_loc)
              OR (temp18.sak_prov_referring_2 = a.sak_prov
                   and     temp18.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp18.DTE_LAST_SVC)     >= :il_prev_18_months
                   OR     NVL(MAX(temp18.DTE_LAST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_phys_hdr temp19
              WHERE ( (temp19.prov_billing     = a.sak_prov
                   and     temp19.cde_service_loc     = a.cde_service_loc)
              OR (temp19.sak_prov_perf     = a.sak_prov
                   and     temp19.cde_perf_svc_loc = a.cde_service_loc)
              OR (temp19.sak_prov_referring = a.sak_prov
                   and     temp19.cde_svc_loc_ref_1 = a.cde_service_loc)
              OR (temp19.sak_prov_referring_2 = a.sak_prov
                   and     temp19.cde_svc_loc_ref_2 = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING ((MAX(temp19.DTE_LAST_SVC) >= :il_prev_18_months
                   OR     NVL(MAX(temp19.DTE_LAST_SVC),0) = 0)
                   and (MAX(temp19.DTE_BILLED)     >= :il_prev_18_months
                   OR     NVL(MAX(temp19.DTE_BILLED),0) = 0) )
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_ub92_dtl temp20
              WHERE ( (temp20.sak_pr_other     = a.sak_prov
                   and     temp20.cde_scv_loc_other = a.cde_service_loc)
                   OR (temp20.sak_pr_other_2     = a.sak_prov
                   and     temp20.cde_svc_loc_other_2 = a.cde_service_loc)
                   OR (temp20.sak_pr_attend     = a.sak_prov
                   and     temp20.cde_svc_loc_attend = a.cde_service_loc)
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING     MAX(temp20.DTE_LAST_SVC)     >= :il_prev_18_months
                   OR     NVL(MAX(temp20.DTE_LAST_SVC),0) = 0
    union
    select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_ub92_hdr temp22
              WHERE ( (temp22.prov_billing     = a.sak_prov
                   and     temp22.cde_service_loc     = a.cde_service_loc)
              OR (temp22.sak_pr_facility     = a.sak_prov
                   and     temp22.cde_svc_loc_fa     = a.cde_service_loc)
              OR (temp22.sak_pr_other_2     = a.sak_prov
                   and     temp22.cde_svc_loc_other_2 = a.cde_service_loc)
              OR (temp22.sak_pr_attend     = a.sak_prov
                   and     temp22.cde_svc_loc_attend = a.cde_service_loc)
              OR (temp22.sak_pr_other     = a.sak_prov
                   and     temp22.cde_svc_loc_other = a.cde_service_loc)
              OR     temp22.id_prov_attend     = to_char(a.sak_prov) || a.cde_service_loc
              OR     temp22.id_prov_other     = to_char(a.sak_prov) || a.cde_service_loc
              OR     temp22.id_prov_other_2     = to_char(a.sak_prov) || a.cde_service_loc
                   GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
              HAVING MAX(temp22.DTE_BILLED)     >= :il_prev_18_months
                   OR     NVL(MAX(temp22.DTE_BILLED),0) = 0
    );

    Perhaps an approach like this would work better. No promises, but it's worth a try.
    SELECT *
      FROM pr_php_elig_tmp a
    WHERE NOT EXISTS (
             SELECT   a.sak_prov,
                      a.cde_service_loc,
                      a.sak_short
                 FROM aim01.t_deny_dntl_dtl temp01
                WHERE temp01.sak_prov_perf = a.sak_prov
                  AND temp01.cde_svc_loc_perf = a.cde_service_loc
             GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
               HAVING MAX (temp01.dte_first_svc) >= :il_prev_18_months
                   OR NVL (MAX (temp01.dte_first_svc), 0) = 0)
       AND NOT EXISTS (
             SELECT   a.sak_prov,
                      a.cde_service_loc,
                      a.sak_short
                 FROM aim01.t_deny_dntl_hdr temp02
                WHERE (   (    temp02.prov_billing = a.sak_prov
                           AND temp02.cde_service_loc = a.cde_service_loc)
                       OR (    temp02.sak_prov_perf = a.sak_prov
                           AND temp02.cde_perf_svc_loc = a.cde_service_loc)
                       OR (    temp02.sak_prov_referring = a.sak_prov
                           AND temp02.cde_svc_loc_ref_1 = a.cde_service_loc)
                       OR (    temp02.sak_prov_referring_2 = a.sak_prov
                           AND temp02.cde_svc_loc_ref_2 = a.cde_service_loc))
             GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
               HAVING MAX (temp02.dte_final) >= :il_prev_18_months
                   OR NVL (MAX (temp02.dte_final), 0) = 0)

  • Performance issue related to OWM? Oracle version is 10.2.0.4

    The optimizer picks hash join instead of nested loop for the queries with OWM tables, which causes full table scan everywhere. I wonder if it happens in your databases as well, or just us. If you did and knew what to do to solve this, it would be great appriciated! I did log in a SR to Oracle but it usually takes months to reach the solution.
    Thanks for any possible answers!

    Ha, sounded like you knew what I was talking about :)
    I thought the issue must've had something to do with OWM because some complicate queries have no performance issue while they're regular tables. There's a batch job which took an hour to run now it takes 4.5 hours. I just rewrote the job to move the queries from OWM to regular tables, it takes 20 minutes. However today when I tried to get explain plans for some queries involve regular tables with large amount of data, I got the same full table scan problem with hash join. So I'm convinced that it probably is not OWM. But the patch for removing bug fix didn't help with the situation here.
    I was hoping that other companies might have this problem and had a way to work around. If it's not OWM, I'm surprised that this only happens in our system.
    Thanks for the reply anyway!

  • Performance ISSUE related to AGGREGATE

    hi Gem's can anybody give the list of issue which we can face related to AGGREGATE maintananece in support project.
    Its very urgent .plz.........respond to my issue.its a urgent request.
    any link any thing plz send me
    my mail id is
        [email protected]

    Hi,
    Try this.
    "---" sign is the valuation of the aggregate. You can say -3 is the valuation of the aggregate design and usage. ++ means that its compression is good and access is also more (in effect, performance is good). If you check its compression ratio, it must be good. -- means the compression ratio is not so good and access is also not so good (performance is not so good).The more is the positives...more is useful the aggregate and more it satisfies the number of queries. The greater the number of minus signs, the worse the evaluation of the aggregate. The larger the number of plus signs, the better the evaluation of the aggregate.
    if "-----" then it means it just an overhead. Aggregate can potentially be deleted and "+++++" means Aggregate is potentially very useful.
    Refer.
    http://help.sap.com/saphelp_nw70/helpdata/en/b8/23813b310c4a0ee10000000a114084/content.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/60/f0fb411e255f24e10000000a1550b0/frameset.htm
    Run your query in RSRT and run the query in the debug mode. Select "Display Aggregates Found" and "Do not use cache" in the debug mode. This will tell you if it hit any aggregates while running. If it does not show any aggregates, you might want to redesign your aggregates for the query.
    use tool RSDDK_CHECK_AGGREGATE in se38 to check for the corrupt aggregates
    If aggregates contain incorrect data, you must regenerate them.
    Note 646402 - Programs for checking aggregates (as of BW 3.0B SP15)
    Check   SE11 > table RSDDAGGRDIR . You can find the last callup in the table.
    Generate Report in RSRT 
    http://help.sap.com/saphelp_nw04/helpdata/en/74/e8caaea70d7a41b03dc82637ae0fa5/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4c0ab590-0201-0010-bd9a-8332d8b4f09c
    /people/juergen.noe/blog/2007/12/13/overview-important-bi-performance-transactions
    /people/prakash.darji/blog/2006/01/26/query-optimization
    Cube Performance
    /thread/785462 [original link is broken]
    Thanks,
    JituK

  • Performance issue - Open a Crystal Report from SAP BW

    Hi,
    I have an general question on the performance of Crystal Reports: We are using Crystal Reports 2008 SP 2 in context with SAP BW 7.0. We don't have a BO XI. We use the BW as a central storage for our reports. Now we have the problem that the opening of some reports takes a long time. For expample one report needs ~13 secound an another > 5 minutes.
    Where can be the problem? What happens in SAP BW when a report is called? And what can we do to make it faster?
    Thanks for your informations!

    Hi Ingo,
    the value of MaxPickListSize is "c8".
    Yesterday I have spent a lot of time to find the bottleneck. I have traced the SQL statements, which are performed from Crystal Reports / Integration Kit when I open a report. It might be the values for the parameters. That's our situation:
    Crystal Reports
           |
    Query (restriced on Cube 1)
           |
    MultiProvider
      - Cube 1
      - Cube 2
      - Cube 3
      - DSO 1
    The slow report is based on the BW Query and in the filter restricted to the Cube 1. If I open the report, all values for the parameters are read from all the InfoProviders under the MultiProvider (Cube 1, Cube 2 Cube 3 and DSO 1). The very big DSO 1, which is not used, increases the duration extremly. This may not be the desired behavior?! Is this a bug? I would expected that only the values are loaded from Cube 1.

  • Performance issue of loading a report

    Post Author: satish_nair31
    CA Forum: General
    Hi,
    I am facing performance related problem in some our reports where we have to fetch some 1-2 lakhs of reports for display. Initially we are passing the dataset as the source of data to the report. It takes hell of time to load using this technique. After that for improving the performance we are only passing the filter condition through the report viewer object. This way we have improved a lot but now also its taking some time to load reports which is not acceptable. Is there any way to improve the performance.

    Post Author: synapsevampire
    CA Forum: General
    How could you possibly know if you're in the same situation, the original poster didn't include the software or the version being used, whether it's the RDC, etc. Very likely the reason why they received no responses.
    They also referenced 2 different methods for retrieving the data, which are you using?
    The trick is to make sure that you are passing all of the WHERE conditions in the SQL to the database.
    You can probably check this using a database tool, but again, nothing technical in your post about the database either, you certainly shouldn't expect quality help.
    -k

  • Performance issue related to BSIS table:pls help

    Theres a select statement which fetches data from BSIS table.
    As in the where clause the only key field used is BUKRS its consuming more time.Below is the code.
    Could you please tell me how to improvise this piece of code.
    I tried to fecth first from BKPF table based on the selection screen paramater t001-bukrs and then for all entries in BKPF fetched from BSIS.But it didnt worked.
    your help would be very much appreciated.Thanks in advance.
      SELECT bukrs waers ktopl periv
             FROM t001
             INTO TABLE i_ccode
             WHERE bukrs IN s_bukrs.
    SELECT bukrs hkont gjahr belnr buzei bldat waers blart monat bschl
    shkzg mwskz dmbtr wrbtr wmwst prctr kostl
               FROM bsis
               INTO TABLE i_bsis
               FOR ALL ENTRIES IN i_ccode
               WHERE bukrs EQ i_ccode-bukrs
               AND   budat IN i_date.
    Regards
    Akmal
    Moved by moderator to the correct forum
    Edited by: Matt on Nov 6, 2008 4:10 PM

    Dnt go for FOR ALL ENTRIES  it will not help in this case .Do like below , you can see a lot of performance improvement.
    SELECT bukrs waers ktopl periv
             FROM t001
             INTO TABLE i_ccode
             WHERE bukrs IN s_bukrs.
    sort i_ccode by bukrs.
    LOOP AT i_ccode.
       SELECT bukrs hkont gjahr belnr buzei bldat waers blart         monat bschl shkzg mwskz dmbtr wrbtr wmwst prctr kostl
             FROM bsis
            APPENDING TABLE i_bsis
            WHERE bukrs EQ i_ccode-bukrs
            AND   budat IN i_date.
      ENDLOOP.
    I dnt know why perform is good for the above query than "bulrs in so_bukrs" .This willl help , i m sure. this approach helped me.
    Edited by: Karthik Arunachalam on Nov 6, 2008 8:52 PM

Maybe you are looking for

  • Very urgent: regarding  problem in  display of output

    hi, i am modifying a report in which i have to display the stock date wise, i.e. it will display that the at this date this amount of stock is there. currently the code is able to display the according to this criteria that if date is <= 15 then it w

  • Weird Thumbnail Dimensions for EPS Files in Bridge CS4

    Using Preferences> Thumbnails, I have set Bridge CS4 to show "Dimensions" as one of the metadata items. It works correctly for PSD, NEF, and TIF files, but not EPS files. For example, a PSD file may show dimensions of 1006 x 583 pixels. But he same i

  • Item descriptor property attribute ?

    Hi In Item Descriptor I have Declared one property with required="true" But while creating that Table I didnt use Not Null constraint to that Column. If I declare like this is it throw any Error , where exactly it will effect I mean while server star

  • ITUNES causes my pc to shut down

    Whenever Itunes is running no matter what I'm doing, my computer shuts down and I uploaded the newest version and it still does it. Anyone out there able to help me figure it out? It is VERY annoying. Thank you

  • Do I have you "code" Stumped?

    Hello, First off this riddle is possible, I used to have the code, but I lost the file and the contained code. Riddle: Ok Simply: How do you code inside a table to have it open and display another .html file in it. Complex: Layers are awesome but the