EGL and Remote Programs on IBM i. Topic. Sub-Topics:. EGL Calls to Remote Programs (Overview) Calling RPG program Calling a CL program Invoking a command Calling a procedure in RPG Service Program Getting a list of records from RPG program Accessing a DataArea. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
In this section you will learn how to call RPG programs running on an IBM iSeries server.
This lab requires you to have open Internet (TCP/IP) access on your PC
You will be calling (up to) four RPG transactions,running in an IBM System i in Toronto, Canada.
The steps you learn here should be generalize-able to your specific shop’s enablement
Here’s what you’ll do:1. Add the iSeries JT400 toolkit to your project2. (For each RPG program to call) Add to the EGL Linkage Part for your Build File3. Create the business logic to call the RPG Program
First we will start with an overview of the system architecture and process
The facility is however extremely flexible and supports the many options that may be required to support many possible options and configurations. EGL takes into account the many possible runtime options that may affect how you run your jobs and call the RPG programs.
EGL uses the System i Toolbox for Java™ to call programs on the System i. The toolbox in turn uses the i5/OS Remote Command server that is a part of the i5/OS Host Servers.
The Remote Command server in i5/OS consists of a server daemon program that listens for TCP/IP requests from “clients”. This program is QZRCSRVSD which runs in the QSYSWRK sub-system.
When the Remote Command Server starts, it starts a number of “worker” jobs that process requests in the QUSRSYS sub-system. These jobs are all named QZRCSRVS.
The next slide describes this process in graphical and technical (in the Notes section) detail
Calling RPG Programs – System Architecture Your EGL application calls RPG through a series of Qxxx system modules, via the JT400.JARJT400.JAR
(Java) toolbox
See See ***Notes***Notes on i5 on i5 module installation, and module installation, and on calling an external RPG on calling an external RPG program and Firewalls.program and Firewalls.
If calling COBOL on the iIf calling COBOL on the i
Calling RPG programs on an iSeries box requires the JT400 toolkit in your build path. There are 2 ways to do this (you only need to do one of these)
1. Add the file to the build path Right-click over your project and select Properties In the window that pops up, select Java Build Path on the left side of the screen Select Add External Jars… Find the jt400.jar file on your pc, select Open, Select OK to close the
properties window.
2. Put the file in the WEB-INFLib folder. Switch to the Resource perspective Expand Web Content WEB-INF lib folder
From Project Explorer, Right-Click over EGLWeb.eglbld and select: Open with Text editorOpen with Text editor Scroll down to the line <remoteCall pgmName=“RPG1”… Click your mouse at the beginning of the line (to set focus) Press Shift/End – to select the entire line (see reverse video line below) Press Ctrl/C – to copy the line Enter a new line, and press Ctrl/V 3 times – to copy/paste the entire line three times Modify the pgmName’s and Alias’ in the new lines to:
RPG2RPG2 RPGCLSP2RPGCLSP2
RPG3RPG3 RPGCLSP3RPGCLSP3
RPG4RPG4 RPGZIPCKRPGZIPCK
Close and save your editsClose and save your edits
3. Create a New Page to Test Your RPG Program Calls
Before creating the page you need to generate the new Build-file entries to Java Right-click over the \EGLSource\ folder and select GenerateGenerate
Now let’s create a page that calls your RPG programs Right-click over \WebContent\ and select, New > Web Page Name the page: callRPG.jspcallRPG.jsp Change the boiler-plate page heading text as shown here…
Right-click and edit the Page CodeFrom inside the JSFHandler
Select and replace all of the boiler-plate code with the code in the Notes section of this slide Note that there is a lot of source code, as the four RPG programs are included as comments at the
bottom Details of the program calls are covered on the next slide
So – you can see from this example, that there is nothing complex whatsoever about calling RPG programs from EGL. This JSFHandler has several different scenarios:
Passing individual parameters to RPGPassing individual parameters to RPG Passing a single recordPassing a single record Passing a record that contains an arrayPassing a record that contains an array
Here are the record definitions (nothing new…hope you’re not disappointed )
Press Ctrl/S (save) your JSFHandlerPress Ctrl/S (save) your JSFHandler
Run the page on the server. Enter the values shown below – and click the buttons.
Note that callRPG2 passes the same data (just using a fixed record instead of individual parms) Note also that you must fill in the input values in the array and click callRPG3 to return the 4 ShipCosts
3. Create a New Page to Test Your CL Program Calls
Before creating the page you need to generate the new Build-file entries to Java Right-click over the \EGLSource\ folder and select GenerateGenerate
Now let’s create a page that calls your COBOL programs Right-click over \WebContent\ and select, New > Web Page Name the page: callCLzipck.jspcallCLzipck.jsp Change the boiler-plate page heading text as shown here…
Right-click and edit the Page CodeFrom inside the JSFHandler
Select and replace all of the boiler-plate code with the code in the Notes section of this slide Note that there is a bit of source code, as the CL program is included as comments at the bottom There is nothing complex in this code There is nothing complex in this code Press Ctrl/S (save) your JSFHandlerPress Ctrl/S (save) your JSFHandler
3. Create a New Page to Test Your CL Program Calls
Before creating the page you need to generate the new Build-file entries to Java Right-click over the \EGLSource\ folder and select GenerateGenerate
Now let’s create a page that calls your COBOL programs Right-click over \WebContent\ and select, New > Web Page Name the page: callcmd.jspcallcmd.jsp Change the boiler-plate page heading text as shown here…
Right-click and edit the Page CodeFrom inside the JSFHandler
Select and replace all of the boiler-plate code with the code in the Notes section of this slide Note that there is a bit of source code, as the CL program is included as comments at the bottom There is nothing complex in this code There is nothing complex in this code We added a try and onException statement for exception handlingWe added a try and onException statement for exception handlingPress Ctrl/S (save) your JSFHandlerPress Ctrl/S (save) your JSFHandler
Run the page on the server. Enter the values shown below – and click the button. Click the button again, to get the error message that the library already exists.
From Project Explorer, in the EGLSource folder: Open the .egldd file using the EGL Build Parts Editor
Select the Service Client Bindings Tab From the Service Bindings Configuration dialog
Click the ADD button Select the Native binding Radio button
On the Add Native Binding DialogEnEnter the following attributes: conversionTable (type): CSOE037CSOE037 Library: Library: EGLPOTEGLPOT location (type):
3. Create a New Page to Test Your Procedure invocation
Before creating the page you need to generate the new Build-file entries to Java Right-click over the \EGLSource\ folder and select GenerateGenerate
Now let’s create a page that calls your COBOL programs Right-click over \WebContent\ and select, New > Web Page Name the page: custrpg.jspcustrpg.jsp Change the boiler-plate page heading text as shown here…
Right-click and edit the Page CodeFrom inside the JSFHandler
Select and replace all of the boiler-plate code with the code in the Notes section of this slide Note that there is a bit of source code, as the RPG program is included as comments at the bottom There is nothing complex in this code There is nothing complex in this code Press Ctrl/S (save) your JSFHandlerPress Ctrl/S (save) your JSFHandler
One time step- The setup steps are the same as in the previous RPG samples
Things that make life easier- If you have external defined data structures that you use to exchange data between RPG and EGL, make sure to specify in the EGL workbench preferences for SQL character types to use EGL char type.
- The default string will not work when exchanging parameter data between EGL and RPG.
- Use the data access wizard to create the EGL record layout
This will create a dynamic record layout, you will need to change this to a fixed record by prefixing the column(field) with a level number
- Remember to add the JT400.jar file to your project
Create a new dynamic Web project named call_getrec
Change the linkage info in the .eglbld file
In the CallLink Elements: Name the program: GETREC GETREC Type: remoteCall remoteCall
Enter the following properties: Alias: GETREC (or blank, since the program name
is the same) conversionTable (type): CSOE037CSOE037 Library: Library: EGLPOTEGLPOT location (type): iseriesd.demos.ibm.comiseriesd.demos.ibm.com luwControl (select): SERVERSERVER remoteBind: GENERATIONGENERATION remoteComType (select): JAVA400JAVA400 remotePgmType (select): STATEFUL (important, you depend on having a STATEFUL (important, you depend on having a
stateful RPG program that continues to read records from the table. stateful RPG program that continues to read records from the table. Close Close and Save Save your Linkage Options – and Close/Save Close/Save the Build File Build File
3. Create a New Page to Test Your RPG Program Calls
Before creating the page you need to generate the new Build-file entries to Java Right-click over the \EGLSource\ folder and select GenerateGenerate
Now let’s create a page that calls your RPG programs Right-click over \WebContent\ and select, New > Web Page Name the page: getcust.jspgetcust.jsp Change the boiler-plate page heading text as shown here…
Right-click and edit the Page Code From inside the JSFHandler
Select and replace all of the boiler-plate code with the code in the Notes section of this slide Note that there is a lot of source code, as the RPG program is included as comments at the bottom Details of the program calls are covered on the next slide
Here’s what you’ll do:The steps for accessing a data area are as follows One time steps
As in the Call examples you will nee the jt400.jar file in your project In addition:
You will need to specify when you create the EGL project that you want to add capabilities to access IBM i resources (DataAreas or data queues). This is done in the New project wizard or in the project properties by checking the EGL with i5/OS objects supportEGL with i5/OS objects support checkbox .
this will put the 2 iseriesobjects packages in EGL source
-
For each dataarea, code the logic using the iseriesobjects package.
- from an EGL “client” logic part:- Service- Interface- JSFHandler- Program- Library
Specify system definitions and dataarea definitions
You use the record Systemdefinition to define:You use the record Systemdefinition to define: the location of the dataarea the location of the dataarea systeminfo.systemName = “iseriesd.demos.ibm.com" The userid to sign on to the IBM i system The userid to sign on to the IBM i system systeminfo.userId = “EGL4RPG"; The password to sign on to the IBM i system The password to sign on to the IBM i system systeminfo.password = EGL4YOU";
You use record DataAreaDefinition to define:You use record DataAreaDefinition to define: Areaname Areaname dataarea1.areaname ="QESTELE"; Libname Libname dataarea1.libname ="QUSRSYS"; NoBytes NoBytes dataarea1.noBytes = 200; Areatype , one of these: Char, numeric, or logical Areatype , one of these: Char, numeric, or logical
Create a new project with jsf support Create a new project eglDtaara Remember to specify EGL with i5/OS object support on the
EGL Settings wizard page
Now let’s create a page that writes to dataareas and reads from dataareas Right-click over \WebContent\ and select, New > Web Page Name the page: eglDtaara.jsptaara.jsp Change the boiler-plate page heading text as shown here…
Right-click and edit the Page CodeFrom inside the JSFHandler
Select and replace all of the boiler-plate code with the code in the Notes section of this slide Note that there is a bit of source code, as the RPG program is
included as comments at the bottom There is nothing complex in this code There is nothing complex in this code Press Ctrl/S (save) your JSFHandlerPress Ctrl/S (save) your JSFHandler
From Page Designer: From Page Data – drag the fieldsthe fields
1.1. datacontentidatacontenti2.2. datadeccontentidatadeccontenti3.3. datalgleontentidatalgleontention to the page Make all fields input From options, specify no Submit buttons (un-
check) Make some space between the fieldsMake some space between the fields From Page Data – select the
(get_dataara_content)) function, and drag it onto the page, to create a submit button.
Accessing Members in Database Files How to access members in database files :How to access members in database files :
Create an SQL AliasCreate an SQL Alias Use an SQL statement in your EGL …or… Use SQL on i to create the alias
Alias is an Alias is an Example: SQL Alias create statement:Example: SQL Alias create statement:
CREATE ALIAS QLINK FOR WFLABXX/MYFILE(mymember)CREATE ALIAS QLINK FOR WFLABXX/MYFILE(mymember) SQL name also works WFLABXX.MYFILE(mymember)WFLABXX.MYFILE(mymember)
Alias will show in RSE as well as OPS NavigatorAlias will show in RSE as well as OPS Navigator
Use SQL Select statement with Alias name•select * from WFLABXX/QLINK
Create Sample Application to Access Source Members
Create a new project with JSF supportCreate a new project: multimem1Change the project properties EGL Runtime Data Source
to a Data Source name that points to iseriesd.demos.ibm.com or your own system.
Now let’s create a page that allows to enter a member nameRight-click over \WebContent\\WebContent\ and select, New > Web PageName the page: lookatmember.jsp.jspChange the boiler-plate page heading text as shown here…
Right-click and edit the Page Code
From inside the JSFHandlerSelect and replace all of the boiler-plate code with the code in the Notes section of this
slideThere is nothing complex in this code There is nothing complex in this code Press Ctrl/S (save) your JSFHandlerPress Ctrl/S (save) your JSFHandler