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 module to get the 'first day of next month'

Former Member
0 Kudos

Hi

I have a selection screen with input fields

1. period (month eg: 07)

2.year(fiscal year eg: 2008 )

If user enters 07 as month and 2008 as year, then I have to display 08/01/2008(MM/DD/YYYY) as output.

Requirement is to calculate the 'first day of next month'

I have written code for this requirement.But I am asked to use function mdule.

Please help me in this regard.

Thanks&Regards

Rama.Mekala

7 REPLIES 7

Former Member
0 Kudos

/message/4866914#4866914 [original link is broken]

Please give me reward points..

Former Member
0 Kudos

Use this FM to get the last day of the current month

SG_PS_GET_LAST_DAY_OF_MONTH

then add one to the output parameter..

will give u the first day of next month

Hope dis helps.

Reward if it does

Former Member

hi,

use the function module OIL_GET_NEXT_MONTH

Former Member
0 Kudos

hi try this FM ...

HR_JP_MONTH_BEGIN_END_DATE

it gives the Begin Date and End date of the month

rewards points if found useful

regards,

Balaji

Former Member
0 Kudos

Try this FM 'OIL_MONTH_GET_FIRST_LAST'

Regards,

Swapnil.

rajib3301
Discoverer
0 Kudos
  DATA: L_LASTDT TYPE DATUM.
  DATA: L_TODAY TYPE DATUM,
        l_date TYPE datum.
  L_TODAY = sy-datum.
  CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
    EXPORTING
      IV_DATE           = L_TODAY
    IMPORTING
*     EV_MONTH_BEGIN_DATE       =
      EV_MONTH_END_DATE = L_LASTDT.
  data: L_DAYSCOUNT TYPE numc2.
 L_DAYSCOUNT = ( L_LASTDT - L_TODAY ) + 1.

 L_DAYSCOUNT = |{ L_DAYSCOUNT ALPHA = OUT }|.


  CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
      DATE      = L_TODAY
      DAYS      = L_DAYSCOUNT
      months    = '00'
      signum   = '+'
      years     = '00'
    IMPORTING
      CALC_DATE = L_DATE.

javier_alonso
Participant
0 Kudos

Use a simple FM to get the next month.

As your selection parameters are the month and year, you can pass the first day of the month to the FM so the output day will always be 01 as well:

DATA(result) = VALUE dats( ).

CALL FUNCTION 'OIL_GET_NEXT_MONTH'
  EXPORTING
    i_date = CONV dats( |{ p_year }{ p_month }01| )
  IMPORTING
    e_date = result.

WRITE / result.