on 2021 Oct 01 3:58 PM
Hello Experts,
when calling a function module using the RFC adapter in CPI with an incorrect date format, we are getting an exception but we could not catch its detailed message. The error is visible in the MPL :
"com.sap.it.rt.adapter.rfc.exceptions.RFCLibraryException: Error in executing RFC Function, cause: com.sap.conn.jco.ConversionException: (122) JCO_ERROR_CONVERSION: Cannot convert the value '14-11-2019' from type java.lang.String to type DATE at field STARTDATE"
We know that the date format is incorrect and should be YYYY-MM-DD (which is working fine) but is there a runtime property or header to catch the detailed message ?
Property ${exception.message} returns hte following message which is not helpful
com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'E' (code 69) in prolog; expected '<' at [row,col {unknown-source}]: [1,1]
Thanks for your inputs
Request clarification before answering.
import com.sap.gateway.ip.core.customdev.util.Message;
def Message processData(Messagemessage){//get a map of properties
def map =message.getProperties();//get an exception java classinstance
def ex = map.get("CamelExceptionCaught");
if(ex!=null){
message.setBody(ex.getCause())
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello soufiane,
Please try below then you should get everything from error.
${exception.stacktrace}<br>
Also try using below groovy script inside your exception subprocess to manually catch the exception to get error response.
import com.sap.gateway.ip.core.customdev.util.Message;
def Message processData(Message message) {
// get a map of properties
def map = message.getProperties();
// get an exception java class instance
def ex = map.get("CamelExceptionCaught");
if (ex!=null) {
if (ex.getClass().getCanonicalName().equals("com.sap.it.rt.adapter.rfc.exceptions.RFCLibraryException")) {
// save the rfc error response as a message attachment
def messageLog = messageLogFactory.getMessageLog(message);
messageLog.addAttachmentAsString("http.ResponseBody", ex.getResponseBody(), "text/plain");
// copy the rfc error response to an exchange property
message.setProperty("RFCErrorResp",ex.getResponseBody());
// copy the rfc error response to the message body
message.setBody(ex.getResponseBody());
}
}
return message;
}
Regards,
Sriprasad Shivaram Bhat,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sri,
thank you for your help. The script gives an error :
java.lang.NoSuchMethodException: No signature of method: com.sap.it.rt.adapter.rfc.exceptions.RFCLibraryException.getResponseBody() is applicable for argument types: () values: []
I think that handling RFC exceptions is different from HTTP.
User | Count |
---|---|
58 | |
10 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.