But to add a message in general, only the workitem context is needed. If you got the context, just use method set_message_to_log.
* context type: im_workitem_context TYPE REF TO if_wapi_workitem_context
" text in im_function will be displayed in workitem log (max char30),
" message in im_message will give further information when clicking on the traffic light (max char 70).
im_workitem_context->set_message_to_log( im_function = |Forward: Mail { var }|
im_message = VALUE #( msgid = '00'
msgty = 'S'
msgno = '000'
msgv1 = |var 1|
msgv2 = |var 2| ) ).
* In some cases "COMMIT WORK" is needed.