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

I need experts help on calculating days using function module.

Former Member
0 Likes
646

Hi Experts,

I have a small issue :

I have to calculate days from month/year is input parameter,for example i am giving input 03/2008(march'08)

i have to see in output march month days(31days) if that year is leap year(02/2008) for the month of feberuary 29 days other wise 28 days to display.

giving input month and year get the days of input month.

Input Parameter is :03/2008(Month/Year)

Desired output: 31 Days(particular month days).

Any sample code also welcome.

I'll assign full points.

Thanks,

5 REPLIES 5
Read only

Former Member
0 Likes
607

You can use FM NUMBER_OF_DAYS_PER_MONTH_GET

Read only

Former Member
0 Likes
607

Hi Eyda,

You can use the following FM.

NUMBER_OF_DAYS_PER_MONTH_GET.

You can use the following piece of code.

CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'

EXPORTING

par_month = month

par_year = year

IMPORTING

PAR_DAYS = days.

Hope this helps you.

Thanks,

Arun

Read only

0 Likes
607

Hi,

In My system that function module not exist..

Where can i find the function module.

I used SE37 and Given FM Tech Name.it is showing not exists.

Can you guide me..

Thanks..

Read only

0 Likes
607

Hi Eyda,

Can you tell me the SAP version you are using.

While giving it se37 remove and spaces that are prefixed.

Thanks,

Arun

Read only

Former Member
0 Likes
607

HI,

first get first day and last day of the given month and the calculate number of days bettween these two days.

1. calculate fisrt day and last day of the month.

s_date is ur given date in the format yyyymm.

lwa_month = s_date-low+4(2).

lwa_year = s_date-low+0(4).

CONCATENATE s_date-low c_01 INTO ws_date.

*To get last day of the month

CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'

EXPORTING

day_in = ws_date

IMPORTING

last_day_of_month = ws_last_day_month

EXCEPTIONS

day_in_not_valid = 1

OTHERS = 2.

2. calculate number of days between these two days,

CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'

EXPORTING

beg_da = ws_date

end_da = ws_last_day_month

IMPORTING

no_cal_day = d.

here ur 'd' will give u number of days of that month .

Regards,

kk.