Adapter for SAP 10.1 | webMethods Adapter for SAP Documentation | webMethods Adapter for SAP Installation and User’s Guide Documentation | Coding Client Applications and Services | Invoking RFCs from Adapter for SAP | Calling Public Adapter for SAP Services from Java Services
 
Calling Public Adapter for SAP Services from Java Services
This section shows an example of how to invoke an RFC from a Java service. The sample app/BAPI.javathat is shown below logs on to an SAP system and invokes a BAPI.
For more information about developing services, see webMethods Service Development Help for your release and the online API documentation.
*To call a public Adapter for SAP service from Java
1. Start Designer if it is not already running.
Note:
The steps for using Designer to call the adapter service from Java are similar.
2. Create a Java service named app.BAPI:callService and enter the following source:
IDataCursor idc=pipeline.getCursor();
IDataUtil.put(idc, "serverName", "CER");
IDataUtil.put(idc, "COMPANYID", "000001");
IDataUtil.put(idc, "$rfcname", "BAPI_COMPANY_GETDETAIL");
try
{
Service.doInvoke("pub.sap.client", "invoke", pipeline);
}
catch (Exception e)
{
throw new ServiceException(e);
}
finally
{
idc.destroy();
}
3. This service will invoke BAPI_COMPANY_GETDETAIL with a company ID of 000001 and return the results. The logon to the SAP system is done automatically using the connection information for the RFC connection alias.
Note:
Change the RFC connection alias (field serverName of the public Adapter for SAP service) to your own alias.