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.
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:
The program gets a customer record, for which the data is stored in
cstruc. It stores the feedback for the data access in
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.
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.
- In the workbench in the top menu bar, select Window > Preferences.
- In the Preferences dialog, set the following options as shown in Figure 1:
- In the tree view on the left, expand EGL
- Select SQL
- In the list of options on the right, select Add level numbers to record definition
Figure 1. EGL preferences
- Click OK.
Create a new EGL Dynamic Web Project. The project in this example is called
- Set the following options, as shown in Figure 2.
- Enter the project name
- Select WebSphere Application Server v6.1 as the Target Runtime
- Select Faces Project from the list of Configurations, since you want to add a Web page based on JSF technology.
- 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
- Click the Next button
- The Project Facets page displays. Choose the following options, as shown in Figure 3.
- Select Default Style sheet (CSS file)
- Select EGL support with JSF
- Select EGL support with JSF Component Interfaces
- Select WebSphere Web (Co-existence)
- Select WebSphere Web (Extended)
Figure 3. Configurations options
- Click the Finish button on this page, because the next two pages contain the correct default values.
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.
- Drill down to the jt400.jar file, as shown in Figure 4.
- Right-click it and select Copy.
Figure 4. Select the JAR file
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.
- In your Web project, in Project Explorer, add the file as shown in Figure 5.
- Expand the new project eglcallweb
- Expand the WebContent directory
- Expand the WEB-INF directory
- Right click on the Lib directory
- Select Paste from the context menu
Figure 5. Project Explorer