Age Bucket in sql

Hi all,
I need to solve it by using procedure.
I have follwoing table:-
Item NO|Date|Lot_No|Location|Quantity|Barcode No|State
I need to create age bucket with 0-10 days,10-20 days and 20-30 days based on dynamic date.
suppose i Pass @date='2010/2/1'
Then i need to calculate 0-10 days(21jan-31 jan[Last 10 days])
,10-20(11jan-20 jan) days and 20-30(1jan-10jan) days 
then my output is like:-
Item NO|Lot_No|Location|Quantity|Barcode No|State|0-10 days|10-20 days|20-30 days

suppose the data:-
Item NO|      Date      |Lot_No |Location|Quantity|Barcode No|         State
1            2010/1/1       1     Delhi     10          B1             New Delhi
1            2010/1/5       1     Delhi     05          B1             New Delhi
2            2010/1/5       3     Punjab    10          B5             Chandi
1            2010/1/11      1     Delhi     10          B1             New Delhi
1            2010/1/17      1     Delhi     10          B1             New Delhi
2            2010/1/18      3     Punjab    10          B5             Chandi
1            2010/1/21      1     Delhi     10          B1             New Delhi
1            2010/1/30      1     Delhi     15          B1             New Delhi
Expected Output:-
Note:-Grouping should be done On Item NO,Lot_No,Location and Barcode No
Item NO|Lot_No|Location|Barcode No|State      |0-10 days|10-20 days|20-30 days
1       1      Delhi     B1         New Delhi    15       20         25
2       3      Punjab    B5         Chandi       10       10         0

Similar Messages

  • How can the dunning letter shows O/S amt and corresponding aging bucket?

    Hi,
    I am going to implement the dunning letter setup in R12. Our user request to have the dunnng letter layout which should show all regular dunning details but also the aging info of the outstanding invoices, i.e. which aging bucket the outstanding amount will be shown. Anybody have idea and help? Thanks a lot.
    Edmond

    Thank you Nagarajan.  I have a dunning letter created in Crystal Reports for our client.  It is fairly limited in scope, it just has the customer name and address, invoice numbers and dates, amounts due and the text they wanted in it.
    I can import it into B1 9.0 and set it as the default for Dunning Letter #1 and it runs, but unlike other formats where there is a DocEntry and/or ObjectID and a ?DocKey@ or ?ObjectId@ parameter, how do I limit the report to just one customer?  Typical document layouts run for the document that's on the screen.  In the dunning process, the report runs once for every customer when the Dunning Letter Method is set to "One Letter per BP".  I have to limit the report to one customer at a time.  Right now, each dunning letter based on the Crystal report is identical and it contains all the data for every customer.
    So, does anyone have any ideas for what selection criteria needs to be included in the Crystal report to have it select just one customer from the dunning wizard tables?  Thanks.
    Michael
    Edit: I created a ?WizardID@ parameter and a ?CardCode@ parameter to limit the report to a single dunning wizard event and a single customer.  While it works fine in Crystal itself, it doesn't work in B1 at all.  I had thought that by limiting the report in this way, it would only create dunning letters for a single customer.

  • Customize AP Trial Balance XML Data Definition for adding Aging Buckets

    Hi
    I have to customize AP Trial Balance Report XML Data Definition Template for adding Aging Buckets & Supplier details in R12 , Could you let me know how i can modify XML file?
    Thanks
    Pravin

    Hi,
    My requirement is different from the one which is in below link.
    I need to add Aging Buckets & Supplier details to AP Trial Balance report (R12) , here i need to modify the XML Data definition template.
    Please help me, very urgent.
    Thanks
    Pravin

  • Create aging bucket in BEx - based on  date variable

    Hi everyone,
    I have a report for which we need to create account receivable aging bucket to classify arrears (1>29 / 30>59 / etcu2026).
    Our solution overall architecture is the following :
    Source System (SAP) >  BW back end...Multiprovider > Super BEx Query > Universe > Webi Report
    BW 7.0
    BO XI 3.2 SP3.0
    In this report, each bucket is defined by the difference between:
    -     the Net Due Date (which is the due date of payment of the invoice)
    -     and the Current Date (date for which the report is run u2013 can be the date of the day or a date in the past)
    We can develop this either in BEx or in Webi, but to avoid potential performance issues in Webi, we take the try to develop this in BEx.
    As you can easily imagine, this BEx query will be used for many reportsu2026so not only for this specific report.
    What weu2019ve done so far:
    1-     We created a variable to prompt the user with the date he wants to run the report for
               - ZTEST is an optional variable, single value, User input, based on characteristic 0CALDAY
    2-     We developed RKF in BEx
    -     Key Figure restricted by Amount
    -     Net Due Date restricted by the variable ZTEST using the between function and an offset (to determine the range)
    => When we save the query we are getting a warning message saying u201CVariable ZTEST for characteristic Net Due Date has been converted to a required entryu201D
    Why? (you probably knowu2026) Because my RKF is using a variable with an offsetu2026which automatically turn on my variable as mandatory and no more as optional.
    Consequences:
    -     In BEx: My variable, which is required to be optional (because we donu2019t have to have this field as mandatory for each and every report running on top of this query) is now mandatory.
    -     In Webi: If I use the variable (funnel in webi), my report is working fineu2026but if I donu2019t use it in the webi report, I get an error message saying u201Cvalue required for ZTESTu201D
    o     Funnel is configured as optional in the universe designer (so the issue is not coming from here)
    => 2 consequencesu2026same issue
    Question: What can we do to keep our bucket logic running in BEx and avoid this variable to become mandatory?
    Solutions (potential)
    -     Create a custom exit routine to work around this issue u2013 how?
    -     Create CKF/Custom exit to create our bucket (using ZTEST as an entry value to determine the range) and then use the created range in our RKF to restrict the amount u2013 how? Not so easyu2026
    -     Build the logic in Webi
    -     Any other suggestions?
    Here we are, any advice would be really appreciated
    Thank you guys
    Regards
    Henri

    Hi peeps,
    We finally find a solution for this problem! So I can share it with you.
    The overall solution is pretty easy to understand.
    1st step is to prompt with the user with a 0DATE variable. The date selected becomes a date input for the next step.
    The variables is defined as a range [01/01/1900;variable_value)...in order to retrieve the right data set.
    2nd step is to use this date to create our aging bucket, dates range.
    To do so, we created 4 user exit variables (for each aging bucket).
    3rd step is to use these ranges in RKF.
    This way you get aging bucket dynamically defined by the user input pretty cool!
    Regards
    H

  • AR - Aging Bucket report Customisation

    I have a requirement from end users to be able to run an aged debt report for any date range in the past e.g. From 01-Jan-2008 to 01-Jan-2013.
    Aging Bucket report only has, "As of date" field in the parameters.
    Is it possible to add additional parameters to this report?

    Hi.
    I don't believe such parameter can be included in the Aging reports. According to the user manual, the design of the report is to:
    Receivables includes all open items whose GL date is before or the same as the date you enter, and whose GL date closed is after the date you enter. The default is the current date.
    Besides, such parameter would cause debts to be excluded from the balance.
    Octavio

  • Aging Bucket - Account Receivable

    I wanted to create a Aged Report. e.g:
    0-30 31-60 61-90 91+
    Invoice 1 100
    Invoice 2 300.8
    I know how to calculate days difference. But I dont know how to put the amount under this certain aging bucket. I tried to use decode function but it doesnt work.
    Thanks

    I haven't given the complete code here, but this is how you can do it.
    SELECT
    I.trx_number invoice_number
    ,ps.amount_due_remaining payment_due
    , decode(floor(floor(sysdate-ps.due_date)/31)
    ,0,nvl(ps.amount_due_remaining,0),0) Days_0_to_30
    , decode(floor(floor(sysdate-ps.due_date)/31)
    ,1,nvl(ps.amount_due_remaining,0),0) Days_31_to_60
    , decode(floor(floor(sysdate-ps.due_date)/31)
    ,2,nvl(ps.amount_due_remaining,0),0) Days_61_to_90
    , nvl(decode(floor(floor(sysdate-ps.due_date)/31)
    ,0,0,1,0,2,0,0,0,nvl(ps.amount_due_remaining,0)),0) Days_90_plus
    FROM AR.ra_customers C
    , AR.ra_customer_trx_all I
    , ar.ar_payment_schedules_all ps
    WHERE C.customer_id = I.bill_to_customer_id
    AND ps.due_date < sysdate
    and ps.amount_due_remaining > 0
    and i.customer_trx_id = ps.customer_trx_id

  • Cusomter aging bucket

    Hello,
    we are trying to print customer aging bucket on monthly statement by print program RFKORD10. in customer due date list, i entered the break down days as 30, 60, 90 and etc. But when i run RFKORD10, the structure RF140 is not updated with the breakdown amount I am looking for. Is there any specific step I have to go through to have the RF140 updated correctly? or how I can make the aging bucket works by the standard print program?
    thanks,

    there is no specific setting for this aging program.
    its just a standard program by SAP.
    for more information, just click on the 'i' icon in the program execution screen.
    Regards
    Anantha

  • Divide Customers based on Aging Bucket

    Is there any way we can split the customers of different profile class having different aging buckets defined?

    Hmmm.... you can put me in the "Ancient" bucket. :-)
    By the way, what is an "aging bucket"?

  • What is aging bucket and charge backs in receivables?

    Hi
    Iam new to oracle apps.
    what is aging bucket and charge backs in receivables?
    help me to learn basic terms of receivables?

    Chargebacks
    http://download.oracle.com/docs/cd/A60725_05/html/comnls/us/ar/teches12.htm
    Aging Buckets
    http://download.oracle.com/docs/cd/A60725_05/html/comnls/us/ar/system08.htm
    Regards,
    Srini

  • Aging buckets in a query

    Hi gurus,
    I am creating an A/R aging queries to age open items in 30days buckets( 0-30days, 31-60days,61-90 days and 91days+).My logic for each buckets is below ..
    eg -- 31-60days bucket (Key fig)-  Item status- Open
                                                     Posting date - <= posting date(Variable)
                                                     Net due date - btw -31 to -60 days, using offsets
                                                                           on the key due date variable
                                  (2nd Key fig)- Posting date- <= Posting date(variable)
                                                      Net due date - btw -31 to -60 days, using offsets
                                                                           on the key due date variable
                                                      Clearing date-- > Clearing date
    Then for the 31-60 days bucket, I now add both key figures together.
    The logic is working fine but I just found out that there are a few plants that the buckets are not aging the data correctly like it is in R/3 because some of the customers make partial payment and in R/3 they are moved from an aging bucket to a current one after the partial payment has been made,but BW is looking at the original invoice posting date and not recognising the date that the partial payment was made.
    How do I make BW to recognise the partial payment date when a partial payment has been made for the aging instead of the original posting date?
    I hope this was not too confusing.
    Thanks

    Hi Kartikey,
    Thanks for the  response. I am not calculating the subtotals at the in the query definition and the sub totals are based on the info object 0customer's setting in the query designer to suppress the result rows. In RSRT also I am unable to get the sub totals.
    If I remove the calculations (aging buckets) and display direct key figure in the columns, I am able to get the sub totals.
    Is there any specific reason why the sub totals can not be calculated if the columns are calculated key figures/new formula.
    Can any one let me know how to fix the sub totals.
    Thanks

  • Aging Buckets (More than 7)

    I am going to create a custom report for Aging in Oracle Receivables. I need a report with more than 7 buckets.
    Has anyone implemented this feature? Any tips on how to proceed?
    Thanks in advance

    All I had to do is
    <ol>
    <li>Alter Queries in Data Model by adding an extra field for every bucket. i.e.
    <br><br>select ....
    <br>, 0 bo
    <br>, 0 b1
    <br>, ...0 b6
    <br>, <b>0 b7
    , 0 b8</b>
    from ...</li>
    <br>
    <li>Alter user variables(used in Data Model Queries as substitution strings in select statements) by adding an extra field for every bucket.</li>
    <br>
    <li>Add formulas, placeholders, summary items for each new bucket in every group that had formulas, placeholdes, summary items for the existing buckets.</li>
    <br>
    <li>Search all code and add logic for every new bucket identical to the code for the others buckets. i.e.
    <br><br>if b0 = .. then ..
    <br>end if;
    <br>if b1 = .. then ..
    <br>end if;
    <br>...
    <br><b>if b7 = .. then ..
    <br>end if;
    <br>if b7 = .. then ..
    <br>end if;
    </b>
    </li>

  • Ageing Buckets for whole query

    Dear All,
    I have to make a BEx query on meter characteristics. No keyfigures
    The whole information should shown against buckets (current date - disconnection date of meter)
    0-30 days     Customer     Meter No     Meter Type     Zone
    31-60 days   Customer     Meter no.     Meter Type     Zone.
    I tried making selections with disconnection date (0calday value range variable 0dat-30to 0dat-0    and   0dat-60 to 0dat-31). I included a dummy keyfigure (disconnection amount) in selection
    But data isn't coming according to conditions. Any suggestions please.
    Regards,
    Cleo

    Cleo,can you please clarify what exactly you need to show in those bucket range.
    I understand you have disconnection date in your provider and for current date you can use sap standard formula variable i.e  0F_ADAY.
    Now to get the difference between the two,if disconnection date is of type char.then you need to convert the same into kf for getting the difference with the help of replacement path.
    Note:It is mandatory to keep that date in rows which you use as reference char.in formula variable otherwise it will not work.
    Please check the above points.
    Regards,
    AL

  • Aging - 7 Buckets - By Account Report

    Hi All,
    I need sql script to get the same output of Oracle Standard Report 'Aging - 7 Buckets - By Account Report' as i am gone through the data model but the query is written in Dynamically and using Dual table.
    Can anyone tell me how to write the sql script for this Oracle standard report.
    Regards,
    Sushant

    Hi,
    Oracle Standard Report 'Aging - 7 Buckets Report' giving output of Customer Name and Customer Number with Outstanding Amount of aging between 7 bucket(0-30 days, 31-45 days, 46-60 days, 61-90 days, 91-120 days, 121-150 days, 151-99999 days)
    As i an able to get the aging colum by below query.
    select a.*, b.*
    from AR_AGING_BUCKETS a,
    AR_AGING_BUCKET_LINES b
    where a.aging_bucket_id=b.AGING_BUCKET_ID
    and a.AGING_BUCKET_ID=1003
    but how to relate the customer name ,customer no (RA_CUSTOMER table) and outstanding amount with this aging bucket table.
    so i need to develop a report customer wise aging 7 bucket and their outstanding amount.
    Please give me idea how to proceed .
    if you need more information please update the forums.
    Regards,
    Sushant
    Edited by: user605933 on Jun 11, 2009 9:17 AM

  • How to handle partial payment in A/R Aging report buckets

    Hello ALL,
             In FIAR_C03 cube we have Item status field and only two values are comming there
             O or C.
              But in R/3 there are some partial payment concept. BI considering partial payment as a open item.
               Example
           We have a invoice of 10,000 USD
           now one payment of 5,000 came from customer side and we settled 5,000 against above invoice
          now remaining is 5,000.
          means 5,000 of payment and 5,000 of invioce should be closed or cleared . But this is not the case becuase of invoice
          is not fully settled. When invoice will settled fully then it will become cleared.
       using open item we are making our AR aging buckets but now 5,000 payment is still open actually its
      cleared and net due date of this payment is different then net due date of invoice thats why
      these two entries are coming in two different aging buckets so the balances are coming different.
    How can we handle this scenario in SAP BI during making of AR aging.
    Any help highly appreciated.
    Thanks,
    Sneha

    There is an OSS note dealing with this 522235 - its shows how to use a virtual char to do this (ie change the due date at runtime)
    This tends to be viewed more as a business process problem - the users woul dlike the part payment to be aged the same as the invoice it's against (like the std R3 aging reports) - I actually like the BW way as it highlights the fact the cach collectors are not doing their jobs of clearing down the debt - problem is now they will all go and create resicual items

  • Aging - 7 Buckets Report needs to display by Calendar month not by days

    The requirement is to display the Aging - 7 Buckets Report display by calendar month not by days. So is it suggestible to customize it or write a new custom report?
    Please let me know if you have any solution on how to do it? i appreciate your help and time.
    EX:If this is OCT and the report is run during this month
    OCT-10 SEP-10 AGU-10 JUL-10 JUN-10 MAY-10 APR-10
    Customer Amount Current Past Due Past Due Past Due Past Due Past Due Past Due

    Hi
    Could you please let me know if you were able to achieve Aging by bucket months?
    Can we create aging bucket that is monthly and not on the basis of days?
    Regards
    Divya

Maybe you are looking for