Hello Experts,
Request your inputs for my query .
Requirement : Fetch all the agents maintained in Z table based on Purchase Group in background task in activity step and assign to Agent container element and then it would proceed to User Decision Step.
However, if no agent is found the workflow should result in error . Hence I am using a condition step for checking if agent is found null then it proceeds to another activity task which has a method and a function module SAP_WAPI_SET_WORKITEM_STATUS is called to set the status of workitem to ERROR.
Please see the code below:
swc_get_element container '_Workitem' lobject.
swc_get_property lobject 'Workitemid' id.
CALL FUNCTION 'SAP_WAPI_SET_WORKITEM_STATUS'
EXPORTING
workitem_id = lcl_l_wid
status = 'ERROR' "status "error'
* user = sy-uname
* language = sy-langu
do_commit = ' '
check_inbox_restriction = ' '
IMPORTING
new_status = stat
return_code = ret_code
TABLES
message_lines = msg_lines
message_struct = msg_str.
ISSUE: Its able to get a workitem ID but it gives return code 900 and message 'Cannot call SAP_WAPI_SET_WORKITEM_STATUS in this context. It runs fine when I try in SE37 .
Please help with your valuable inputs. Thanks !!