Skip to Content
avatar image
Former Member

Any FM in Splitting date with select options

Hi,

Can any one help me in splitting the dates on selection screen, user can enter the dates given below selection screen with dates 01.04.2008 to 31.03.2013

on output it should display like

01.04.2008 to 31.03.2009

01.04.2009 to 31.03.2010

01.04.2010 to 31.03.2011

01.04.2011 to 31.03.2012

01.04.2012 to 31.03.2013

Is there any function module to convert into consecutive dates ?

Many Thanks

SM

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Where user can some times enter 2010 to 2013 / 2009 to 2013 .... But he will enter dates within Quinquennial...

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 05, 2017 at 11:55 AM

    data :lv_yr TYPE ZREM_LAND_RATES-FRM_PERIOD,

    lv_yr1 TYPE ZREM_LAND_RATES-FRM_PERIOD.

    DATA: lv_yrtmp TYPE p0001-begda.
    DATA: lv_yrtmp1 TYPE p0001-begda.

    WHILE lv_yr <= lv_yr1.
    wa_rem-syear = lv_yr.
    CALL FUNCTION 'BKK_ADD_MONTH_TO_DATE'
    EXPORTING
    months = 12
    olddate = lv_yr
    IMPORTING
    newdate = lv_yrtmp.
    lv_yr = lv_yrtmp.
    CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
    date = lv_yrtmp
    days = 01
    months = 00
    signum = '-'
    years = 00
    IMPORTING
    calc_date = lv_yrtmp.
    wa_rem-eyear = lv_yrtmp.
    wa_rem-zone = p_zone.
    APPEND wa_rem TO it_rem.
    CLEAR wa_rem.
    ENDWHILE.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 06, 2017 at 07:44 AM

    You can find thousands of answers in the forum how to perform calculations on a date (PS: I don't know why people use function modules although there exists standard ABAP-only ways to do it ; especially those function modules are often only available in SAP ERP systems, but not in CRM/SRM/etc. systems, or vice versa):

    • To add one year to a date (but it won't work well with February 29, 2016 + 1 year, what result should it give, as February 29, 2017 doesn't exist !?):
      DATA date TYPE d.
      date = '20150101'.
      date = |{ date(4) + 1 }{ date+4(2) }{ date+6(2) }|.
      ASSERT date = '20160101'.
    
    • To subtract one day from a date (of type D) :
      date = date - 1.

    j

    Add comment
    10|10000 characters needed characters exceeded