ISAP Xpages Connectorf you want to connect to SAP from Xpages or JAVA the easiest way is by using the SAP JAVA Connector.

You can download the SAP Connector from the SAP website here.

I spend a few hours on trying different ways of doing this and at the end I used the SAP JAVA Connector which I found very easy to use.  The one small problem with this is you will need a SAP username and password to download the SAP Connectors.  You will need the correct SAP connector for your operating system in order to get it to work.

I will explain the Windows 64-bit SAP Connector for Xpages or JAVA.

Note: Before installing JCo, please install the latest Microsoft Visual Studio 2005 C/C++ runtime libraries.

Note: Do not copy the sapjco3.dll neither into the {windows-dir}system32 nor into the {windows-dir}SysWOW64 directory. This will other JCo versions that are already installed on the same system. Furthermore you would risk that the current installation also would not work anymore, if the sapjco3.dll gets replaced in the respective Windows system directory in the future.

Then add {sapjco3-install-path} to the PATH environment variable.
Finally, add {sapjco3-install-path}sapjco3.jar to your CLASSPATH environment variable.

Now you can open your Xpages or JAVA application and simple add the sapjco3.jar file to your build path.  From here you will be able to connect to SAP using the JCo classes.

You can create a Xpages or JAVA function that looks like this:

public static void loadBAPPIE() throws JCoException
{
JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
JCoFunction function = destination.getRepository().getFunction("ZWTYB_VEHICLE_ENQ");
if(function == null)
throw new RuntimeException("ZWTYB_VEHICLE_ENQ not found in SAP.");
 
System.out.println(function.getImportParameterList());
function.getImportParameterList().setValue("JOB_NUMBER", "");
function.getImportParameterList().setValue("ENGIN", "");
function.getImportParameterList().setValue("CUSTOMER", "");
function.getImportParameterList().setValue("VINNO", "AHTCS166666666");
try
{
function.execute(destination);
}
catch(AbapException e)
{
System.out.println(e.toString());
return;
}
 
System.out.println(function.getExportParameterList().getStructure(0));
System.out.println("Branch: " + function.getExportParameterList().getString("CHILDBIR"));
}

The ABAP_AS_POOLED is the file name of the SAP connection file.

When you download the SAP Connector you get a few examples of how to connect and create the SAP connectors.

Please let me know if you have any questions. You can contact me on Skype @ corvitech