‎2007 Nov 12 8:29 AM
Hi can anyone psl give me code for the below reqiremet
if i give a date range i need the diff between that dates excluding non-working days so by using FM DATE_CHECK_WORKINGDAY any pls help me
‎2007 Nov 12 8:39 AM
&----
*& Form BILLING_DAY_IS_WORKING_DAY
&----
Using the date passed in next_date, verify that the date is
a working day in the factory calendar the user specifies. This form
calls the standard ABAP function for determining if a date is a
"working day". The function first determines if the day of the week
corresponding to the calendar date entered is a billing day. Then
it checks to see if the calendar date is a holiday. If either are
true the date_no_workingday flag is passed back as "X" and this
routine passes back "X" to the calling routine in the parameter
p_billing_flag.
----
FORM CURRENT_DAY_IS_WORKING_DAY USING P_NEXT_DATE TYPE D
CHANGING P_NOT_BILLING_DAY TYPE C.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
DATE = P_NEXT_DATE
FACTORY_CALENDAR_ID = FACTCALD
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.
CASE SY-SUBRC.
WHEN '0'.
CLEAR P_NOT_BILLING_DAY.
WHEN '4'.
IF SY-DATUM > CURRENT_BDATE.
P_NOT_BILLING_DAY = SPACE.
ELSE.
P_NOT_BILLING_DAY = 'X'.
ENDIF.
WHEN OTHERS.
CONCATENATE: 'Error Accessing Calendar with ID: ' FACTCALD
INTO ZZMSG_TAB2.
APPEND ZZMSG_TAB2.
CLEAR ZZMSG_TAB2.
V_LEVEL = 'E'.
PERFORM F_ERROR_MESSAGE.
MESSAGE E305 WITH FACTCALD.
ENDCASE.
ENDFORM. " BILLING_DAY_IS_WORKING_DAY
&----
*& Form BILLING_DAY_IS_WORKING_DAY
&----
Using the date passed in next_date, verify that the date is
a working day in the factory calendar the user specifies. This form
calls the standard ABAP function for determining if a date is a
"working day". The function first determines if the day of the week
corresponding to the calendar date entered is a billing day. Then
it checks to see if the calendar date is a holiday. If either are
true the date_no_workingday flag is passed back as "X" and this
routine passes back "X" to the calling routine in the parameter
p_billing_flag.
----
FORM BILLING_DAY_IS_WORKING_DAY USING P_NEXT_DATE TYPE D
CHANGING P_NOT_BILLING_DAY TYPE C.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
DATE = P_NEXT_DATE
FACTORY_CALENDAR_ID = FACTCALD
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.
CASE SY-SUBRC.
WHEN '0'.
CLEAR P_NOT_BILLING_DAY.
WHEN '4'.
P_NOT_BILLING_DAY = 'X'.
WHEN OTHERS.
CONCATENATE: 'Error Accessing Calendar with ID: ' FACTCALD
INTO ZZMSG_TAB2.
APPEND ZZMSG_TAB2.
CLEAR ZZMSG_TAB2.
V_LEVEL = 'E'.
PERFORM F_ERROR_MESSAGE.
MESSAGE E305 WITH FACTCALD.
ENDCASE.
ENDFORM. " BILLING_DAY_IS_WORKING_DAY
Reward points if useful
‎2007 Nov 12 8:42 AM
hi,
use the following code
data:startdate like sy-datum,
enddate like sy-datum.
no_of_dates = (enddate - startdate) - noofnonworking days.
use the FM for getting the noofnonworking dates.
Please reward me the points if you find this will solve your purpose.
‎2007 Nov 12 8:56 AM
is there any FM for finding the noof nonworking days between dates
‎2007 Nov 12 9:04 AM
Hi Chaaya ,
You can find the <b>number of working days</b> using the Fm "WDKAL_DATE_ADD_FKDAYS".
Reward If Useful.
Regards,
Chitra
‎2007 Nov 12 9:31 AM
Hi
I wrote small program to find diff between working days and non working days...
...because in your case you must use Factory calendar so better option is
DATE_CHECK_WORKINGDAY.
check this..
DATA : date LIKE scal-date.
SELECT-OPTIONS : s_date FOR sy-datum.
DATA: non_work_days TYPE i,
work_days TYPE i,
tot_days TYPE i.
CHECK s_date-high IS NOT INITIAL .
date = s_date-low.
DO.
ADD 1 TO tot_days.
CHECK date IN s_date.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
date = date
factory_calendar_id = 'VC' "your factory calendar id
message_type = 'S'
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
ADD 1 TO work_days.
ENDIF.
date = date + 1.
ENDDO.
non_work_days = tot_days - work_days.
WRITE :/ work_days, tot_days, non_work_days.
‎2007 Nov 12 9:37 AM