IRepository irepos = JCO.createRepository(“IREPOS”,jcoClient);
IFunctionTemplate iFuncTemp = irepos.getFunctionTemplate(“BAPI_COMPANY_GETLIST”);
JCO.Function jcoFunc = iFuncTemp.getFunction();
JCO.ParameterList jcoParam = jcoFunc.getTableParameterList();
JCO.Table jcoTable = jcoParam.getTable(“COMPANY_LIST”);
JCO.MetaData jcoMetaComp = new JCO.MetaData(“BAPI0014_1”);
JCO.MetaData input_md = new JCO.MetaData(“MY_TABLES”);
JCO.Table jcoTable = JCO.createTable(jcoMetaComp);
JCO.Function jcoFunc = new JCO.Function(“BAPI_COMPANY_GETLIST”);
JCO.ParameterList jcoParam = JCO.createParameterList(iNmd);
The difference here is that the Function module metadata is coded into the application. So no extra calls to grab the metadata and the call is reduced to just 1. The APIs used are at a much lower level and coding can sometimes be tedious plus SAP recommends not use this type of programming though they themselves have coded some examples in this way.
In which case one option would be to use the first example but to cache the metadata away on application start-up and keep reusing the metadata from the cache but the best way would be to use the
SAP Enterprise Connector
, which is available with Netweaver Developer Studio and also standalone. This is a Java proxy solution from SAP, which relies on the same principle as in example 2 and the connector does all the dirty work of creating a Java proxy that has the Function module metadata coded into it. The client program just needs to initialise the right classes and call the right methods from the proxy to achieve the desired call.
A Detailed example is available here