‎2006 Mar 07 10:50 AM
How to capture errors when a Function module is called as BACKGROUND TASK?.Please advise.
FUNCTION ZRPM_DELETE_PROJECT_DATA_API.
*"----
""Local interface:
*" IMPORTING
*" VALUE(IV_EXTERNAL_ID) TYPE RPM_TV_EXTID OPTIONAL
*" VALUE(IV_PROJECT_GUID) TYPE RPM_TV_GUID OPTIONAL
*" VALUE(FLAG) TYPE BOOLEAN OPTIONAL
*" EXPORTING
*" VALUE(EV_RC) TYPE I
*" VALUE(EV_MSG) TYPE STRING
*" VALUE(ET_MSG) TYPE RPM_TT_MESSAGES
*"----
IF flag = cl_rpm_co=>sc_true.
Call function 'RPM_DELETE_PROJECT_DATA' IN BACKGROUND TASK
EXPORTING
IV_EXTERNAL_ID = IV_EXTERNAL_ID
IV_PROJECT_GUID = IV_PROJECT_GUID
IMPORTING
EV_RC = EV_RC
EV_MSG = EV_RC
ET_MSG = ET_MSG.
COMMIT WORK.
ELSE.
CALL FUNCTION 'RPM_DELETE_PROJECT_DATA'
EXPORTING
IV_EXTERNAL_ID = IV_EXTERNAL_ID
IV_PROJECT_GUID = IV_PROJECT_GUID
IMPORTING
EV_RC = EV_RC
EV_MSG = EV_MSG
ET_MSG = ET_MSG.
ENDIF.
ENDFUNCTION.
In above code how to capture 'EV_RC' when FM is called as background task.
‎2006 Mar 07 12:23 PM
I'm not sure if it's valid for BACKGROUND TASK also, but you might try with exception ERROR_MESSAGE:
<i>ERROR_MESSAGE: This exception instructs the system to ignore S messages, I messages, and W messages until return from the function module (although they still appear in the log during background processing). When an E message or an A message occurs, the called function module terminates, as if the exception ERROR_MESSAGE has been triggered. If an A message is handled using ERROR_MESSAGE, the ROLLBACK WORK statement is triggered implicitly.</i>
Peter
‎2006 Mar 07 10:57 AM
Prakash,
I guess that is the flip side of calling a function as a background task. Whenever the task fails, the user will get an intimation in his Inbox.
Regards,
Ravi
‎2006 Mar 07 11:01 AM
Hi,
Please have look in the below document. You need to some settings in the debugger.
‎2006 Mar 07 12:23 PM
Hi Prakash,
Refer to the link
<a href="http://help.sap.com/saphelp_erp2005/helpdata/en/41/7af4e0a79e11d1950f0000e82de14a/frameset.htm">call function in update task</a>
Hope it helps...
Lokesh
‎2006 Mar 07 12:23 PM
I'm not sure if it's valid for BACKGROUND TASK also, but you might try with exception ERROR_MESSAGE:
<i>ERROR_MESSAGE: This exception instructs the system to ignore S messages, I messages, and W messages until return from the function module (although they still appear in the log during background processing). When an E message or an A message occurs, the called function module terminates, as if the exception ERROR_MESSAGE has been triggered. If an A message is handled using ERROR_MESSAGE, the ROLLBACK WORK statement is triggered implicitly.</i>
Peter
‎2006 Mar 07 1:00 PM
Prakash,
CALL FUNCTION IN BACKGROUND TASK allows no IMPORTING parameters, so that your code will produce a syntax error.
The calling program can only handle errors of remote function calls (RFC) if these are either
- synchronous RFC (that is CALL FUNCTION ... DESTINATION ...) or
- asynchronous RFC (that is CALL FUNCTION STARTING NEW TASK ... DESTINATION ...).
Both synchronous and asynchronous RFC allow the capturing of errors by means of exceptions. But that is a different topic.