I was in the need to offer some more detailed information to the workflow-administrator when processing a workitem exit. A single "message" wasn't sufficient, and storing the result in the workitem container could be an option, but it wasn't that obvious to the user, although some additional information was stored in that container, too.
So I chose to add some entries to the technical workflow protocol on the step, I was working with, and this is, how it can be done with ECC 6.00 and up.
If you need to add an exception text, when a workitem runs into (a temporary) error, I suggest that you read one of my previous blog posts: http://scn.sap.com/community/bpm/business-workflow/blog/2013/04/25/use-exceptions-in-abap-oo-workflo...
First of all you need to get the work item context. Within a work item exit class, this is already provided by the event interface: IF_SWF_IFS_WORKITEM_EXIT~EVENT_RAISED has the importing parameter im_workitem_context. So you're going to use that one.
If you're within the processing step of a work item you first need to retrieve the currently active workitem-ID and from that you need to get the context.
DATA: lv_current_workitem_ID TYPE SWOTOBJID-OBJKEY,
lv_workitem_ID TYPE SWW_WIID.
* *********************************************************************
* * Retrieve the currently active workitem, which is being executed *
* *********************************************************************
CALL METHOD cl_swf_evt_requester=>get_workitem
IMPORTING
EX_WORKITEM_ID = lv_current_workitem_ID.
IF NOT lv_current_workitem_ID IS INITIAL. "workitem found
lv_workitem_id = lv_current_workitem_ID. "I love it, that you always
"have different data elements in use
* *********************************************************************
* * Get the ABAP OO instance of that working object *
* *********************************************************************
"Retrieve the workitem handle
DATA: lo_workitem_handle TYPE REF TO IF_SWF_RUN_WIM_INTERNAL.
TRY.
CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
EXPORTING
im_wiid = lv_workitem_id
im_read_for_update = ' '
RECEIVING
re_instance = lo_workitem_handle.
CATCH CX_SWF_RUN_WIM_ENQ_FAILED. "Enqueue error
EXIT.
CATCH CX_SWF_RUN_WIM_READ_FAILED. "Read failed
EXIT.
CATCH CX_SWF_RUN_WIM. "System exception
EXIT.
ENDTRY.
* *********************************************************************
* * Retrieve the context, as we need to use this for logging *
* *********************************************************************
DATA: lo_current_workitem_context TYPE REF TO IF_WAPI_WORKITEM_CONTEXT.
lo_current_workitem_context = lo_workitem_handle->get_workitem_context( ).
IF NOT lo_current_workitem_context IS INITIAL.
"There it is...
And then you simply give a short message (up to 30 characters are possible) to the technical protocol, and the message-reference, so that the user can click on the traffic light and can retrieve further detailed information and the long text of that message, too.
* *********************************************************************
* * Add a technical detail log message through the context.
* * Within a workitem-exit you can directly use the given context.
* *********************************************************************
DATA: lv_message_text TYPE CHAR30,
ls_message TYPE SWR_MSTRUC.
MESSAGE I101(WF) WITH 'Testing world' INTO lv_message_text.
"Transfer the system elments now into the log structure
ls_message-MSGID = sy-msgid.
ls_message-MSGTY = sy-msgty.
ls_message-MSGNO = sy-msgno.
ls_message-MSGV1 = sy-msgv1.
ls_message-MSGV2 = sy-msgv2.
ls_message-MSGV3 = sy-msgv3.
ls_message-MSGV4 = sy-msgv4.
lo_current_workitem_context->set_message_to_log( im_function = lv_message_text
im_message = ls_message ).
"The commit don't needs to be requested here (within the workitem execution),
"as we expect the commit after ending the current execution.
"However, you may have to adapt that.
... as one example.
Take care.
Florin Wach
Systems-Integration
SAP Business Workflow Senior-Expert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
10 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |