import com.sap.mw.JCo.*;
public class SAPLoadTest extends Thread {
static final String[][] sapParams = { { "client", "000" },
{ "user", "myUsername" }, { "passwd", "myPassword" }, { "lang", "en" },
{ "ashost", "mySapHost" }, { "sysnr", "00" } };
static final int maxConnections = 100; //Number of threads
static int count = 0;
static int maxThread = 0;
static JCo.Function function;
public SAPLoadTest() {
super("" + ++count);
start();
}
public void run() {
JCo.Client threadConn = null;
try {
threadConn = JCo.createClient(sapParams);
threadConn.connect();
} catch (Exception pEx) {
pEx.printStackTrace();
}
for (int i = 0; true; i++) {
try {
threadConn.execute(function);
if (maxThread < new Integer(getName()).intValue()) {
maxThread = new Integer(getName()).intValue();
System.out.println(maxThread);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public static void main(String[] args) {
JCo.Client connection = JCo.createClient(sapParams);
connection.connect();
IRepository repository = new JCo.Repository("SAPRep", connection);
IFunctionTemplate functionTempl = repository
.getFunctionTemplate("RFC_SYSTEM_INFO");
function = functionTempl.getFunction();
connection.disconnect();
for (int i = 0; i < maxConnections; i++) {
new SAPLoadTest();
}
}
}
Bear in mind, any create/update RFC/BAPI will continue to modify the system until the application is manually terminated.
THE JCO UTILITY COOKBOOK
Home: Introduction
Part 1: Writing an RFC structure to XML
Part 2: Generating metadata for an RFC structure
Part 3: Load testing SAP with JCo
Part 4: Creating a serialized RFC interface
Review: Conclusion and more resources
This was first published in August 2005