Application Development and Automation 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: 
Read only

Function module

Former Member
0 Likes
296

Hi ,

I wand to get no of days , month , year when i give

the 2 month , year only as input , no date is given.

Is there any standard function module that accepts

month and year and give the no of month , year between

them

Thanks & Regards

Renjith Kumar

2 REPLIES 2
Read only

Former Member
0 Likes
265

Hi,

You do not have directly a function module but you can use this.

&----


*& Form CALC_FIRST_LAST_DAY_OF_MO

&----


  • Calculates the first and last day of the month for the

  • Month/Year that was input as report parameters.

  • Also formats the first and last day of the month in

  • all the different formats needed to read production tables

  • and Razorfish tables

----


  • -->P_YEAR Year in format YYYY

  • -->P_MO Month in format MM

----


FORM calc_first_last_day_of_mo USING p_year "YYYY

p_month "MM

CHANGING p_beg_dt LIKE sy-datum

p_end_dt LIKE sy-datum

p_prev_beg_dt LIKE sy-datum

p_prev_end_dt LIKE sy-datum

p_beg_dt_000000

p_beg_dt_240000

p_end_dt_000000

p_end_dt_240000.

CHECK NOT ( p_year IS INITIAL ) AND

NOT ( p_month IS INITIAL ).

  • First day of the month in sy-datum format

DATA: BEGIN OF l_first_day,

year(4),

mo(2),

day(2) VALUE '01',

END OF l_first_day.

l_first_day-year = p_year.

l_first_day-mo = p_month.

p_beg_dt = l_first_day.

  • Last day of the month in sy-datum format

CALL FUNCTION 'OIL_LAST_DAY_OF_MONTH'

EXPORTING

i_date = p_beg_dt

IMPORTING

e_last_day = p_end_dt.

  • CALL FUNCTION 'OIU_GET_PREV_MONTH' "DEL OSS 102253

  • EXPORTING

  • i_date = p_end_dt

  • IMPORTING

  • e_date = p_prev_end_dt.

p_prev_end_dt = ( p_beg_dt - 1 ). "INS OSS 102253

l_first_day-year = p_prev_end_dt(4).

l_first_day-mo = p_prev_end_dt+4(2).

p_prev_beg_dt = l_first_day.

  • First and last days of the month with timestamps set to

  • '000000' and '240000'

CONCATENATE p_beg_dt '000000' INTO p_beg_dt_000000.

CONCATENATE p_beg_dt '240000' INTO p_beg_dt_240000.

CONCATENATE p_end_dt '000000' INTO p_end_dt_000000.

CONCATENATE p_end_dt '240000' INTO p_end_dt_240000.

  • First Day of the month in format YYYYMMDD+++++, where '+++++' is

  • in timestamp. Put in range with option = CP.

CLEAR r_prd_dt[].

CLEAR r_prd_dt.

CONCATENATE p_beg_dt

'++++++'

INTO r_prd_dt-low.

r_prd_dt-sign = 'I'.

r_prd_dt-option = 'CP'.

APPEND r_prd_dt.

ENDFORM. " CALC_FIRST_LAST_DAY_OF_MO

Read only

Former Member
0 Likes
265

Hi,

You can use this function module...

"CSCP_PARA1_GET_PERIODS" with the following parameters.

Date from: 01.01.2006 (First date of the starting moth)

Date to : 01.10.2006 (First date of the last month)

Time Unit: 'M'.

This will return 10 records in the internal table.

Describe the internal table for LINES option.

This will give the number of months between the given months.

You can also try the following FMs...

HR_HK_DIFF_BT_2_DATES, DAYS_BETWEEN_TWO_DATES

Thanks and Regards,

Bharat Kumar Reddy.V