!--a11y-->
RFC Server Exceptions 
If an exception is thrown while the SAPServer is executing, this exception will be passed to the SAPServerHost on which the SAPServer instance is hosted by calling the SAPServerHost’s OnServerException function. This is a virtual function and can be overridden in the derived class.
SAP ABAP exceptions can be returned from your RFC Server component by throwing an RFCAbapException. The RfcAbapException contains two strings: error code and message.
Error code is the name of the exception in ABAP/4 (for example, NOTHING_SPECIFIED) and is referenced inside the ABAP/4 program as a SY-SUBRC code. Message is mapped to SY-MSGV1and can be examined for additional detail.
Example:
|
// exceptions are returned to SAP ABAP/4 program as appropriate SY-SUBRC & SY-MSGV1 if (""== Kunnr & "" == Name1) { RfcAbapException ns = new RfcAbapException("NOTHING_SPECIFIED", " Both kunnr and name1 were empty"); throw ns; } if ("RHD" == Name1) { RfcAbapException nrf = new RfcAbapException("NO_RECORD_FOUND", " No customer by name: " + Name1); throw nrf; } |
For a complete RFC Server example with exception handling, see the RFCServerConsole sample.