How to Include previous Month/Year in Transformation

Hi,
From Source System (DB Table;DB Connect)
Location_ID,EMP_ID,AMOUNT
There is no date field avaliable in the source system.
The Data load to BW will me Monthly frequency...I,e:Data will be loaded once in a Months on 1st of every month.
My requirment is to Include a date field in BW transformations which input previous month/year data for every record
How can i do that and wether do i need to write a start or field routine in transformations
Code please
Thanks

Hi Pal,
You could use the following code to achieve this:
DATA: v_calmonth(6) TYPE c,
      v_month(2) TYPE c,
      v_year(4) TYPE c.
v_month = sy-datum+4(2).
v_year = sy-datum+0(4).
IF v_month = 1.
  v_year = v_year - 1.
ENDIF.
IF v_month = 1.
  v_month = 12.
ELSE.
  v_month = v_month - 1.
ENDIF.
CONCATENATE v_year v_month INTO result.
Hope this helps.
Thanks and Regards
Subray Hegde

Similar Messages

  • Previous month year

    I have 2 tables-> facts and facts1 and i have to create a "sale revenue - last completed month" metric based on the columns of the tables.
    the formula on the metric right now is CASE WHEN ."Last Completed Month Indicator" = 'Y' THEN ("Sale Order Cost" +"Sale Order Cost Promotional Adjustment") / USD SPot Rate" END
    i have another table "month year" which has a columns "previous month year key no" which is in the format 190001 ( january 1900) ,"previous month year description" , "previous month year name".
    I need to use this previous month year column and put it in the metric above and calculate the revenue for last completed month. Can i do it???
    Thanks!

    Hi,
    what is the granularity of fact table and how is it related to month year table?
    Also are the fact tables partitioned? If they are partitioned AGO and TODATE functions cannot be used.
    Is any of the fact tables aggregated???
    -bifacts
    http://www.obinotes.com
    J

  • How to Get Previous Month Salary for a particular employee?

    Hi
    I am developing a report to get the Net Pay Difference from Previous month.
    I am using logical database pnp.
    My question is how can we get the last month (Previous from current selected month) salary of perticular employee. I read the thread which is related to this but I can't understand the reply's. I think it is due to that I am new in ABAP and my experience in only 22 days. If someone reply with code example then it will more helpful for me.
    Also If you can tell me the table name from where we can get the salary of particular month of particular employee then it will also helpful for me.
    Regards
    Iftikhar

    Hi,
    Payroll data is stored in cluster tables.
    You can either use macro for retrieving the data or Function module.
    1. Use FM -CU_READ_RGDIR for getting the RG directory values.Pass  
      employee Number and molga.You will get all the sequence Numbers from this
      FM.
        The last record will be the latest  one.
    2.  Then Use FM - PYXX_READ_PAYROLL_RESULT for getting the payroll  
         results table.Pass cluster ID- 'IN'  ,pernr ,sequence number for which period
          you want (In your case ,current period minus   1) and
          READ_ONLY_INTERNATIONAL            = 'X',
    3. You will get all the results from PAYROLL_RESULT                     = it_result
      Then you can loop this internal table like LOOP at it_result-inter-rt into wa..
    Get the net pay value(/560 wage type)
    Reward points if helpful.
    Regards,
    Manoj.

  • How to get previous month data from current month values

    Hi Experts,
    I have made one universe from BW Query in which Fiscal year period is entered in interval.
    I have made a universe from that and want to develop webI reports on top of that.
    In my webI reports, i have used one cross tab. In Rows section i have added Company Code and in Column section i have used Fiscal Year/Period and in Value section i have added Sales Value. I want this value of previous month.
    Requirement:
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Jan'09         Sales of Feb'0f         and so on....
    I am getting this.
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Feb'09         Sales of Mar'09         and so on....
    I hope i have clear my requirements.
    Please help as soon as possible.
    Thanks in Advance,
    Rishit

    Hi Rishit,
    Follow the below steps to get the desired result.
    Step1: Convert your fiscal year period from char to a date in your database or in your designer however its feasible.
    to_date('substr('009.2009',2)','mm.yyyy')
    you will get the result 01 sep 2009
    Step2: Convert this format to 01/09/2009 by using date functions.
    Step3: Create a Detail associated to the 'date' field (typically your fiscal period).
    Step4: Create a cross tab Like : Rows section should have Company Code and in Column section should have 'date'(created detail) and in Value section should be Sales Value.
    you should get the following result.
    01/02/2009 01/03/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Step5: Use the following formula in your Column (date) formula bar.
    =(<date>-1)-DayNumberOfMonth(<date>-1)+1
    You will get the following result:
    01/01/2009 01/02/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Format the cell according to your reruirement.
    Let me know if you will get any break in the above steps.
    Regards,
    Swati.

  • How to calulate previous fiscal year from current year and periods as input

    hi all,
    i have a report where i have 2 select options as year and period.
    my period can be a range  like( Ex: 1 to 6).
    i like to know previous fiscal year from the following inputs.
    Tel me a suitable conversion routine to calculate
    depending on periods and fiscal year.
    regards
    sivaram.

    Hi
    U need to check the lower period, if it's 1 the previous fyscal year will be the year before:
    IF PERIOD = '1'.
      PREV_YEAR = YEAR - 1.
    ENDIF.
    U can also use the fm FI_PERIOD_DETERMINE, in this case you need a date, u can get it from lower current period:
    Get the first day of the period
    BUDAT(4)   = YEAR.
    BUDAT+4(2) = PERIDO_LOW.
    BUDAT+6(2) = '01'.
    Now get the last day of the previous month:
    BUDAT = BUDAT - 1.
    Use this date to get its period by fm FI_PERIOD_DETERMINE
    Max

  • How to get previous month's values for current month

    Hi..
    I have a requirement on a report, where for a particular month, the key figure value should be from the previous month.
    Eg: KF1 value for Sept 2007 should come from Aug 2007, KF value for Dec 2007 should be the value of Nov 2007, etc.
    There are other key figures on the report which do not need this logic. It is only for one key figure.
    Should we do this on the backend or front-end, and how? Any tips will be appreciated.
    Thanks
    R.

    hi,
    Use a Restricted Keyfigure.
    Drag your KF1 and Drag Calandar Month with a Variable Current Cal Month with variable Offset to -1.
    KEERTTHi

  • How to Calculate column (Month, Year) from date or timestamp

    Hi,
    Name
    SQL Data Type
    Dimension
    Column Store Data Type
    Key
    Not Null
    Default
    Comment
    T_STAMP
    TIMESTAMP
    LONGDATE
    How to generate Month and Year from timestamp field in Analytic View.
    Please provide me some valuable input. I have searched SCN before posting this discussion.

    Hi KD,
    You can apply the following formulas in the expression:
    For Year :
    leftstr(string("Timestamp"),4)
    For Month:
    midstr(string("Timestamp"),6,2)
    Regards,
    Krishna Tangudu

  • How to get days , months , years between two dates with groovy

    I've a table that contains Start Date and End Date and I want to get the difference between then in this format 2 days , 1 moth , 1year
    Can I make this with Groovy
    I've added a transient attribute to a view object and make its value      return (EndDate) - (StartDate); but this returns the difference of days like 200 day
    I want it in this format 2 days , 1 moth , 1year

    AFAIK - You cannot do it in groovy.
    You can achieve the same using the transient variable approach.
    Create a VORowImpl Class for VO, and in the getter method of the transient variable - do the necessary logic and return the string as required in your use-case.
    Thanks,
    Navaneeth

  • Display Month and 12 previous Months

    I am trying to create a report (CRXI) which will display month data for the current month and the 12 previous months.   I am going to use subreports (similar to a calendar report) but am having trouble displaying the 12 previous month, year  headers.  
    I get the current month, year from a prompt date and then need to decrease a month for 12 months.  
    Any help would be appreciated.

    Hi Martha,
    If you want to create a report for last 12 months and don't want to include present month then use the record selection for main report as
    (month({DateField}) < month(currentdate)
    and
    year({DateField})= year(currentdate))
    or
    (month({DateField})>=month(currentdate)
    and
    year({DateField})=year(currentdate)-1)
    and in the subreport use the record selection to get current month date as
    (month({DateField}) =month(currentdate)
    and
    year({DateField})= year(currentdate))
    Regards,
    Raghavendra

  • Getting previous month

    could you please tell me how to get previous month?
    using sysdate gives me current date. from that i can get current month using to_char function. But how can I get the previous month?

    All you ned to remember is that there are two date units, days and months. Everything else is a multiple/fraction of these.
    To increment
    n days:    SYSDATE + n
    n hours:   SYSDATE + n/24
    n minutes: SYSDATE + n/24/60
    n seconds: SYSDATE + n/24/60/60
    n weeks:   SYSDATE + n*7
    n months:  ADD_MONTHS(SYSDATE,n)
    n years:   ADD_MONTHS(SYSDATE,12*n)

  • Last/latest 10 months data ( including current month)

    Hi,  
    I need to find the last/latest 10 months data ( including current month)
    Year
    1/1/2014
    1/2/2014
    1/3/2014
    1/4/2014
    1/5/2014
    1/6/2014
    1/7/2014
    1/8/2014
    1/9/2014
    1/10/2014
    1/11/2014
    1/12/2014
    1/1/2013
    1/2/2013
    1/3/2012
    1/4/2012

    Hi,
    this is my data 
    Year column with Nvarchar datatype. 
    Year
    1/1/2014
    1/2/2014
    1/3/2014
    1/4/2014
    1/5/2014
    1/6/2014
    1/7/2014
    1/8/2014
    1/9/2014
    1/10/2014
    1/11/2014
    1/12/2014
    1/1/2013
    1/2/2013
    1/3/2012
    1/4/2012
    now form this yea) column i need to fetch the latest/last 10 months data only .
    OutpUt for the Query to be:
    Year
    1/3/2014
    1/4/2014
    1/5/2014
    1/6/2014
    1/7/2014
    1/8/2014
    1/9/2014
    1/10/2014
    1/11/2014
    1/12/2014
    Hope this will give you clear picture

  • Input: Month Year and Out Put Display

    Dear SDN,
    Is it possible to view a Query, if we provide only Month & Year..
    Then the following result has to display..
    Entered month year --- Previous month year --- YTD entered month -- YTD Previous month year
    Example : During execution of a query -- suppose if i enter Sep 2007
    Sep2007 -- Sep2006 -- YTD Sep2007 -- YTD Sep2006
    Please suggest me...
    Help will appreciated with points
    This is very urgent...
    Thanks in advance

    Hi,
    Create a VAR Ready for input on 0FISCPER (eg ZFPIN)
    COL 1: RKF with your KF restricted to 0FISCPER = ZFPIN
    COL 2: RKF " 0FISCPER = ZFPINLY
    COL 3: RKF " 0FISCPER = ZFPINYTD
    COL 4: RKF " 0FISCPER = ZFPINLYYTD
    ZFPINLY, ZFPINYTD, ZFPINLYYTD are variables NOT ready for input processed by customer exit (CMOD).
    The code should basically be:
    DATA: l_s_range     TYPE rsr_s_rangesid.
    DATA: loc_var_range LIKE rrrangeexit.
    DATA: fiscal_year LIKE t009b-bdatj.
    CASE i_vnam.
    WHEN 'ZFPINLY'.
    IF I_STEP = 2.
    LOOP AT i_t_var_range INTO loc_var_range
    WHERE vnam = 'ZFPIN'.
       fiscal_year = loc_var_range-low(4).
       fiscal_year = fiscal_year - 1.
       CONCATENATE fiscal_year loc_var_range-low+4(3) INTO l_s_range-low.
       EXIT.
    ENDLOOP.
    l_s_range-sign     = 'I'.
    l_s_range-opt      = 'EQ'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    WHEN 'ZFPINYTD'.
    IF I_STEP = 2.
    LOOP AT i_t_var_range INTO loc_var_range
    WHERE vnam = 'ZFPIN'.
       CONCATENATE loc_var_range-low(4) '001' INTO l_s_range-low.
       l_s_range-high = loc_var_range-low.
       EXIT.
    ENDLOOP.
    l_s_range-sign     = 'I'.
    l_s_range-opt      = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    WHEN 'ZFPINLYTD'.
    IF I_STEP = 2.
    LOOP AT i_t_var_range INTO loc_var_range
    WHERE vnam = 'ZFPIN'.
       fiscal_year = loc_var_range-low(4).
       fiscal_year = fiscal_year - 1.
       CONCATENATE fiscal_year '001' INTO l_s_range-low.
       CONCATENATE fiscal_year loc_var_range-low+4(3) INTO l_s_range-high.
       EXIT.
    ENDLOOP.
    l_s_range-sign     = 'I'.
    l_s_range-opt      = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    ENDCASE.
    hoping this will guide you....
    Olivier.

  • Trying to fetch previous month data

    hi ...
    i have to develope a report in which cutomer on selecting month from the prompt , i have to show transactions for that selected month,transactions for previous month and growth %.
    for fetching previous month data i am using the below formula in column
    FILTER(etxnmistopbr.tot_txns USING (etxnmistopb(TIMESTAMPADD(SQL_TSI_MONTH, -1,etxnmistopbr.month_year)))
    but it doesnt fetch any result.
    i have tried
    FILTER(etxnmistopbr.tot_txns USING (etxnmistopbr.month_year= TIMESTAMPADD(SQL_TSI_MONTH,-1,timestamp '@{current_year}{2012}-@{current_month}{07}-31 00:00:00')))
    where current_year and current_month are presentation variable
    but it throws error as "
    HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46046] Datetime value 2012-8-31 00:00:00 does not match the specified format. (HY000) "
    can anyone please help how to retrieve previous month data and current month data
    Edited by: 8826 on Sep 27, 2012 4:31 AM

    I would recommend using Time Series Functions, specifically the Ago function in the RPD. This is precisely what they have been designed for and is a very powerful feature of OBIEE. This removes the need for complex formulae embedded within result columns (which you will have to replicate each time you create a new analysis).
    The syntax of the Ago function is as simple as:-
    AGO(Measure, Time Dimension Level, Number of Periods Ago) e.g.
    AGO(Core."Fact - Project Cost".Cost, Core."Date - Fiscal Calendar"."Fiscal Period", 1)
    Please mark if helpful/answered.
    Andy.

  • How to create report which includes records of current month and last 7 days of previous month.

    Hi Experts,
    I need to create a report which includes records of current month and last 7 days of previous month.
    I will get records of current month by this formula :- month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)
    Please tell me how to add the records of last 7 days of previous Month for the same report.
    Thanks in Advance.

    Hi Ajay,
    If you have more than a year data in your database then your formula will return wrong results. ie. If your data consist of 2012,2013,2014 data then below formula will return all 8th month data irrespective of year. So, you need to check year also here
    month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)  and
    Year({PROBSUMMARYM1.OPEN_TIME})=Year(currentdate)
    Now add Abhilash second statement in OR so, your formula should look like :
    (month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)  and
    Year({PROBSUMMARYM1.OPEN_TIME})=Year(currentdate))
    OR
    Date({PROBSUMMARYM1.OPEN_TIME}) IN [DateAdd('d',-7,Maximum(LastFullMonth)), Maximum(LastFullMonth)
    -Sastry

  • How to get the previous month and year accordingly

    Hi friends,
    I wanted to select month as number like 4 and year as 2011
    but I want to select the previous month as of sysdate
    like if the sysdate is 10-jun-2011
    it should give me 5 as month and
    in the year it should give as 2011
    if the sysdate is 01-jan-2012
    the month should be as 12 and year should be as 2011
    thanks

    Hi,
    776317 wrote:
    thanks a lot I just dont need the 0 being prefixed... can you pls tell how to avoid that as well pls
    TO_CHAR ( ADD_MONTHS (SYSDATE, -1)
            , 'FMmm yyyy'
           )For details about how the FM modifier works, wee the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements004.htm#sthref456

Maybe you are looking for