2009 Jan 08 3:58 PM
Hello friends,
I have a requirement to add no of days to the factory calender working days.
date format: MM/DD/YYYY
for example: when I give date : 12/31/2008
no of days : 1
result should be 01/02/2009
Is there any function module for this. pls help me.
for your information: itried some of the function modules but no use.
WDKAL_DATE_ADD_FKDAYS
BKK_ADD_WORKINGDAY
Thanks
Regards
Raghu
2009 Jan 08 4:11 PM
Hi..
To any date type variable you can directly add days and it will give you that date..
DATA wa_date TYPE sy-datum.
wa_date = '20090108'.
wa_date = wa_date + 3.
write wa_date. " here wa_date will be 11/01/2009
Hope this helps you.
2009 Jan 08 4:15 PM
No my question is ...
add no of days to the factory calender working days and it should not consider holidays.
date format: MM/DD/YYYY
for example: when I give date : 12/31/2008
no of days : 1
since january first is holiday...result should be 01/02/2009
this function module is not checking holidays other than saturday and sunday. WDKAL_DATE_ADD_FKDAYS
Is there any other function module for this. pls help me.
Thanks
Regards
Raghu
2009 Jan 08 4:19 PM
2009 Jan 08 4:22 PM
the following code will work .
PARAMETER : p_date TYPE scal-date,
p_days(3) TYPE n .
DATA : ind TYPE scal-indicator ,
new_date TYPE scal-date.
DO.
IF p_days > 0 .
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
correct_option = '+'
date = p_date
factory_calendar_id = '01'
IMPORTING
date = new_date
workingday_indicator = ind
EXCEPTIONS
calendar_buffer_not_loadable = 1
correct_option_invalid = 2
date_after_range = 3
date_before_range = 4
date_invalid = 5
factory_calendar_not_found = 6
OTHERS = 7.
IF sy-subrc EQ 0.
p_date = new_date .
IF ind EQ space.
p_date = p_date + 1.
ENDIF.
ENDIF.
p_days = p_days - 1 .
ELSE.
EXIT.
ENDIF.
ENDDO.
WRITE p_date.
Thanks,
Adi
2009 Jan 08 4:28 PM
2009 Jan 13 11:17 AM
Hi Raghunath,
Try it this way.
Parameters:
p_days type i,
p_date like sy-datum.
Data:
w_factorydate like scal-facdate,
w_finaldate like sy-datum.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
* CORRECT_OPTION = '+'
date = p_date
factory_calendar_id = 'IN'
IMPORTING
* DATE =
FACTORYDATE = w_factorydate
* WORKINGDAY_INDICATOR =
EXCEPTIONS
CALENDAR_BUFFER_NOT_LOADABLE = 1
CORRECT_OPTION_INVALID = 2
DATE_AFTER_RANGE = 3
DATE_BEFORE_RANGE = 4
DATE_INVALID = 5
FACTORY_CALENDAR_NOT_FOUND = 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.
ENDIF.
w_factorydate = w_factorydate + p_days.
CALL FUNCTION 'FACTORYDATE_CONVERT_TO_DATE'
EXPORTING
factorydate = w_factorydate
factory_calendar_id = 'IN'
IMPORTING
DATE = w_finaldate
EXCEPTIONS
CALENDAR_BUFFER_NOT_LOADABLE = 1
FACTORYDATE_AFTER_RANGE = 2
FACTORYDATE_BEFORE_RANGE = 3
FACTORYDATE_INVALID = 4
FACTORY_CALENDAR_ID_MISSING = 5
FACTORY_CALENDAR_NOT_FOUND = 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.
ENDIF.
Write:/
w_finaldate.
With luck,
Pritam.
2009 Jan 13 11:32 AM
HI,
Refer to this link
[FM related to Data calculations|https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/functionModulerelatedonDate+calculations]