Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How do I Raise Exception in an ABAP OO method and see error in workflow log

Hello All,

Here is what I am trying to do: ECC 6, basis release 7, support pack 15

I am developing approval workflows for purchasing documents. We decided to use ABAP OO rather than BOR objects and have had good luck to this point. All we have left to do at this point is get the error messages to show up in the workflow log. I would like to be able to see them when I drill down on the workflow technical log to the details tab of the workitem and when go in to check workflow errors. Normally we would be able to se the error text/message or what ever we had put in the return structure.

Here is a sample of the code we have developed

DATA: BEGIN OF ls_pa0001,

mstbr TYPE mstbr,

begda TYPE begda,

END OF ls_pa0001,

lt_pa0001 LIKE TABLE OF ls_pa0001,

lw_userid TYPE syuname,

ls_agent LIKE gs_agent,

BEGIN OF ls_userid,

usrid TYPE sysid,

begda TYPE begda,

END OF ls_userid,

lt_userid LIKE TABLE OF ls_userid,

l_oref TYPE REF TO cx_root,

l_textid LIKE if_t100_message=>t100key,

result TYPE string,

lw_msg TYPE swf_t100ms,

lw_log TYPE swf_logctx.

CLEAR: et_agent.

LOOP AT it_agent INTO gs_agent.

  • strip out the user id

CLEAR: lw_userid.

lw_userid = gs_agent+2(12).

CLEAR: gw_pernr.

CALL METHOD zcl_mpr_wf=>get_pernr


iw_userid = lw_userid.

  • Get the supervisor area

CLEAR: lt_pa0001.

SELECT mstbr begda

FROM pa0001

INTO TABLE lt_pa0001

WHERE pernr = gw_pernr

AND begda LE sy-datum

AND endda GE sy-datum.

  • Get the most current record

SORT lt_pa0001 BY begda DESCENDING.

READ TABLE lt_pa0001 INTO ls_pa0001 INDEX 1.

IF sy-subrc = 0 AND ls_pa0001-mstbr IS NOT INITIAL.

gw_pernr = ls_pa0001-mstbr.

  • get the userid linked to the pernr

SELECT usrid begda

FROM pa0105

INTO TABLE lt_userid

WHERE pernr = gw_pernr

AND usrty = '0001'.

  • Get the most current record

SORT lt_userid BY begda DESCENDING.

READ TABLE lt_userid INTO ls_userid INDEX 1.

  • convert to agent format

CONCATENATE 'US' ls_userid-usrid INTO ls_agent.

APPEND ls_agent TO et_agent.



CHECK sy-subrc <> 0 OR ls_pa0001-mstbr IS INITIAL.

CLEAR: gs_return.

MESSAGE i001 WITH lw_userid.



type = 'E'

cl = sy-msgid

number = sy-msgno

par1 = sy-msgv1

par2 = sy-msgv2

par3 = sy-msgv3

par4 = sy-msgv4


return = gs_return.

APPEND gs_return TO et_return.

l_textid-msgid = 'ZMPR_WF'.

l_textid-msgno = '001'.

l_textid-attr1 = lw_userid.

  • lw_msg-msgid = 'ZMPR_WF'.

  • lw_msg-msgty = 'E'.

  • lw_msg-msgno = '001'.

RAISE EXCEPTION TYPE cx_swf_app_log_error

EXPORTING textid = l_textid.

  • t100_msg = lw_msg.


  • sy-msgty = 'E'.

  • sy-msgno = '001'.

  • sy-msgid = 'ZMPR_WF'.

CATCH cx_swf_app_log_error INTO l_oref.

result = l_oref->get_text( ).

CALL METHOD cl_hrrcf_exception_handler=>write_exception_log


ex = l_oref.

  • MESSAGE e001 WITH lw_userid.




CX_SWF_APP_LOG_ERROR is specified as an exception for our method

IF_WORKFLOW is there and all methods are active.

We have read through the postings by Jocelyn Dart - very well done - but do not cover exceptions.

If anyone can help us get this working it would be graeatly appreciated.

Thanks in advance,


Former Member

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question