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 to find the working days between two dates.

Former Member
0 Likes
16,070

Hi all,

I want a function module which calculates for me

the actaul working days between two dates.

for eg the working days between 9th march 2008 and 16th march is 5.

i tried a lot of searching...but havent still found one.

i will continue searching but is anyone knows the FM please let me know.......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,190

Use the FM RKE_SELECT_FACTDAYS_FOR_PERIOD,


Pass I_DATAB as 01.01.2007
         I_DATBI as 31.12.2007
         I_FACTID as '01' 

In my system 01 in table TFACD indicates 5 working days in a week and the holiday calender <blank>. This will not consider holidays.

If you want to exclude holidays also, find a suitable factory calender id which has holiday calender id also included. In my system i could find one factory calender say US.


Pass I_DATAB as 01.01.2007
         I_DATBI as 31.12.2007
         I_FACTID as 'Z1' 

The FM will return all the days in an internal tbl. To get the count of the days, get the number of records returned in the internal table by using

 DESCRIBE <tbl> LINES <lines> 

.

Hope this helps. Reward points if helpful.

Thanks

Balaji

8 REPLIES 8
Read only

Former Member
0 Likes
6,190

This message was moderated.

Read only

Former Member
0 Likes
6,190

HOLIDAY_CHECK_AND_GET_INFO

Useful for determining whether or not a date is a holiday. Give the function a date, and a holiday calendar, and you can determine if the date is a holiday by checking the parameter HOLIDAY

it may solve ur problem partially

Read only

Former Member
0 Likes
6,190

Hi,

Try with Fm

K_ABC_WORKDAYS_FOR_PERIODS_GET

Read only

0 Likes
6,190

we us a comination of the following functions:

DATE_CONVERT_TO_FACTORYDATE

RKE_SELECT_FACTDAYS_FOR_PERIOD

Read only

Former Member
0 Likes
6,190

Hi aditya ,

try this function module .....

WEEK_GET_NR_OF_WORKDAYS......

i guess it will solve your problem....

Dont forgot to reward points.....

regards,

Sreenivasa sarma k.

Read only

Former Member
0 Likes
6,190

hi,

use the below FM,

FORM add_working_days USING p_days

CHANGING p_paydate TYPE sy-datum.

DATA: gd_factorydat LIKE scal-facdate,

gd_resdate LIKE sy-datum.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'

EXPORTING

date = p_paydate "Starting date

factory_calendar_id = 'GB'

IMPORTING

factorydate = gd_factorydat. "Factory calender date

  • Add n number of days to factory date, ignors non working days

gd_factorydat = gd_factorydat + p_days.

  • Convert factory date back to actual date

CALL FUNCTION 'FACTORYDATE_CONVERT_TO_DATE'

EXPORTING

factorydate = gd_factorydat

factory_calendar_id = 'GB'

IMPORTING

date = gd_resdate. "Actual date

p_paydate = gd_resdate.

ENDFORM.

FACTORYDATE_CONVERT_TO_DATE - In the factory calendar the working days are numbered sequentially from the first working day. The numbers of the working days are called factory dates. This function module calculates the date for a factory date.

DATE_CONVERT_TO_FACTORYDATE-In the factory calendar, the working days are numbered sequentially fromthe first working day. The working day numbers are called the factory date. This function module calculates the factory date for a calendar date. If the date passed is not a working day, the next or previous working day is calculated.

rewards points if useful.

regards

sandhya

Read only

Former Member
0 Likes
6,191

Use the FM RKE_SELECT_FACTDAYS_FOR_PERIOD,


Pass I_DATAB as 01.01.2007
         I_DATBI as 31.12.2007
         I_FACTID as '01' 

In my system 01 in table TFACD indicates 5 working days in a week and the holiday calender <blank>. This will not consider holidays.

If you want to exclude holidays also, find a suitable factory calender id which has holiday calender id also included. In my system i could find one factory calender say US.


Pass I_DATAB as 01.01.2007
         I_DATBI as 31.12.2007
         I_FACTID as 'Z1' 

The FM will return all the days in an internal tbl. To get the count of the days, get the number of records returned in the internal table by using

 DESCRIBE <tbl> LINES <lines> 

.

Hope this helps. Reward points if helpful.

Thanks

Balaji

Read only

Former Member
0 Likes
6,190

This message was moderated.