For example, viewing an XML document in Internet Explorer displays the nested interface structures that can be used as a drilldown to determine specific table, structure and field names. I have found this utility especially useful when, during the course of JCo development, I need to look up a specific field name and don't want to go through the hassle of logging onto SAP to do so.
This utility can also be used to generate XML structures that can be imported into other XML-based mapping tools. You can use this structure to pass data as an XML document to your JCo application. Of course, your JCo application is still responsible for parsing the XML and making the appropriate JCo calls.
import com.sap.mw.JCo.*;
public class Rfc2Xml {
static final String[][] sapParams = { { "client", "000" }, { "user", "myUsername" },
{ "passwd", "myPassword" }, { "lang", "en" }, { "ashost", "mySapHost" }, { "sysnr", "00" } };
static final String filePath = "c:/dev/interface";
static final String interfaceName = "RFC_SYSTEM_INFO";
public static void main(String[] args) {
try {
JCo.Client connection = JCo.createClient(sapParams);
IRepository repository = new JCo.Repository("saprep", connection);
JCo.Function function = repository.getFunctionTemplate(
interfaceName).getFunction();
connection.disconnect();
function.writeHTML(filePath + ".html");
function.writeXML(filePath + ".xml");
System.out.println("Output written to " + filePath + ".html");
System.out.println("Output written to " + filePath + ".xml");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
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