on 05-07-2009 3:40 PM
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
EXPORTING
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.
ELSE.
TRY.
CHECK sy-subrc <> 0 OR ls_pa0001-mstbr IS INITIAL.
CLEAR: gs_return.
MESSAGE i001 WITH lw_userid.
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
type = 'E'
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
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
EXPORTING
ex = l_oref.
MESSAGE e001 WITH lw_userid.
ENDTRY.
ENDIF.
ENDLOOP.
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,
Jeff
The SAP Online help is fairly clear about how to use ABAP OO exceptions in workflow.
See at the bottom of [this section of the help|http://help.sap.com/saphelp_nw2004s/helpdata/en/df/cea92eb23d1f4a9ce74dfaf6e3d698/content.htm].
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is an article under workflows section available on SAPTECHNICAL.COM.
Hope that gives you an fair idea how to handle exceptions.
Edited by: sanju on May 8, 2009 11:29 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the code samples given in this [Article|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f86c9290-0201-0010-7a93-dda3716dc0d2].
Regards,
Surjith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.