Transcript IBM i stuff

®
IBM Software Group
EGL and IBM i
Connectivity, Calling things, JDBC properties
Claus Weiss [email protected]
Last Update: 6/1/2008
© 2008 IBM Corporation
EGL and Remote Programs on IBM i
Topic
Sub-Topics:
 EGL Calls to Remote Programs (Overview)
 Calling programs on IBM i
 Invoking a command
 Invoking a procedure in a Service Program
 Dealing with
members
date fields on IBM i
© 2008 IBM Corporation
2
Calling programs
 In this section you will learn how to call programs
running on an IBM i.
 Here’s what you need to do:
Add the iSeries JT400 toolkit to your project
EGL Logic Part
2. (For each program to call) Add a callLink entry to the EGL Linkage
call program…
Part for your Build File
3. Create the business logic to call the RPG Program
 First we will start with an overview of the system architecture and
process 
© 2008 IBM Corporation
3
Calling RPG Programs - Overview
 Calling a RPG, COBOL, CL, or other program on the System i from EGL is as simple as coding:
call “myProgram”
(parm1, parmN);
 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
 Note: When using pre-started jobs, UDATE will return date value of start of job not the date time
of program start. Use timestamp at start of program to get system time at start of program
© 2008 IBM Corporation
4
Calling RPG Programs – System Architecture
 Your EGL application calls programs through a series of Qxxx system modules, via the
JT400.JAR (Java) toolbox
If
calling programs
directly
Property:
remotePgmType:
stateless
or
stateful
red path
Else
generated COBOL call
blue path
© 2008 IBM Corporation
If calling COBOL on the i
5
EGL and Remote Programs on IBM i
Topic
Sub-Topics:
 EGL Calls to Remote Programs (Overview)
 Calling programs on IBM i
 Invoking a command
 Invoking a procedure in a Service Program
 Dealing with
members
date fields on IBM i
© 2008 IBM Corporation
6
Calling programs – Steps (Revisited)
 Here’s what you need to do:
One time step
 Add the iSeries JT400 toolkit to your project and Java Build Path
Once per project
 Add an EGL Linkage Part for external programs
Once for each program to call
 For each program add a callLink element
For each call
- Code the business logic to call the RPG Program, from an EGL “client” logic part:
- Service
- JSFHandler
- Program
- Library
© 2008 IBM Corporation
7
 Add the JT400 Toolkit to your Project
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-INFLib folder.
 Switch to the Resource perspective
 Expand Web Content  WEB-INF  lib folder
– Drag jt400.jar into this folder
© 2008 IBM Corporation
Drag Here
8
 Add to the Build File’s Linkage Option – 1 of 2


From Project Explorer, Open EGLWeb.eglbld using the EGL Build Parts Editor
From the Window menu, open the Outline View

Add a linkage part for the project
From the externalPrograms part:
 Click: Add
In the CallLink Elements:
 Name the program: RPG1
 Type: remoteCall
Enter the following properties:
 Alias: RPGCLSP1
 conversionTable (type): CSOE037
 Library: EGLPOT
 location (type): iseriesd.demos.ibm.com
 luwControl (select): SERVER
 remoteBind: GENERATION /runtime
 remoteComType (select): JAVA400
 remotePgmType (select): STATELESS
 Close and Save your Linkage Options – and Close/Save the Build File
Note: if you specify remotePgmType stateless or stateful you will not need QEGL on IBM i
© 2008 IBM Corporation
9
 Add to the Build File’s Linkage Option – 2 of 2
 From Project Explorer, Right-Click over EGLWeb.eglbld and select: Open 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:
RPG2
RPG3
RPG4
RPGCLSP2
RPGCLSP3
RPGZIPCK
 Close and save your edits
© 2008 IBM Corporation
10
2. Replicate the Linkage Options for Additional Programs – 3 of 3
 Close and save your edits to the Linkage Options
 Open EGLWeb.eglbld with the EGL Build Parts Editor
 Un-check: Show only specified options
 From the linkage Option, open the drop-down list and
select:externalPrograms
 Close and save your Build file
 Right-click over your EGLWeb project and Generate
© 2008 IBM Corporation
11
3. EGL Program Calls to IBM i
So – you can see from this
example, that there is nothing
complex whatsoever about calling
programs from EGL. This
JSFHandler has several different
scenarios:
 Passing individual parameters to RPG
 Passing a single record
 Passing a record that contains an array
 Here are the record definitions
 Fixed records are required
 Fixed arrays are required
© 2008 IBM Corporation
12
EGL and Remote Programs on IBM i
Topic
Sub-Topics:
 EGL Calls to Remote Programs (Overview)
 Calling programs on IBM i
 Invoking a command
 Invoking a procedure in a Service Program
 Dealing with
date fields on IBM i
members
© 2008 IBM Corporation
13
Invoking IBM i comands – Steps
 Here’s what you’ll do:
The steps for invoking commands on IBM i is similar as for
calling a program, but the linkage part needs to point to the
QCMDEXC program.
One time step
- Add the iSeries JT400 toolkit to your project and Java Build Path
For this step, follow the instructions for calling an RPG program
Once in a project for external calls
- Add an EGL Linkage Part for the QCMDEXC program
For each call to QCMDEXC
- Code the logic to add the command string as
a parameter and to call the QCMDEXC Program,
from an EGL “client” logic part:
- Service
- JSFHandler
- Program
- Library
© 2008 IBM Corporation
14
 Add to the Build File’s Linkage Option
 From Project Explorer, Open the .eglbld file
using the EGL Build Parts Editor
 From the Window menu, open the Outline View
 (It should be located at the bottom left corner of the
tool, next to “Page Data” View)
 From the Outline View, select “externalPrograms”
 (you should have created this during the calling Cobol
workshop)
From the externalPrograms part:
 Click: Add
In the CallLink Elements:
 Name the program: COMANDONI
 Type: remoteCall
Enter the following properties:
 Alias: QCMDEXC
 conversionTable (type): CSOE037
 Library: %LIBL%
 location (type):
iseriesd.demos.ibm.com
 luwControl (select): SERVER
 remoteBind: GENERATION
 remoteComType (select): JAVA400
 remotePgmType (select): STATEFUL
 Close and Save your Linkage Options –
and Close/Save the Build File
© 2008 IBM Corporation
15
EGL and Remote Programs on IBM i
Topic
Sub-Topics:
 EGL Calls to Remote Programs (Overview)
 Calling programs on IBM i
 Invoking a command
 Invoking a procedure in a Service Program
 Dealing with
members
date fields on IBM i
© 2008 IBM Corporation
16
Invoking a procedure in a Service Program – Steps
 Here’s what you need to do:
The steps for invoking procedures are different than for
calling a program, no linkage part is need instead you will use a
deployment descriptor instead.
No Call statement is needed instead you invoke the procedure
like a function, the procedure interface is described in an EGL
interface.
One time step
- Add the iSeries JT400 toolkit to your project and Java Build Path
Once for each procedure to invoke
- Add an EGL deployment descriptor entry
For each invocation
- Code the business logic to call the RPG Program,
from an EGL “client” logic part:
- Service
- Interface
- JSFHandler
- Program
- Library
© 2008 IBM Corporation
17
 Add to the Service Client binding
 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 Dialog
Enter the following attributes:
 conversionTable (type): CSOE037
 Library: EGLPOT
 location (type):
iseriesd.demos.ibm.com
 Userid(type): EGL4RPG
 Password(type): EGL4YOU
 Press the Finish button
 Close and Save your Deployment
Descriptor –
© 2008 IBM Corporation
18
4. Create the Interface for procedure invocation
Before finishing the project you need to create the EGL interface
 Right-click over the \EGLSource\ folder and select New  Interface


Package name: Interfaces
EGL sourec file name: getdssol
package Interfaces;
import basicrecords.cstruc;
// interface
interface getdssol
function getrecord(custnoi char(7),myds cstruc, fdback char(20)) ;
end
© 2008 IBM Corporation
19
EGL and Remote Programs on IBM i
Topic
Sub-Topics:
 EGL Calls to Remote Programs (Overview)
 Calling programs on IBM i
 Invoking a command
 Invoking a procedure in a Service Program
 Dealing with
 members
 date fields on IBM i
© 2008 IBM Corporation
20
 Accessing members in data base files
 How to access members in data base files :
 Create an SQL Alias
 Use an SQL statement in your EGL
 Use SQL on i to create the alias
 Alias is an
 Sample use SQL Alias statement to create :
 CREATE ALIAS QLINK FOR WFLABXX/MYFILE(mymember)

SQL name also works
WFLABXX.MYFILE(mymember)
 Alias will show in RSE as well as OPS Navigator
•Use SQL Select statement with Alias name
•select * from WFLABXX/QLINK
© 2008 IBM Corporation
21
Some notes for accessing DB2 on i
In the jdbc data source when working with yyyy
Specify these properties:
 dateformat : iso
 timeformat: iso
 Setting a date to 0001-01-01
 Assign in EGL = “01/01/0001” ; use Quotes
 Or assign NULL, to Null the date field
 One more:
 For working with the library list, use
 Naming: system
© 2008 IBM Corporation
22