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
1,746

Hi Friends,

I need a Funciton module to find the working days between two dates.

Thanks in Advance.

Sure of reward points.

8 REPLIES 8
Read only

Former Member
0 Likes
1,172

parameters: p_start type sy-datum,

p_end type sy-datum.

data: idays type table of rke_dat with header line.

data: workingdays type i.

call function <b>'RKE_SELECT_FACTDAYS_FOR_PERIOD'</b>

exporting

i_datab = p_start

i_datbi = p_end

i_factid = 'P8' " Fact Calender ID

tables

eth_dats = idays

exceptions

date_conversion_error = 1

others = 2.

describe table idays lines workingdays.

write:/ workingdays.

Message was edited by: kishan negi

Read only

Former Member
0 Likes
1,172

Hi,

You can get holidays between 2 dates using function module HOLIDAY_GET

Hope with that you can derive number of working days.

regards

Damasus

Read only

Former Member
0 Likes
1,172

Hi,

you can try this FM

DATE_CHECK_WORKINGDAY

Regards,

Sumit.

Read only

0 Likes
1,172

r u trying this it is tested...

parameters: p_start type sy-datum,

p_end type sy-datum.

data: idays type table of rke_dat with header line.

data: workingdays type i.

call function <b>'RKE_SELECT_FACTDAYS_FOR_PERIOD'</b>exporting

i_datab = p_start

i_datbi = p_end

i_factid = 'P8' " Fact Calender ID

tables

eth_dats = idays

exceptions

date_conversion_error = 1

others = 2.

describe table idays lines workingdays.

write:/ workingdays.

Read only

Former Member
0 Likes
1,172

data: idays type table of rke_dat with header line.

data: workingdays type i.

call function 'RKE_SELECT_FACTDAYS_FOR_PERIOD'

exporting

i_datab = p_start

i_datbi = p_end

i_factid = 'P8' " Fact Calender ID

tables

eth_dats = idays

exceptions

date_conversion_error = 1

others = 2.

describe table idays lines workingdays.

write:/ workingdays.

Read only

Former Member
0 Likes
1,172

Sample code:

report zcalculate_days.

  • Sample code to calculate total working days and holidays between 2 dates.

data: total_days(4) type c,

v_holidays type i,

v_work_days type i,

v_total_days type i.

data: begin of holidays occurs 0.

include structure iscal_day.

data: end of holidays.

parameters: from_dt like sy-datum,

to_date like sy-datum,

calendar like scal-hcalid.

start-of-selection.

  • Get total days between 2 dates

call function 'DAYS_BETWEEN_TWO_DATES'

exporting

i_datum_bis = to_date

i_datum_von = from_dt

i_kz_excl_von = '0'

i_kz_incl_bis = '1'

i_kz_ult_bis = ' '

i_kz_ult_von = ' '

i_stgmeth = '0'

i_szbmeth = '2'

importing

e_tage = total_days

exceptions

days_method_not_defined = 1

others = 2.

  • Get Holidays between 2 dates

call function 'HOLIDAY_GET'

exporting

holiday_calendar = calendar

factory_calendar = calendar

date_from = from_dt

date_to = to_date

tables

holidays = holidays

exceptions

factory_calendar_not_found = 1

holiday_calendar_not_found = 2

date_has_invalid_format = 3

date_inconsistency = 4

others = 5.

describe table holidays lines v_holidays. "Total holidays

v_total_days = total_days. "Total days

v_work_days = total_days - v_holidays. "Total working days

write:/ 'Start date : ', from_dt.

write:/ 'End date : ', to_date.

write:/ 'Calendar : ', calendar.

write:/ 'Total days : ', v_total_days.

write:/ 'Working days : ', v_work_days.

write:/ 'Holidays : ', v_holidays.

Read only

Former Member
0 Likes
1,172

Hi,

<b>RKE_SELECT_FACTDAYS_FOR_PERIOD</b> : Give working days for a period

The above function module will give you the number of working days if you pass the start and end date of a any year with SAP Calendar ID.

Note: The date should be of the same year like Start - 01/08/2006 End - 31/08/2006

But if you want to get the number of working days for any date use the below Function Module:

<b>DATE_CONVERT_TO_FACTORYDATE</b>

Regards,

AS

Read only

Former Member
0 Likes
1,172

adf