Skip to Content

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 symsgid TYPE symsgty NUMBER symsgno WITH symsgv1 symsgv2 symsgv3 symsgv4 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

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply