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 profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

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]

developerWorks Community:

  • Close [x]

Calling IBM i programs from EGL using Rational Business Developer

Claus Weiss, Advisory Software Consultant, IBM
Claus Weiss is an advisory software consultant with the Rational Software System i – Ecosystem team at the IBM Canada Toronto Laboratory. He has degrees in industrial engineering and computer science from the University of Hamburg in Germany. He worked as a systems engineer with IBM Germany and joined the IBM Toronto Laboratory in 1984. He was a developer and team leader for System/38 development tools. He has been a member of the Design Control Group for the AS/400 development tools. He has worked as a consultant for IBM iSeries Application Development for the past 10 years, specializing in Visual Tools. Claus is a frequent speaker at COMMON and other iSeries conferences and a six-time winner of COMMON's Speaker Excellence award. He is also the lead author of the book title "Understanding the IBM WebFacing Tool," published by IBM Press, and has co-authored several IBM Redbooks.

Summary:  This tutorial describes how to write Enterprise Generation Language (EGL) code that calls programs (RPG, COBOL, CL, CL Commands, or programs written in any supported language) on your IBM® System i5™ machine. The process for you to call an existing IBM i™ program from EGL has been very much improved in IBM® Rational® Developer for System i™ V7.1 (and later), and is incredibly simple. EGL leverages the IBM i Toolbox for Java™, which in turn utilizes the System i5’s Remote Command Host Server (QZRCSRVSD in the QSYSWRK subsystem).

Date:  19 Aug 2008
Level:  Intermediate PDF:  A4 and Letter (3472 KB | 44 pages)Get Adobe® Reader®

Activity:  290 views
Comments:  

Prepare to call an IBM i program from EGL

In this section, you will walk through the steps involved in creating an EGL Dynamic Web Project. Next, you will create a simple Java™Server Faces (JSF) component-based Web Page that calls an RPG program on IBM i.

IBM i RPG Program

The program that you are going to call is named GETDATAE. It is an RPG program with one input parameter of type character that will return two parameters. One of the parameters is an externally defined data structure, which contains detail data, and the other is a character field that contains feedback data.

Listing 1 shows the RPG source code.


Listing 1. GETDATAE RPG program
     FCUSTOML3  IF   E           K Disk
      *
      *Input parameter from Web page
     DCustnoi          s                   like(CUSTNO)
      * Data structure to specify output structure to return to caller
     D CSTRUC        E DS                  extname(customl3:custom01)
     D feedback        s             20
     c     *entry        plist
     c                   parm                    custnoi
     c                   parm                    cstruc
     c                   parm                    feedback
     c                   eval      feedback=*blank
      * 
     c     custnoi       chain(E)  customl3
     c                   if        not %found(CUSTOML3)
     c                   eval      feedback= CUSTNOI
     c                   else
     c                   eval      feedback='0'
     c                   endif      
      *
     c                   return                                   

As you can see, when this program is called it is passed three variables:

  • custnoi
  • cstruc
  • feedback

The program gets a customer record, for which the data is stored in cstruc. It stores the feedback for the data access in feedback. The feedback variable either contains a 0 if the record was found, or the customer number that could not be found if the access wasn’t successful.

Setting up the EGL preferences

Before you start to create an EGL Web project, you need to change a preference in the workbench to make sure that the data structure description for the second parameter in the call matches what is accepted as a parameter in an IBM i call.

  1. In the workbench in the top menu bar, select Window > Preferences.
  2. In the Preferences dialog, set the following options as shown in Figure 1:
    1. In the tree view on the left, expand EGL
    2. Select SQL
    3. In the list of options on the right, select Add level numbers to record definition

Figure 1. EGL preferences
Select preference area on left, options on right
  1. Click OK.

EGL Dynamic Web Project

Create a new EGL Dynamic Web Project. The project in this example is called eglcallweb.

  1. Set the following options, as shown in Figure 2.
    1. Enter the project name
    2. Select WebSphere Application Server v6.1 as the Target Runtime
    3. Select Faces Project from the list of Configurations, since you want to add a Web page based on JSF technology.
    4. Make sure that the EAR Project Name is the same as the Project name, with EAR appended to the end of the name.

Figure 2. Dynamic Web Project options
Runtime, Configuration, and EAR drop-down lists
  1. Click the Next button
  2. The Project Facets page displays. Choose the following options, as shown in Figure 3.
    1. Select Default Style sheet (CSS file)
    2. Select EGL support with JSF
    3. Select EGL support with JSF Component Interfaces
    4. Select WebSphere Web (Co-existence)
    5. Select WebSphere Web (Extended)

Figure 3. Configurations options
WebSphere XDoclet annotations support
  1. Click the Finish button on this page, because the next two pages contain the correct default values.

Add JT400.JAR to your project

EGL uses the IBM i Java Toolbox classes to communicate with an IBM i-based machine. You must locate the jt400.jar file and add it to your Web project.

Use Windows Explorer to drill down in the Rational Developer for System i SOA plugins directory.

  1. Drill down to the jt400.jar file, as shown in Figure 4.
  2. Right-click it and select Copy.

Figure 4. Select the JAR file
select folder on left, file on right

Here is the path to the default install location in Rational Developer for System i SOA:

X:\Program Files\IBM\SDP70Shared\plugins\ com.ibm.etools.iseries.toolbox_7.1.0.v200801310337\runtime\jt400.jar

Note: If multiple versions of the toolbox directory exist, look for the one with the highest version number.

  1. In your Web project, in Project Explorer, add the file as shown in Figure 5.
    1. Expand the new project eglcallweb
    2. Expand the WebContent directory
    3. Expand the WEB-INF directory
    4. Right click on the Lib directory
    5. Select Paste from the context menu

Figure 5. Project Explorer
tree view

3 of 9 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational, Sample IT projects
ArticleID=330659
TutorialTitle=Calling IBM i programs from EGL using Rational Business Developer
publish-date=08192008
author1-email=weiss@ca.ibm.com
author1-email-cc=