Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 

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

  1. From the workflow task, we will need the workitem ID.
  2. We need to define in the container a workitem ID to hold this data:
    WorkitemID with type SWW_WIID
  3. We need to bind the workitem ID in the Workflow task:
    From     &_WORKITEM.WORKITEMID&
    To         &WORKITEMID&
  4. 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

Labels in this area