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

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 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

  • 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

  • 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 with HRALXSYNC report..

    HI,
    I'm facing performance issue with the HRALXSYNC report. As this is Standard report, Can any body suggest me how to optimize the standard report..
    Thanks in advance.
    Saleem Javed
    Moderator message: Please Read before Posting in the Performance and Tuning Forum, also look for existing SAP notes and/or send a support message to SAP.
    Edited by: Thomas Zloch on Aug 23, 2011 4:17 PM

    Sreedhar,
    Thanks for you quick response. Indexes were not created for VBPA table. basis people tested by creating indexes and gave a report that it is taking more time with indexes than regular query optimizer. this is happening in the funtion forward_ag_selection.
    select vbeln lifnr from vbpa
         appending corresponding fields of table lt_select
         where     vbeln in ct_vbeln
         and     posnr eq posnr_initial
         and     parvw eq 'SP'
         and     lifnr in it_spdnr.
    I don't see any issue with this query. I give more info later

  • Strange performance issue in bex report

    Hello Experts,
    I have a performance issue on my bex report.
    I'm running the report with below selection criteria and getting 'too much data' error.
    Country :  equals EMEA
    Category: not equlas 13
    Date : 02/2010 to 12/2010.
    But when I ran the report for smaller date ranges the number of records are not exceeding 13000.
    02.2010 - 06.2010 - 6,555 rows
    07.2010 - 09.2010 - 3,671 rows
    10.2010 - 12.2010 - 2,780 rows
    I know excel can't fit more than 65000 records, but I'm expecting 13000 records for my wide date range which excel can easily fit.
    Any ideas on this one will be appreciated.
    Regards,
    Brahma Reddy

    Hi,
    For Question 1:
    In query designer Go to the Query properties and select the tab "Variable Sequence", here you can set the order of variables as per you requirement.
    For Question 2:
    There will be a option "Hide Repeated Key values", if you uncheck this option then you will have the values for each row even though the material values are same.
    Note; if you are viewing the report in web or WAD report you need to make the same changes in the Web template also because the settings in the query designer will be overridden when you run the query in web.
    Hope this helps.
    Regards,
    Rk.

  • Performance Issue with BSIS(open accounting items)

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

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

  • Performance issue of frequently data inserted tables

    Hi all,
    Have a table named raw_trap_store having columns as trap_id(number,PK),Source_IP(varchar2), OID(varchar2),Message(CLOB)  and received_time(date).
    This table is partitioned across 24 partitions where partitioning column being received_time. (every hour's data will be stored in each partition).
    This table is getting inserted with 40-50 records/sec on an average. Overall number of records for a day will be around 2.8-3 million. Data will be retained for 2 days.
    No updates will be happening on this table.
    Performance issue:N
    Need a report  which involves selection of records from this table based on certain values of Source IP (filtering condition on source_ip column).
    Need a report  which involves selection of records from this table based on certain values of OID (filtering condition on OID column).
    But, if i create an index on SourceIP and OID column, then inserts are getting slow. (have created a normal index. not partitioned index)
    Please help me to address the above issue.

    Giving the nature of your report (based on Source_IP and OID) and the nature of your table partitioning (range partitioned by received_time), you have already made a good decision to create these particular indexes as a normal (b-tree or global) and not locally partitioned. Because if you have locally partitioned them, your reports will not eliminate partitions (because they do not include the partition key in their where clause) and hence your index range scans will scan all 24 partitions generating a lot of logical I/O
    That is said, remember that generally we insert once and select many times. You have to balance that. If you are sure that it is the creation of your two indexes that has decreased the insert performance then you may set them at in an unusable state before the insert and rebuild them after. But this might be a good advice only if the volume of data to be inserted is much bigger than the existing volume of data before the insert.
    And if you are not deleting from the table and the table does not contain triggers and integrity constraints (like FK constraint) then you can opt for a direct path insert using the hint /*+ append */
    Best regards
    Mohamed Houri
    <mod. action: removed unecessary blog ref.>
    Message was edited by: Nicolas.Gasparotto

  • How do I handle large resultsets in CRXI without a performance issue?

    Hello -
    Problem Definition
    I have a performance problem displaying large/huge resultset of data on a crystal report.  The report takes about 4 minutes or more depending on the resultset size.
    How do you handle large resultsets in Crystal Reports without a performance issue?
    Environment
    Crystal Reports XI
    Apache WebSvr 2.X, Jboss 4.2.3, Struts
    Java Reporting Component (JRC),Crystal Report Viewer (CRV)
    Firefox
    DETAILS
    I use the CRXI thick client to build my report (.rpt) and then use it in my webapplication (webapp) under Jboss.
    User specifies the filter criteria to generate a report (date range etc) and submits the request to the webapp.  Webapp  queries the database, gets a "resultset".
    I initialize the JRC and CRV according to all the specifications and finally call the "processHttpRequest" method of Crystal Report Viewer to display the report on browser.
    So.....
    - Request received to generate a report with a filter criteria
    - Query DB to get resultset
    - Initialize JRC and CRV
    - finally display the report by calling
        reportViewer.processHttpRequest(request, response, request.getSession().getServletContext(), null);
    The performance problem is within the last step.  I put logs everywhere and noticed that database query doesnt take too long to return resultset.  Everything processes pretty quickly till I call the processHttpRequest of CRV.  This method just hangs for a long time before displaying the report on browser.
    CRV runs pretty fast when the resultset is smaller, but for large resultset it takes a long long time.
    I do have subreports and use Crystal report formulas on the reports.  Some of them are used for grouping also.  But I dont think Subreports is the real culprit here.  Because I have some other reports that dont have any subreports, and they too get really slow displaying large resultsets.
    Solutions?
    So obviously I need a good solution to this generic problem of "How do you handle large resultsets in Crystal Reports?"
    I have thought of some half baked ideas.
    A) Use external pagination and fetch data only for the current page being displayed.  But for this, CRXI must allow me to create my own buttons (previous, next, last), so I can control the click event and fetch data accordingly.  I tried capturing events by registering event handler "addToolbarCommandEventListener" of CRV.  But my listener gets invoked "after" processHttpRequest method completes, which doesnt help.
    Some how I need to be able to control the UI by adding my own previous page, next page, last page buttons and controlling it's click events. 
    B) Automagically have CRXI use a javascript functionality, to allow browser side page navigation.  So maybe the first time it'll take 5 mins to display the report, but once it's displayed, user can go to any page without sending the request back to server.
    C) Try using Crystal Reports 2008.  I'm open to using this version, but I couldnt figureout if it has any features that can help me do external pagination or anything that can handle large resultsets.
    D) Will using the Crystal Reports Servers like cache server/application server etc help in any way?  I read a little on the Crystal Page Viewer, Interactive Viewer, Part Viewer etc....but I'm not sure if any of these things are going to solve the issue.
    I'd appreciate it if someone can point me in the right direction.

    Essentialy the answer is use smaller resultsets or pull from the database directly instead of using resultsets.

  • Deductions Report performance issue

    Has anyone encountered performance problems lately with the Deductions Report?
    We have a custom report that is a modified version of the seeded report, and we cannot run the report to completion since our last round of patching. Patches applied are listed below, and include YE Phase 2.
    We have not yet opened a TAR on this, because we'll need to gather some information internally first.
    Thanks,
    Carrie
    Year-end and year-start updates, as follows:
    Patches 5555555, 5555550, 5650846, and HR Global – 2006 Oracle Year-End Phase 2
    Patch 5573903 – Quantum 2.8.2, Quantum 2006 Upgrade
    Patches 5589335 (prerequisite) and 5511810 – EEO Patch
    Patch 5416623 – Unable to process Admin Life Events (Benefits)
    Carrie Hollack
    [email protected]

    We've hit the performance bug and logged an SR. We ran the shipped report and it chugged for 2 1/2 days then blew up on snapshot too old. If you can avoid that error then it fails with ORA-01722: invalid number. I defragged and analyzed the Payroll tables and indexes but it's not enough to help the bad code. I think part of the issue is that the report code just uses a generic /*+ RULE */ hint. Another part of the issue may be that NULLs in the payroll tables aren't properly accounted for in the code.
    The behavior of the 'RULE' hint seems to be dependent on what the Paryoll LOW_VOLUME parameter is set to. That is, with LOW_VOLUME=Y and small tables the 'RULE' hint might be fine, but in the real World with with LOW_VOLUME=YouGottaBeKidding it doesn't.
    The new Payroll Activity Report for the whole year has very good performance--it only took 4 hours in our environment--and it used to take days.
    Open an SR and ask to be attached to Bug 5742521.

  • Report Performance Issue - Activity

    Hi gurus,
    I'm developing an Activity report using Transactional database (Online real time object).
    the purpose of the report is to list down all contacts related activities and activities NOT related to Contact by activity owner (user id).
    In order to fullfill that requirment I've created 2 report
    1) All Activities related to Contact -- Report A
    pull in Acitivity ID , Activity Type, Status, Contact ID
    2) All Activities not related to Contact UNION All Activities related to Contact (Base report) -- Report B
    to get the list of activities not related to contact i'm using Advanced filter based on result of another request which is I think is the part that slow down the query.
    <Activity ID not equal to any Activity ID in Report B>
    Anyone encountered performance issue due to the advanced filter in analytic before?
    any input is really appriciated
    Thanks in advanced,
    Fina

    Fina,
    Union is always the last option. If you can get all record in one report, do not use union.
    since all records, which you are targeting, are in the activity subject area, it is not nessecery to combine reports. add a column with the following logic
    if contact id is null (or = 'Unspecified') then owner name else contact name
    Hopefully, this is helping.

Maybe you are looking for

  • Media Encoder stops working and I get the goat.

    I have downloaded the latest update for Media Encoder CC 2014 8.0.1.48. All day I have had hit and miss success when encoding. Sometimes it works, and sometimes it will fail and I get the goat sound. I hate the goat sound. This has only happened sinc

  • I Pod Update Problems

    This message appears when I try to update my I Pod. The software works for playing music from my library, but my I Pod can't sync with the new updates. There is a Problem downloading the I Pod software for the I Pod "Phil's I Pod". An unknown error o

  • Importing photos from iphoto to iphone

    I have the 'old' version of the iphone and cannot transfer photos from iphoto to the iphone. When i click on the photos tab for the iphone in itunes, the albums and everything except "sync photos from" at the very top are grayed out. Then my only opt

  • Abstract Classes vs Private Constructor

    Hopefully this doesn't make me sound to naive If we have a super class called food, and subclasses chocolate, chicken, cereal and so on then its clear we dont want to make instances of the super class food correct? So we can make this class an abstra

  • Windows acrodist command line parameters

    How would I pass parameters like -permspassword, -allowchangestonotes, -allowplaintextmetadata, etc...  to acrodist when running it from the command line? I am only familiar with switches like /J, /N, /Q ... And the joboptions are static. Should thes