All,
We have currently developed a Java client application that communicates with SAP via the JCO v3.0 API. During a stateful call, where multiple BAPI functions are invoked, we use the JCoContext class to establish a stateful session. We call JCoContext.begin() before the JCoFunctions are executed and JCoContext.end() in a finally block after all functions are complete.
The problem arises on JCoContext.end(). It could potentially raise a JCoException. The documentation is not very clear on why an Exception may occur or how to handle it. In testing, I have been able to observe an exception when a NULL destination is passed to the JCoContext.end() method. While this can occur, it most definitely will not occur in our production code. So the question remains, are there any other reasons why an exception would be raised?
Also, I have observed strange behavior if the JCoContext.end() method is not invoked. It those cases, I have seen subsequent BAPI calls not complete successfully. This indicates to me that if the end() method does not complete successfully, it could leave the JCo in a bad state. So, how should we handle an exception that occurs here. What recourse do I have as a developer? It appears that the only guarantee I have is to shut the program down.
Let me know if you have any ideas, thanks,
Paul Manning