AR  posting and clearing

Hi all,
I posted several customer invoices with same reference but each invoice has different assignment field value.
I configured selection criteria for clearing and Payment advice note.
when I am trying to process incoming payment of one invoice through EDI 820 payment advice, system clearing all invoice under reference number and creating residual amount. i.e. clearing all invoices under reference no. and creating
Debit: Cash( incoming invoice amount )
Debit entry : (total invoices amount of same reference - one invoice Payment)
Credit entry : Sum of invoices amount of same reference
There is any way to clear specific above invoice automatically??.
I appreciate your solution.
Raj
Message was edited by: RK Talabathula
Message was edited by: RK Talabathula
Message was edited by: RK Talabathula

Hi Barry,
Thanks for your response,
I already defined fields.
XBLNR - Reference,
ZUONR - Assignment.
Here System using FB05- post and clear for incoming EDI 820 payment advice.
Here we have
XBLNR - invoice reference
ZUNOR - Material number
We have a split invoice based on material number and many invoices under same invoice reference but assignment value is different(material is different).
My problem is system not considering two fields together as selection criteria.it is taking one field i.e. XBLNR -reference or zunor- assignment and clearing amounts but not together.
Thanks,
Raj.

Similar Messages

  • System allows GRs to be reversed after invoices have posted and clear

    Users have noticed that it is possible to post a GR, post and clear and Invoice, then reverse the GRs, which is an audibility problem. Previously (possibly before upgrade to ECC 6) this was not possible.Is there any configuration available to change this behavior, or  is it a standard SAP in ECC 6, or if there are unapplied OSS notes that would fix the issue.
    I checked transaction code OMBZ and the movement type 102, 106, 122, and 162 do not have a check on them.
    Is there another way of preventing the Goods Receipts to be reversed after invoices have been posted and cleared?
    Thanks,

    System allows GRs to be reversed after invoices have posted and clear
    Users have noticed that it is possible to post a GR, post and clear and Invoice, then reverse the GRs, which is an audibility problem. Previously (possibly before upgrade to ECC 6) this was not possible.Is there any configuration available to change this behavior, or is it a standard SAP in ECC 6, or if there are unapplied OSS notes that would fix the issue.
    I checked transaction code OMBZ and the movement type 102, 106, 122, and 162 do not have a check on them.
    I also checked the "GR based IV" in the PO item details, inoive tab and that is not checked.
    Invoice have been posted and cleared and now the GRs are reversing them, how to prevent this from happening. Is there a config. solution???
    Thanks,

  • FB05 (post and clearing) u0093The difference is too large for clearingu0094

    I am passing entry through FB05 (Post and clear). The entry is between two GL accounts maintained as open items. At the time of passing the entry there is difference between these two accounts. I want this difference to be posted automatically to profit and loss account. (I don’t want to charge of the difference manually). I can not post the entry because system is throwing error such as “The difference is too large for clearing”. I checked the tolerance limit(OBA4), but the difference is within the tolerance limit.
    Does anybody know how to configure for this situation?
    Do I need to do any configuration in FBKP?
    (Please consider this very urgent)
    Regards,
    Amit Bedekar.

    Hello
    Check if this helps.
    Reason Codes
    Use
    To use the clearing document to find out why a difference existed, you can assign reason codes to the line items. Reason codes are indicated by keys that you define in Customizing.
    You can assign reason codes for the following:
    Partial payments made for open items.
    Residual items created for an open item. Here you can assign one or more reason codes. In this case, you divide the difference amount into a corresponding number of partial amounts.
    Differences posted on account without reference to an open item.
    For each line item you enter in the clearing procedure, if the reason code field for the account is ready for input.
    Integration
    When you process residual items, the reason code also controls how the remaining amount is posted. The remaining amount can be posted as follows:
    To a G/L account that is assigned to the reason code you enter.
    As a new customer or vendor open item if you do not enter a reason code, or if the reason code you enter is not indicated as described.
    Features
    Properties of Reason Codes
    For incoming payments, you can send a payment notification to the customer. This process can run automatically if differences arise during clearing. In the tolerance group set up for the customer, you can define what type of notice to create for partial payments, residual items, and payments on account.
    The system can use the specified reason code to determine the type of notice to create as long as only one reason code is specified in the entire clearing transaction.
    In order to check a customer's credit limit, the total of open items is taken into account. If certain contentious items should not be considered, you can define a separate reason code for these items.
    Reason codes control:
    How the difference is posted (as a new open item or to a predefined G/L account)
    What type of payment notice is created
    Whether an item is included in credit limit checks
    For information on defining reason codes, see the following activities in the Financial Accounting  Implementation Guide:
    Define Reason Codes (Incoming Payments)
    Define Reason Codes (Manual Outgoing Payments)
    Define Standard Reason Codes for Clearing with Payment Advice Notes
    Reg
    *assign points if useful

  • Out standing expencess posting and clearing

    Hi,
    Can any one please give me the posting of “out standing payments and its clearing”.
    I mean to ask “I have to post outstanding salaries and I have to clear it later” can you please give me the transaction codes for these two activities.
    1.     transaction code to post outstanding expenses
    2.     transaction code to post clearing outstanding expenses
    thanku

    Hi,
    You can use the following T Codes,
    1. Use F-02 or FB01 to post the outstanding expenses
    2. Use F-04 to post with clearing or use F-03 to clear the GL debits and credits.
    If you wanted to make the provision entry and you wanted to reverse it on the first day of the next month, then use T code FBS1 to post the provision entry and to reverse it use T code F.81.
    Hope it clears you problem
    Regards,
    A.Saravanan

  • Issues during posting and Clearing together in custom code SAP FICA

    Hello Experts,
    We have a custom functionality for credit card refunds. For account update during refunds a new debit document is created and force cleared with the credit card payment posted earlier on customer account. Logic for posting the debit document and clearing it with an already existing payment is in the same RFC Function module. Once the document is posted code issues COMMIT work and then goes for clearing.
    We are facing intermittent failures during this process. Clearing fails to happen on some accounts.
    Can this be because we are trying to do two types of database update on same document( i.e., creation and then clearing)?
    Kindly advice.
    Thanks,
    Josep

    Hi Josep,
    Same situation was faced by me in custom RFC FM,
    so as a solution i put a wait of 2 second after debit document was posted and then credit card payment was executed after wait, moreover one more thing to be taken care is that while posting the debit document system apply some locking entry so if possible clear the lock entry and then start credit card payment.
    Hope it helps.
    Thanks

  • Post with clearing : process open items

    hi,
    i do post and clearing FB05.
    i select incoming payment for transaction to be processed in the selection screen.
    Q1
    in the first line items, i put PK 40 for bank account and the next screen i put the amount, say 100 and hit process open items button.
    i choose the customer account and hit process open items button.
    in the standard tab, it shows list of document and also the amount entered (amount to be cleared) 100.
    now my question comes :
    as i debit bank 100 (pk 40), it should credit cust 100- (pk 15), right?
    amount entered field is showing 100 then assigned field should be 100- to make it 0 in not assigned field, right?
    but in this case, i need to select positive 100 and not negative 100 in the cust account document list.
    this is what i confused. as in f-03 or f-32, i remember if amount entered field is positive then i need to choose negative amount so that in not assigned field is 0.
    Q2
    why in first line item, if i put PK 15, i not able to process open items anymore. for example if i enter 100 and click process open items, when i put in PK 50 the same amount on the next item line, i not able to simulate correctly as with unassigned figure.
    can explain?
    thanks

    Hi
    When you select "process open items", the system lists the Open items of customer. You are supposed to select an open item to be cleared with the amount received from the customer. When you sell a product, Customer is debited and hence it is positive only.....
    I hope it is clear
    S Jayaram

  • Incoming payments posting without clearing the customer open item

    Hi,
    Is there a way to post an incoming payment to a customer and let it sit as an open item?
    I want to segregate the posting and clearing of AR payments.
    One user posts the payments to the customer account.
    Another user clears this payment against an open item.
    All t.codes F-26, f-52 and f-28 all go on to processing open items and don't work for me..
    Does anyone have any workaround or suggestion on how to accomplish this?
    Thanks

    I can suggest posting the cash to the customers account as an unallocated enty using F-28 - we use charge of the difference and the posting keys to mange this.
    The the other users can contra the items to the open items using F-32 clear customer.

  • F-30: posting with clearing a document with special G/L indicator and tax

    Hi All,
    by t.code F-02 I've posted a document with the follow items:
    PK     SG      Account Description
    40                Bank G/L Account   u20AC 1200,00
    19      A       Customer code         u20AC 1000,00-  (1000,00 amount and 200,00 tax amount)
    50                Tax G/L Account     u20AC  200,00-
    If I launch the t.code F-30 (post with clearing), choose that customer and select the special G/L indicator "A", SAP displays
    the document I've posted with an amount equal to 1.200,00- instead of 1000,00.
    This does't allow me to clear the open Item....
    Could anyone hel me?
    Thanks
    Gandalf

    Hi
    A   payment  recorded  with   special GL indicator  is automatically set  as  locked.  This is  sap  program and cant be changed.  When  the  related invoice is  recorded ,  the   down payment  can  be cleared  with it  using  F-39, provided  the down payment relates to the same  sales / purchase order.
    For  the  difference in customer  amount,  its  difficult  to answer as    it may be due to  wrong account selection or  wrong amount entered in customer.
    Thanks
    kamala

  • Posting Cash Payments and Clearing Invoices

    Hi everybody,
    Can anybody suggest a transaction to post payments (money) and clear FI invoices.
    I am looking for a transaction where the user can pull an invoice by doing a search by invoice number, or by PO number, and to post a payment against the invoice, do clear it down.
    I tried the transaction F-28 and, apparently, I can´t search the invoice by the PO number.
    Appreciate your help!
    Thank you very much!
    Kind regards
    Drimas

    Hello,
    If I understand correctly you are trying to make payment for vendor invoice. Whereas, the transaction code F-28 relating to Customers.
    You have two option in SAP to post invoice
    1. MIRO - If you have Purchase Order details and your MM module is in place, then you can post. However, before posting MIRO, you should have Purchase Order in place ME21N and goods receipt must have been made in MIGO.
    2. If it is pure FI Invoice, then you can post the invoice through F-43 or FB60
    Now for any of the invoices 1 or 2, you would like to make the payment,
    You can make the payment by using
    F-53 - Creates Payment Document (To assign check manually use FCH5, to assign automatically use FBZ5)
    F-58 - Creates the Payment document as well as assign the check automatically.
    F110 - For Automatic Payment Program
    If you want to void the check, then FCH9
    If you want to void the check as well reverse payment document FCH8
    If you have not assigned any check so far, but would like to reverse the payment document, then use FBRA.
    Once you have reversed the payment, if you still wanted reverse invoice document, then use FB08.
    If you want to see the check register, use FCHN.
    To update the check number on assignment or reference field, you can use FCHU.
    May be some of transaction codes are irrelevant for you, but just for your future reference, I have provided additional information.
    Please let me know if you need any further information.
    Regards,
    Ravi

  • Partial Payment posting in AR and clearing of invoice on fifo basis

    Dear Gurus,
    It is related to partial incoming payment in AR and clearing of invoices on FIFO basis, let me clarify my requiremnt through an Example
    Assume there an ivoice of PKR 100,000 in customer Account XYZ
    Company received partial PAyment of PKR 50,000 on specific date
    Data entry clerk enters payment in F-28 in partial payment tab and assign it to invoice (please note that at present payment is not being assigned and both item invoice and payment remains open without any assignment with each other)
    assume next payment which data entry clerk tries to enter with this refernce is PKR 60,000 while reamining amount with this invoice refernce is PKR 50,000 ,system should not allow to enter excess amount with partial paid invoice i.e. user has to be restricted to enter PKR 50,000 against this invoice
    As data entry clerk enter partial payment and there is any other open invoice, system should not allow to enter payment till clearance of first open invoice
    means specific requirement is
    in case of partial payment  with refernce to invoice, at the time of data entry system should chekc that no any other invoice is open in AR ledger
    as partial payment document is entered system assign this document to Invoice
    if data entry clerk tries to enter acess amount with refernce to invoice, system should not allow means Invoice amount = Payment amount
    please advice procedure to meet this requirement
    BR
    sajida

    Hi,
    For posting partial Invoice, At the time you received 50000, post it through F-28 only as a partial knockoff against a particular Invoice and at the time you enter second part of the Payment in excess of 50000, the system will not accept as the remaining amount of the Invoice is 50000 only.
    For Fifo Invoice Clearing -
    At the time of Posting F-28, click on "Distribute by age" the system will automatically clear the value on FIFO Basis.
    Regards,
    Prashant

  • Deferred Tax:Post invoice and clearing of open payment seperately $

    Hi Team,
    User not able to clear the vendor Through F-44
    Down payment was done at 2013 and Invoice is generated at 2014 . now user trying to clear thevendor through F-44 .When he is trying to clear the vendor system throwing error message stating that “Deferred Tax:Post invoice and clearing of
    open payment seperately$” .What is the reason for this .Thanks
    Regards,
    Raj

    Hi
    Check if OSS Note 913805 is relevant for your EhP and patch level
    Regards
    Sanil Bhandari

  • Post with clearing and only clearing

    hi,
    what is the difference between POST WITH CLEARING and CLEAR GL/CUSTOMER/VENDOR?
    fb05 is post with clearing whereas f-03, f-32 and f-44 are clearing.
    so what is the difference that 1 is POST with clearing and the other 3 are just clearing.
    thanks

    hi,
      According to ur requirement, u have to make use of this, like f-32 it is for clearing at the time of vendor who is also a customer, like custmer pay 100, for vendor we have to pay 100, in this case no need to go for payment, u can clear by using f-32, u check this u can able to understand, where as other cases are with payment, u can try down payment clearing also with that u can able to understand, if u have any doubts let me know , i can try
    Thanking u,
    swathi

  • My fonts are changing in iWed after I publish. I need step by step instructions on how to go to my third party server and clear out all of my files and reload my whole website, the solution I saw posted by another. Please someone help me on this. Urgent

    My fonts are changing in iWed after I publish. I need step by step instructions on how to go to my third party server and clear out all of my files and reload my whole website, the solution I saw posted by another. Please someone help me on this. Urgent

    If your fonts are changing when viewed on other computers - epecially those running windows - you need to look at using web-safe fonts...
    http://www.iwebformusicians.com/iWeb/Fonts-Colors.html
    Also make sure you clear your browser cache before viewing you published files.

  • Open and Cleared Items

    Hi all
    We are currently busy finalising our FI-CA BW Data Modeling exercise - and in process to complete Dataflow documentation.
    We will make use of the standard open and cleared item extractors with enhancements on different levels. Some background on the requirements:
    - We will have to extract document types, divisions, dates, clearing reasons, contract account, Business Partner etc.. information to meet the requirements.
    - We will have to keep history for at least 26 months to produce the required management reports (very high number of data), and 'partition' the cubes on date level for both Cleared and Open Items.
    - Most of the reports display 13 months worth of billing/ payment figures. I.e. the report for the end of October show billings vs. payments for October 2006, September, August, July, ... to October 2005.
    - The requirement is that the report figures will not change from one month to the next (i.e. if I run the report for end of October - all figures from October 2006 to Oct 2005 will remain the same when I run the report for end of November). I.e. if reversals, transfers, returns etc. occur - these will be picked up in later months.
    - For the above requirement, we are looking at extracting open (end of month) and cleared items (for the specific monthly interval) on a monthly basis, and appending the data in the cubes. We will then always base the June figure in the report on the June month extraction (LAUFD/ LAUFI fields) and we will pick up any movement in the next month/s - i.e. July.
    Has anyone had these types of requirements before - to report on billings vs. payments, and report on history as described above. We would appreciate it if you could share your report requirements, and also design documents, especially the DataFlow documentation that we can look at as input to our design.

    We had a requirement to retrieve "aging of receiveables" by customer. Basically, it goes thru each record and depending on the due date places the amounts in the following buckets (example). 0-30 day Overdue, 31-60 days Overdue, 61-90 days overdue, 30+ days overdue, 60+ days overdue) etc all the way to 6+ years overdue.
    There are also cooresponding buckets for coming due analysis. For example, what is: 0-30 days coming due, 31-60 days coming due, 30+ days coming due, etc...
    To do this, first I needed to be able be able to produce an open items statement at any given time in the past. Now, this seems impossible because of how the items go from open to cleared all the time. And an item that was open one month ago, may not be open anymore.
    What I did was first remove any selections on item status. Then compare the posting date with teh key date in the past, if the posting date is less than or equal to the key date, keep the record.
    Then compare the clearing date with the key date. First, keep all that are #. (This keeps all records still open from that posting date/key date)
    Then, add another check for all items that were cleared after the key date (GT Key Date). This gives you the open items on that date.
    Hope that makes sense. Let me know if you want clarification.
    /smw

  • Custom purchase requsitionto vendor open and cleared payment report

    dear all i develop report but i cant ableto show in that open amount and cleared amount of vender in that report so please see this report and feedback me for logic to show open and clear amount of vendor purchase orderwise or vendorwise
    report zpo_purchase_history no standard page heading message-id 00.
    TABLES : bsik, bsak, lfa1, lfb1, skb1, t001, bapifvdexp_vzzbepp.
    type-pools:slis,ICON.
    types :begin of ty_po,
            banfn type eban-banfn,
            "Purchase Requisition Number
            bnfpo type eban-bnfpo,
            "Item Number of Purchase Requisition
            ekgrp type eban-ekgrp,                 "Purchasing Group
            badat type eban-badat,
            "Requisition (Request) Date
            menge type eban-menge,
            KNTTP TYPE EBAN-KNTTP,
             PSTYP type eban-PSTYP,
            "Purchase Requisition Quantity
            meins type eban-meins,
            "Purchase Requisition Unit of Measure
            lifnr type ekko-lifnr,                 "Vendor Account Number
            bedat type ekko-bedat,                 "Purchasing Document Date
            ebeln type ekpo-ebeln,
            "Purchasing Document Number
            ebelp type ekpo-ebelp,
            "Item Number of Purchasing Document
            matkl type ekpo-matkl,                 "Material Group
            mtart type ekpo-mtart,                 "Material Type
            matnr type ekpo-matnr,                 "Material Number
            txz01 type ekpo-txz01,                 "Short Text
            menge1 type ekpo-menge,                "Purchase Order Quantity
            meins1 type ekpo-meins,
            "Purchase Order Unit of Measure
            balqty type ekpo-menge,                "Balance Quantity
            netpr type ekpo-netpr,
            "Net Price in Purchasing Document
            peinh type ekpo-peinh,                 "Price Unit
            mblnr type mseg-mblnr,
            "Number of Material Document
            zeile type mseg-zeile,                 "Item in Material Document
            menge2 type mseg-menge,                "GR Quantity
            meins2 type mseg-meins,                "GR Unit of Measure
            werks type mseg-werks,                 "Plant
            charg type mseg-charg,                 "Batch
            belnr type rbkp-belnr,
            "Document Number of an Invoice Document
            bldat type ekbe-bldat,                 "Document Date in Document
            belnr_b type rbkp-belnr,
            SHKZG type ekbe-SHKZG ,                "Debit/Credit Indicator
            DMBTR type   bsik-dmbtr,                "Amount in Local Currency
            DMBTR_C type   bsAk-dmbtr,                "Amount in Local Currency
            thick(10) type c,                      "Thickness
            width(10) type c,                      "Width
            length(10) type c,                     "Length
            grade(10) type c,                        "Grade
            BELNR_d type bseg-belnr,
            xblnr type bkpf-xblnr,
            awkey  type bkpf-awkey,
            RMWWR type rbkp-RMWWR,
            WMWST1 type rbkp-WMWST1,
            end of ty_po.
    types :begin of ty_ekko,
            ebeln type ekko-ebeln,
            lifnr type ekko-lifnr,
            bedat type ekko-bedat,
            end of ty_ekko.
    types:begin of ty_ekpo,
            ebeln type ekpo-ebeln,
            ebelp type ekpo-ebelp,
            matnr type ekpo-matnr,
            txz01 type ekpo-txz01,
            menge type ekpo-menge,
            meins type ekpo-meins,
            netpr type ekpo-netpr,
            peinh type ekpo-peinh,
            banfn type ekpo-banfn,
            bnfpo type ekpo-bnfpo,
            mtart type ekpo-mtart,
            end of ty_ekpo.
    types :begin of ty_eban,
            banfn type eban-banfn,
            bnfpo type eban-bnfpo,
            matnr type eban-matnr,
            menge type eban-menge,
            meins type eban-meins,
            end of ty_eban.
    types : begin of ty_ekbe,
             ebeln type ekbe-ebeln,
             ebelp type ekbe-ebelp,
             belnr type ekbe-belnr,
             bldat type ekbe-bldat,
             gjahr type ekbe-gjahr,
             buzei type ekbe-buzei,
             matnr type ekbe-matnr,
             DMBTR type ekbe-dmbtr,
             shkzg type ekbe-shkzg,
             end of ty_ekbe.
    types : begin of ty_mseg,
             mblnr type mseg-mblnr,
             mjahr type mseg-mjahr,
             zeile type mseg-zeile,
             menge type mseg-menge,
             meins type mseg-meins,
             ebeln type mseg-ebeln,
             ebelp type mseg-ebelp,
             matnr type mseg-matnr,
             werks type mseg-werks,
             charg type mseg-charg,
             end of ty_mseg.
    types : begin of ty_rbkp,
             belnr type rbkp-belnr,
             gjahr type rbkp-gjahr,
             bldat type rbkp-bldat,
             lifnr type rbkp-lifnr,
             ZUONR type rbkp-ZUONR,
             RMWWR type rbkp-RMWWR,
             WMWST1 type rbkp-WMWST1,
             end of ty_rbkp.
    types : begin of ty_bseg,
             bukrs type bseg-bukrs,
             belnr type bseg-belnr,
             gjahr type bseg-gjahr,
             buzei type bseg-buzei,
             valut type bseg-valut,
             wrbtr type bseg-wrbtr ,
             augbl type bseg-augbl,
             matnr type bseg-matnr,
             lifnr type bseg-lifnr,
             ebeln type bseg-ebeln,
             end of ty_bseg.
    types : begin of ty_rseg,
             belnr type rseg-belnr,
             gjahr type rseg-gjahr,
             ebeln type rseg-ebeln,
             ebelp type rseg-ebelp,
             matnr type rseg-matnr,
             bukrs type rseg-bukrs,
             end of ty_rseg.
    types : begin of ty_bsik,
             belnr type bsik-belnr,
              buzei type bsik-buzei,
             DMBTR type bsik-DMBTR,
             budat type bsik-budat,
             shkzg type bsik-shkzg,
             ebeln type bsik-ebeln,
             lifnr type bsik-lifnr,
             end of ty_bsik.
    types : begin of ty_bsak,
             belnr type bsak-belnr,
       lifnr type bsak-lifnr,
        ebeln type bsak-ebeln,
             DMBTR_C type bsak-DMBTR,
    ZUONR type bsak-ZUONR,
             end of ty_bsak.
    types: begin of ty_bkpf,
             BELNR type bkpf-belnr,
             xblnr type bkpf-xblnr,
             awkey  type bkpf-awkey,
           end of ty_bkpf.
    data: it_po type standard table of ty_po,
           it_ekko type standard table of ty_ekko,
           it_ekpo type standard table of ty_ekpo,
           it_eban type standard table of ty_eban,
           it_ekbe type standard table of ty_ekbe,
           it_mseg type standard table of ty_mseg,
           it_rbkp type standard table of ty_rbkp,
           it_rseg type standard table of ty_rseg,
           it_bseg type standard table of ty_bseg,
           it_bsik type STANDARD TABLE OF ty_bsik with header line,
           it_bsak type STANDARD TABLE OF ty_bsak,
           it_bkpf type standard table of ty_bkpf,
           wa_po type ty_po,
           wa_ekko type ty_ekko,
           wa_ekpo type ty_ekpo,
           wa_eban type ty_eban,
           wa_mseg type ty_mseg,
           wa_rbkp type ty_rbkp,
           wa_rseg type ty_rseg,
           wa_bseg type ty_bseg,
           wa_ekbe type ty_ekbe,
           wa_bsik type ty_bsik,
           wa_bsak type ty_bsak,
           wa_bkpf type ty_bkpf.
    data: it_fcat type slis_t_fieldcat_alv,
           it_lshead type slis_t_listheader,
           it_sort type slis_t_sortinfo_alv,
           wa_fcat type slis_fieldcat_alv,
           wa_lshead type slis_listheader,
           wa_layout type slis_layout_alv,
           wa_sort type slis_sortinfo_alv.
    data :it_cl_data like table of clobjdat,
           wa_cl_data like clobjdat.
    data: values(10) type n.
    data: value1(4) type N.
    data: c_matkl type ekpo-matkl,
           c_matnr type ekpo-matnr,
           c_ekgrp type eban-ekgrp,
           c_badat type eban-badat,
           c_index type sy-tabix,
           c_grmenge type mseg-erfmg,
           c_low(10) type c,
           c_high(10) type c,
           c_date type string,
           c_bukrs type ekko-bukrs,
           c_WERKS type eban-WERKS.
    data: gd_date(10).
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
           WA_EVENT TYPE SLIS_ALV_EVENT.
    *********Selection screen variables*********
    selection-screen:begin of block b1 with frame title text-001.
    select-options: s_bukrs for c_bukrs DEFAULT  'bmp1',
                     s_WERKS for c_WERKS,
                     s_matnr for c_matnr DEFAULT 'rm-01',
                     s_matkl for c_matkl ,
                     s_badat for c_badat ,"obligatory,
                     s_ekgrp for c_ekgrp.
    parameters: ch_bal as checkbox.
    selection-screen:end of block b1.
    *initialization.
    * PERFORM EVENT_CALL.
    *  PERFORM POPULATE_EVENT.
    start-of-selection.
         PERFORM EVENT_CALL.
       PERFORM POPULATE_EVENT.
       perform getdata.
       perform setdata.
       perform fieldcat.
       perform display.
    *&      Form  GETDATA
    form getdata .
       select a~BANFN
              a~bnfpo
              a~ekgrp
              a~badat
              a~KNTTP
              a~PSTYP
              b~ebeln
              b~ebelp
              b~matkl
              b~matnr
              b~bukrs
              into corresponding fields of table it_po
              from eban as a inner join ekpo as b
              on a~banfn = b~banfn and
                 a~bnfpo = b~bnfpo AND
                 A~KNTTP = B~KNTTP and
                 a~PSTYP = b~PSTYP
              where  a~badat in s_badat and
                     a~ekgrp in s_ekgrp and
                     a~WERKS in s_WERKS and
                     b~matnr in s_matnr and
                     b~matkl in s_matkl and
                     b~bukrs in s_bukrs and
                     b~loekz <> 'L' and
                     a~loekz <> 'X'.
       if it_po[] is not initial.
         select ebeln
                ebelp
                matnr
                txz01
                menge
                meins
                netpr
                peinh
                banfn
                bnfpo
                mtart
                from ekpo into table it_ekpo
                for all entries in it_po
                where ebeln = it_po-ebeln and
                      ebelp = it_po-ebelp and
                      loekz <> 'L'.
         select banfn
                bnfpo
                matnr
                menge
                meins
                from eban into table it_eban
                for all entries in it_po
                where banfn = it_po-banfn and
                      bnfpo = it_po-bnfpo and
                      loekz <> 'X'.
         if it_ekpo[] is not initial.
           select ebeln
                  lifnr
                  bedat
                  from ekko into table it_ekko
                  for all entries in it_ekpo
                  where ebeln = it_ekpo-ebeln.
           select ebeln
                  ebelp
                  belnr
                  bldat
                  gjahr
                  buzei
                  matnr
                  DMBTR
                  shkzg
                  from ekbe into table it_ekbe
                  for all entries in it_ekpo
                  where ebeln = it_ekpo-ebeln and
                        ebelp = it_ekpo-ebelp .
    *if it_ekbe-shkzg = 'H'.
    **ekbe-dmbtr = ekbe-dmbtr * -1.
    **ekbe-menge = ekbe-menge * -1.
    *endif.
    * select belnr
    *             gjahr
    *             ebeln
    *             ebelp
    *     from bseg into table it_bseg
    *             for all entries in it_ekpo
    *             where ebeln = it_ekpo-ebeln and
    *                   ebelp = it_ekpo-ebelp.
           select belnr
                  gjahr
                  ebeln
                  ebelp
                  matnr
                  bukrs
                  from rseg into table it_rseg
                  for all entries in it_ekpo
                  where ebeln = it_ekpo-ebeln and
                        ebelp = it_ekpo-ebelp.
         endif.
         if it_ekbe[] is not initial.
           select mblnr
                  mjahr
                  zeile
                  menge
                  meins
                  ebeln
                  ebelp
                  matnr
                  werks
                  charg
                  from mseg into table it_mseg
                  for all entries in it_ekbe
                  where mblnr = it_ekbe-belnr and
                        mjahr = it_ekbe-gjahr and
                        zeile = it_ekbe-buzei and
                        bwart = '101'.
         endif.
         if it_rseg[] is not initial.
           select belnr
                  gjahr
                  bldat
                  lifnr
                  ZUONR
                  RMWWR
                  WMWST1
                  from rbkp into table it_rbkp
                  for all entries in it_rseg
                  where belnr = it_rseg-belnr.
         endif.
    *if it_rseg[] is not initial.
    *      SELECT bukrs
    *              belnr
    *              gjahr
    *              buzei
    *              valut
    *              wrbtr
    *              augbl
    *              matnr
    *              lifnr
    *              ebeln
    *        INTO TABLE it_bseg
    *          FROM bseg
    *          FOR ALL ENTRIES IN it_rseg
    *          WHERE bukrs = it_rseg-bukrs and ebeln = it_rseg-ebeln and mwskz = ''.
    *endif.
    *loop at it_BKPF into wa_BKPF.
    *  values = wa_rbkp-belnr.
    *  value1 = wa_rbkp-gjahr.
       data: aekey_1 type string .
    *CONCATENATE values value1 into aekey_1.
    *  if it_BSEG[] is not initial.
    *MESSAGE aekey_1 type 'I'.
           SELECT single belnr xblnr awkey into wa_bkpf
             from bkpf
             where awkey = aekey_1.
    SELECT SINGLe belnr
    buzei
    dmbtr
    budat
       shkzg
       ebeln
       lifnr
       FROM bsik
    INTO CORRESPONDING FIELDS OF  wa_bsik
    *FOR ALL ENTRIES IN it_bseg
    WHERE
        bukrs in s_bukrs and
        lifnr = wa_rbkp-lifnr
    and
    *AND gjahr = it_bseg-gjahr
    * AND
        belnr = wa_bkpf-belnr.
    insert wa_bsik into table it_bsik.
    CLEAR wa_bsik.
    CLEAR it_bsik.
    *endloop.
    * and ebeln = it_bseg-ebeln .
    *    select BELNR
    **           SHKZG
    **           DMBTR
    *           from bkpf into table it_bkpf
    *            for ALL ENTRIES IN it_rbkp
    *            where belnr = it_rbkp-belnr.
    *        ENDif.
    IF IT_bseg[] IS NOT INITIAL.
           select belnr
             LIFNR
             ebeln
                  DMBTR
              ZUONR
                  from bsik into table it_bsik
                  for all entries in it_bseg
                  where belnr = it_bseg-belnr.
           select belnr
             LIFNR
             ebeln
                  DMBTR
              ZUONR
                  from bsak into table it_bsak
                  for all entries in it_bseg
                  where belnr = it_bseg-belnr.
    ENDIF.
       else.
         message s002.
         leave list-processing.
       endif.
    endform.                    " GETDATA
    *&      Form  SETDATA
    form setdata .
       clear wa_po.
       loop at it_po into wa_po.
         c_index = sy-tabix.
    ********Calculate PR Quantity**********
         clear wa_eban.
         read table it_eban into wa_eban
                    with key banfn = wa_po-banfn
                             bnfpo = wa_po-bnfpo.
         if sy-subrc eq 0.
           move:wa_eban-menge to wa_po-menge,
                wa_eban-meins to wa_po-meins.
         endif.
    ********Calculate PO Quantity**********
         clear wa_ekpo.
         read table it_ekpo into wa_ekpo
                    with key banfn = wa_po-banfn
                             bnfpo = wa_po-bnfpo .
         if sy-subrc eq 0.
           move:wa_ekpo-txz01 to wa_po-txz01,
                wa_ekpo-netpr to wa_po-netpr,
                wa_ekpo-peinh to wa_po-peinh,
                wa_ekpo-mtart to wa_po-mtart,
                wa_ekpo-menge to wa_po-menge1,
                wa_ekpo-meins to wa_po-meins1.
         endif.
    ********Calculate Balance Quantity******
         clear wa_mseg.
         loop at it_mseg into wa_mseg
                where ebeln = wa_po-ebeln and
                      ebelp = wa_po-ebelp.
           c_grmenge = c_grmenge + wa_mseg-menge.
         endloop.
         move:wa_mseg-mblnr to wa_po-mblnr,
              c_grmenge to wa_po-menge2,
              wa_mseg-meins to wa_po-meins2,
              wa_mseg-werks to wa_po-werks,
              wa_mseg-charg to wa_po-charg.
         wa_po-balqty = wa_eban-menge - c_grmenge.
         clear : wa_rseg,wa_rbkp.
         read table it_rseg into wa_rseg with key
                        ebeln = wa_mseg-ebeln
                        ebelp = wa_mseg-ebelp.
         read table it_rbkp into wa_rbkp
                    with key belnr = wa_rseg-belnr
                             gjahr = wa_rseg-gjahr.
         if sy-subrc eq 0.
           move : wa_rbkp-belnr to wa_po-belnr,
                  wa_rbkp-bldat to wa_po-bldat,
                  wa_rbkp-RMWWR to wa_po-RMWWR,
                  WA_RBKP-WMWST1 TO WA_PO-WMWST1.
         endif.
           read table it_bseg into wa_bseg with key
                         ebeln = wa_rseg-ebeln
                         bukrs = wa_rseg-bukrs.
           if sy-subrc eq 0.
             move wa_bseg-belnr to wa_po-belnr_d.
           endif.
    *    read table it_bkpf into wa_bkpf
    *    with key belnr = wa_ekbe-belnr.
    *    read table it_bseg into wa_bseg
    *    with key belnr = wa_bkpf-belnr.
    CLEAR wa_bsik.
    clear it_bsik.
         read table it_bsik into wa_bsik
         with key belnr = wa_bkpf-belnr.
    *    if wa_bsik-shkzg = 'H'.
    *     wa_bsik-DMBTR = wa_bsik-DMBTR * 1.
    *     endif.
           if sy-subrc eq 0.
             move : wa_bsik-belnr to wa_po-belnr,
                     wa_bsik-DMBTR to wa_po-DMBTR.
            endif.
    *    clear wa_bsik.
    *    read table it_bsik into wa_bsik
    *               with key  belnr = wa_bseg-belnr.
    *    if sy-subrc eq 0.
    *        move : wa_bsik-DMBTR to wa_po-DMBTR.
    *    endif.
    *clear wa_bsak.
    *    read table it_bsak into wa_bsak
    *               with key  belnr = wa_bseg-belnr.
    *    if sy-subrc eq 0.
    *        move : wa_bsak-DMBTR_C to wa_po-DMBTR_C.
    *    endif.
    *clear : wa_rbkp.
    *loop at it_bsik into wa_bsik.
    *read table it_bsik into wa_bsik with key belnr = wa_rbkp-belnr.
    *if sy-subrc eq 0.
    *  move : wa_bsik-DMBTR to wa_po-DMBTR.
    *    endif.
    *endloop.
    *********Assign Vendor,PO Date*********
         clear wa_ekko.
         read table it_ekko into wa_ekko
                    with key ebeln = wa_po-ebeln.
         if sy-subrc eq 0.
           move:wa_ekko-lifnr to wa_po-lifnr,
                wa_ekko-bedat to wa_po-bedat.
         endif.
    *clear wa_ekko.
    *read table it_ekko into wa_ekko
    *with key lifnr = wa_po-lifnr.
    *if sy-subrc eq 0.
    *  move: wa_bsik-DMBTR to wa_po-DMBTR.
    *  endif.
    *    call function 'ZSD_BATCH_CLASSIFICATION_DATA'
    *      exporting
    **        ch_charg                   = wa_po-charg
    *        ch_matnr                   = wa_po-matnr
    *        ch_werks                   = wa_po-werks
    *      tables
    *        cl_data                    = it_cl_data
    **       I_SEL_CHARACTERISTIC       =
         loop at it_cl_data into wa_cl_data.
           if wa_cl_data-ausp1 ne '?'.
             if wa_cl_data-atnam eq 'THICKNESS'.
               move wa_cl_data-ausp1 to wa_po-thick.
             elseif wa_cl_data-atnam eq 'LENGTH'.
               move wa_cl_data-ausp1 to wa_po-length.
             elseif wa_cl_data-atnam eq 'WIDTH'.
               move wa_cl_data-ausp1 to wa_po-width.
             elseif wa_cl_data-atnam eq 'GRADE'.
               move wa_cl_data-ausp1 to wa_po-grade.
             endif.
           endif.
         endloop.
         modify it_po from wa_po index c_index.
         clear :c_grmenge,wa_po,wa_ekpo,wa_mseg,c_index.
       endloop.
    endform.                    " SETDATA
    *&      Form  FIELDCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form fieldcat .
       perform buildfields using '1' 'BANFN'  'IT_PO' 'PR Number' '' ''.
    *  perform buildfields using '2' 'BNFPO'  'IT_PO' 'PR Item Number' '' ''.
       perform  buildfields using '2' 'KNTTP' 'IT_PO' 'A/c Assignment Cat' '' ''.
       perform  buildfields using '2' 'PSTYP' 'IT_PO' 'Item Cat' '' ''.
       perform buildfields using '3' 'EKGRP'  'IT_PO' 'Purchase Group' '' ''.
       perform buildfields using '4' 'BADAT'  'IT_PO' 'Request Date' '' ''.
       perform buildfields using '5' 'MENGE'  'IT_PO' 'PR Quantity'  'X' ''.
       perform buildfields using '6' 'MEINS'  'IT_PO' 'PR Unit' '' ''.
       perform buildfields using '7' 'LIFNR'  'IT_PO' 'Vendor Number' '' ''.
       perform buildfields using '8' 'EBELN'  'IT_PO' 'Purchasing Doc No' '' ''  .
       perform buildfields using '9' 'BEDAT'  'IT_PO' 'PO Date' '' ''.
       perform buildfields using '10' 'MTART' 'IT_PO' 'Material Type' '' ''.
       perform buildfields using '11' 'MATKL' 'IT_PO' 'Material Group' '' ''.
       perform buildfields using '12' 'MATNR' 'IT_PO' 'Material Number' '' ''.
       perform buildfields using '13' 'TXZ01' 'IT_PO' 'Material Desc' '' ''.
       perform buildfields using '18' 'MENGE1' 'IT_PO' 'PO Quantity' 'X' ''.
       perform buildfields using '19' 'MEINS' 'IT_PO' 'PO Unit' '' ''.
       perform buildfields using '20' 'NETPR' 'IT_PO' 'Net Price' '' ''.
       perform buildfields using '21' 'PEINH' 'IT_PO' 'Price Unit' '' ''.
       perform buildfields using '22' 'MBLNR' 'IT_PO' 'GR Number' '' ''.
       perform buildfields using '23' 'MENGE2' 'IT_PO' 'GR Quantity' 'X' ''.
       perform buildfields using '24' 'MEINS2' 'IT_PO' 'GR Unit' '' ''.
       perform buildfields using '25' 'BELNR' 'IT_PO' 'Invoice doc. number' '' ''.
       perform buildfields using '26' 'BLDAT' 'IT_PO' 'Invoice Date' '' ''.
    *  perform buildfields using '26' 'BELNR_D' 'IT_POP' 'A/C Doc. No.' '' ''.
    *  perform buildfields using '26' 'AUGBL' 'IT_PO' 'Clearing Doc No.' '' ''.
       perform buildfields using '26' 'DMBTR' 'IT_PO' 'OPEN AMOUNT' '' ''.
      perform buildfields using '26' 'DMBTR' 'IT_PO' 'clear AMOUNT' '' ''.
    *  perform buildfields using '26' 'DMBTR_C' 'IT_PO' 'Clear balance' '' ''.
       if ch_bal = 'X'.
         perform buildfields using '27' 'BALQTY' 'IT_PO' 'Balance Quantity'
         'X' ''.
       endif.
       perform buildfields using '26' 'WMWST1' 'IT_PO' 'TOTAL TAX ADDED' 'X' ''.
       perform buildfields using '26' 'RMWWR' 'IT_PO' 'TOTAL AMOUNT IN INVOICE' 'X' ''.
    endform.                    " FIELDCAT
    *&      Form  BUILDFIELDS
    *       text
    *      -->P_0449   text
    *      -->P_0450   text
    *      -->P_0451   text
    *      -->P_0452   text
    form buildfields  using    value(p_col_pos) like sy-cucol
                                value(p_fldname) type slis_fieldname
                                value(p_tabname) type slis_tabname
                                value(p_reptext) like dd03p-reptext
                                value(p_do_sum) type char1
                                value(hotspot) type char1.
       wa_fcat-col_pos = p_col_pos.
       wa_fcat-fieldname = p_fldname.
       wa_fcat-tabname = p_tabname.
       wa_fcat-reptext_ddic = p_reptext.
       wa_fcat-do_sum = p_do_sum.
       wa_fcat-hotspot = hotspot.
       append wa_fcat to it_fcat.
       clear wa_fcat.
    endform.                    " BUILDFIELDS
    *&      Form  DISPLAY
    form display .
       clear wa_layout.
       wa_layout-zebra = 'X'.
       wa_layout-colwidth_optimize = 'X'.
    * wa_layout-box_fieldname     = 'SEL'.
    * wa_layout-edit = 'X'.
       perform build_sort using 'BANFN' '1' 'X'.
       call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
          i_callback_program               = sy-cprog
    *   I_CALLBACK_PF_STATUS_SET          = ' '
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND '
          i_callback_top_of_page           = 'TOP_OF_PAGE'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
        i_background_id                   = 'ALV_BACKGROUND'
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
          is_layout                        = wa_layout
          it_fieldcat                      = it_fcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
         it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
        I_SAVE                            = 'A'
    *   IS_VARIANT                        =
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
         tables
           t_outtab                          = it_po[]
      exceptions
        program_error                     = 1
        others                            = 2
       if sy-subrc <> 0.
         message id sy-msgid type sy-msgty number sy-msgno
                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       endif.
    endform.                    " DISPLAY
    *&      Form  top_of_page
    *       text
    form top_of_page.                                           "#EC *
    **********Create report header*********
       refresh it_lshead.
       clear wa_lshead.
    **********To display date in header*********
    *  write: s_badat-low to c_low dd/mm/yyyy,s_badat-high to c_high
    *  dd/mm/yyyy.
    *  if s_badat-high is initial.
    *    concatenate 'Dated on' c_low into c_date separated by space.
    *  else.
    *    concatenate 'Dated between' c_low 'and' c_high into c_date separated
    *    by space.
    *  endif.
       wa_lshead-typ = 'H'.
       wa_lshead-info = 'PR To Payment History'.
    *  'Pending Indents History -

    We had a requirement to retrieve "aging of receiveables" by customer. Basically, it goes thru each record and depending on the due date places the amounts in the following buckets (example). 0-30 day Overdue, 31-60 days Overdue, 61-90 days overdue, 30+ days overdue, 60+ days overdue) etc all the way to 6+ years overdue.
    There are also cooresponding buckets for coming due analysis. For example, what is: 0-30 days coming due, 31-60 days coming due, 30+ days coming due, etc...
    To do this, first I needed to be able be able to produce an open items statement at any given time in the past. Now, this seems impossible because of how the items go from open to cleared all the time. And an item that was open one month ago, may not be open anymore.
    What I did was first remove any selections on item status. Then compare the posting date with teh key date in the past, if the posting date is less than or equal to the key date, keep the record.
    Then compare the clearing date with the key date. First, keep all that are #. (This keeps all records still open from that posting date/key date)
    Then, add another check for all items that were cleared after the key date (GT Key Date). This gives you the open items on that date.
    Hope that makes sense. Let me know if you want clarification.
    /smw

Maybe you are looking for