‎2008 Aug 07 5:45 PM
Hello
I have written this routine in which I am calculating the difference between 2 days and then calculating how many holidays were there between those dates. The I am subtracting the total difference with the number of holidays to calculate the number of wokign days.
But when I am loading my data I am getting this error
Exceptions in Substep: Rules and it points at this line CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
Please can someone explain
Here is the code which i have written.
data: no_days type I,
no_holi type I,
l_day TYPE /BI0/OICRMPOSTDAT.
data: no_holidays type table of ISCAL_DAY.
MOVE SOURCE_FIELDS-CRMPOSTDAT to l_day.
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = l_day
TIME1 =
DATE2 = sy-datum
TIME2 =
IMPORTING
DATEDIFF = no_days
TIMEDIFF =
EARLIEST =
EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2
.
CALL FUNCTION 'HOLIDAY_GET'
EXPORTING
HOLIDAY_CALENDAR = ' '
FACTORY_CALENDAR = 'GB'
DATE_FROM = l_day
DATE_TO = SY-DATUM
IMPORTING
YEAR_OF_VALID_FROM =
YEAR_OF_VALID_TO =
RETURNCODE =
TABLES
HOLIDAYS = no_holidays
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
DATE_HAS_INVALID_FORMAT = 3
DATE_INCONSISTENCY = 4
OTHERS = 5
.
describe table no_holidays lines no_holi.
RESULT = no_days - no_holi.
‎2008 Aug 07 6:10 PM
‎2008 Aug 07 9:17 PM
An easy way to do this:
********************************************************************************
do.
if date1 ge date2.
exit.
endif.
date1 = date1 + 1.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
DATE = date1
FACTORY_CALENDAR_ID = calender_id
IMPORTING
WORKINGDAY_INDICATOR = workday_flag.
if workday_flag = ' '. "Day is a workday
day_count = day_count + 1.
endif.
enddo.
********************************************************************************
The variable day_count will have the number of workdays.
Hope this helps.
Jerrod Baldauf