Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to capture errors when a Function module is called as BACKGROUND TASK

Former Member
0 Likes
3,108

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.

1 ACCEPTED SOLUTION
Read only

Peter_Inotai
Active Contributor
0 Likes
1,420

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,420

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

Read only

venkata_ramisetti
Active Contributor
0 Likes
1,420

Hi,

Please have look in the below document. You need to some settings in the debugger.

http://www.sappro.com/downloads/Settings&SystemAreas.pdf

Read only

Former Member
0 Likes
1,420

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

Read only

Peter_Inotai
Active Contributor
0 Likes
1,421

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

Read only

Former Member
0 Likes
1,420

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.