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: 

problem with factory calender days calculation

Former Member
0 Kudos

Hi

I have created a simple test program for calculating the number of working days between two dates:

report ztestalok.

data : to_date_fact like SCAL-FACDATE,

from_date_fact like SCAL-FACDATE.

parameters: fr_date like SCAL-DATE,

to_date like SCAL-DATE.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'

EXPORTING

CORRECT_OPTION = '+'

DATE = fr_date

FACTORY_CALENDAR_ID = '01'

IMPORTING

FACTORYDATE = from_date_fact

.

CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'

EXPORTING

CORRECT_OPTION = '+'

DATE = to_date

FACTORY_CALENDAR_ID = '01'

IMPORTING

FACTORYDATE = to_date_fact

.

data: days type i.

days = to_date_fact - from_date_fact.

Write: 'The number of days = ', days.

The output is correct if i run this report for the whole year of 2006, however if i run this for january, feb month wise, the report is not giving the correct number of days.

I am totally puzzled. Pl help with your inputs.

Regards

Alok Pathak

3 REPLIES 3

suresh_datti
Active Contributor
0 Kudos

Hi Alok,

PL change CORRECT_OPTION = '-' in the second call ie when converting the 'to date' and you should be OK. ie because if you put '+' it goes to next work day if the date you passed is a Factory Holiday..

Regards,

Suresh Datti

0 Kudos

it doesn't solve the problem, i passed CORRECT_OPTION = '-', and it is working fine if the day is not working day (january 2006) but it doesn't work fine for the month where the date is a working day (feb 2006)

pl let me know where the problem is

Former Member
0 Kudos

Hi alok,

1. Not only the num of working days,

but also the list of all days (dates)

we can get.

2. I have another FM.

3. Just copy paste in new program.

(it will ask for two dates, by default is jan 2006)

then on execution,

it will list out all the 21 working days (in case of jan2006)

4.

REPORT abc.

data : num type i.

parameters : frdate type sy-datum default '20060101'.

parameters : todate type sy-datum default '20060131'.

perform getinfo using frdate todate changing num.

write 😕 ' Total Days ' , num.

&----


*& Form getinfo

&----


  • text

----


FORM getinfo USING fromdate todate CHANGING numofdays type i.

DATA : d TYPE sy-datum.

d = fromdate - 1.

DO.

d = d + 1.

IF d > todate.

EXIT.

endif.

CALL FUNCTION 'DATE_CHECK_WORKINGDAY'

EXPORTING

date = d

factory_calendar_id = '01'

message_type = 'I'

EXCEPTIONS

date_after_range = 1

date_before_range = 2

date_invalid = 3

date_no_workingday = 4

factory_calendar_not_found = 5

message_type_invalid = 6

OTHERS = 7.

IF sy-subrc = 0.

numofdays = numofdays + 1.

write 😕 d.

ENDIF.

ENDDO.

ENDFORM. "getinfo

regards,

amit m.