Part 1: Writing an RFC structure to XML

Working with SAP's Java Connector, JCo? Then you should check out this collection of handy utilities for working with RFC/BAPI interfaces when doing development with JCo. These truly are development utilities in the sense that their intent is to provide generic support for almost any programming effort that utilizes JCo to interface with SAP.

This utility takes any RFC/BAPI name as input and automatically generates an XML representation of the various parameters/structures/tables that make up the external interface to this function. This tool is very useful for generating a structured view of the RFC/BAPI that can readily be viewed in XML-capable browsers like Internet Explorer.

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.


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(
            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) {


 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

Dig Deeper on SAP Web applications