Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

An easier way to connect components to SAP server functions: Part 2. Create a JavaServer Page for the connector and test the J2C bean

Ellen L. Chen (ellen_chen2002@yahoo.ca), Software Developer, IBM
author photo
Ellen Chen is a software developer with the IBM Rational Java EE Connector Tools team in the IBM Toronto Lab. She has a bachelor’s degree in engineering.

Summary:  This is the second part of a two-part article. It demonstrates how to use Java EE connector tools in IBM® Rational® Application Developer 8.0 to generate a J2C bean in a Java EE application to communicate with a SAP server that is running at the back end of an enterprise information system.

View more content in this series

Date:  16 Aug 2011
Level:  Intermediate PDF:  A4 and Letter (529KB | 14 pages)Get Adobe® Reader®

Activity:  3222 views
Comments:  

Prerequisite

This article is continues Part 1, where you generated and tested a J2C (or JCA) bean for a SAP resource adapter outbound scenario, using the enhanced Java EE connector tools in Rational Application Developer Version 8.0. The J2C bean artifacts have been generated in the workspace and the workspace has been launched. Part 1 also tells you what you need to have installed to work through this hands-on example.

Be sure that you've read that article before proceeding with this one. You can find it easily by clicking "More in this series."


Create a simple JSP to expose the J2C bean functionality

After the "J2C Java bean selection" view is launched under the "Java EE Resource from J2C Bean" window, the path to the generated J2C bean that you generated in Part 1 is automatically entered in the "J2C bean implementation" field (see Figure 1). Now you need to create a simple JavaServer Page (JSP) to expose the functionality provided by the generated J2C bean.

  1. In that "J2C Java bean selection" window, click Next.

Figure 1. Select the J2C bean to generate deployment artifacts
J2C Java bean selection view

  1. On the Deployment Information page (Figure 2), there are four deployment options: EJB, Faces Web Page, Simple JSP and Web Service. The default deployment method is Simple JSP.
  2. Check the box labeled Configure Resource Adapter Deployment so you can configure the way that the resource adapter deployment will show, in step 5.
  3. Click Next.

Figure 2. Simple JSP selected by default
Deployment Information page, selections completed

  1. To generate a Simple JSP, you need to create a dynamic web project to hold it, so click the New button next to the web project to generate that project. For Target Runtime, use WebSphere Application Server V7.0.

The name of the web project will automatically show in the "Web project" name field.

  1. For the "JSP folder" name, enter sample (see Figure 3), and click Next.

Figure 3. Generate the simple JSP
Specify Web project and JSP folder which holds the simple JSP

  1. When the Resource Adapter Deployment page appears, click Finish to generate the deployment artifacts.

Note:
If you do not select the "Configure Resource Adapter Deployment" check box in step 2, this page won't show.

The default SAP resource adapter deployment is "Deploy as Stand Alone," which means that the resource adapter will be installed on WebSphere Application Server. For this example, it will be installed on Version 7.0. After it is installed on that server, the applications that need the SAP resource adapter to connect SAP server can share the same resource adapter.

However, if you select "Deploy within EAR," the resource adapter will be packaged within the EAR file and will not be visible or used by other applications.


Figure 4. Select the default resource adapter deployment option
Two options for Resource Adapter Deployment: Deploy as Stand Alone and Deploy within EAR

  1. Inspect the content of the Java project and the web project. Figure 5 shows the structure of the artifacts generated both for the Java project, SAPBAPISample, and the web project TestWeb.

The J2C bean is generated in the Java project with schema files, and simple JSPs are generated in the web project.


Figure 5. Artifacts generated for both the web and Java projects
Directory of SAPBAPISample and TestWeb artifacts


Test the simple JSP on WebSphere Application Server

  1. First, you must deploy an EAR file that contains your web project to the WebSphere Application Server, Version 7.0, as shown in the Add and Remove window in Figure 6.

Figure 6. Add the EAR file to the WebSphere server
Add and remove resources configured on the server

Note:
To deploy the EAR file to the WebSphere, you need to open the Server view, right-click the WebSphere 7.0 server instance, and select Add and Remove.

  1. Now, right-click TestClient.jsp, and then select Run As > Run on Server (see Figure 7).
  2. Run TestClient.jsp on the WebSphere Application Server.

Figure 7. Test the createSapBapiDemoWrapper method
Selections described are highlighted on menus

  1. In the left pane of the Web Services Test Client tab (TestClient.jsp file), under Methods, click createSapBapiDemoWrapper in. Input data is shown in the Inputs.jsp file which is shown in Figure 8.

Figure 8. Test the "createSapBapiDemoWrapper" method
Display all input fields to create a new customer record

  1. Enter this input data in the Inputs.jsp file:
    1. Under sapPiPersonaldata, enter those values:
      • city: Burlingame
      • lastName: Johnson
      • firstName: Tom
      • countryKey: US
      • currencyKey: USD
      • cityPostalCode: 94010
      • dateOfBirth: May 03, 1965
      • languageKey: EN
      • regionStateProvinceCounty: CA
    2. Under sapPiCopyreference, enter the following values:
      • distributionChannel: 01
      • division: 01
      • salesOrganization: 0001
      • referenceCustomer: 01
  2. Then click Invoke from Result.jsp to create a new customer number.

Figure 9. The Result.jsp display
Shows the newly created customer

As Figure 10 shows, similar log messages are displayed from the WebSphere Application Server console view.


Figure 10. WebSphere Application server console view log
Messages that include BAPI_CUSTOMER_CREATEFROMDATA1


Summary

This article showed how easy a J2C bean can be created with the J2C tools provided in Rational Application Developer V8.0. With just a few steps, you can build an application that can access the functions of the SAP backend system. That functionality can be quickly exposed to other applications and business processes through the generated web page.


Resources

Learn

Get products and technologies

Discuss

About the author

author photo

Ellen Chen is a software developer with the IBM Rational Java EE Connector Tools team in the IBM Toronto Lab. She has a bachelor’s degree in engineering.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=752048
ArticleTitle=An easier way to connect components to SAP server functions: Part 2. Create a JavaServer Page for the connector and test the J2C bean
publish-date=08162011
author1-email=ellen_chen2002@yahoo.ca
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers