Part 1 of this article series discussed how IBM ® WebSphere® software products provide support for accessing SAP® systems. Part 2 examined the different types of SAP applications that can be built using these WebSphere products. In Part 3, we'll bring together important information, tips and techniques that will not only help you more efficiently develop Web applications to access SAP systems, but also help you migrate beans generated from VisualAge® for Java's SAP Access Builder to WebSphere Studio.
This article will cover how to:
- Deploy applications to WebSphere Application Server, Advanced Edition
- Trace SAP connectivity
- Set default values for your server connection
- Reduce clutter in Java perspectives
- Access BAPI/RFC parameters using service proxy classes
- Retrieve SAPConnection using a ConnectionSpec object
- Migrate BAPI, RFC and business object proxy beans from VisualAge for Java
Deploy applications to WebSphere Application Server, Advanced Edition
The target platform for J2EE applications developed with WebSphere Studio Application Developer, Integration Edition, Version 4.11 is typically WebSphere Application Server, Enterprise Edition, Version 4.x. However, a fixpak is available that makes it possible to deploy JCA applications to WebSphere Application Server, Advanced Edition (hereafter called Advanced Edition).
The high level steps for deploying JCA applications on a standalone Advanced Edition server include:
- Apply WebSphere Application Server Advanced Edition V4 FixPak 4 to your standalone Advanced Edition server.
- Ensure JCA support is installed in Advanced Edition. The option to install JCA is included in Advanced Edition Version 4.02 and later.
- Export the JCA application from WebSphere Studio Application Developer, Integration Edition, Version 4.11, using the Export EAR wizard.
- Using Advanced Edition's admin console, install WebSphere Adapter for mySAP.com, and set up an SAP connection factory.
- If desired, add security or make other deployment descriptor changes in the exported JCA application using the Application Assembly Tool.
- Using Advanced Edition's admin console, use the installation wizard to install the JCA application as you would any EAR.
The steps to accomplish the above are described in detail in the article Running WebSphere Studio Application Developer Integration Edition Version 4.1.1 JCA Applications on WebSphere Application Server, Advanced Edition.
When tracing SAP connectivity, errors can be thought of as occurring during two distinct phases:
- while connecting to an SAP system; these errors are considered SAP domain errors
- after connecting, and while executing the desired BAPI/RFC; these errors are considered WebSphere domain errors.
The following sections explain how to trace errors from each of these layers.
Based on our experience, most errors will occur in this layer.
The first thing to do when faced with an exception while connecting to an SAP system is to check the trace file. This trace reports on errors which occur on the SAP side, including communications, user ID and password errors. Make sure that the methods returning from SAP return a completion code of 0. Any other value indicates an error, which is usually accompanied with messages explaining what type of error occurred and in which component (BAPI, etc.).
The ability to trace SAP connectivity data is available through a serialized
class called JNISettings (unchanged from the VisualAge for Java SAP Access
Builder), details of which can be found in Chapter 14 "Performing
Specific Tasks" of the SAP.PDF file that ships with WebSphere Studio Application Developer, Integration
Edition, Version 4.11 (hereafter called Application Developer). To set
the JNISettingsclass from inside Application Developer to trace SAP
domain errors:
- Locate the JNISettings class:
- From a Java or Enterprise Server perspective, open a project containing the definition of any SAP Service. (It doesn't matter which SAP service you select.)
- Expand the project.
- Locate the
ijvsap35.jarfile, and expand it. - Locate the
com.ibm.sap.bapi.jnipackage, and expand it. - Locate the
JniSettings.class, as shown in Figure 1.
Figure 1. Locate JNISettings class
- Set the properties of the class:
- Right click on JniSettings.class, then select Properties.
- In the Execution Arguments pane, enter the following parameters into the
Program Arguments field:
-tracefile X:\Saptrace.txt -rfctracemode 1This command directs WebSphere Adapter for mySAP.com to set tracing mode to on and to direct the trace text to a file calledX:\Saptrace.txt.
- Run the class:
- Select the class JNISettings.class and select the Run button
on the tool bar. - From the Select Launcher dialog, select Java Application and make sure you deselect the set as default launcher check box.
- Select Next, then Finish.
- An output similar to Figure 2 should appear on your console.
Figure 2. Console messages when launching class
When this program is run, a file calledJNISettings.seris created in the directory where Application Developer is installed. WebSphere Adapter for mySAP.com will open this file at run time to decide the tracing policy to be used during execution. You can have differentJNISettings.serfiles for different phases of testing. When deploying your application, copy this file to the directory from which you will start your Java application, which is typically<WAS_HOME>\binwhen running WebSphere Application Server. - Select the class JNISettings.class and select the Run button
Tracing WebSphere domain errors
To trace WebSphere Adapter for mySAP.com and WebSphere's implementation of JCA, follow these steps:
- Open the Server perspective.
- From the Server Configuration view, expand Server Configurations and double-click on was40 to open the server configuration editor.
- Select the Trace page.
- Ensure the Enable trace checkbox is checked.
- Modify the trace string to read:
com.ibm.connector2.sap.*=all=enabled:com.ibm.ejs.j2c.*=all=enabled - Select the J2C page.
- In the J2C Resource Adapters box, select SAP.
- In the J2C Connection Properties box, select SAPConnectionFactory.
- In the Resource Properties box, set the property TraceLevel to
3. The trace levels for SAP correspond to:1: no tracing, trace exceptions only2: trace method entry and exits3: output all debug entries.
The trace output is stored in <workspace>/.metadata/.plugins/com.ibm.etools.websphere.tools/logs/trace.log. Regardless of the trace string entered in the Trace page, WebSphere Adapter
for mySAP.com's TraceLevel resource property must be set in order to turn
on tracing. Otherwise, tracing will not be performed.
Set default values for the server connection
Default values for the server connection, like host name, client number,
and others, can be set by customizing the ImportSAP.wsdl file. Normally, this connection info needs to be set everytime the user
wants to create an SAP service. An SAP service is like a Web service except
it represents an operation on an SAP R/3 system. In WebSphere Studio Application
Developer, Integrated Edition, the New Service wizard is used to create
SAP services. The initial page for this wizard asks you for connection
information, which it uses to connect to a live SAP R/3 system in order
to retrieve its metadata. The user than selects this metadata and the wizard
generates an SAP service for it. Having the connection information added
to this WSDL file for reference is a real time saver.
This ImportSAP.wsdl file exists in the <your workspace directory>\Installed Resource
Adapters\<your SAP adapter name>\com\ibm\jca\importservice\sap directory. Edit the file using a text editor and change the line highlighted
below in this section of code:
<service name="ImportService"> <port binding="tns:ImportSAPBinding" name="ImportSAPPort"> <sap:address systemNo="0" /> </port> |
to look like this:
<service name="ImportService"> <port binding="tns:ImportSAPBinding" name="ImportSAPPort"> <sap:address hostName="com.sap.servername" systemNo="0" client="800" userName="username" password="password" /> </port> |
You can add additional attributes in the same manner, as long as the variable name in the WSDL file matches the screen name of the field for which you want to create a default.
Reduce clutter in Java perspectives
When you create a new SAP service you'll notice a number of libraries added to your Java/Service project, which might be annoying when scrolling between different projects. To hide those libraries, click the down-arrow icon in the Packages view, and deselect Show Referenced Libraries, as Shown in Figure 3.
Figure 3. Hide referenced libraries

Access BAPI/RFC parameters using service proxy classes
When generating a session bean or a client stub style proxy bean, only the first BAPI/RFC output parameter is accessible from the generated proxies. Since most SAP applications return multiple output parameters, you want to make sure you get them all. To do this, WebSphere Adapter for mySAP.com generates an output container class with getter methods for all output parameters and tables of the respective BAPI/RFC. The output container is accessible from the session bean and from the client stub style proxy (return parameter of the session bean/proxy method to execute the BAPI/RFC). These output parameters can be retrieved from the proxy class directly if you are using command bean style proxies.
Retrieve SAPConnection using a ConnectionSpec object
The ConnectionSpec user ID and password properties, which are used to retrieve a managed connection from SAP R/3, are generally the user ID and password entered in the SAPConnectionFactory in the server configuration. However, it is possible to override these properties at run time by setting an attribute on the address extensibility element of your SAP service. By setting the overwriteLookup attribute to true, the SAPConnection returned will be based on the user ID and password set in the address extensibility element, as opposed to was set in the SAPConnectionFactory. For example:
<service name="BapiCompanyGetlistService">
<port binding="tns:BapiCompanyGetlistSAP" name="BapiCompanyGetlistSAPPort">
<sap:address checkAuthorization="true" client="800" codepage=""
destination="" gatewayHost="" gatewayService="" groupName=""
hostName="r3host.com" language="" loadBalancing="false" msgServer=""
password="r3password" rfcMode="3" systemName="0" systemNo="0"
traceLevel="0" userName="r3user" overwriteLookup="true"/>
</port>
</service>
|
Migrate BAPI, RFC and business object proxy beans from VisualAge for Java
Follow the steps below to regenerate all RFC/BAPIs that had not already been generated with the RFC proxy for J2EE connector for SAP R/3 checkbox. (If your Java beans are already generated into a J2EE connector, begin at step 6.)
- In the Access Builder for SAP R/3 menu, select Options => Change Options.
- Check the RFC proxy for J2EE connector for SAP R/3 checkbox in the "VAJ generation" dialog.
- Click OK.
- Select Options => Save Options.
- Regenerate all RFC/BAPI beans you want to migrate using the new settings.
- Export your projects as you would normally, and include all generated classes in preparation for migrating for migrating it to WebSphere Studio.
Figure 4. Generation options

In Application Developer, follow these steps:
- Switch to a Java perspective.
- Create a new Java project, as follows:
- Name the project, then select Next.
- From the Libraries tab, select Add External JARs.
- Browse to
<your workspace directory>\Installed Resource Adapters\SAP JCA. - Select all the available JAR files and click Open.
- Browse to
<WebSphere Studio installation Directory>\plugins\com.ibm.etools.websphere.runtime\lib\. - Select the following JAR files:
jca.jarwsif.jarwsdl4j.jarwsatlib.jar
- Click Finish.
- Import your previously generated Visual Age for Java ZIP file into the
Java project:
- Make sure the project is highlighted, then select File => Import.
- Select the VisualAge for Jaza ZIP file(s), then select Next.
- Use the Browse button to locate your ZIP file, verify you are importing all the necessary files, then select Finish.
- Open the RFC Proxy files that will contain some errors (double click on the file and it will open in a java editor).
- From the Outline view, right click on the class name and select Add Unimplemented Methods to offset these errors, as shown in Figure 5.
Figure 5. Add unimplemented methods

In this series, we've examined the new tooling strategy of IBM for connecting to SAP R/3 systems. By plugging WebSphere Adapter for mySAP.com into WebSphere Studio Application Developer, Integration Edition, you can browse BAPIs/RFCs of SAP R/3 systems and add WSDL representations of the desired function modules. The WSDL representations can be used to generate Java applications, J2EE applications and Web service applications. We've also shown how to migrate your VisualAge for Java SAP Access Builder-generated beans into WebSphere Studio.
Sandy Minocha works for the WebSphere Studio Jumpstart ISV Enablement team at the IBM Toronto Software Lab. The team engages with key WebSphere Studio tools partners, providing technical guidance and support as they integrate into the WebSphere Studio set of products. The team also performs technical validations of partner plug-ins for the Ready for WebSphere Studio partner program. Sandy has a BASc in Electrical Engineering degree from University of Waterloo and a MEng in Telecommunications degree from University of Toronto. He is also a PEng. You can contact Sandy at minocha@ca.ibm.com.
Ahmed Khalifa works for the VisualAge and WebSphere Enablement team at the IBM Toronto software lab. His career started back in 1986, in the hot summer of Upper Egypt, when he wrote his first spreadsheet using Basic on a Commodore 64. In 1990, Ahmed received an engineering degree in architecture with a diploma in computer science, and then worked on CAD applications using C++ on DOS, Windows, and Macintosh. Ahmed joined IBM Egypt in 1993 and worked on the development of Arabic APIs for OS/2. Ahmed joined the IBM Toronto Lab team in 1997. He can be reached at akhalifa@ca.ibm.com.




