Dear expert,
In a leave workflow for HCM ( Time Module ), we are supposed to send the a notification to the approver if he doesn't approve the workitem after certain days ( only notification --- no need to send workitem ). These certain days come from a customized table; we can't maintain no of days in Latest End or in Requested End statically. Based on above requirements, we have already written a program exit and tried to fetch the days from the table. These days are updated in an internal table correctly. But at the last step when we call function module SWW_WI_DEADLINES_CHANGE, the sy-subrc's value becomes 3. Values don't get updated. I am not able to get why this is happening. Would you please guide me about the same ? Below is snippet from the program exit.
CALL METHOD wi_context->get_header
RECEIVING
re_workitem_header = lcl_s_wihead.
***---Get Work item ID
CALL METHOD wi_context->get_workitem_id
RECEIVING
re_workitem = workitem_id.
*--Get deadlines
CALL METHOD wi_context->get_deadlines
IMPORTING
desired_end = des_end
latest_end = lat_end
desired_start = des_start.
lv_wi_id = lcl_s_wihead-wi_id.
lv_wi_cd = lcl_s_wihead-wi_cd.
lv_wi_ct = lcl_s_wihead-wi_ct.
CLEAR : lv_time, lv_time1,ex_date,ex_date1,ex_time,ex_time1.
IF lat_end IS NOT INITIAL.
lv_time = lat_end-time_in . "Latest end
lv_date = lat_end-date_in.
ENDIF.
IF des_end IS NOT INITIAL.
lv_time1 = des_end-time_in. "Requested end
lv_date1 = des_end-date_in.
ENDIF.
SELECT * FROM zhr_deadline CLIENT SPECIFIED
INTO TABLE it_zhr_deadline
WHERE mandt EQ sy-mandt.
IF sy-subrc EQ 0.
*---latest end
CLEAR: wa_zhr_deadline.
READ TABLE it_zhr_deadline INTO wa_zhr_deadline WITH KEY zdeadline_type = 'LE'.
IF sy-subrc EQ 0.
CLEAR : lv_days.
lv_days = wa_zhr_deadline-zdays.
IF lv_days IS NOT INITIAL.
l_date = lv_date + lv_days - 1.
ELSE.
l_date = lv_date - 1.
ENDIF.
CLEAR : lv_tim.
lv_tim = wa_zhr_deadline-ztime.
IF lv_tim IS NOT INITIAL.
CALL FUNCTION 'DIMP_ADD_TIME'
EXPORTING
iv_starttime = lv_time
iv_startdate = lv_date
iv_addtime = lv_tim
IMPORTING
ev_enddate = ex_date
ev_endtime = ex_time.
ELSE.
ex_time = lv_time.
ENDIF.
ENDIF.
*---requested end
CLEAR wa_zhr_deadline.
READ TABLE it_zhr_deadline INTO wa_zhr_deadline WITH KEY zdeadline_type = 'DE'.
IF sy-subrc EQ 0.
CLEAR: lv_days.
lv_days = wa_zhr_deadline-zdays.
IF NOT lv_days IS INITIAL.
l_date1 = lv_date1 + lv_days - 1.
ELSE.
l_date1 = lv_date1 - 1.
ENDIF.
CLEAR : lv_tim.
lv_tim = wa_zhr_deadline-ztime.
IF lv_tim IS NOT INITIAL.
CALL FUNCTION 'DIMP_ADD_TIME'
EXPORTING
iv_starttime = lv_time1
iv_startdate = lv_date1
iv_addtime = lv_tim
IMPORTING
ev_enddate = ex_date1
ev_endtime = ex_time1.
ELSE.
ex_time1 = lv_time1.
ENDIF.
ENDIF.
ENDIF.
REFRESH lt_deadline.
IF lat_end IS NOT INITIAL.
CLEAR: w_deadline.
w_deadline-wi_dattype = 'LE'. "Latest end
w_deadline-wi_date = l_date.
w_deadline-wi_time = ex_time.
w_deadline-wi_action = 'SWW_WI_DEADLINE_CALLBACK'.
APPEND w_deadline TO lt_deadline.
ENDIF.
IF des_end IS NOT INITIAL.
CLEAR : w_deadline.
w_deadline-wi_dattype = 'DE'. "Requested end
w_deadline-wi_date = l_date1.
w_deadline-wi_time = ex_time1.
w_deadline-wi_action = 'SWW_WI_DEADLINE_CALLBACK'.
APPEND w_deadline TO lt_deadline.
ENDIF.
CALL FUNCTION 'SWW_WI_DEADLINES_CHANGE'
EXPORTING
wi_id = lv_wi_id
do_commit = 'X'
* AUTHORIZATION_CHECKED = ' '
* PRECONDITIONS_CHECKED = ' '
* DEADLINES_CHECKED = ' '
* IMPORTING
* DEADLINES_EXIST =
TABLES
deadline_attributes = lt_deadline
EXCEPTIONS
no_authorization = 1
invalid_type = 2
update_failed = 3
invalid_status = 4
OTHERS = 5
.
IF sy-subrc <> 0.
CALL FUNCTION 'DEQUEUE_E_WORKITEM'
EXPORTING
wi_id = lv_wi_id. "swldy_list-wi_id.
ENDIF.