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

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

  • How to do Performance analysis of any ABAP report

    Hello Friends,
                         I have to do the performance analysis of ABAP report, it takes time to execute. I am  not aware about, how to do performance analysis? I know only we have check index, do ST04 and ST05 analysis. but how to do these things  that i don't know.
                        Can anyone please guide me in this regards.
    Thanks

    HI,
    Please Check this,
    System Trace: Transaction ST01 lets you do various levels of system trace such as authorization checks, SQL traces, table/buffer trace etc. It is a general Basis tool but can be leveraged for BW.
    Workload Analysis: You use transaction code ST03
    Database Performance Analysis: Transaction ST04 gives you all that you need to know about whatu2019s happening at the database level.
    Performance Analysis: Transaction ST05 enables you to do performance traces in different are as namely SQL trace, Enqueue trace, RFC trace and buffer trace.
    ABAP Runtime Analysis Tool: Use transaction SE30 to do a runtime analysis of a transaction, program or function module. It is a very helpful tool if you know the program or routine that you suspect is causing a performance bottleneck.
    Rgds
    Sabu

  • 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 with the ABAP statements

    Hello,
    Please can some help me with the below statements where I am getting performance problem.
    SELECT * FROM /BIC/ASALHDR0100 into Table CHDATE.
    SORT CHDATE by DOC_NUMBER.
    SORT SOURCE_PACKAGE by DOC_NUMBER.
    LOOP AT CHDATE INTO WA_CHDATE.
       READ TABLE SOURCE_PACKAGE INTO WA_CIDATE WITH KEY DOC_NUMBER =
       WA_CHDATE-DOC_NUMBER BINARY SEARCH.
       MOVE WA_CHDATE-CREATEDON  to WA_CIDATE-CREATEDON.
    APPEND WA_CIDATE to CIDATE.
    ENDLOOP.
    I wrote an above code for the follwing requirement.
    1. I have 2 tables from where i am getting the data
    2.I have common fields in both the table names CREATEDON date. In both the tables I hve the values.
    3. While accessing the 2 table and copying to thrid table i have to modify the field.
    I am getting performance issues with the above statements.
    Than
    Edited by: Rob Burbank on Jul 29, 2010 10:06 AM

    Hello,
    try a select like the following one instead of you code.
    SELECT field field2 ...
    INTO TABLE it_table
    FROM table1 AS T1 INNER JOIN table2 AS T2
    ON t1-doc_number = t2-doc_number

  • 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

  • How do you take care of performance issues in your ABAP programs?

    HI,
    SEND ME REPLAY

    hi,
    This topic has been discussed often in these forums.Check these links:
    Re: Monitoring & Performance Tuning
    Re: Query Enhancement and performance
    Re: performance tuning related issues
    Re: Performance analysis
    Re: BW performance
    In specific check this:
    take a look
    Business Intelligence Performance Tuning [original link is broken] [original link is broken] [original link is broken]
    and e-learning
    https://www.sdn.sap.com/irj/sdn/developerareas/bi?rid=/webcontent/uuid/fe5b0b5e-0501-0010-cd88-c871915ec3bf [original link is broken]
    'intermediate course'
    also take a look
    Prakash's weblog
    /people/prakash.darji/blog/2006/01/27/query-creation-checklist
    /people/prakash.darji/blog/2006/01/26/query-optimization
    BW Performance Tuning Knowledge Center - SAP Developer Network (SDN)
    Business Intelligence Performance Tuning [original link is broken] [original link is broken] [original link is broken]
    performance docs on query
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3f66ba90-0201-0010-ac8d-b61d8fd9abe9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ce7fb368-0601-0010-64ba-fadc985a1f94
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c8c4d794-0501-0010-a693-918a17e663cc
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/064fed90-0201-0010-13ae-b16fa4dab695
    oss note
    557870 'FAQ BW Query Performance'
    and 567746 'Composite note BW 3.x performance Query and Web'.
    Also take a look sdn forum performance center
    Business Intelligence Performance Tuning [original link is broken] [original link is broken] [original link is broken]
    there are lots of docs
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5ee957e5-0201-0010-9c83-fe14a43cd04a
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ce7fb368-0601-0010-64ba-fadc985a1f94
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3f66ba90-0201-0010-ac8d-b61d8fd9abe9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c0ab590-0201-0010-bd9a-8332d8b4f09c
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1955ba90-0201-0010-d3aa-8b2a4ef6bbb2
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c8c4d794-0501-0010-a693-918a17e663cc
    and check oss note
    557870 'FAQ BW Query Performance' and 567746 'Composite note BW 3.x performance Query and Web'
    417307, 409641 etc (search with 'bw performance')
    Regards,
    Jayant

  • 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

Maybe you are looking for

  • E-mail button using something other then Outlook

    My question is simple when using an e-mail button you can send the PDF or XML through e-mail to a certain address such as a gmail, yahoo, msn or etc.. email account but the host e-mail server it is using is the Outlook on your local machine. My quest

  • Performance issue with XI interfaces - Help Needed

    Hi all,        We are having idoc->xi->file. We have the design of collecting the idocs as the standard example BpmPatternCollectTime.         We have given the collection time of say 5minutes after the first idoc hits the BPM process. The issue is t

  • How to listen to iTunes through two separate stereo systems simultaneouly?

    I was thinking of buying two Airport Express units in order to run iTunes to two seperate stereo systems in two different rooms. Can this be done, or is there a better way to accomplish this? thanks for any help! pjo iMac G4, 800 Mhz   Mac OS X (10.3

  • Profitcenter wise data mismatch In T-code FAGLL03 & S_PL0_86000030

    Data Mismatch In two Report for e.g. IN GL 610120 FOR the Period of 01.04.2009 to 30.06.2009 T-CODE T-CODE Profit center          *FAGLL03*                *S_PL0_86000030* -( General -> G/L Account Balances -> G/L Account Balances (New)) 1           

  • Can not send email - port 25

    Hello. I really hope somebody can help me. I bought my first Mac. And I can not get port 25 (out going mail port) to "open". I am using Microsoft Entourage (version 11.3.3) as a multi-mail program. The only informations that I got on the router is th