Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function that return the next month

Former Member
0 Kudos

Hi gurus!

I need a Function that retun the next month in the format: yyyymmdd (without points) if it´s possible or yyyymm. The first option is better than the second one. My import parameter has the format: yyyymmdd.

Maybe, I'll be useful a similar function but with the next day.

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Refer to my answer.

<b>Put a break-point at</b>

*--Output format in yyymmdd (without points)
WRITE : future_date.

You will have future_date in YYYYMMDD format.

Regards,

AS

12 REPLIES 12

Former Member
0 Kudos

Try with FM /BEV4/PLPS__ADD_MONTH_TO_DATE or SG_PS_ADD_MONTH_TO_DATE.

But most of the FM accepts the dates in sy-datum format only.

So whatever date format you have you can convert them into sy-datum form then try to use above FMs.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

0 Kudos
data: wa_date like sy-datum.
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 0
months = 1
signum = '+'
years = 0
importing
calc_date = wa_date.
write: wa_date.

kishan negi

former_member404244
Active Contributor
0 Kudos

Hi,

check out the function module

RE_ADD_MONTH_TO_DATE.

Regards,

Nagraj

anversha_s
Active Contributor
0 Kudos

hi,

simple chk this.

data : wa_date type sy-datum.
 
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days =  0
months = 1 --------------------> give ur required month
years = 0
signum = '+'        -------------> add sign
importing
calc_date = wa_date.
 
write 😕 wa_date. -> next month date in sy-datum format.

rgds

Anver

if hlped pls mark points

Former Member
0 Kudos

Hi

PARAMETERS: P_DAY LIKE SY-DATUM.

DATA: NEXT_MONTH(6).
DATA: LAST_DAY LIKE Y-DATUM.


* Set the first day
LAST_DAY = P_DAY.
LAST_DAY+6(2) = '01'.

* Get last day

CALL FUNCTION 'LAST_DAY_OF_MONTHS'
     EXPORTING 
          DAY_IN = LAST_DAY
     IMPORTING 
          LAST_DAY_OF_MONTH = LAST_DAY.

* Get next month
LAST_DAY = LAST_DAY + 1.
NEXT_MONTH = LAST_DAY(6).

Max

Former Member
0 Kudos

Hi ,

Check this out..

Function module              MONTH_PLUS_DETERMINE


<b>Import parameters               Value</b>

MONTHS                          1
OLDDATE                         13.11.2006


<b>Export parameters               Value</b>

NEWDATE                         13.12.2006

Check out this code..


REPORT  zztest_date                             .


DATA :

months_offest(2)         TYPE c,
present_date             TYPE  sy-datum,
future_date              TYPE  sy-datum.


*--Present Date
present_date  = sy-datum.

*--Future date with Months as offset
months_offest = '1'   .   "Date after 1 month

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
  EXPORTING
    months  = months_offest
    olddate = present_date
  IMPORTING
    newdate = future_date.


*--Output format in yyymmdd (without points)
WRITE : future_date.

Regards,

AS

Message was edited by:

Arun Sambargi

Former Member
0 Kudos

try this fm

CALL FUNCTION 'HR_BR_ADD_MONTH_TO_DATE'

EXPORTING

DMM_DATIN = dateinput (like sy-datum)

DMM_COUNT = 1

DMM_OPER = '+'

DMM_POS = 0

IMPORTING

DMM_DAOUT = data output (like sy-datum)

EXCEPTIONS

UNKNOWN = 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.

it will add one month to the input date.

shiba prasad

Former Member
0 Kudos

just execute the code ..

************************

DATA: BEGIN OF intern OCCURS 0.
        INCLUDE STRUCTURE  RSINTRANGE.
DATA: END OF intern.
data : date like sy-datum,
       datex(10) type c.
CALL FUNCTION 'RS_VARI_V_1_NEXT_MONTH'
 IMPORTING
   P_DATE           =  date
  TABLES
    p_intrange       = intern.


write:/ date.
datex = date.

write:/ datex.

regards,

VIjay

Former Member
0 Kudos

just execute teh code ..

my prev post will give u the answer ..

this is the more precise way for getting the date to internal format ..

regards,

VIjay

-


DATA: BEGIN OF intern OCCURS 0.
        INCLUDE STRUCTURE  RSINTRANGE.
DATA: END OF intern.
data : date like sy-datum,
       datex(10) type c.
CALL FUNCTION 'RS_VARI_V_1_NEXT_MONTH'
 IMPORTING
   P_DATE           =  date
  TABLES
    p_intrange       = intern.


write:/ date.
*datex = date.
write date to datex.
*write:/ datex.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                 = datex
 IMPORTING
   DATE_INTERNAL                  = datex
 EXCEPTIONS
   DATE_EXTERNAL_IS_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.

write:/ datex.

regards,

VIjay

Former Member
0 Kudos

Hi all,

Thanks for your help but the problem hasn´t been solved.

I need that the function return the format YYYYMMAA

Thanks

Former Member
0 Kudos

Hi,

Refer to my answer.

<b>Put a break-point at</b>

*--Output format in yyymmdd (without points)
WRITE : future_date.

You will have future_date in YYYYMMDD format.

Regards,

AS

0 Kudos

Hi Arun!

Problem solved!

Thanks a lot!