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.

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 last published in August 2005

Dig Deeper on SAP Web applications

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close