Details of open invoices

Can anyone please write me how to create a report with the details of open invoices for the current year.
Which table I should look into to get the details of open invoices..
I'm new to SAP..any help is really appreciated..
Thanks!
Uma

Hi,
If i understand your requirement, you want the report for "open invoice", that is invoice which are not paid / cleared. Then write the logic for below given steps.
<b>[1].</b> Read data from table BSIK (Vendor open item ) Based on BUKRS (company code) and LIFNR ( vendor number )
<b>[2].</b> Then for all data from BSIK, take bsik-bukrs, bsik-belnr and bsik-buzei and read table BKPF and BSEG ( put GJAHR = "current fiscal year )
There you go, you got all open invoice in current year. You can not do any claculation with this data and display as output.
You can also use transaction FBL1N to see vendor open items.
Let me know if you have any question.
Regards,
RS

Similar Messages

  • Details of open invoices for the current year/ material price analysis

    Hi,
    I'm very new to SAP SD,MM modules. Can any one help me in the following of my requirements?
    1. How to get the details of open invoices for the current year? Which table should I look into?
    2. I have to create a report to display material price analysis. How should I do that?
    3. How to develope a report to list out all the Open Sales Order with earliest ship date and requested ship date
    4.How to create an interactive report for displaying plant status to know the status of a particular material
    5. How to develope a report on Sales Order displaying Sales order Number, Sales order date, Material, PO Date and Customer requested date
    Thanks in advance!!
    Uma.
    Message was edited by:
            Uma Ravi

    Hi Ravi,
    for 3, 4, 5 --> u can go through the code ...
    REPORT ZEX2  MESSAGE-ID arc NO STANDARD PAGE HEADING.
    Tables :kna1,vbak.
    SELECT-OPTIONS : so_vkorg FOR  vbak-vkorg OBLIGATORY,
                     so_vtweg FOR  vbak-vtweg OBLIGATORY,
                     so_spart FOR  vbak-spart,
                     so_kunnr FOR  kna1-kunnr.
    DATA : BEGIN OF sales_open OCCURS 0 ,
           vbeln LIKE vbak-vbeln,
           auart LIKE vbak-auart,
           kunnr LIKE kna1-kunnr,
           bstnk LIKE vbak-bstnk,
           lfstk LIKE vbuk-lfstk,
           fkstk LIKE vbuk-fkstk,
           gbstk LIKE vbuk-gbstk,
           END OF sales_open.
    DATA : BEGIN OF itm_sales OCCURS 0,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           kwmeng like vbap-kwmeng,
           lfsta LIKE vbup-lfsta,
           lfgsa LIKE vbup-lfgsa,
           fksta LIKE vbup-fksta,
           fksaa LIKE vbup-fksaa,
           gbsta LIKE vbup-gbsta,
           END OF itm_sales.
    DATA : l_kunnr LIKE kna1-kunnr,
           l_vkorg LIKE vbak-vkorg,
           l_vtweg LIKE vbak-vtweg,
           l_spart LIKE vbak-spart.
    DATA: v_statusl(20) TYPE c,
          v_statusb(20) TYPE c,
          v_statusf(20) TYPE c,
          v_statusg(20) TYPE c,
          v_status(20) TYPE c,
          v_field(1) TYPE c.
    data : v_openqty like vbap-kwmeng.
    **Selection Screen Validations.
    AT SELECTION-SCREEN.
      PERFORM validations.
    *&      Form  Validations
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM validations.
    **Customer
      IF NOT so_kunnr[] IS INITIAL.
        SELECT SINGLE kunnr INTO l_kunnr
               FROM kna1
               WHERE kunnr IN so_kunnr.
        IF sy-subrc NE 0.
          MESSAGE e002 WITH text-005.
        ENDIF.
      ENDIF.
    **Sales Organization
      IF NOT so_vkorg[] IS INITIAL.
        SELECT SINGLE vkorg INTO l_vkorg
               FROM tvko
               WHERE vkorg IN so_vkorg.
        IF sy-subrc NE 0.
          MESSAGE e003 WITH text-006.
        ENDIF.
      ENDIF.
    **Distribution Channel
      IF NOT so_vtweg[] IS INITIAL.
        SELECT SINGLE vtweg INTO l_vtweg
                FROM tvkov
                WHERE   vkorg IN so_vkorg
                 AND    vtweg IN so_vtweg.
        IF sy-subrc NE 0.
          MESSAGE e004 WITH text-007.
        ENDIF.
      ENDIF.
    **Division
      IF NOT so_spart[] IS INITIAL.
        SELECT SINGLE spart INTO l_spart
                FROM tvta
                WHERE   vkorg IN so_vkorg
                AND     vtweg IN so_vtweg
                AND     spart IN so_spart.
        IF sy-subrc NE 0.
          MESSAGE e005 WITH text-008.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Validations
    Top-of-page.
    PERFORM sales_top_of_page.
    Start-of-selection.
    PERFORM sales_sel.
    *&      Form  sales_sel
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_sel.
    SELECT vbeln auart kunnr bstnk
         lfstk fkstk gbstk
         INTO TABLE sales_open
         FROM vbakuk
         WHERE vkorg IN so_vkorg
         AND   vtweg IN so_vtweg
         AND   spart IN so_spart
         AND   kunnr IN so_kunnr
         AND gbstk NE 'C'.
      LOOP AT sales_open.
        WRITE:/4 sy-vline,
               5 sales_open-vbeln HOTSPOT ON COLOR 2 INTENSIFIED OFF,
               16 sy-vline,
               17 sales_open-auart COLOR 2 INTENSIFIED OFF,
               27 sy-vline,
               28 sales_open-kunnr COLOR 2 INTENSIFIED OFF,
               40 sy-vline,
               41 sales_open-bstnk COLOR 2 INTENSIFIED OFF,
               55 sy-vline,
               56 sales_open-lfstk,
               76 sy-vline,
               77 sales_open-fkstk,
               96 sy-vline,
               97 sales_open-gbstk ,
               117 sy-vline.
        HIDE sales_open-vbeln .
      ENDLOOP.
    ENDFORM.                    " sales_sel
    *&      Form  sales_top_of_page
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_top_of_page.
      WRITE:/4 sy-uline(114),
         50 'OPEN SALES ORDERS' COLOR 7 INTENSIFIED ON .
      WRITE: /4 sy-vline,
              5 'SalesOrder' COLOR 1 ,
              16 sy-vline,
             17  'OrderType' COLOR 1,
             27  sy-vline,
             28  'Customer' COLOR 1,
             40  sy-vline,
             41  'PoNumber' COLOR 1,
             55  sy-vline,
             56  'Delivery Status' COLOR 1,
             76  sy-vline,
             77  'Billing Status' COLOR 1,
             96  sy-vline,
             97  'Processing Status' COLOR 1,
             117  sy-vline .
      WRITE:/4 sy-uline(114).
    ENDFORM.                    " sales_top_of_page
    AT LINE-SELECTION.
      SELECT       a~vbeln
                   a~posnr
                   a~matnr
                   a~kwmeng
                   b~lfsta
                   b~lfgsa
                   b~fksta
                   b~fksaa
                   b~gbsta
                   INTO TABLE itm_sales
                   FROM vbap AS a JOIN vbup AS b
                   ON a~vbeln EQ b~vbeln
                   AND a~posnr EQ b~posnr
                   AND b~gbsta NE 'C'
                   WHERE a~vbeln EQ sales_open-vbeln.
      IF NOT sales_open IS INITIAL.
        LOOP AT itm_sales.
          at end of vbeln .
          sum.
          v_openqty = itm_sales-kwmeng.
          endat.
          WRITE:/5  itm_sales-vbeln,
                    itm_sales-posnr,
                    itm_sales-matnr,
                    itm_sales-kwmeng,
                    itm_sales-lfsta,
                    itm_sales-lfgsa,
                    itm_sales-fksta,
                    itm_sales-fksaa,
                    itm_sales-gbsta.
        ENDLOOP.
      ENDIF.
    skip 2.
      write:/  'open Quantity for the order is ', v_openqty .
    for 1.
    open invoices..
    SELECT vbeln
             fkart
             kunag
             gbstk
             INTO TABLE it_billing_h
             FROM vbrkuk
             WHERE vkorg IN so_vkorg
             AND vtweg IN so_vtweg
    *        AND spart IN so_spart
             AND kunag IN so_kunnr
            and   year in p_year                  ---->"parameter for year..
             AND gbstk NE 'C'.                   "----> open invoices
    for 2..
    2. refer TABLES mara, EINA ..
    regards,
    VIjay

  • Help me in  'AR Details ' report shows total open invoices by customer

    hi friends,
    please  help me in  'AR Details ' report shows total open invoices by customer and PO number over selected time range.
    any thing related to open invoices please send me as early as possible.
    Thanks,
    Regards,
    Yogesh

    Hi,
    Find the T.code VF05. You will get the list of open billing docs. Its SIS report. Please find whether the SIS is active or not in your system
    Regards,

  • HELP: AR Open Invoices Conversion with Revenue Recognition (Daily Revenue)

    Hi,
    I need some help on Conversion of AR Open Invoices with Accounting Rules in R12, Here the client wanted to use Daily Revenue Schedule rule,
    I am developing Functional Specification Document (CV.040); Need to understand the Assumptions, Approach and Which data needs to be extracted from Legacy System.
    Appreciate your reply at the earliest
    Thanks
    Ravi

    Anil,
    Thanks for your response, Here are the answers to your questions.
    1) The invoices that you want to convert - Do they already have revenue recognition on them?
    Ans: Yes they have Revenue Recognition On Them.
    2) Are you bringing only Open Invoices? What about Invoices that are closed (paid), but still have unrecognized revenue on them? DO you want to bring them
    over? If no, how will be mage the recognition of those invoices?
    Ans: We want to bring only Open Invoices. i.e the following scenarios want in Data Extraction
    a) Invoice is Fully Paid (REC is Zero) and Unearned is Full Invoice Amount, Revenue is 0
    b) Invoice is Partially Paid (REC is Partial) and Unearned is Partial, Revenue is partial
    c) Invoice is fully Paid (Rec is Zero) and Unearned is Partial and Revenue is Partial
    d) We do not want to bring the invoices with Fully Paid and Fully Recognized, Unearned is Zero
    3) What about partially paid invoices? How do you want to bring them in?
    Ans: See above scenarios.
    4) Do you want to bring in all Invoice details,or just bring in a summary line with the outstanding amount?
    we assume only Summary, but if the Invoices with Several Lines and Different Accounting Rules, We may have to bring them too
    Appreciate your response; Suggest some possibilties?
    Thanks
    Ravi

  • Open invoices and GR/IR report

    Hi experts,
    Would like to know is there any report that will show the open invoices that tie to the balances in GR/IR account report from FS10N?
    I've tried on ME80FN, MB5S, ME2N (RECHNUNG) but none of the reports are tie to the balances in GR/IR account report from FS10N.
    Thanks and regards,
    JT

    Use T-Code F.19 which will give you an analysis of the open items lying in the GRIR account.
    Also after doing Invoice Verification (MIRO) use T-Code F.13 to do clearing of items lying in the GRIR a/c
    Use of F.13 regularly will ensure that your GRIR account will always show open items pending for Invoice Verification.
    Regds,
    Rajan Narayanswamy

  • Aging report for Open Invoice

    Hi All,
    I need to develop an Aging report for open invoice, there is no indication for open invoice or close invoice since we are using customise DS and DS from third party system. only one key flag we have is clearing date. so kindly let me know how to write the logic for this requirement.. can I use Customer exit for this? I have an Idea to do like
    first logic is
    *If Clearing date = blank than invoice is = open (by using of this logic we can get all open invoice).
    second logic
    total number of invoice = current date - document date.
    but I do not know how to implement this logic in BEx hnece kinnly advice me whether this logic can be work or suggest with different solution ples..
    Regards,

    hi,
    You can  check few default PO reports wid proper paramater in it
    or
    Can check table EKBE
    or
    Check PO history in the PO doc
    Or
    Check the ME80FN
    Regards
    Priyanka.P

  • Closing An Open Invoice With BO

    Hello,
    How do you close an open invoice that has a Back Order?  The Back Order has been cancelled by the customer but the order was accidentally invoiced.  Now, we are not able to close the invoice even though the SO has been  closed.
    Please help.
    Thanks,
    Mike

    hi mike,
    When a sales order is cancelled entierly by the customer,
    go to data --> cancel if there is no transactions associated with it.
    If it is partially delivered order then close the
    order by choosing open rows,right click it and close it.
    Then sales orders that is cancelled/closed may not
    appear for selection to subsequent documents like
    delivery/ar invoice.
    Jeyakanthan

  • Is there any function module which gives open invoices &open amount?

    Hello All,
    I want to use function module which gives open invoices with open amount.
    I know 'CUSTOMER_OPEN_ITEMS'  'BAPI_AR_ACC_GETOPENITEMS' function which gives open invoices but does not give open amount.
    Can anyone help me to find such function?

    From this BAPI ,
    BAPI_AR_ACC_GETOPENITEMS, You got amount for items in lc_amount field of lineitems table parameter.
    I hope, it will helpful to you.
    by
    Prasad GVK.

  • AR Open Invoice Error

    Hi Gurus,
    I am doing AR Open Invoice Migration.
    I am using two interface tables, they are AR_INTERFACE_LINES_ALL & AR_INTERFACE_DISTRIBUTIONS_ALL,
    When i run the concurrent program only one table is populating i.e AR_INTERFACE_LINES_ALL, i can't understand how to populate the AR_INTERFACE_DISTRIBUTIONS_ALL interface table.
    The link between the two table is INTERFACE_LINE_ID, but this column value is generated automatically, so how can i join both the tables for populating the data in the both tables
    Please help me.
    Thanks in Advance.

    Probably this forum: General EBS Discussion

  • AR Open Invoice Migration error

    Hi Gurus,
    I am doing AR Open Invoice Migration.
    I am using two interface tables, they are AR_INTERFACE_LINES_ALL & AR_INTERFACE_DISTRIBUTIONS_ALL,
    When i run the concurrent program only one table is populating i.e AR_INTERFACE_LINES_ALL, i can't understand how to populate the AR_INTERFACE_DISTRIBUTIONS_ALL interface table.
    The link between the two table is INTERFACE_LINE_ID, but this column value is generated automatically, so how can i join both the tables for populating the data in the both tables
    Please help me.
    Thanks in Advance.

    hi,
    The link between 2 table is following columns values
    INTERFACE_LINE_CONTEXT, -- Context name of the Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE1, -- Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE2, -- Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE3, -- Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE4, -- Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE5, -- Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE6, -- Line Transaction Flexfield
    INTERFACE_LINE_ATTRIBUTE7... etc
    Please create a line transaction flexfield and assign that flexfield context name into INTERFACE_LINE_CONTEXT
    Regards

  • Total count of open invoices

    Hi,
    I want to get the total count of open invoices and paid invoices and total amount for a give list of vendors between a date range. Could anyone tell me what tables I should use to get the data?
    Thanks

    Hi,
    two vendor tables BSIK (for open items) and BSAK (for vendor cleared items) will serve the purpose for using them in you program.
    regards,
    chaitanya

  • AR Open Invoices Load

    Hi All,
    I am trying to open invoices i.e. Invoice, Credit Memo and Debit Memo. I am wondering which of these tables I need to populate and what will be the whole process.
    a)RA_INTERFACE_LINES_ALL
    b)RA_INTERFACE_DISTRIBUTIONS_ALL
    c)RA_INTERFACE_SALESCREDITS_ALL
    Thanks
    John

    Hi John,
    In order to distinguish/ populate the transacation types in ra_interface_lines_all table,you need to know whether your populating transation type value/id in ra_interface_lines_all.
    if you have front end access please check whether your populating transaction type value/id.
    a.Navigation Path:
    (R) Receivables Manager > Setup > Sources > (query for the required source using in interface table) > go to other information.
    check for the transaction type radio button whether your using value or id,based on value or id you can pass different transaction types defined in --> (R)Receivables Manager > Setup > Sources > Transaction types.
    Table used for batchsource and transation types are :
    a) RA_BATCH_SOURCES -> used to know the batch source information.
    b) RA_CUST_TRX_TYPES -> used to know the different transaction types available.
    Thanks
    Rock

  • Re: AR Open Invoice Error

    Hi Friends,
    I am getting the following errors while doing the AR Open Invoice Migration, as this is the first time i am doing. I am facing the down error in the Error Table
    'RA_INTERFACE_ERRORS_ALL'
    Error Message:
    "You must supply an invoice number when your batch source indicates manual invoice numbering; otherwise you must leave invoice number blank"
    If any one knows this error solution please reply this
    Thanks in Advance.
    Thanks
    Bindhu Behra

    Hi,
    Complementing the answer, the profile option "OM: Invoice Numbering Method" allows you to choose between using automatic numbering and use the delivery number as your transaction number.
    If you have records in your receivables interface with a manually number batch source and no transaction number you can either manually number your transactions, filling the field transaction number (trx_number), or change the batch source to one automatically numbered. You can do both using the interface lines form available in Control: Autoinvoice: Interface Lines. If you are going to change the batch source, remember reviewing all related records (taxes, salescredits, accounting lines).
    If you want to move from manual to automatic numbering, you''ll need to define a new batch source, with automatic numbering, and change the batch source used by OM to interface data to AR. This can be done by OM order or line types or using the profile option "OM: Invoice Source", depending on your current setup.
    Hope it helps,
    Ketter Ohnes

  • Issue in counting open invoices

    Hi All,
    I am facing an issue which could be common but i am getting the correct count for open invoices.
    We have following scenario :
    Assume, we are loading an invoice(INV1) which was open(determined by item status = O) yesterday and loaded the same into ODS and to the cube yesterday itself.
    As we want to see the invoices which are open as of that particulat day.
    we have a CKF defined with value = 1 and aggregation : counter of all values, reference characteristic : 0REFERENCE.
    I run the report and I see open invoices = 1, which is correct.
    Now,the invoice which was open yesterday was cleared and paid today.
    Now , I loaded the data to ODS and then to the cube.
    In the cube, I have three entries like
    Invoice     Item Status            Amount 
    INV1         O(Open)                   100
    INV1         O(Open)                  -100
    INV1         C(Cleared)                100
    Since, this invoice is cleared today, when i run the report , i should get invoice count "Zero" but I am getting the count as "1" and the amount "0".
    The CKF which was created is getting the count as "1" even though it is cleared.If the invoice is cleared, it should not be counted.
    Anyone has any suggestions ?
    Regards,
    Jeevan

    okay - a number of issues here
    The two item statuses of O will cancel each other out and be deleted if you have zero elemination on the cube and run the next compression
    The negative zero was generated by the change log of the ODS when the item status = C cleared document came in
    You always run the open items as at a point in time using two RKFs added together in one CKF
    RKF1 is item status = O AND posting date <= key date of query
    RKF2 is cleared date > key date of query AND posting date <= key date of query
    Thus you can always restate the open items which have been subsequently cleared back to a point in time (ie historical aged debt reports etc..)
    You must not just use item status = O
    Now how to do the counts..
    I normally put a counter onto the cube and negate the counter when the changelog negative O record (so the two Os cancel each other out) and then just add up the values of the counter as per the RKFs above
    However there is another option but it still involves a change to the data model
    The counts are based on the uniqueness of a document number
    The full key of a uniqieness of an AR or AP document number in SAP is...
    Company Code, Fiscal Year, Document Number, line item
    (the line item is due to one AP document being split across many lines due to installment plans with different net due dates or partially allocated cash across many outstanding line items)
    The other items have to be considered in uniqueness because SAP allows you to configure number ranges per company code wither with internal or external numbering and these ranges can be year specific - hence the full key is required
    You cannot just count document number as this will give a false result as the same document numebr can be used in multiple years within the same company code AND across company codes as well (so group reporting of outstanding counts will be affected as well)
    So you have to create a new infoobject that is called "Document Full Key" - that concatenates Company Code, Fiscal Year, Document Number, line item into one object string
    You then put that in yoru cube and update it via the transformation rules
    Then you can create the RKFs above and do a count all values based on the characteristic  "Document Full Key" - then create a few more RKFs to do the splits of net due date and the offsets required for -30 -60 etc as per normal
    Sorry for the bad news - but if you want to do it properly - I don;t think you have another other choice but the two options above..
    But then what do I know!

  • Query for Open Invoices

    Hi 2 all
    Anybody know that how to fetch open invoices in 11i and these invoices balances should be match with Supplier Statement of Account Report.
    Thanks,
    Zulqarnain

    Hi,
    I use this one:
    SELECT HEADER.*,
    HEADER.END_BALANCE - HEADER.BEGIN_BALANCE NET_BALANCE,
    HEADER.BEGIN_BALANCE BEGIN_BALANCE_2,
    LINE.*,
    NVL(LINE.DEBE, 0) - NVL(LINE.HABER, 0) NETO_LINEA
    FROM (SELECT TP.THIRD_PARTY_ID,
    TP.THIRD_PARTY_NAME,
    TP.THIRD_PARTY_NUMBER,
    S.SUB_ID,
    S.SUB_NAME,
    AB_START.ACCOUNT_SEGMENT,
    AB_START.PERIOD_NAME BEGIN_BALANCE_PERIOD,
    AB_END.PERIOD_NAME END_BALANCE_PERIOD,
    AB_START.END_BALANCE_DR - AB_START.PERIOD_NET_DR +
    AB_START.PERIOD_NET_CR - AB_START.END_BALANCE_CR BEGIN_BALANCE,
    AB_END.END_BALANCE_DR - AB_END.END_BALANCE_CR END_BALANCE
    FROM AX_THIRD_PARTIES_V TP,
    AX_SUBS_V S,
    AX_BALANCES AB_START,
    GL_PERIOD_STATUSES GPS_START,
    AX_BALANCES AB_END,
    GL_PERIOD_STATUSES GPS_END
    WHERE TP.APPLICATION_ID = 200
    AND TP.APPLICATION_ID = S.APPLICATION_ID
    AND TP.APPLICATION_ID = AB_START.APPLICATION_ID
    AND TP.APPLICATION_ID = GPS_START.APPLICATION_ID
    AND TP.APPLICATION_ID = AB_END.APPLICATION_ID
    AND TP.APPLICATION_ID = GPS_END.APPLICATION_ID
    AND TP.THIRD_PARTY_ID = AB_START.THIRD_PARTY_ID
    AND S.THIRD_PARTY_ID = AB_START.THIRD_PARTY_ID
    AND S.SUB_ID = AB_START.SUB_ID
    AND AB_START.SET_OF_BOOKS_ID = GPS_START.SET_OF_BOOKS_ID
    AND AB_START.PERIOD_NAME = GPS_START.PERIOD_NAME
    AND TP.THIRD_PARTY_ID = AB_END.THIRD_PARTY_ID
    AND S.THIRD_PARTY_ID = AB_END.THIRD_PARTY_ID
    AND S.SUB_ID = AB_END.SUB_ID
    AND AB_END.SET_OF_BOOKS_ID = GPS_END.SET_OF_BOOKS_ID
    AND AB_END.PERIOD_NAME = GPS_END.PERIOD_NAME
    AND AB_START.SET_OF_BOOKS_ID = :P_SOB
    AND TP.THIRD_PARTY_NUMBER =
    NVL(:P_VENDOR_NUMBER, TP.THIRD_PARTY_NUMBER)
    AND TP.THIRD_PARTY_NAME = NVL(:P_PARTY_NAME, TP.THIRD_PARTY_NAME)
    AND S.SUB_NAME = NVL(:P_SUB_NAME, S.SUB_NAME)
    AND AB_END.ACCOUNT_SEGMENT = AB_START.ACCOUNT_SEGMENT
    AND GPS_START.EFFECTIVE_PERIOD_NUM =
    (SELECT MIN(P_BALANCE.EFFECTIVE_PERIOD_NUM)
    FROM AX_BALANCES BALANCE,
    GL_PERIOD_STATUSES P_BALANCE,
    GL_PERIOD_STATUSES P_DATE
    WHERE BALANCE.APPLICATION_ID = AB_START.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_BALANCE.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_DATE.APPLICATION_ID
    AND BALANCE.THIRD_PARTY_ID = AB_START.THIRD_PARTY_ID
    AND BALANCE.SUB_ID = AB_START.SUB_ID
    AND BALANCE.SET_OF_BOOKS_ID = AB_START.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_BALANCE.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_DATE.SET_OF_BOOKS_ID
    AND P_DATE.PERIOD_NAME = :P_PERIOD_START
    AND P_BALANCE.EFFECTIVE_PERIOD_NUM >=
    P_DATE.EFFECTIVE_PERIOD_NUM
    AND P_BALANCE.PERIOD_NAME = BALANCE.PERIOD_NAME
    AND BALANCE.CODE_COMBINATION_ID =
    AB_START.CODE_COMBINATION_ID)
    AND GPS_END.EFFECTIVE_PERIOD_NUM =
    (SELECT MAX(P_BALANCE.EFFECTIVE_PERIOD_NUM)
    FROM AX_BALANCES BALANCE,
    GL_PERIOD_STATUSES P_BALANCE,
    GL_PERIOD_STATUSES P_DATE
    WHERE BALANCE.APPLICATION_ID = AB_END.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_BALANCE.APPLICATION_ID
    AND BALANCE.APPLICATION_ID = P_DATE.APPLICATION_ID
    AND BALANCE.THIRD_PARTY_ID = AB_END.THIRD_PARTY_ID
    AND BALANCE.SUB_ID = AB_END.SUB_ID
    AND BALANCE.SET_OF_BOOKS_ID = AB_END.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_BALANCE.SET_OF_BOOKS_ID
    AND BALANCE.SET_OF_BOOKS_ID = P_DATE.SET_OF_BOOKS_ID
    AND P_DATE.PERIOD_NAME = :P_PERIOD_END
    AND P_BALANCE.EFFECTIVE_PERIOD_NUM <=
    P_DATE.EFFECTIVE_PERIOD_NUM
    AND P_BALANCE.PERIOD_NAME = BALANCE.PERIOD_NAME
    AND BALANCE.CODE_COMBINATION_ID =
    AB_END.CODE_COMBINATION_ID)) HEADER,
    ((SELECT LINE.THIRD_PARTY_ID VENDOR_ID,
    HEAD.EFFECTIVE_DATE FECHA_CONTABLE,
    INV.INVOICE_DATE FECHA_TRANSACCION,
    LOOK.DESCRIPTION TIPO_TRANSACCION,
    LINE.REFERENCE_25 NUM_TRANSACCION,
    INV.DOC_SEQUENCE_VALUE SECUENCIA,
    LINE.ACCOUNTED_DR DEBE,
    LINE.ACCOUNTED_CR HABER,
    CODE.SEGMENT3 CUENTA
    FROM AX_SLE_LINES LINE,
    AX_SLE_HEADERS HEAD,
    GL_CODE_COMBINATIONS CODE,
    AP_INVOICES_ALL INV,
    FND_LOOKUP_VALUES LOOK
    WHERE HEAD.EFFECTIVE_DATE BETWEEN
    (SELECT START_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_START
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND (SELECT END_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_END
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND HEAD.SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND HEAD.SET_OF_BOOKS_ID = INV.SET_OF_BOOKS_ID
    AND HEAD.JOURNAL_SEQUENCE_ID = LINE.JOURNAL_SEQUENCE_ID
    AND HEAD.SET_OF_BOOKS_ID = :P_SOB
    AND LINE.REFERENCE_7 = INV.INVOICE_ID
    AND CODE.CODE_COMBINATION_ID = LINE.CODE_COMBINATION_ID
    AND LINE.SLE_HEADER_ID = HEAD.SLE_HEADER_ID
    AND LINE.SOURCE_TABLE != 'AP_INVOICE_PAYMENTS'
    AND LOOK.LOOKUP_TYPE = 'INVOICE TYPE'
    AND LOOK.LANGUAGE = 'E'
    AND LOOK.LOOKUP_CODE = INV.INVOICE_TYPE_LOOKUP_CODE
    AND LINE.CODE_COMBINATION_ID IN
    (SELECT CODE_COMBINATION_ID
    FROM GL_CODE_COMBINATIONS
    WHERE SEGMENT3 LIKE '40%' -- Segment3 is our natural account, 40, 04, 41 are the natural accounts for suppliers
    OR SEGMENT3 LIKE '04%'
    OR SEGMENT3 LIKE '41%')) UNION ALL
    (SELECT LINE.THIRD_PARTY_ID VENDOR_ID,
    HEAD.EFFECTIVE_DATE FECHA_CONTABLE,
    INV.CHECK_DATE FECHA_TRANSACCION,
    'Pago' TIPO_TRANSACCION,
    LINE.REFERENCE_25 NUM_TRANSACCION,
    INV.DOC_SEQUENCE_VALUE SECUENCIA,
    LINE.ACCOUNTED_DR DEBE,
    LINE.ACCOUNTED_CR HABER,
    CODE.SEGMENT3 CUENTA
    FROM AX_SLE_LINES LINE,
    AX_SLE_HEADERS HEAD,
    GL_CODE_COMBINATIONS CODE,
    AP_CHECKS_ALL INV
    WHERE HEAD.EFFECTIVE_DATE BETWEEN
    (SELECT START_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_START
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND (SELECT END_DATE
    FROM GL_PERIOD_STATUSES_V
    WHERE PERIOD_NAME = :P_PERIOD_END
    AND SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND APPLICATION_ID = 101)
    AND HEAD.SET_OF_BOOKS_ID = LINE.SET_OF_BOOKS_ID
    AND HEAD.JOURNAL_SEQUENCE_ID = LINE.JOURNAL_SEQUENCE_ID
    AND HEAD.SET_OF_BOOKS_ID = :P_SOB
    AND LINE.REFERENCE_7 = INV.CHECK_ID
    AND CODE.CODE_COMBINATION_ID = LINE.CODE_COMBINATION_ID
    AND LINE.SLE_HEADER_ID = HEAD.SLE_HEADER_ID
    AND LINE.SOURCE_TABLE = 'AP_INVOICE_PAYMENTS'
    AND LINE.CODE_COMBINATION_ID IN
    (SELECT CODE_COMBINATION_ID
    FROM GL_CODE_COMBINATIONS
    WHERE SEGMENT3 LIKE '40%' --Segment3 is our natural account, 40, 04, 41 are the natural accounts for suppliers
    OR SEGMENT3 LIKE '04%'
    OR SEGMENT3 LIKE '41%'))) LINE
    WHERE HEADER.THIRD_PARTY_ID = LINE.VENDOR_ID(+)
    AND HEADER.ACCOUNT_SEGMENT = LINE.CUENTA(+)
    ORDER BY LINE.FECHA_CONTABLE
    :P_VENDOR_NUMBER -> Supplier Num
    :P_PARTY_NAME -> Supplier Name
    :P_SUB_NAME -> Supplier Address
    :P_SOB -> set_of_books_id
    :P_PERIOD_START -> Period Start
    :P_PERIOD_END -> Period End

Maybe you are looking for