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: 

Get number of work days of factory calendar

dschiener
Participant
1,402

Hi there,

I want to get the number of work days (days without weekend and holidays) based on both, a factory calendar and a year (or date period).

So regarding transaction scal I would simply like to get as result 248 for year 2023:
(Or 117 when asking for free days)

I would like to know if there is any FM that returns exactly the data from the upper screenshot?

To determine 248 days I could use FM DURATION_DETERMINE or WLB3_GET_NUMBER_OF_WORKDAYS, whereby WLB3_GET_NUMBER_OF_WORKDAYS did not work for me. And DURATION_DETERMINE performs a lot of calculation stuff, which, I don't know, might not be needed if there is a possibility to simply read the static value of 248 from factory calendar...

I am sorry, because I know this question has been asked a lot in the community.
But none of the proposed solutions makes me really happy...

BR

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
1,299

You have the official function modules to convert a date into an integer number called the "factory date": in one factory calendar, the number of <day right after date> = the number of <date> +1.

To get the number of dates in one year, of a given factory calendar, you get the numbers of 01/01/YYYY and 01/01/YYYY+1, and you subtract them.

Released function modules:

  • FACTORYDATE_CONVERT_TO_DATE
  • DATE_CONVERT_TO_FACTORYDATE
5 REPLIES 5

Sandra_Rossi
Active Contributor
1,300

You have the official function modules to convert a date into an integer number called the "factory date": in one factory calendar, the number of <day right after date> = the number of <date> +1.

To get the number of dates in one year, of a given factory calendar, you get the numbers of 01/01/YYYY and 01/01/YYYY+1, and you subtract them.

Released function modules:

  • FACTORYDATE_CONVERT_TO_DATE
  • DATE_CONVERT_TO_FACTORYDATE

1,299

Thank you sandra.rossi, that worked for me!

Very interesting. I knew the FMs by name but haven't worked with them so far.

0 Kudos
1,299

In your other comment, you are saying that in fact you don't want to consider exactly your factory calendar, but to add the holidays which "match a week days from Monday to Friday", and you are proposing to determine it using HOLIDAY_GET + any known logic to get the week days out of these dates.

I guess it's the easiest way.

dschiener
Participant
0 Kudos
1,299

In my use case I have to determine the number of work days in a time period, e.g. in 1 year.

When I use the solution based on the upper proposed FM DATE_CONVERT_TO_FACTORYDATE, it returns the number of work days minus holidays that match a week day from Monday to Friday.

That behavior is caused by the fact that our default factory calendar references our holiday calendar, too.

So in general, I would like to determine the number of work days including holidays that match a week days from Monday to Friday.


I could create a solution by using FM HOLIDAY_GET, and determine the number of holidays that do not match a free day. But maybe there is a better more efficient solution around? sandra.rossi, maybe you do have a recommendation here, too?

BR

0 Kudos
1,299

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.