on 10-29-2004 2:02 PM
Hello!
I want to retrieve a list of BAPIs in Java. Does anyone have a code sample how to do this with JCO and SWO_QUERY_API_METHODS?
Regards,
Jan
Hallo Jan,
you can use the RFC_FUNCTION_SEARCH FM instead. Use "BAPI_*" to get all the BAPIs available in the System.
Bye,
Sameer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's a solution. I use some of our own Utility-Methods but it shows the flow of control:
String bapi = "SWOQUERY_API_METHODS";
Object object = browser.createFunction(bapi);
JCO.Function _function = (JCO.Function) _object;
JCO.ParameterList _paramList = _function.getTableParameterList();
if (_paramList != null) {
System.out.println(_paramList.getMetaData("API_METHODS"));
browser.setValue(_function, "WITH_OBJECT_NAMES", "X", String.class, -1);
browser.execute(_function);
int size = browser.processTableSize(function, "API_METHODS", -1);
System.out.println(_size);
for (int i = 0; i < _size; i++) {
System.out.print(browser.getValue(_function, "API_METHODS.FUNCTION", i, String.class));
System.out.print(", ");
System.out.print(browser.getValue(_function, "API_METHODS.METHODNAME", i, String.class));
System.out.print(", ");
System.out.print(browser.getValue(_function, "API_METHODS.DESCRIPT", i, String.class));
System.out.println();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Diana,
I've written a small example here (refresh my rusty JCo!) which returns just the function names in a Vector.
Hope this helps,
Gregor
/**
* Fetch a list of BAPIs
* @author Gregor Brett
*/
import com.sap.mw.jco.*;
import java.util.*;
public class GetBapis
{
private JCO.Client client;
private JCO.Repository repository;
private Vector bapis;
public GetBapis()
{
try
{
client = JCO.createClient("CLIENT","USERNAME","PASSWORD","EN","SERVERNAME","00");
client.connect();
repository = new JCO.Repository("Gregor", client);
IFunctionTemplate ftemplate = repository.getFunctionTemplate("SWO_QUERY_API_METHODS");
JCO.Function function = ftemplate.getFunction();
client.execute(function);
JCO.Table table = function.getTableParameterList().getTable("API_METHODS");
bapis = new Vector();
do
{
JCO.Field functionName = table.getField("FUNCTION");
bapis.add(functionName.getString());
}
while(table.nextRow());
}
catch(Exception e)
{
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}
}
public Vector getBapiList()
{
return bapis;
}
public static void main(String[] args)
{
GetBapis gb = new GetBapis();
Vector v = gb.getBapiList();
System.out.println("Fetched " + v.size() + " BAPIs.");
}
}
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.