I wanted to read the SAP BAPI using Java Code with help of Java Connector(JCo).
I have "Jco JAR" and other connector JAR files. I tried using the sample code provided in this link [ https://archive.sap.com/kmuuid2/409e7358-6985-2a10-7ab7-ba68e40a5902/Code%20Sample%20%20to%20Execute%20BAPI%20in%20Java.pdf ] On Page-4 in Eclipse IDE. I have setup Build path for those JAR files. When tried to import JCO in the code, it says "com.sap..." is Unresolved. The code in the above link was actually told to use in Netweaver Developer Studio. But I want to use in Eclipse IDE.
IConnection connection = null;
try {
// get the Connector Gateway Service
Object conservice = PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
IConnectorGatewayService cgService =(IConnectorGatewayService) conservice;
if (cgService == null) {
response.write("Error in get Connector Gateway Service <br>");
}
try {
connection = cgService.getConnection(<SAP SYSTEM >, request);
}
catch (Exception e) {
response.write("Connection to SAP system failed <br>");
}
}
I am not sure what would the actual results look like. But I should be able to connect to SAP using the Java Connector.