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: 

FM for last date of month

Former Member
0 Kudos

Hi,

Can anyone help me with a function module where i'll be importing the month number and year and the FM will return the last date of the month (not the last day).

Thanks,

Anindita

12 REPLIES 12

former_member188829
Active Contributor
0 Kudos

Hi,

RP_LAST_DAY_OF_MONTHS

0 Kudos

This imports date and not the month number.

Regards,

Anindita

former_member386202
Active Contributor
0 Kudos

Hi,

USE FM

*--Call function module to Calcute the last day of month

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = lv_date1

IMPORTING

last_day_of_month = lv_date2

EXCEPTIONS

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

Reawrd Points

Regards,

Prashant

JozsefSzikszai
Active Contributor
0 Kudos

what is 'last date of month'?

0 Kudos

last date means the entire date, eg. for last date for November, it should be 30.11.2007 and not just 30.

0 Kudos

Hi,


DATA : date1 LIKE sy-datum,
date2 LIKE sy-datum,
            yr  TYPE char4 VALUE '2007',
            month TYPE char4 VALUE '10'.

CONCATENATE yr month '01' INTO date1.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
  EXPORTING
    day_in            = date1
  IMPORTING
    last_day_of_month = date2.  "date2 is type SY-DATUM
WRITE 😕 date2.

Message was edited by:

Perez C

0 Kudos

Use this FM. This will help you.

<b> JVA_LAST_DATE_OF_MONTH</b>

ex:

Import parameters Value

YEAR_MONTH 200703 ---> year month

Export parameters Value

LAST_DATE_OF_MONTH 31.03.2007

Gives the last date.

<b>Reward points.</b>

Regards,

Vimal

Message was edited by:

Vimal Kumar

Former Member
0 Kudos

HI

You can use FM RP_LAST_DAY_OF_MONTHS.

DATA: WA_DATE LIKE SY-DATUM,

WA_LDATE LIKE SY-DATUM.

WA_DATE = SY-DATUM - 30.

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = WA_DATE

IMPORTING

LAST_DAY_OF_MONTH = WA_LDATE

EXCEPTIONS

DAY_IN_NO_DATE = 1

OTHERS = 2.

WRITE: / WA_LDATE.

Former Member
0 Kudos

Hi

Please try LAST_DAY_IN_PERIOD_GET , however please remember to pass the correct period variant.

Best Regards

Arun

Former Member
0 Kudos

year = '2008'.

month = '11'.

pp = '02'.

CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'

EXPORTING

I_GJAHR = year

I_PERIV = 'K1'

I_POPER = month

IMPORTING

E_DATE = date1

  • EXCEPTIONS

  • INPUT_FALSE = 1

  • T009_NOTFOUND = 2

  • T009B_NOTFOUND = 3

  • OTHERS = 4

.

Former Member
0 Kudos

This problem is solved.

Thanks and Regards,

Anindita

Former Member
0 Kudos

Hi,

You can use the below FM and code.

Assuming sp_gjahr is selection parameter and lv_poper is the period, and for i_periv you should use the fiscal year variant. And declare variable as sy-datum to hold date result.

CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
    EXPORTING
      i_gjahr        = sp_gjahr
      i_periv        = 'K4'
      i_poper        = lv_poper
    IMPORTING
      e_date         = gv_lastday
    EXCEPTIONS
      input_false    = 1
      t009_notfound  = 2
      t009b_notfound = 3
      OTHERS         = 4.

Thanks,

Sriram Ponna.