We can also directly test the connection outside of AE by using the SAP JCO classes. Below sample code can be used for testing the SAP JCO connectivity.
package JCOConnectionTest; import com.sap.mw.jco.*; public class JCOConnector { public JCOConnector() { super(); } JCO.Client mConnection; public void Connect1() { try { // Change the logon information to your own system/user mConnection = JCO.createClient("010", // SAP client "SAP_USER", // userid "sap_pswd", // password null, // language "sap_server", // application server host name "00"); // system number mConnection.connect(); System.out.println(mConnection.getAttributes()); mConnection.disconnect(); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } } public static void main (String args[]) { JCOConnector app = new JCOConnector(); app.Connect1(); } }
Make sure the sapjco.jar file is present in your classpath(add to project classpath if you are running this from Jdeveloper.) On successful connection you are shown the details of the server with an exit code of 0 and incase of failure you are shown some RFC errors like RFC_LOGON_FAILURE etc.
Thanks! Although it's a small post it's useful all the same. I have to confess - I love your blog and I've read most of your posts regarding SAP (somehow, I just keep ending up here). I'd love to read about some more testing tools.
ReplyDelete