User exit to calculate Same period Last Year

Dear gurus,
can some help me to code the user exit to calculate the same period last year for bex variable
i.e
System date :18.05.2010
Same period last tear : 18.05.2009
Your help  highly appreciated
Thank you
BR

Hi,
The above code creates problem only when date is 29th of Feb.
To find whether year -1 is leap yr or not include following code also:
l_year = sy-datum(4)-1 .
l_mod4 = l_year mod 4.
l_mod100 = l_year mod 100.
l_mod400 = l_year mod 400.
if ( l_mod4 = 0 and l_mod100 ne 0 ) or l_mod400 eq 0.
if( l_date = 29)
l_date= l_date -1.
endif.
endif.
Modify your code according to youe need. Hope this helps you.
Thanks,
Jitender.

Similar Messages

  • SSAS DAX formula for same period last year not same month last year

    The DAX function sameperiodlastyear, only works if the period we are interested in, is the same as a month.
    However our Period 3 for 2014 was 05-march to 04-April and Period 3 in 2013 was 01-March to 31-March
    I have a dim_Date table with a separate Year Number and Period Number so you be able to match on Period Number and Year - 1
    The sort of formula I am after is this, so that the P3 total for 2013 matches the value reported as 'PY' against P3 2014
    so for example
    PY:=calculate(sum(amount), dim_date(year) = dim_date(year-1) && dim_date(period) = dim_date(period)
    I cannot find an exact example of how to construct the DAX formula to achieve this.
    I have tried DAXPatterns.com, but that does not have an exact example.
    Thanks in advance
    Sotn

    All built-in time intelligence functions work on the standard Gregorian calendar. The only fiscal calendars that can be handled by the built-in functions are those that end on another day than December 31, but otherwise respect the standard months/quarters.
    The problem you are encountering in your [PY] is that CALCULATE() only allows simple boolean predicates (no calculations allowed. FILTER() is the function that allows you to execute arbitrary logic in your CALCULATE() filter arguments.
    Try this:
    PY:=
    CALCULATE(
    SUM( <fact table>[amount] )
    , FILTER(
    ALL( dim_date )
    , dim_date[year] = MAX( dim_date[year] ) - 1
    && dim_date[period] = MAX( dim_date[period] )
    Here's what's going on in that FILTER(). FILTER() is an iterator - it steps row-by-row through the table that you pass as the first argument, and returns only those rows that meet the criterion you set in the second argument.
    We pass ALL( dim_date ). This strips the current filter context from the pivot table and returns every row of dim_date.
    In the second argument to FILTER() we define the logic that will determine which rows to return. This comes in two parts, connected with the logical and operator, &&. I will only explain one in detail as we're using the same pattern in each part.
    dim_date[year] is referring to the value of the column [year] based on where you are in the table (remember, FILTER() is stepping row-by-row through), so will return one value from the current row based on FILTER()'s iteration.
    It then compares that value to what is returned by MAX( dim_date[year] ) - 1. This expression is not evaluated in the current row context of FILTER(), rather in the filter context of the pivot table (in a pivot table your row and column labels are referred
    to as rowfilters and columnfilters - this nomenclature can get confusing). Thus, it returns whatever the current year of the pivot table is and subtracts one. When the value of [year] in dim_date matches the value returned by this expression, that row is part
    of the set returned by FILTER().
    Once FILTER() has completed its iteration, it returns the filtered table, and that table is used to set the filter context that SUM( <fact table>[amount] ) is evaluated in.

  • How to get the same period last year value using Fiscal Calendar?

    Hi there,
    I am using DAX in a Tabular Model project but I am getting stuck trying to get the following:
    We are using a Fiscal Calendar (from 01 April to 31 March). 
    Previous Period Value
           Value
    2012
    April
    15
    May
    10
    Jun
    20
    2013
    April
    15
    30
    May
    10
    20
    Jun
    20
    25
    I have tried to use sameperiodlastyear but there is an error saying that this function cannot be used for non contiguous dates. DATEADD is given the same error...
    Could anyone help me getting the right measure expressions for [Previous Period Value]?
    Thanks and best regards,
    Joss

    Hi Joss,
    In SQL Server Analysis Services, we can can compare revenue with the hierarchy periods (year, month, day) by using the PARALLELPERIOD function, and now you want to compare with custom periods. (NOTE: We cannot compare it with the PARALLELPERIOD function
    since
    PARALLELPERIOD function returns a member from a prior period in the same relative position as a specified member. So if the first time span not equal to the second one (such as the first period is 3 days, and the second period is 2 month)).  Here
    is a sample query about PARALLELPERIOD function for your reference.
    with
    set Hotels as
    [Hotels].[Hotel ID].&[1015],
    [Hotels].[Hotel ID].&[5640],
    [Hotels].[Hotel ID].&[8800]
    set Period as [Arrival Date].[Date].[Month].&[2012]&[1]:[Arrival Date].[Date].[Month].&[2012]&[12]
    member [Arrival Date].[Date].[0] as sum({ Period })
    member [Total Amount N-1] as (PARALLELPERIOD([Arrival Date].[Date].[Year], 1, [Arrival Date].[Date].[Year].&[2012]), [Measures].[Total Amount])
    select
    [Measures].[Total Amount],
    [Measures].[Total Amount N-1]
    } on 0,
    nonemptycrossjoin
    Hotels,
    Hotels.[Hotel].children,
    *{[Arrival Date].[Date].[0]}
    } on 1
    from [Booking_Cube]
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to load member for "sales same date last year"?

    I need to load a member in Measures named "PriorYrSales" with "Sales" for the same date last year as today's date. Thus, retrieving "PriorYrSales" for 2/10/2002 would return the sales amount for 2/10/2001. Since days roll-up to months, quarters, years, it would be easy to determine how we're doing compared to the same time last year.Data is loaded each day for a date range from the current date and the preceding x days. Substitution variables are available for the beginning and ending date and the same dates for last year.For example: Data is loaded from beginning date of 2/01/2002 through ending date of 2/10/2002.The prior year date variables contain 2/01/2001 and 2/10/2001.The time period dimension is as follows:FY01->Jan2001-->01012001 (Alias: 1/01/2001)-->01022001 (Alias: 1/02/2001)-->all the dates in Jan->Feb2001-->02012001 (Alias: 2/01/2001)-->02022001 (Alias: 2/02/2001)-->all the dates in Febetc.FY02->Jan2002-->01012002 (Alias: 1/01/2002)-->01022002 (Alias: 1/02/2002)-->all the dates in Jan->Feb2002-->02012002 (Alias: 2/01/2002) -->02022002 (Alias: 2/01/2002)-->all the dates in Febetc.Thanks your any and all suggestions.Phil

    Perhaps I wasn't clear in the first post. The intent is to easily compare sales for a current date/period to the same date/period last year. Neither Excel nor Analyzer provide a method that I'm aware of to retrieve data as follows:-------------------------------------Period Sales PriorYrSales Diff4/15/2002 1,000 900 100-------------------------------------(900 is sales for 4/15/2001)(100 is the calculated difference.)Nor can I do this:-------------------------------------Period Sales Period Sales Diff4/15/2002 1,000 4/15/2001 900 100-------------------------------------What Excel and Analyzer do allow is:-------------------------------------Period Sales 4/15/2002 1,0004/15/2001 900-------------------------------------I readily acknowledge that the data is redundant but I can't think of another option that will allow Excel and Analyzer to easily retrieve the values for comparison. If the PriorYrSales member can be loaded then the users can compare years, quarters, months and days quite easily.My challenge is knowing how use a calc script to derive prior year dates that correspond to current year dates. Something like:PriorYrSales->04152002 = Sales->04152001I've considered arrays but I've never used them and the documentation is not helpful enough for me.Thanks for your response.Phil

  • Problem with bex query listing sales "this month" and "same month last year

    Hi,
    I've created a query in BW BEx, where I have a mandatory variable for 0calmonth, and I list 0material and sales (in volume, liter). And I have a restricted key figure giving me sales (volume in liter) restricted with 0calmonth = variable - 12, to give me the sale for the same month the user select, previous year.
    This seems to be working, the sum is correct, but when adding up the number for the sales in the month previous year, the numbers does not fit the sum in the end.
    I think the report only lists materials with sales the month selected in the variable, if a material has not been sold that month, but in the same month last year, it's not listed in the reports, but it's added in the sum in the end.
    Example.
    We have three records like this:
    material - calmonth - volume
    101 - 01.2010 - 5
    101 - 01.2011 - 8
    201 - 01.2010 - 7
    The report will give the following (calmonth variable = 01.2011)
    Material - volume this month - volume same month last year
    101 - 8 - 5
    Sum 8 - 12
    Any way to solve this issue? We noticed because we run BO - Webi on top of the BEx query, and BO sum's the values per material, and in webi the report would give us the sum 8 and 5.
    Any input is appreciated.
    Regards,
    Øystein

    Hi,
    thanks for your reply.
    The error is that the report only seems to list materials that has been sold "this month", and if the same material was sold the same month last year, it will also list the volume for this.
    But if the material is only sold in the same month last year, it's not listed in the report, but it's calculated into the sum at the end.
    The report is listing material, which is why the error presents itself, as you said
    Getting 8 minus 12 is correct unless you drill down by material. In that case, it should be 8 minus 5 and 0 minus 7.
    The row with 0 - 7 is not shown, and my guess is that the report will only list materials that has sales this month (which has been selected in the variable)
    Regards,
    Øystein
    Edited by: Oystein Gundersen on Mar 21, 2011 4:36 PM

  • Balances not  same as last year.

    Hi , Presently we are faceing a problem in Balances BF. Actually from the last year to  new year balances are not showing corectly. Ex. there is 100,000 balance last year for the new year it should b opening balance but opening ablace is showing as 99500.But very strangely when we double clik this figure the total of line items = 100,000, it is not displaying waht is inside.
    Please it is important to our closeing

    Hope you are in ECC 6.00 System does not show the correct balances when you carry forward during test run.  But finally when you remove test run and carry forward balances to next year there will not be any difference in the balances.  We also faced the same problem.  But the same got solved when you carry forward the balances to next year.  Do not worry about the balances after double clicking the same.

  • User exit for four quaters of a year

    Hi All,
    I need to write an user exit to fetch the Quater1(3 months) to Quater4 from a Calyear.
    If the user enters 2008 then i want to get the sales for the 4 quaters for  an year in separate columns. I think of creating 4 restrcited KFs with the sales KF and restrict it with the four user exit variables which we fetch three months for each quaters.
    Please help me to write an user exit.
    Thanks,
    Pallavi

    Hi,
    Do you have Fiscal year in cube. If you have year then you can go with the below code.
    In that case create a variable for calmonth with select option and type as user exit. Then use the below code.
    LOOP AT lt_var_range INTO ls_var_range WHERE vnam = 'YEARVARIABLE'.
    Concatenate ls_var_range-low '01' INTO ls_range-low.
    Concatenate ls_var_range-low '03' INTO ls_range-high.
    ls_range-sign = 'I'.
    ls_range-opt = 'BT'.
    APPEND ls_range TO et_range.
    CLEAR ls_range.
    ENDLOOP.
    If you have only calmonth in cube get the input any one of the calmonth and using below code.
    LOOP AT lt_var_range INTO ls_var_range WHERE vnam = 'CALMONTHUSER ENTRY VARIABLE'.
    Concatenate ls_var_range-low+0(4) '01' INTO ls_range-low.
    Concatenate ls_var_range-low+0(4) '03' INTO ls_range-high.
    ls_range-sign = 'I'.
    ls_range-opt = 'BT'.
    APPEND ls_range TO et_range.
    CLEAR ls_range.
    ENDLOOP.
    Use this to restrict the calmonth in first key figure. In 2nd,3rd and 4th key figures use offset for low and high value and you can get the output as you expected.
    Hope this helps
    Regards
    Akhan
    Edited by: Akhan_BI on Sep 5, 2009 12:30 AM

  • User exit to Change Accrual period in revenue  recognition

    Hi All ,
    I have requirement to change the accrual period while revenue posting from VF44 in collective processing from 365 days to static 12 months .
    Need help finding the rigth user exit and approach .
    Thanks in advance
    vinay

    Hi Amuktha ,
    Look s like I have to implement a Bussiness transaction event OUTBOUND_CALL_00503103_E
    the program LVFRR069 , I found below lines
        If accrual period start date and/or end date has been changed
        through userexit 'OUTBOUND_CALL_00503102_E' forecarst lines are
        created in single step mode
          if pif_accpd_start ne lvf_fplt_start or
             pif_accpd_end   ne lvf_fplt_end.
    Need help in implemeting this .
    thanks
    Vinay

  • IOS 7 Wifi greyed out..... same as last year

    This time last year my phone 'died' when IOS 6 was installed, the phone was less than a year old and was replaced for a new phone at the apple store brighton, i understand I wasnt the only person who lost Wifi altogether.
    Low and behold......... IOS7 has done the same to my 4s............ gutted is an understatement, anyone know whats going on? Once was unlucky, twice im pretty fuming, just had a really unsatisfying call with apple who kindly advised me first off I was out of warranty and that the new handset provided in the apple store only had 90 days warranty on it? am confused.
    So tried all the usual stuff, shouting at it, incantations outside and am now resounded to a trip to brighton to the apple store on saturday.....
    my questions are..... anyone else suffered the same? any chance apple with replace my phone? if not what costs am i looking at...............
    am really hacked off here and yes have tried all the resets, reboots, rebuilds etc etc....
    Apple.....im dissapointed......... as a matter of point all our other IOS products upgraded fine with no issue.
    Any help, moral support or random acts of kindness appreciated.......
    Kinda wished Id stayed with android!
    Our contract with T Mob is up for renewak in feb so an early release is not an option.

    S,
    All of the Settings text is Grey...
    but seriously,
    What is Greyed-out? the WiFI Icon? The WiFi icon should be a strong blue  Does it say "Off" to the right?
    As Traxx suggested, Try a hard reset. Usually if a hardware option is unacessible it means that there is a hardware failure.
    -Alan

  • User exit today's date vs. last week

    hi all,
    Can anyone send me the ABAP code to get the previous week data from today's date (user entry).  I created a variable in qry but i need to write the user exit code.
    I'll assign points.
    thanks

    hi SKB,
    just sent 'how to derive var doc' to [email protected],
    try
      DATA: L_S_RANGE TYPE RSR_S_RANGESID.
      DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
      CASE I_VNAM.
      WHEN 'yourvar'.
        IF I_STEP=2.    "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                  WHERE VNAM = 'variablename where user entry'.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW      = LOC_VAR_RANGE-LOW - 7.
            L_S_RANGE-SIGN     = 'I'.
            L_S_RANGE-OPT      = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
      ENDCASE.
    hope this helps.

  • VA02 User exit - authorization (AND same requirement for IW32)

    I require user exits in VA02 and IW32 that allows me to stop some users profile from changing Sales Orders and Service Orders.
    Our idea is to create an Autorization object and asign it to a user profile.
    When users try to Modify a Sales order or a Service Order, system should verify authorization object first. If not then user cannot access to the document.
    User exits should be available when document is going to be open, not after opening (meaning that user exits where saving do not work either).
    Thanks for your help

    If you require some user to use VA02 or IW32 then at the t-code level you can set the authorization.
    But when you say "User exits should be available when document is going to be open, not after opening", it is confusing.
    Userexit works only after the document is "opened"
    You can try fieldexit.
    This weblog (/people/ashish.mohapatra/blog/2007/11/28/sd-userexit--i) may also be helpful to you.

  • How to calculate YTD and Last year YTD on Date in Bex

    Hi,
    I have a requirement in which I need to show the report as following format.
    I need to show    Year>monthday as Hierarchy. user will drill down on Month to Date.
                 Del Qty              Ord Qty              Del  Qty LY              Del Qty YTD                  Del Qty  L YTD
    Year
    > Drill Down to Months
            Jan
            Feb
            Mar
              ---> 1.03.2010
              ---> 2.03.2010
              ---> 3.03.2010
            Dec
    I have Calday, Calmonth, Calyear all three objects.
    Now my question is how I can achive this? On which i need to create hierarchy?
    and how to calculate the YTD at day level.
    Note:- in the selection calyear is mandatory. User wants to display as per year.   So What infoobject I need to take in selection?
    and the way to calculate YTD on Day (in the case also ,where user doesn't give the date in selection)
    Plz reply asap its uregent !!!
    Thanks in advance,
    Amit

    Hi,
    As per my understanding I think YTD means JAN to current date result. I means say if user enter 062005 then result in YTD should be from 012005 to 062005.
    And to do this you need to write a customer exit variable where LOW field of internal table you will put JAN year and HIGH will contain month year entered by user.
    Hope this will help you.
    Suneel

  • New Nano hardware same as last year's?

    I know this might have been answered before, but just wanted to confirm: The new Nano is just software, not hardware, correct? (and price drop).
    Sorry...
    Thanks.

    Different suppliers of flash memory and a slightly faster processors.  Source is Ifixit dot com. Features between the 6th and 7th gen (current) are the same.

  • Sales Summary - Compare same weekday sales last year.

    Post Author: geoffh
    CA Forum: Formula
    I have a table storing invoices going back several years. I wish to calculate the total sales for yesterdays date, & compare it with total sales for the same weekday in the previous year. For example if it is Tuesday today, I need to calculate Mondays total sales (yesterday) & also Mondays total sales for the same week period last year.
    Date fields I have available are 'history.date_invoiced' (invoice date) , history.week_invoiced , history_year.invoiced. Sales values are history.sell_account & history.sell_cash.
    I'm new to crystal.......Using V 11.0.0.1282 . Any help would be greatly appreciated.

    Post Author: yangster
    CA Forum: Formula
    create a formula with the following informationnumbervar weeknumber_curr_year := datepart("ww", dateadd("d", -1, ));numbervar weekdaynumber_curr_year := datepart("d", , 1);  //assuming sunday is the start date of the week, change to 2 if monday isthose 2 variables will tell you the current week number and what day of the week you are after for the current yearnumbervar last_year := dateadd("yyyy", -1, currentdate);if year() = last_year and datepart("ww", ) = weeknumber_curr_year anddatepart("d", , 1) = weekdaynumber_curr_year then amt_field else 0put that in the details section and create a summary of the formula and you should have the total sum of sales for exactly the same week and day of week one year prior to yesterdaymaybe kai has a more simplified solution but that's what comes off the top of my head

  • Rolling Period User-Exit

    Hi All,
        I have a requirement where I have to populate 11 prior months based on user entered Period and Year. I've created declared 24 customer exit variables ( 12 for month and 12 for year ), upon debugging the user-exit I found that the user-exit populates the values in the variables correctly. But when data is displayed I only get values in my first column ( 1 of 12 ) and all others remain blank. Here is the code snippet for your review. Kindly advice.:
    The following code is only for the periods.
    DATA:P1(3),  " type /BI0/SFISCPER3-FISCPER3
    P(3) TYPE N.
    when 'ZCPOST1' or 'ZCPOST2' or 'ZCPOST3' or
           'ZCPOST4' or 'ZCPOST5' or 'ZCPOST6' or
           'ZCPOST7' or 'ZCPOST8' or 'ZCPOST9' or
           'ZCPOST10' or 'ZCPOST11' or 'ZCPOST12'.
        temp = i_vnam.
        IF I_STEP = 2.
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                   WHERE VNAM = 'ZCPOST'.
            p1 = LOC_VAR_RANGE-low.
          endloop.
          case temp.
            when 'ZCPOST1'.
              p1 = p1.
            when 'ZCPOST2'.
              p1 = p1 - 1.
            when 'ZCPOST3'.
              p1 = p1 - 2.
            when 'ZCPOST4'.
              p1 = p1 - 3.
            when 'ZCPOST5'.
              p1 = p1 - 4.
            when 'ZCPOST6'.
              p1 = p1 - 5.
            when 'ZCPOST7'.
              p1 = p1 - 6.
            when 'ZCPOST8'.
              p1 = p1 - 7.
            when 'ZCPOST9'.
              p1 = p1 - 8.
            when 'ZCPOST10'.
              p1 = p1 - 9.
            when 'ZCPOST11'.
              p1 = p1 - 10.
            when 'ZCPOST12'.
              p1 = p1 - 11.
          endcase.
          IF p1 <= 0.
             y = y - 1.
            IF p1 = 0.
              p1 = 12.
            ELSE.
              p1 = 12 - ABS( p1 ).
            ENDIF.
          ENDIF.
          MOVE P1 TO P.
          l_s_range-low = p.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
        endif.
    Regards,
    Srini D

    Thanks for your advice. But here is my problem: I have two selection screen exit variables one for year and one for Period. If the user enters
    005 and 2006, I should be able to calculate the following:
    5,4,3,2,1,12,11,10,9,8,7,6 for periods and the year should roll from 2006 to 2005. That's why I had the user-exit, It calculates fine for the first column but all other columns remain blank.
    Also, I tried your solution:
    When I use fiscalyear/period variable, and use use offsets ( 0, -1, -2 and so on ), only the first column is getting populated and the others are coming out as blank.
    Kindly advice.
    Regards,
    Srini D

Maybe you are looking for

  • REP-0004: Warning: Unable to open user preference file.

    Hi, I am creating an invoice header in Payable through open interface in r12. I have inserted one line in  ap_invoices_interface table. When I run Payables Open Interface Import request, it completes normal but invoice does not create. Please see bel

  • Slackware 12.2 USB w/ hdd install on a t400

    I am having so much trouble with this... I'm working with a t400, and using the hdd in the ultrabay not wanting to touch the main hdd. The idea is to Install slackware to the Ultrabay drive, which should be simple... However I can't boot from DVD, so

  • Workflow - AVCHD to DVD but without optimised footage?

    I am an enthusiast and I have a few Panasonic prosumer camcorders with which I shoot basic AVCHD and ultimately I burn DVDs - which people tell me look just fine. When importing I have "Leave files in place" checked and I create Proxy files ONLY as o

  • Dataguard:How to check the timestamp of archivelog generation?

    Hi , I want to test my DR database. Is there any dictionary view provided the three below information. 1.When archivelog created in primary? 2.When archivelog created in standby server?(Network latency) 3.When logs applied in DR database? Thanks & Re

  • Fetchmail, Postfix user unknown in local recipient table

    Hello all -- My fetchmail job has been failing to get mail to my mailbox with this error: SMTP error: 450 4.1.1 <username@localhost>: Recipient address rejected: User unknown in local recipient table (I replace my actual user name with "username") Th