Transformation routine to get last month value

Hi experts,
I am trying to write a routine in a transformation to get last months value from another dso.
Here is my code:
Data:
zamnt type F,
zmonth type c length 6.
zmonth = sy-datum+0(6).
select sum( /BIC/ZAMNT ) into i_amnt
from /BIC/AZDSP00700
where CALMONTH = zmonth -1.
     RESULT = zamnt.
I get an incorrect expression "where CALMONTH = zmonth -1." because it does not understand "-1"
Can anyone help me?

Hi Odd Hilt,
Please confirm CALMONTH format is yyyymm or something different.
If CALMONTH format is yyyymm.
try following code
zmonth = sy-datum+0(6).
ZMONTH1 = ZMONTH - 1.
select sum( /BIC/ZAMNT ) into i_amnt
from /BIC/AZDSP00700
where CALMONTH = zmonth1.
RESULT = zamnt.
Thanks,
Chandra

Similar Messages

  • How should get last month value from report?

    Hi experts,
    How should last month value. For example
    jan    feb    march
    100   --       ---
    Here i want to get jan month value in march coloumn.

    Hi ,
    It is only show last month value. but my requirement is if last month is empty it should bring Before Last month.
    For Example
      Jan       Feb       Mar
    1000   
    i need if the Feb value is empty should come jan month value.

  • Urgent: Formular question: get first/last month value with qty value

    We've got a query result as the following:
    Jan_2007 -- Feb_2007 -- Mar_2007 -- Apr_2007
    0 --- 54 --- 0 --- 3
    23 ---0 --- 12 --- 7
    In the above query result,
    1st row shows the sales quantity in Jan_2007 is 0, in Feb_2007 is 54, in Mar_2007 is 0, and in Apr_2007 is 3.
    2nd row shows the sales quantity in Jan_2007 is 23, in Feb_2007 is 0, in Mar_2007 is 12, and in Apr_2007 is 7.
    We would like to add a new column to get the first/last month value with quantity, e.g., in 1st row, the 1st month value with quantity value (>0) is Feb_2007, and the last month value with quantity value (>0) is Apr_2007. Therefore the 1st month value with qty is Feb_2007 and the last month value with qty is Apr_2007. In 2nd row, the first month value with qty is Jan_2007 and the last month value with qty is Apr_2007. But how to use formular to get the 1st/last month values with qty?
    We will give you reward points!

    Hello Kevin,  
    You can create forumula using [Boolean Operator|http://help.sap.com/saphelp_nw04/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm]
    IF<Logic Expression> THEN <Expression1> ELSE <Expression2> can also be made using a formula in the form
    You can also use the [AND, OR Logical operators |http://help.sap.com/saphelp_nw04/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm]to check all the keyfigure columns.
    Thanks
    Chandran

  • Need formula in my subreport to get last month date - CR XIr2

    Post Author: olesco
    CA Forum: Formula
    I need to pass the value (#of units) from the subreport to the main report u2013 I know how to do that but my problem is I donu2019t know what formula should I put in my subreport  to get last month date.
    Both main report and subreport have a date parameter (Field link - {?DatePrompt}. What I need is when I fill in the current month date to the main report the subreport should process the last moth date.
    Main report u2013 Date Range (2007-10-1) (2007-10-31) - result  #of units = 22
    u201CRecord Selection Formula Editor
          DateRecd = {@DatePrompt} &#91;i.e. current month&#93;
    Subreport u2013 should have data from last month - result  #of units = 25
    u201CRecord Selection Formula Editor
          DateRecd < {@DatePrompt} &#91;last month&#93;   ??????
    There are   22 3 units this month and   25  units last month.
    Any help is greatly appreciated.

    Post Author: SKodidine
    CA Forum: Formula
    DateRecd in dateadd('m',-1,minimum({@DatePrompt})) to dateadd('m',-1,maximum({@DatePrompt}))

  • How to get last month with af:convertDateTime?

    Hi All:
    I know use af:convertDateTime can get the month value from the inputText which stored the datatime value. But if use this can get the datetime value's last month?
    Thanks.
    regards.
    Alex

    Hi,
    not sure what the usecase is about. Can you provide more information?
    "Converts string into java.util.Date and vice versa based on the pattern and style set."
    http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/core/convertDateTime.html
    Its a converting between data types and doesn't change the value. However, I am wondering if what you want to accomplish can be done in Java using a ValueChangeListener
    Frank

  • Last Month value for the keyfigure in Report

    HI ALL,
    how do we get keyfigure value for the last month in the report.
    for ex:  for  amount keyfigure should come for the last month  rest of the key figures should come for the current month values.
    SBU |    AMOUNT (LAST MONTH VALUE) |      QTY(CURRENT MONTH) |     NETPROFIT(CURRENT MONTH)
    The above shown is ex as i required in same manner. Even i restricted with calmonth offset value -1 in keyfigure but it is not working. please help me to get solution .
    Thanks
    Pinky Reddy

    Hi Pinky,
    It is not advisable to use offset to get the previous month value.This is not effective in the case when your current month is Jan & u have to get the previous year's dec month value.It is always better to opt for Exits
    Do use the code mentioned below.
    Note:- ZCUSMFIS3 - Variable in the selection screen for entering current month
               'ZPREVPER - Variable with which the amount key figure has to be resticted.
      WHEN 'ZPREVPER'.
        IF I_STEP = 2. "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                                  WHERE VNAM = 'ZCUSMFIS3'.              
            V_PERIOD = LOC_VAR_RANGE-LOW+4(3).
            V_FYEAR = LOC_VAR_RANGE-LOW+0(4).
            V_FVARIANT = 'B1'.
            V_FISCPERYEAR = LOC_VAR_RANGE-LOW.
            IF V_PERIOD = '001'.
              V_PERIOD = '012'.
              V_FYEAR = V_FYEAR - 1.
              CONCATENATE V_FYEAR V_PERIOD INTO V_FISCPERYEAR.
            ELSE.
              V_FISCPERYEAR = V_FISCPERYEAR - 1.
              LOC_VAR_RANGE-LOW = V_FISCPERYEAR.
            ENDIF.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW = LOC_VAR_RANGE-LOW. "YYYYMMDD - DD will indicate the no of days
            L_S_RANGE-SIGN = 'I'.
            L_S_RANGE-OPT = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
    Hope this provides the solution for your requirement.
    Regards,
    Saswati.

  • Getting Last Month End date

    Dear Experts,
    I want the following result. I have a date parameter. I want to
    get the last / end date of the previous month
    for any given date which the user inputs.
    For ex:
    If user puts the date 15.06.2008
    then i want to get the previous month end date i.e. 31.05.2008.
    The reason being i am creating a program for updating Opening and Closing Stocks of every month in a ZTABLE. The user will put the date in the parameter and system will bring the closing stock of previous month and then calculate for the current month.
    I hope i am not complicating matters too much....
    Basic funda is to arrive at the end date of the previous month for any date which the user puts.
    Please help me... it is mission critical..
    Thanks & Regards,
    Jitesh M Nair

    hi,
    use this to get last month end date.
    ex:
    data: d2 like sy-datum.
    d2 = sy-datum.
    d2+6(2) = '01'.
    d2 = d2 - 1. "prev mnth last date
    write:/ d2.

  • Getting the Month value and Name from the Ranges of the Date given input.

    Hi Techies,
    I am developing Monthly wise report in FICO. My Inputs are Company Code, Fiscal Year and Date Range. From the Date Range I have to get the month and Generate the Report.
    For Ex:
    BUKRS : 1000
    GJAHR : 2009
    FKDAT : 01.04.2008 to 01.04.2009
    From the Above Date range how can I get the individual month names or periods. As per my Knowledge I can get the month value when the date is parameter but here the date is ranges.  Is any code available for this ?
    Thanks in Advance
    Regards,
    Muralikrishna Peravali.
    Edited by: muralipsharma on Aug 31, 2010 10:30 AM
    Edited by: muralipsharma on Aug 31, 2010 12:57 PM

    DATA: lv_dat          TYPE dats,
          lv_day          TYPE c LENGTH 2,
          lv_month        TYPE c LENGTH 2,
          lv_year         TYPE c LENGTH 4.
    DATA: lv_poper        TYPE t009b-poper.
    DATA: lt_poper        TYPE TABLE OF t009b-poper.
    SELECT-OPTIONS: so_dat        FOR sy-datum.
    break fis-kemmer.
    lv_dat = so_dat-low.
    DO.
      CLEAR: lv_poper.
      CALL FUNCTION 'FI_PERIOD_DETERMINE'
        EXPORTING
          i_budat        = lv_dat
        IMPORTING
          e_poper        = lv_poper
        EXCEPTIONS
          fiscal_year    = 1
          period         = 2
          period_version = 3
          posting_period = 4
          special_period = 5
          version        = 6
          posting_date   = 7
          OTHERS         = 8.
      APPEND lv_poper TO lt_poper.
      lv_day    = lv_dat+6(2).
      lv_month  = lv_dat+4(2).
      lv_year   = lv_dat(4).
      lv_month = lv_month + 1.
      IF lv_month LE 9.
        CONCATENATE '0' lv_month INTO lv_month.
      ENDIF.
      CONCATENATE lv_year lv_month lv_day INTO lv_dat.
      IF lv_dat GT so_dat-high.
        EXIT.
      ENDIF.
    ENDDO.
    after that you have a list of all the FI periods in internal table LT_POPER.
    get the idea?

  • Want last month value of a Quarter instead of to-date value

    Hi All
    I have a report that has 2 columns : Quarter-year , Measure1. Quarter-Year can be drilled down to the month level. Now, what is happening is because I only have the Quarter-Year as the dimension column, I'm getting the cumulative (todate) value for the measure. Say I have Q1-2010 drills down to Jan - 10,000 .. Feb-20,000.. Mar-30,000... I want the report
    to show the value as of March (the last month of the quarter): Q1-2010     30,000.
    Instead I see the value as (10k+20k+30k = 60,000). Is there a way of achieving 30,000 value for Q1-2010 in Answers?
    Thanks
    Ananth
    Edited by: Ananth V on Feb 4, 2010 8:54 AM

    Excuse the re-edit, the instructions below will give you a level based measures. if you used function QUARTER_OF_YEAR(expr) you should be able to use a case statement below to only pull Quarters 3, 6, 9 and 12 (ie last quarters) in your measure definition, then use the level based mechanism if required.
    Create another measure (duplicate your existing) and set the level of this measure to 'Quarter' by editing content tab on that measure or dragging it up to the Quarter level in your date hierarchy.
    This will return the Quarter total , regardless of group by- you may need to set other levels in accordance with other dimensions used on the report.
    Hope this helps,
    Rgrds
    Alastair
    Edited by: Alastair_PeakIndicators on Apr 26, 2010 4:12 PM
    Edited by: Alastair_PeakIndicators on Apr 26, 2010 4:13 PM

  • How to get the month value in a date?

    I am retrieving a Date from the database using the getDate() method! However, I want the value of the month in this obtained result, which i want to compare with an integer!
    I dont see any other option but to use the deprecated getMonth() method on this Date object! Or rather get the date as a String & apply the substring methods to get the reqd value!
    Is there any other go on this?

    Hi
    You can use GregorianCalendar.
    Date d = new Date();
    Calendar c = new GregorianCalendar();
    c.setTime(d);
    System.out.println(c.get(Calendar.MONTH)+1);
    -nmw-

  • Update Rule routine to get last 4 characters of a field

    I am aware I can do this using a formula.  However, can someone assist in writing the routine which gets the last four characters of a field.  The field is part of the COMM_STRUCTURE? Thanks

    Hi,
    For determining the length of the field, you have to use first the statement DESCRIBE so you get the figure into a variable (I do not have a SAP system right now, so errors can occur in the following):
    <b>data length type i.
    describe comm_structure-field length into length.
    length = length - 4.
    result = comm_structure-field+(length)(4).</b>
    However, please shift your field is RIGHT JUSTIFIED earlier than using these statements. Please consider the instruction SHIFT. That will insure you that you get the right characters.
    Regards

  • Routine to capture last month data

    Hello Frnds,
    For a Dataload from the datasource Actual Cost Component Split(0CO_PC_ACT_10), we want to capture last month data ,
    we are planning to write a routine in infopackage level,
    using the option 6-ABAP routine, to select the last month data ,
    we have the time characteristics 0FISCPER, At present we managing the load by manually changing the selection for last month every time ,
    It would be a great help if anybody can show a sample code to select last month data,
    Thanks,
    saty

    If 'last month data' for you is equivalent to 'actual month data', post this code (corrected) into your IPACK dynamic selection:
    DATA: zyear type /BI0/OIFISCYEAR,
    ______zperiod type /BI0/OIFISCPER3,
    ______zfiscper type /BI0/OIFISCPER.
    CLEAR: zyear,
    _______Zperiod,
    _______zfiscper.
    MOVE sy-datum+0(4) to zyear.
    MOVE sy-datum+4(2) to zperiod.
    concatenate  zyear zperiod into zfiscper.
    l_t_range-iobjnm = '0FISCPER'.
        l_t_range-fieldname = '/BI0/FISCPER'.
        l_t_range-sign = 'I'.
        l_t_range-option = 'EQ'.
        l_t_range-low  = zfiscper.
        l_t_range-high = zfiscper.
        APPEND l_t_range.
    Message was edited by: Claudio Caforio

  • Refreshing the page to get last saved value in the select box

    Hi,
    I have a combo box in a form and i have loaded the country name from the DB using bean. Now i have a button near the combo box and if i don't have any particular country in the combo box. I will click that button and the country form will open. Now i will save the country name which is not available and i will close the form. When i close the pop up country window automatically the last saved country name should come and loaded in the parent form's combo box. How should i do that. I have refreshed the page and i am getting some error in that and when i reload the page my previous text box values are vanished. Please help me.
    Thanks in advance.

    Hi,
    Thanks for u r reply.
    But i haven't used the session and hidden variables. can u please explain me in detail.

  • To Get Last Updated Value.

    Hi All
    I want to fetch data from nearly 15 tables.
    All the tables contains a Modified_date and Insert_date columns
    If any of the table contains a modifed_date or insert_date with in last 2 Days, Then i have to pick that rows.
    Please suggest me how to fetch these values in an optimistic way,Since all the tables contains millions of data.
    Note:
    Im using oracle 11g
    Thanks
    Jo

    Johney  wrote:
    Hi All
    I want to fetch data from nearly 15 tables.
    All the tables contains a Modified_date and Insert_date columns
    If any of the table contains a modifed_date or insert_date with in last 2 Days, Then i have to pick that rows.
    Please suggest me how to fetch these values in an optimistic waywhat is difference between optimistic fetch & pessimistic fetch?
    >
    Note:
    Im using oracle 11g
    Thanks
    Jowe can't write SQL when we don't know table names or column names.
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Get the yesterday or last month data

    Hi ,
    I've need a small help .
    This is the scenario.
    If today is 1st feb. so I need to get last month data.
    if today is 30 th i need to get the current month data before 30 I mean 29 days data.
    I have to do it automatically i mean i need to write case statement in my existing query by using sysdate and i have to get it .
    pls help me out . Your help is greatly appreciated.
    Thanks & Regards,
    madhav.

    Haven't tested it, but you could try something like
    This gives you last months data if executed on the first day of the month otherwise this months data until the day before today
    select *
    from my_table
    where my_date >= add_months(trunc(sysdate, 'MM'), sign(trunc(sysdate)-trunc(sysdate, 'MM'))-1)
    and   my_date <trunc(sysdate)After I read your posting again, I guess you wanted something else
    This query now gives you last months data if executed on the first day of the month otherwise the data of the day before today
    select *
    from my_table
    where my_date >= (case when trunc(sysdate) = trunc(sysdate, 'MM') then add_months(trunc(sysdate, 'MM'), -1) else trunc(sysdate-1) end)
    and   my_date <trunc(sysdate)Message was edited by:
    Jens Petersen

Maybe you are looking for

  • DVD to MP4 or M4V

    Been searching discussions for information on converting DVD's to either MP4 or M4V format. About the only free source I can find is HandBrake. Is that the best one?

  • How to set a trail file as completed?

    I am using GoldenGate to do an initial load, using parameters like: EXTFILE /tmp/aa, MAXFILES 1000, MEGABYTES 2000 I don't understand why all the files except the last one are marked as completed. In my use case, I need all the generated files to be

  • One of my usb ports is dead, dv6-6070ee

    i have purchased my laptop about 2 months ago, suddenly one of the usb ports is no longer working the usb port is a USB2.0 , the other one is working and the USB 3.0 x 2 are working too it doesnt work in windows not even at boot, my logitech mouse ha

  • Sync folders in folder actions

    I'll explain : Is there a way to tell acions folder to copy files over whenever a file is modified ? Thanks MJ

  • Unbale to access an Anonymous WebDynpro iView

    Hi All, I am facing small problem while trying to access an WebDynpro iView by an Anonymous User. EX: Anonymous UserName: John Getting this Exception: Error in Service call of Portal Component User: John and specifying Caused by: Portal Runtime Excep