Customer Exit to get last day of month from Year/month

Hi Experts,
I need to create a customer exit to get the last day of month from Cal Year month input variable.
Examples
1)
User input period: 12.2008
I need from the customer exit: 31.12.2008
2)
User input period: 02.2009
I need from the customer exit: 28.02.2009
Can someone help me with the ABAP code to achieve this with a customer exit?
Help will be appreciated.

Hi,
Please use the following code,
Second one is the suitable solution for you, I can understand that, if it leafe year then you have the problem so use the secon one.
First one is using Period i.e. 010.2008 (December 2008).
Secodn one is based on Date/Month.
Note: Insted of SY-DATUm, you give your variable name
*******To get the Last day of the Fy Period entered by User in ZFYP***
    WHEN 'ZLDAY_FI'.
      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZFYP'.
        zbdatj = loc_var_range-low+0(4).
        zbuper = loc_var_range-low+4(3).
        CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
          EXPORTING
            i_gjahr = zbdatj
            i_periv = 'V3'
            i_poper = zbuper
          IMPORTING
            e_date  = zzdate.
        CLEAR: l_s_range.
        l_s_range-low = zzdate.
        l_s_range-sign = 'I'.
        l_s_range-opt = 'EQ'.
        APPEND l_s_range TO e_t_range.
      ENDLOOP.
Note: in the below code I given SY-DATUM, so you change to your Month Variable like using  
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'XXXX'.
** Last Day of Current Calendar month
      zzdate = sy-datum.
      CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
        EXPORTING
          iv_date = zzdate
        IMPORTING
          ev_days = znum.
      CLEAR: l_s_range.
      l_s_range-low+6(2) = znum.
      l_s_range-low+0(4) = sy-datum+0(4).
      l_s_range-low+4(2) = sy-datum+4(2).
      l_s_range-sign = 'I'.
      l_s_range-opt = 'EQ'.
      APPEND l_s_range TO e_t_range.
Thanks
Reddy
Edited by: Surendra Reddy on Jan 27, 2009 2:47 PM
Edited by: Surendra Reddy on Jan 28, 2009 6:12 AM

Similar Messages

  • Getting last days of several months - Bex Analyzer

    Hello, BW experts~
    I need to calculate with last days of several months.
    For example,
    - The sales in July: $100
       -> sales per day in July = $100 / <b>31</b>
    - The sales in last month(June): $100
       -> sales per day in last month(June) = $100 / <b>30</b>
    - The sales in 2 month ago(May): $100
       -> sales per day in 2 month ago = $100 / <b>31</b>
    I used to calculate a last day on a month with a customer exit variable. It works well when executing  the BEx query with one month. But, when executing the query with 3 months, it doesn't work well.
    For example, when executing the query in July, all last days, which are calculated via customer exit variable, become 31. Only one month.
    - Last day -
    July: <b>31</b>
    Last month(June): <b>31</b>
    2 month ago(May): <b>31</b>
    They have to be each 31(July), 30(June), 31(May).
    I want to get fit last days of several months at a time and one BEx query.
    Is it possible? (I wish it's possible.)
    Can I do something in CMOD?
    Thank you~
    Sihyoung Jurn

    Hi,
    You can get it by creating 3 formula variables with 'customer ext' as processing.
    Let us assume user enters the First month by a 'user entry' variable.
    In the code of user exit for 1st formula variable you will calculate the last day of the user entered month.
    In the code of user exit for 2nd formula variable you will calculate the last day of the (prevoius month to user entered month).
    Similarly for 3rd Formula Variable also.
    there will be 3 Restricted key figures.
    one for sales of user entered month.
    2nd one for sales of prevoius month to user entered month.
    3nd one for sales of two month to user entered month.
    you will have 3 calculated kfs.
    in first one you do 1st RKF/Formula variable1.
    in second one you do 2nd RKF/Formula variable2.
    in third one you do 3rd RKF/Formula variable3.
    Hope, you understood my explanation.
    With rgds,
    Anil Kuamr Sharma .P

  • Getting last day of the month

    hi ,
    is there an existing date funtion to get last day of the month ?
    pls advise
    else
    i'll try to add_month + 1 to current month and format to the first day and minus 1 day from that new month
    tks & rdgs

    last_day function
    <br>
    jeneesh

  • How to get Last Day of a Previous Month

    Hi all,
    I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
    But I need previous Month's Last Day.
    Thanks
    Vamshi.

    Thanks all....
    I have been trying the same and could get it.....
    here is the code for that....
    SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
    Calendar calendar = Calendar.getInstance();
    month = calendar.get(Calendar.MONTH);
    //year = calendar.get(Calendar.YEAR);
    calendar.set(Calendar.MONTH, month-1);
    calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
    //lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
    System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
    this works....
    thanks for ur replys....

  • Customer Exit for 15 month from current month

    Hi Gurus,
    I have a requirement to write customer exit for 15 months from current month based on todays day.
    if current day is less than 10 then we have to get 15 months from current month other wise from next month to 15 months.
    this exit I am writing on calendar year/month.
    Please assist for logic.
    Thanks
    Ganesh Reddy.

    I hope this code will do the trick.
    DATA: L_S_RANGE TYPE RSR_S_RANGESID,
    LOC_VAR_RANGE LIKE RRRANGEEXIT,
    zcalmonth(6) type c.
    zcurrentmonth(6) type c.
    zyear(4) type n,
    znextyear(4) type n,
    zyear1(4) type c,
    znextyear1(4) type c,
    zmonth(2) type n,
    zmonth1(2) type n,
    zmonth2(2) type c,
    zmonth3(2) type n,
    zmonth4(2) type c,
    IF i_step = 2.
    CASE i_vnam.
    WHEN '<VARNAME>'.
    zyear = sy-datum+0(4).
    znextyear = zyear + 1.
    zyear1 = zyear.
    znextyear1 = zlastyear.
    zmonth = sy-datum+4(2).
    if sy-datum+6(2) LE 10.
    zmonth1 = zmonth + 2.
    if zmonth1 GT 12.
    zmonth1 = zmonth1 - 12.
    zmonth2 = zmonth1.
    zcurrentmonth = sy-datum+0(6).
    endif
    concatenate znextyear1 zmonth2 into zcalmonth.
    else.
    zmonth1 = zmonth + 3.
    ZMONTH3 = ZMONTH + 1.
    if zmonth1 GT 12.
    zmonth1 = zmonth1 - 12.
    zmonth2 = zmonth1.
    endif
    if zmonth3 GT 12.
    zmonth3 = zmonth3 - 12.
    zmonth4 = zmonth3.
    endif
    concatenate znextyear1 zmonth2 into zcalmonth.
    concatenate znextyear1 zmonth4 into zcurrentmonth.
    endif.
    l_s_range-low = zcurrentmonth.
    l_s_range-high = zcalmonth.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    ENDIF.
    rgds, Ghuru

  • Adding reminders to my calendar items is no longer an option after the software upgrade.  I also can't get to day and week view, only month view.  What's a possible solution?

    Adding reminders to my calendar items is no longer an option after the software upgrade.  I also can't get to day and week view, only month view.  What's a possible solution?  I'm using Andriod version 4.4.2 with kernal 3.4.0.

        @MaloneTP
    Thanks for keeping me updated!  Do you see the screen options displayed in the following link: http://bit.ly/T2koBL for changing the calendar view options in Kies Air?  Also, let me know if you're able to add a Reminder by following these steps: http://bit.ly/T2l9dY.  Keep me posted.  Thanks!
    AnthonyTa_VZW
    Follow us on Twitter @VZWSupport

  • Customer Exit for 13 month from current month

    Hi Gurus,
    I need a customer exit for 13 months from current month. Based on the requirement I have written following code
    When 'VPI_13CALYRMON'.
        IF i_step = 1.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'BT'.
          l_s_range-low = sy-datum+0(6).
          l_s_range-high = sy-datum+0(6) + 13.
          append l_s_range to e_t_range.
        endif.
    Please could you guide me the code.
    Thanks
    Ganesh Reddy.

    Hi,
    I think you can do it in below way.
    When 'VPI_13CALYRMON'.
    IF i_step = 1.
    temp1 = sy-datum+0(4).
    temp1 = temp1 +1. (because adding 13 months would take year to next year)
    temp2 = sy-datum+4(2).
    temp2 = temp2 + 1. (after adding 13 months, the month would be one more than of previous year)
    concatenate temp1 temp2 into temp3.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    l_s_range-low = sy-datum+0(6).
    l_s_range-high = temp3.
    append l_s_range to e_t_range.
    endif.
    Hope this helps.

  • How to get last week of the month from a month

    Hello,
    I want to get last week of the month from a month. For example: If Input = April then Output = Week17. Is there any function module? Or what should be the logic inorder to meet such requirement?
    Thanks in advance for your answers.
    Nitin.

    Hi,
    Just cpoy and past this program, and see the result and apply for you requirements.
    Data: ZSCDATUM TYPE SCDATUM,
          ZKWEEK TYPE KWEEK,
          ZDAY TYPE SY-DATUM,
          ZLDAY TYPE SY-DATUM,
          ZWK(3) TYPE N,
          ZM(2) TYPE N.
          ZDAY = SY-DATUM.
          ZM = ZDAY+4(2).
          CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
            EXPORTING
              day_in                  = ZDAY
            IMPORTING
             LAST_DAY_OF_MONTH       =  ZLDAY
    *       EXCEPTIONS
    *         DAY_IN_NOT_VALID        = 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.
          ZSCDATUM = ZLDAY.
          CALL FUNCTION 'DATE_GET_WEEK'
            EXPORTING
              date               = ZSCDATUM
           IMPORTING
             WEEK               = ZKWEEK
    *       EXCEPTIONS
    *         DATE_INVALID       = 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.
          ZWK = ZKWEEK+4(2).
          WRITE: ZKWEEK.
          WRITE: ZWK.
    Thanks
    Reddy

  • Function Module to get first day of the fiscal year on passing a date

    Hi Experts!!
    Can you please suggest a Function Module to get first day of the fiscal year on passing a date..?
    Example:  if a fiscal year starts from 30 November 2009 and ends at 28 november 2010.
    it should return 30 th nov 2009 (first day of the fiscal year)

    Moderator message - Welcome to SCN.
    I think you'll find that this question has been answered before. Please search the forum before posting.
    Also, Please read Please read "The Forum Rules of Engagement" before posting!  HOT NEWS!! and How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
    Rob

  • Formula to subtract current month from previous month

    Hi
    I would like to how to subtract current month from previous month in Crystal 10.  Basically am looking at the variations that between the two month .   I would also like to know the 12 m onth rolling data formula.  Using the same formula, you need to get the difference between the two month.
    Any help on this is very much appreciated.
    Thanks
    Regards
    Cauvery

    Hi Thanks for reponding.
    Though the formula is correct, I don't think it will work out in that way because I have a 12 months rolling data  formula and using this formula  I have to subtract the current month from previous month.
    This the formula that am currently using for 12 months rolling data
    {HPD_HelpDesk.Arrival Time} >= DATEADD ("yyyy", -1, CURRENTDATE)
    Please advise.
    Regards
    Cauvery

  • Customer Exit for Number of Days from 1 st Apr to last date of Month Enter

    Hello BI Experts,
    I have a requirement to count the number of days from 1 st April of current year to the last date of month entered.
    For example : The use will enter say July 2010 or 003.2010  (as Fiscal Year Variant is V3 ).
    Today is 14 July ...So we have to first find out the end date of the July month ie 31 st July
    Then go to 1 st April 2010.
    Now calculate the Number of days between 1 st April to 31 st July 2010.
    I consider I have to create two Customer Exit variable
    as below
    1 st customer exit Bex variable  say  ZLY_MTH  ( Last day of Month Entered)
      and i_step = 1
    2 nd Customer Exit BEx Formula variable say ZF_NUMDAYS ( Number of days between two dates)
    i_step =1 .
    Please provide me the logic for the above two.
    Thanks in Advance.
    Regards,
    Amol Kulkarni

    PSUDEO CODE:
    1. Initially LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZMONTH'.
    2. Get the Month input using VAR_MONTH2 = LOC_VAR_RANGE-LOW+4(2)
    3. Now calculate Month+1: VAR_MONTH2 = VAR_MONTH2 + 1 (Refer **)
    4. Now calculate the Current Year: VAR_YEAR = LOC_VAR_RANGE-LOW+0(4).
    5. Get the 1st Day of the Month (VAR_MONTH2):  CONCATENATE '01' '/' VAR_MONTH2 '/' VAR_YEAR INTO L_S_RANGE-LOW.
    6. SUBRACT 1 (0DATE) from this DATE (This will give the logic for last day of the current month)
    Insert this code also for using the date conversions
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = VAR_MONTH2
              IMPORTING
                OUTPUT = VAR_MONTH2.
    Pls. check out this logic. Guess it would solve your need.
    Thanks,
    Arun Bala

  • Dynamic variable to get last day of month

    Hi all,
    I have created one report where in YTD is calculated based on stsyem date. NOw in this report the cal month is in row thus displaying data month wise. But i need one key figure which giving the last day vaue of every month that are displayed in YTD i.e this is based on cal day. Thus the report layout is as follows:
    if report is run in mar 2007 then it should display:
    For calmonth       key figure due amount
    For Jan 07           this should show due value on last day of jan 07 (i.e 31st jan 07)
    for Feb 07           this should show due value on last day of feb 07 (i.e 28th feb 07)
    for Mar 07          this should show due value on last day of mar 07 (i.e 31st mar 07)
    customer exit variable can give me only one value at a time. How can I make it dynamic to take last day value of every month as per cal month. Could anybody explain me if worked on any such issue.
    If there is some how to paper kindly mail me at my email Id : [email protected]
    thanks in advance
    Regards,
    Wrushali

    Hi,
    U can use FM : SLS_MISC_GET_LAST_DAY_OF_MONTH to get the last day of the month by passing the date/current date.
    Thanks,
    Debasish

  • How to get last day of prev month?

    SELECT to_char(SYSDATE, 'MM') -1, last_day(sysdate)
    FROM DUAL;
    If current month is April, How to get the last day of March? Thanks.

    SQL> select sysdate, trunc(sysdate, 'mm') - 1 from dual ;
    SYSDATE     TRUNC(SYSDA
    06-APR-2004 31-MAR-2004
    1 row selected.
    SQL>

  • How to get last day of a month

    using pl/sql
    What i need is that all members whose birthdate is in the curren month will be included as having had their birthdate regardless of the date of the month. The code i have is:
    Select me607.subscriber_id
    me607.mbr_dob,
    ** trunc(months_between (*end of current month*,me607.mbr_dob) / 12) as age
    from odw.mbr607_member_expanded me607
    The asterixed line is what I need to change. If I put the end of the current month (where I put 'end of current month') then all those whose birthday month is in Feb will show as having had their birthdate. So if run today, folks whose birthdate is 26-feb-2005 will show an age of 5.
    When grabbing the last day of the month using visual basic I just use the first day of the subsequent month minus 1. Any assistance is appreciated..

    Hi,
    This does what you requested:
    Select  me607.subscriber_id,     -- Don't you need a comma here?
         me607.mbr_dob,
         ROUND ( MONTHS_BETWEEN ( SYSDATE
                                , me607.mbr_dob
               / 12
    from    odw.mbr607_member_expanded     me607
    WHERE     TO_CHAR (me607.mbr_dob, 'MONTH') =
         TO_CHAR (SYSDATE,      'MONTH')
    ;If this is run sometime in February, 2010, and mbr_dob is sometime in Febrary, 2005, then the result of MONTHS_BETWEEN will be between 59 and 61. When we divide by 12 convert that to years, that difference of up to one month becomes so small that it will be lost in the rounding.
    If this isn't exactly what you need, tthen post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    Edited by: Frank Kulash on Feb 17, 2010 1:32 PM
    Added explanation.

  • How to get date difference in terms of years,months and also days

    Tool : Eclipse
    Framework : JSF & Springs
    JRE : jdk1.5.0_06
    Iam using oracle 10G DB as back end.I have two date fields in a table.
    1)premium_paying_start_date
    2)premium_paying_end_date
    Iam getting these two dates from the database and storing these values within a entity.Now in the delegate layer,
    i have to get the premium_term i.e, the difference between the two dates(premium_paying_end_date-premium_paying_start_date).
    The difference should show the year,month and no of days difference.
    For example :
    premium_paying_start_date : 14-10-1984
    premium_paying_end_date : 01-03-2008
    Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
    So please give me the solution for this.

    Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
    So please give me the solution for this.How did you determine what the difference should be?
    ~

Maybe you are looking for

  • Dropdown in Abap Webdynpro

    Hi friends, How to have custom dropdown list for field in abap webdynpro. It is possible in general abap with FM 'VRM_SET_VALUES' how it's possible in abap webdynpro. Please reply..... Thanks in advance.

  • HT1695 Safari cannot open the page because it is not connected to the Internet

    I recently bought iPhone 4 which is still "Locked" for cellular carriers in my country.It's a jailbroken phone.Therefor I connected to internet using a hotspot in my laptop via wi-fi.I'm using windows 7 in my laptop.I was able to connect to the inter

  • Hi good Mrng..........

    Hi good Morning frnds,           I got one requirement. Blocking a customer i IW32  As per my Functional requirement in VD05  they have sales areas. one is All sales area and other one  Seleted sales area. My functional consultant wants to use the se

  • Newbie question - SWF file download size

    If I have say 20 different screens to display in a flex application, after I compile the size of the swf file would be quite big (5+Mbs apprx) for the browser to download.  Hence, the users will have a waiting state unless the SWF file is completely

  • Issues loading data in table component after dploying to tomcat5.5.28

    Hi I export a war file from sjsc2 u 1 into tomcat5.5.28 and also set up jndi to point to the datasource properly but displaying table component with the data loaded from creator.i'm getting the following error type Exception report message descriptio