2008 May 22 9:45 AM
How to do error handling in BAPI and RFC?
2008 May 22 9:47 AM
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.
2008 May 22 9:50 AM
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.
2008 Aug 13 10:19 AM
Hi,
Is there a list available of the predefined exceptions?
Regards,
Bob
2008 Sep 12 9:50 AM
I have to analyse the return table of a rfc, is there a list which return messages are possible?
2008 May 22 9:51 AM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |