‎2005 Dec 23 7:51 AM
Need a sample program, which gives the number of days between the given date range excluding the weekends.
eg: suppose is give start date is: 16.12.2005 and end date as: 21.12.2005, it should display 19.12.2005, 20.12.2005, 21.12.2005, leaving 17.12.2005 and 18.12.2005, because these two days are saturday and sunday.
For this example i need the ouput as 3.
‎2005 Dec 23 8:09 AM
Hi Anitha,
1. DATE_CHECK_WORKINGDAY
This is one useful FM
2. Try this code (just copy paste)
IT DOES EXACTLY WHAT U REQUIRE.
REPORT abc.
data : num type i.
parameters : frdate type sy-datum default '20051216'.
parameters : todate type sy-datum default '20051221'.
perform getinfo using frdate todate changing num.
break-point.
&----
*& 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
I hope it helps.
Regards,
Amit M.
‎2005 Dec 23 8:06 AM
Hi Anitha
you will need to convert to factory date and to make the minus beetween the two values.
For that, you will need to use a calendar.
FM : DATE_CONVERT_TO_FACTORYDATE
Rgd
Frédéric
‎2005 Dec 23 8:09 AM
Hi Anitha,
1. DATE_CHECK_WORKINGDAY
This is one useful FM
2. Try this code (just copy paste)
IT DOES EXACTLY WHAT U REQUIRE.
REPORT abc.
data : num type i.
parameters : frdate type sy-datum default '20051216'.
parameters : todate type sy-datum default '20051221'.
perform getinfo using frdate todate changing num.
break-point.
&----
*& 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
I hope it helps.
Regards,
Amit M.
‎2005 Dec 23 10:20 AM
here the function module will be called 100 time , if the difference which will reduce the performance. can u suggest some other way.
‎2005 Dec 23 10:23 AM
Hi Anitha,
1. other than FM we don't have any way
to find out saturday sunday.
2. There is no command/statement in abap.
3. DON'T WORRY ABOUT PERFROMANCE.
100 TIMES IS NOTHING.
EVEN 1000 TIMES CALLING THIS FM
won't be much strain on the server.
regards,
amit m.
‎2005 Dec 23 8:10 AM