Professional Documents
Culture Documents
Exercises
Tuesday, July 28
IBM Summer School 2009
IBM Power Systems: IBM i and AIX
Password __summer09________
Host Name _________________ This is written on the Board
Page 1 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Table of Contents
IBM Summer School 2009 ....................................................................................................................... 1
Starting Rational Developer for IBM I (RDi)........................................................................................... 3
Welcome Window .................................................................................................................................... 3
Create A Connection: ............................................................................................................................... 4
Connect to the IBM i system .................................................................................................................... 5
Check the contents of your Library .......................................................................................................... 6
Compile the Print file for this Lab............................................................................................................ 6
Convert RPG program to a RPG ILE Module.......................................................................................... 7
Copy the RPG program--------------------------------------------------------------------------7
Open the RPG Member SA2205 .............................................................................................................. 8
Delete the Old PLIST Code ---------------------------------------------------------------------9
Review the New Prototype and interface Code -----------------------------------------------9
Add the Prototype and Interface Code------------------------------------------------------- 10
Save the revised source member-------------------------------------------------------------- 11
Compile the revised source member as a MODULE.-------------------------------------- 12
Check the results of the Compile ------------------------------------------------------------- 12
Convert the CL program to a CL Module .............................................................................................. 13
Change the CALL to CALLPRC -------------------------------------------------------------- 13
Create the program object from the two modules .................................................................................. 14
Check the results of the Compile ------------------------------------------------------------- 15
RUN the CL Program ............................................................................................................................. 16
Page 2 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Starting Rational Developer for IBM I (RDi)
Start RDi by clicking on the desktop icon or select RDi from the start menu at the following
location – Start > Programs > IBM Software Delivery Platform > IBM Rational Developer for i >
Rational Developer for i.
You will see the screen below next – If you haven’t taken the time to explore this screen you should!
Remember, this screen can always be seen by clicking on it from the “Help” entry on the toolbar.
Welcome Window
Page 3 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Create A Connection:
Close the Welcome window by clicking on the X in the Tab at the top left of the window.
The default perspective for RDi is the Remote System Explorer and your screen should look like the
one below. Notice the Window named “IBM i Remote System Explorer Getting Started.” This is an
invaluable resource for new users of RDi and you can restore this by clicking on “IBM i RSE Getting
Started” from the “Help” entry on the toolbar.
Right click the IBM i icon and you will be able to create a new connection as shown below.
Page 4 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Connect to the IBM i system
We have now created a connection and we need to login and set our Library list for this lab.
Expand the Library list icon as shown on the right. The login
window will be displayed as shown in the graphic a right. Enter
the profile IBMCLLABXX (Where XX is the number given to
you for this lab). The password is SUMMER09.
Page 5 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Check the contents of your Library
Note: Your library will be IBMCLLABXX where XX is the number assigned to you!
After you login, expand the icon Library list and your remote
Systems view should look like the graphic on the right. Below is
an explanation of the contents of the IBMCLLABXX Library
(XX should correspond to the number assigned to you).
QDDSSRC – Print file source code for the RPG programs in this
lab. You will need to compile this member.
Page 6 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Convert RPG program to a RPG ILE Module
The program SA2205OPM is a report program that uses a PLIST to accept a fifteen character
parameter (LastNameParm) and then uses SQL to produce a report. This section of the lab will show
you how to change the PLIST to a Prototype to accept the LastNameParm parameter and then make
the needed changes to change the program to a module with one callable procedure for the CL
program.
You will see a window similar to the window below. Select rename and rename the member SA2250
as shown.
Page 7 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Finally you will see the window below. Click OK and you have created a copy of the original member.
Now we will add the Prototype, Procedure interface and the Procedure Boundary Specifications.
Page 8 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Delete the Old PLIST Code
Navigate to the code shown below and highlight it. You can cut the code like you would if you were
using Word or you could delete the block of code using the traditional SEU commands – DD.
Page 9 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Add the Prototype and Interface Code
We will need to add the code shown on the previous page to this member. There are a number of areas
we need to add code and each area is described below. If you have problems adding the code; F4 will
give you a format line as shown in the second graphic.
Since this module will not have a main; we will add the H-Spec shown below.
Add the code to check and see if the output file is closed. If it is open it.
Page 10 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
We also don’t need the *inlr = *on, but we do need to manually close the output file.
At the bottom of the source member, add the ending Procedure Boundary Specification as shown
below.
Page 11 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Compile the revised source member as a MODULE.
Right-Click the member in the Remote Explorer Window and select Compile [Prompt]
The window shown below will open – In the dropdown box select “Compile Type” = *Module and
then click OK.
/* Call the Listing program and pass the Last name parameter */
CALL PGM(SA2205) PARM(&lastname)
to this
Save the source member by clicking on the Save icon on the top left corner of the IDE (or do a Ctrl+S).
Right-Click the member in the Remote Explorer Window and select Compile (CRTCLMOD) as shown
below.
Page 13 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
Create the program object from the two modules
You have now created the CL and the RPG modules; the next step is to Bind them into an executable
program object.
The first step is to navigate back to the Remote System window as shown in the graphic below. It is
often a good idea to Right-Click the library and select Refresh. This will refresh the contents of the
window.
Select and Right-Click the CL module that you have created and select Create > program as shown in
the graphic below.
Page 14 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
You will be presented with the window shown below. This is the step where you bind the two modules
together and create an executable program.
Page 15 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
RUN the CL Program
You can now login to the system and run the CL program as shown below. Note to have the report
show any records you need JOHNSON in caps.
The output from your completed program should look like the screen below.
Page 16 of 16
© Copyright 2009 – James E. Buck
CL and The Integrated Language Enviroment Lab.doc
IBM Summer School 2009
IBM Power Systems: IBM i and AIX
Password __summer09________
Host Name _________________ This is written on the Board
Page 1 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Table of Contents
IBM Summer School 2009 ....................................................................................................................... 1
Starting Rational Developer for IBM I (RDi)........................................................................................... 3
Welcome Window .................................................................................................................................... 3
Create A Connection: ............................................................................................................................... 4
Connect to the IBM i system .................................................................................................................... 5
Check the contents of your Library .......................................................................................................... 6
Compile the Print file and the RPG Program required for this lab. -----------------------6
Code the Command .................................................................................................................................. 7
Create the Command-----------------------------------------------------------------------------8
Check the results of the CRTCMD in the Commands Log window. -----------------------9
Run the command from the 5250command line.----------------------------------------------9
Code the Command Processing Program (CPP) ...................................................................................... 9
Create the Command Processing Program (CPP)----------------------------------------- 10
Recreate the RUNPDATRPT command.----------------------------------------------------- 11
Review and Test the Validity Checking Program (VCP)....................................................................... 12
Review the code in the current SA2305VCP ------------------------------------------------ 12
Compile the CL program SA2305VCP ------------------------------------------------------ 12
Change the RUNPDATRPT command------------------------------------------------------- 13
Run the RUNPDATRPT command ----------------------------------------------------------- 14
Change the SA2305VCP CL program.................................................................................................... 15
Change the Error Handling Segment -------------------------------------------------------- 15
Compile the CL program SA2305VCP ------------------------------------------------------ 16
Run the RUNPDATRPT command with the new VCP ------------------------------------- 16
Page 2 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Starting Rational Developer for IBM I (RDi)
Start RDi by clicking on the desktop icon or select RDi from the start menu at the following
location – Start > Programs > IBM Software Delivery Platform > IBM Rational Developer for i >
Rational Developer for i.
You will see the screen below next – If you haven’t taken the time to explore this screen you should!
Remember, this screen can always be seen by clicking on it from the “Help” entry on the toolbar.
Welcome Window
Page 3 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Create A Connection:
Close the Welcome window by clicking on the X in the Tab at the top left of the window.
The default perspective for RDi is the Remote System Explorer and your screen should look like the
one below. Notice the Window named “IBM i Remote System Explorer Getting Started.” This is an
invaluable resource for new users of RDi and you can restore this by clicking on “IBM i RSE Getting
Started” from the “Help” entry on the toolbar.
Right click the IBM i icon and you will be able to create a new connection as shown below.
Page 4 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Connect to the IBM i system
We have now created a connection and we need to login and set our Library list for this lab.
Expand the Library list icon as shown on the right. The login
window will be displayed as shown in the graphic a right. Enter
the profile IBMCLLABXX (Where XX is the number given to
you for this lab). The password is SUMMER09.
Page 5 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Check the contents of your Library
Note: Your library will be IBMCLLABXX where XX is the number assigned to you!
After you login, expand the icon Library list and your
remote Systems view should look like the graphic on
the right. Below id an explanation of the contents of
the IBMCLLABXX Library (XX should correspond to
the number assigned to you).
Compile the Print file and the RPG Program required for this lab.
Expand QDDSSRC and Right-Click LISTGTCSTP then select Compile > CRTPRTF.
Page 6 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Code the Command
The first step is to create the command. Open the source member SA2305CMD in the source file
QCMDSRC and key in the following code. Remember, you can always press F4 to have RDi prompt
the statement.
The following KWD names the parameter, TYPE is a character field, MIN makes is a required field
and PROMPT describes the prompt displayed.
The following KWD names the parameter, TYPE is a character field, MIN makes is a required field
and PROMPT describes the prompt displayed.
/* Prompts for the Second Date */
PARM KWD(eDATE) TYPE(*CHAR) LEN(8) MIN(1) PROMPT('Enter +
End Date YYYYMMDD')
The following KWD names the parameter, TYPE is a character field, LEN(1) sets the length to one,
RSTD restricts the values entered to the values listed in the VALUES keyword, DFT sets the default
value and PROMPT describes the prompt displayed.
/* Prompts and Validates the Batch Variable */
PARM KWD(BATCH) TYPE(*CHAR) LEN(1) RSTD(*YES) DFT(Y) +
VALUES(Y N) PROMPT('Submit to Batch (Y/N)')
Save the source member by clicking on the Save icon on the top left corner of the IDE (or do a Ctrl+S).
Page 7 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Create the Command
Create the command using Compile [Prompt] as shown in the graphic below.
You will see the window shown below. Change the command name to RUNPDATRPT and click OK.
Page 8 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Check the results of the CRTCMD in the Commands Log window.
Add the code below to the member. This code checks the &BATCH parameter and either runs the
program SA2305RPT interactively or submits it to batch.
Page 9 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
The completed code should look similar to the code below.
Do not forget to check the outcome of the compile in the Commands Log window.
Page 10 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Recreate the RUNPDATRPT command.
This time we will include the 2305CPP program. Make the changes shown and click OK. Do not
forget to check the outcome of the compile in the Commands Log window.
Run the command from the 5250 command line. Did you get a report? What happens to the report if
you enter an invalid date?
Page 11 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Review and Test the Validity Checking Program (VCP)
Open the member SA2305VCP in the source file QCLLESRC as shown in the graphic below.
Page 12 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Change the RUNPDATRPT command
You can also change a command that you have
already created. Right-Click the command from the
Remote Systems Explorer window and select Change
as shown in the graphic on the right.
The graphic below shows the CHGCMD and all of the changes you can make. Add the SA2305VCP
program you recently compiled and click OK.
Page 13 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Run the RUNPDATRPT command
From the 5250 command line run the command and use an invalid date as shown below.
What Happened? The program ABENDS with a CPF0555 Function check. This wouldn’t be good for
an interactive program. We’ll fix this in the next few pages.
Page 14 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Change the SA2305VCP CL program
Modify the Error Handling Segment to send a message to the users screen without ending the
command that is running. This will allow the user to change invalid input without exiting the
command.
The error flag &errflg will tell us where the error occurred.
Add the code in RED to the Declarations section of the member SA2305VCP.
Add the code in RED to the Procedure section of the member SA2305VCP.
END: ENDPGM
Page 15 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc
Compile the CL program SA2305VCP
This was shown previously. Be sure to check the Commands Log for the results of the compile.
You will not need to change the command it will run the NEW version of the Validity Checking
Program.
Notice that the Message “Start Date Invalid” now shows the field in error and the program will not
continue till the problem is resolved. The VCP is called each time the user hits the enter key.
Page 16 of 16
© Copyright 2009 – James E. Buck
Creating Commands CPPs & VCPs Lab.doc