In a class-based Workflow when an error occurs with the RAISING statement, the error message data can be sent to the Workflow.
Examples
Traditional
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING error_occurred.
With Error Class
RAISE EXCEPTION TYPE ZCX_BO_ERROR_WITH_MESSAGE EXPORTING textid = ls_message.
In the Workflow, this error message is not directly available - however, usually, it is a good idea to show the error message to the user.
Workaround
- From the workflow task, we will need the workitem ID.
- We need to define in the container a workitem ID to hold this data:
WorkitemID with type SWW_WIID - We need to bind the workitem ID in the Workflow task:
From &_WORKITEM.WORKITEMID&
To &WORKITEMID& - Then we have to write a method in the Workflow class to call FM SWL_WI_HEADER_READ:
CALL FUNCTION 'SWL_WI_HEADER_READ'
EXPORTING
wi_id = WorkitemID
ACT_LANGU = SY-LANGU
I_ONLY_HEAD_STATUS_TYPE = ' '
changing
workitem = ls_workitem
EXCEPTIONS
WORKITEM_NOT_FOUND = 1
OTHERS = 2
The error message is in the fields:
ls_workitem-code
ls_workitem-errortype
ls_workitem-name
ls_workitem-workarea
ls_workitem-message
ls_workitem-variable1
ls_workitem-variable2
ls_workitem-variable3
ls_workitem-variable4
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.