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: 

Last Date of the next month

Former Member
0 Kudos

Hi,

How to find the last date of the next month.

Thanks in advance

Sunitha

1 ACCEPTED SOLUTION

Former Member
0 Kudos
REPORT ychatest.

DATA : date1 LIKE sy-datum,
       month(2).


date1 = sy-datum.
month = date1+4(2).
month = month + 1.
date1+4(2) = month.

CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'
  EXPORTING
    day_in            = date1
  IMPORTING
    last_day_of_month = date1
  EXCEPTIONS
    day_in_not_valid  = 1.


WRITE : date1+6(2).
.
10 REPLIES 10

Former Member
0 Kudos

Hi,

Use this FM : HR_JP_MONTH_BEGIN_END_DATE

or LAST_DAY_OF_MONTHS

Regards,

GSR.

Former Member
0 Kudos

Use the below mentioned FM

call function 'LAST_DAY_IN_PERIOD_GET'

exporting

i_gjahr = p_finyear

i_periv = 'X1'

i_poper = lv_popere

importing

e_date = p_edate

exceptions

input_false = 1

t009_notfound = 2

t009b_notfound = 3

others = 4.

if sy-subrc <> 0.

endif.

Supply the proper parameters, u will get the last date in the next month.

former_member181962
Active Contributor
0 Kudos

Use this FM LAST_DAY_OF_MONTHS

get the next month from

v_next_month = sy-datum+4(2) + 1.

and pass v_next_month to the FM.

REgards,

Ravi

0 Kudos

Just add 1 to the month in sy-datum and pass this value to the fucntion module LAST_DAY_OF_MONTHS.This will provide you the date that you are looking for.

Cheers

Nishanth

naimesh_patel
Active Contributor
0 Kudos

Hello,

Use FM, RP_LAST_DAY_OF_MONTHS

Regards,

Naimesh

Former Member
0 Kudos
REPORT ychatest.

DATA : date1 LIKE sy-datum,
       month(2).


date1 = sy-datum.
month = date1+4(2).
month = month + 1.
date1+4(2) = month.

CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'
  EXPORTING
    day_in            = date1
  IMPORTING
    last_day_of_month = date1
  EXCEPTIONS
    day_in_not_valid  = 1.


WRITE : date1+6(2).
.

0 Kudos

try:

DATA date LIKE sy-datum .
DATA year LIKE bkpf-gjahr.
DATA month LIKE bkpf-monat.

IF sy-datum+4(2) > 10.
  year = sy-datum(4) + 1.
  month = sy-datum+4(2) + 2 - 12.
ELSE.
  year = sy-datum(4).
  month = sy-datum+4(2) + 2.
ENDIF.

CONCATENATE year month '01' INTO date.
date = date - 1.
WRITE date.

Andreas

0 Kudos

I don't think this works for December. Instead of sy-datum, try it with '20061215'.

Rob

Former Member
0 Kudos

Hello Sunitha,

Use FM RS_VARI_V_1_NEXT_MONTH to get the next month. U don't have to pass anything to the FM. Get the output from P_datum and pass it to the FM LAST_DAY_OF_MONTHS.

Former Member
0 Kudos

REPORT ZTESTJRG .

parameters: pdate type sydatum default sy-datum.

data: ldate type sydatum.

ldate = pdate.

* Set to the next month
ldate+4(2) = pdate+4(2) + 1.

if ldate+4(2) = '13'.
  ldate+4(2) = '01'.
  ldate+0(4) = ldate+0(4) + 1.  "Add a year
endif.

* Set to the month after the next month
ldate+4(2) = ldate+4(2) + 1.

* Set to the first day of the month
ldate+6(2) = '01'.

* Set to one day less than the first day of two months from pdate
ldate = ldate - 1.

write: /1 'Current date:', 25 pdate,
       /1 'Last day of next month:', 25 ldate.