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

error handling in BAPI and RFC

Former Member
0 Likes
2,514

How to do error handling in BAPI and RFC?

How to do error handling in BAPI and RFC?

5 REPLIES 5
Read only

former_member156446
Active Contributor
0 Likes
1,220

You have to create a parameter named Return for every BAPI. This parameter returns exception messages or success messages to the calling program.

BAPIs themselves must not trigger any messages (such as MESSAGE xnnn) in the coding. In particular they must not generate terminations or display dialog boxes. Instead, all messages must be intercepted internally and reported back to the calling program in the Return parameter. Otherwise the BAPI will not be processed correctly and control may not be given back to the calling program.

All error messages or indeed any message that may be returned by the BAPI, must be defined in message table (Tools ® ABAP Workbench ® Development ® Programming environment ® Messages) and described in the documentation for the return parameter. This also applies to the most important or most likely error messages generated by other programs that can be indirectly passed via the BAPI to the application program.

Read only

Sm1tje
Active Contributor
0 Likes
1,220

do not forget to add predefined exceptions:

http://help.sap.com/saphelp_nw70/helpdata/EN/22/0425e0488911d189490000e829fbbd/content.htm

The RFC interface defines two additional exception types:

· SYSTEM_FAILURE

This exception reports all failures and system problems on the remote machine.

· COMMUNICATION_FAILURE

This exception is raised when a connection or communications failure occurs. It does not report system problems (for example, abnormal termination) that occur on the remote machine.

Requesting Error Messages

In the function modules that you call, you should use exceptions for any error reporting, and not the MESSAGE keyword.

CALL FUNCTION Remotefunction

DESTINATION Dest

EXPORTING...

IMPORTING...

TABLES...

EXCEPTIONS

SYSTEM_FAILURE = 1 MESSAGE msg

COMMUNICATION_FAILURE = 2 MESSAGE msg

The system sets the message variable (msg) to the system message. You can then display the message or log it in a file. You should not try to interpret message text in your program.

You can use MESSAGE only with the two system exceptions described here.

Read only

Former Member
0 Likes
1,220

Hi,

Is there a list available of the predefined exceptions?

Regards,

Bob

Read only

Former Member
0 Likes
1,220

I have to analyse the return table of a rfc, is there a list which return messages are possible?

Read only

Former Member
0 Likes
1,220

Hi,

Check the BAPI you going to use in SE37, Under the TABLES tab there will be RETURN parameter which stores the return value.

First test the BAPI in SE37 and check whether any value populated in the return parameter.Using the RETURN parameter we handle error in BAPI.

Regards,

Raghu