CL Programming
Overview:
This module enables the student to
understand the concept of CL program.
Outline:
Topics covered,
- CL
introduction
- CL
program introduction
- Concept
of CL commands
- Concept
of error handling
Objective:
By the end of this module, the student should be
able to:
- Create
CL program
- Use
CL commands
- Compilation
of CL program
- Commands
related to files.
- Use of MONMSG command
Control language(CL):
Control Language is the primary interface to the
operating system and can be used at the same time by user at different
workstations. A single control language statement is called a command. Commands
can been entered in the following ways:
·
Individually from a workstation.
·
As part of batch jobs.
·
As source statements to create a CL program or
procedure
Here we write a source program in ‘CL’ to attach our library in our profile.
Lab session:
- Use
STRPDM / WRKMBRPDM on command line to create a CL program.
- Create
program member ‘SETMYLIBL’ in source file PB01U01S/ MYCLP
- Write
command line using program editor
- Save
program member
- Compile
CL program in library PB01U01O
- Run
program SETMYLIBL
- Change
user profile to run programs every time user logins AS/400.
Steps:
- Enter
command WRKMBRPDM at command line.
- Edit
library list using ‘EDTLIBL’ command.
- After
adding your libraries change your library as current library using command
CHGUSRLIB.
- Now
create CL program using CL program.
Press ‘F6’ to create ‘CL’ program and add Source
Member as SETMYLIBL source type as CLP.
Start Source Entry
Utility (STRSEU)
Type choices, press Enter.
Source file
. . . . . . . . . . > MYCLP
Name, *PRV
Library . . . . . . . . . . .
> PB01U01S Name, *LIBL, *CURLIB, *PRV
Source member
. . . . . . . . . SETMYLIBL Name, *PRV, *SELECT
Source type
. . . . . . . . . . CLP Name, *SAME, BAS, BASP...
Text 'description' . . . . . . . 'program to set libraries in library
list'
Bottom
F3=Exit
F4=Prompt F5=Refresh F12=Cancel
F13=How to use this display
F24=More keys
Write Library name, source type as ‘CLP’ write
text description as shown above & hit enter.
As we already discussed the CL commands we are
able to write or execute those commands using CL program. Using CL we are able
to execute group of commands at a time.
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==> SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
Member SETMYLIBL added to file
SHLIB/QCLPSRC.
+
In CL /* ----
*/ is used to comment the statement
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
''''''' /*PROGRAM : SETMYLIBL*/
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
Member SETMYLIBL added to file
SHLIB/QCLPSRC.
+
Press enter.
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
I001.00
/*PROGRAM : SETMYLIBL*/
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
CL program start with PGM & end with PGM.
We have to write program as shown below-
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.00 /* PROGRAM: SETMYLIBL */
0002.00 /* PURPOSE: TO SET LIBRARIES IN
LIBRARY LIST'*/
0003.00 /* PROGARMMER : PB01U01O */
0004.00 PGM
....... ADDLIBLE
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
Press F4 which gives you following screen:
Add Library List Entry
(ADDLIBLE)
Type choices, press Enter.
Label .
. . . . . . . . . . . .
Library
. . . . . . . . . . . .
PB01U01O Name
Library list position:
List position . . . . . . .
. *FIRST *FIRST, *LAST, *AFTER...
Reference library . . . . .
. Name
Comment
. . . . . . . . . . . .
Bottom
F3=Exit
F4=Prompt F5=Refresh F12=Cancel
F13=How to use this display
F24=More keys
Press enter after entering your library name.
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.00 /* PROGRAM: SETMYLIBL */
0002.00 /* PURPOSE: TO SET LIBRARIES IN
LIBRARY LIST'*/
0003.00 /* PROGARMMER : PB01U01S */
0004.00 PGM
0004.01 ADDLIBLE LIB (PB01U01O)
0007.00 ENDPGM
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
Enter another library as discussed above which
gives you following program.
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.00 /* PROGRAM: SETMYLIBL */
0002.00 /* PURPOSE: TO SET LIBRARIES IN
LIBRARY LIST'*/
0003.00 /* PROGARMMER : MYCLP */
0004.00 PGM
0005.00 ADDLIBLE LIB(PB01U01O) POSITION(*LAST)
0006.00 ADDLIBLE LIB(PB01U01D) POSITION(*LAST)
0007.00 ENDPGM
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
(C)
COPYRIGHT IBM CORP. 1981, 2002.
Press F3 after writing of above program.
Compile this program using option ‘14’ and
press F4 or using command ‘CRTCLPGM + F4’ as shown below.
Create CL Program
(CRTCLPGM)
Type choices, press Enter.
Program
. . . . . . . . . . . . > SETMYLIB Name
Library . . . . . . . . . . .
> PB01U01S Name, *CURLIB
Source file
. . . . . . . . . . > MYCLP Name
Library . . . . . . . . . . .
> PB01U01O Name, *LIBL, *CURLIB
Source member
. . . . . . . . . > SETMYLIB
Name, *PGM
Text 'description' . . . . . . . *SRCMBRTXT
Additional
Parameters
Replace program . . . . . . . . > *NO *YES, *NO
Bottom
F3=Exit
F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
Note: you can set program library default by
pressing F18 in WRKMBRPDM screen.
PRESS ENTER
Confirm Compile of
Member
The
following object already exists for the compile operation:
Object which exists . . . . . . .
. : SETMYLIB
Library . . . . . . . . . . . . .
: PB01U01O
Object type . . . . . . . . . . .
. : *PGM
Member to compile . . . . . . . .
. : SETMYLIB
File . . . . . . . . . . . . . . . . :
MYCLP
Library . . . . . . . . . . . . .
: PB01U01S
Type choice, press Enter.
Press F12=Cancel to return and not perform the
compile operation.
Delete existing object . . . . . . . .
Y Y=Yes, N=No
F12=Cancel
Make option ‘Delete existing object’ as ‘Y’
to create object.
Work with Members
Using PDM S653278B
File .
. . . . . MYCLP
Library . . . . PB01U01O Position to . . . . .
Type options, press Enter.
2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename
8=Display description 9=Save 13=Change text 14=Compile
15=Create module...
Opt
Member Type Text
14 SETMYLIBL CLP
program to set libraries in library list
Bottom
Parameters or command
===>
F3=Exit F4=Prompt F5=Refresh F6=Create
F9=Retrieve F10=Command entry F23=More options F24=More keys
Member SETMYLIBL in file PB01U01S/MYCLP
changed with 7 records.
HIT ENTER WHICH DISPLAYS YOU FOLLOWING
MESSAGE:
Work with Members
Using PDM S653278B
File .
. . . . . MYCLP
Library . . . . PB01U01S Position to . . . . .
Type options, press Enter.
2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename
8=Display description 9=Save 13=Change text 14=Compile
15=Create module...
Opt
Member Type Text
SETMYLIBL CLP program to set libraries in library
list
Bottom
Parameters or command
===>
F3=Exit F4=Prompt F5=Refresh F6=Create
F9=Retrieve F10=Command entry F23=More options F24=More keys
Program SETMYLIBL created in library
PB01U01S.
To call/ run the program use ‘CALL
SETMYLIBL’ command on command line or simply use ‘C’ option in
option. This program will add these 2 libraries in your program
Edit Library
List
System: S653278B
Type new/changed information, press
Enter.
Sequence Sequence Sequence
Number Library Number Library Number Library
0 150 300
10 QGPL 160 310
20 QTEMP 170 320
30 PB01U01O 180 330
40 PB01U01D 190 340
50 200 350
60 210 360
70 220 370
80 230 380
90 240 390
100 250
400
110 260
410
120 270 420
130 280
430
140 290
440
More...
F3=Exit
F5=Refresh F12=Cancel
Press enter & attached this program in
your profile.
If you run the program again in same job
you will get following error,
Display Program
Messages
Job
074778/PB01U01S/QPADEV000F started on 02/11/05 at 11:36:05 in subsystem Q
Message queue PB01U01S is allocated to another
job.
CPF2110 received by SETMYLIBL at 500. (C D I
R)
Type reply, press Enter.
Reply . . .
F3=Exit
F12=Cancel
For handling this error in CL ‘MONMSG
(Monitor Message)’ command is used in CL. This command is used at two levels
- Program level : Apply for whole program
- Command level : Apply for particular command only
Command is written as shown below:
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.00 /* PROGRAM: SETMYLIBL */
0002.00 /* PURPOSE: TO SET LIBRARIES IN
LIBRARY LIST'*/
0003.00 /* PROGARMMER : PB01U01 */
0004.00 PGM
''''''' MONMSG
0005.00 ADDLIBLE LIB(PB01U01S) POSITION(*LAST)
0006.00 ADDLIBLE LIB(PB01U01SD) POSITION(*LAST)
0007.00 ENDPGM
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
After writing command press ‘F4’ which
provides you following screen—
Monitor Message
(MONMSG)
Type choices, press Enter.
Label .
. . . . . . . . . . . .
Message identifier . . . . . . . CPF0000 Name
+ for more values
Comparison data . . . . . . . . *NONE
Command to execute . . . . . . .
Comment
. . . . . . . . . . . .
Bottom
F3=Exit
F4=Prompt F5=Refresh F12=Cancel
F13=How to use this display
F24=More keys
Message Identifier must be ‘7’
character only. This identifier handles all sorts of error. We are defining
this message at program level.
Columns . . . : 1
71 Edit MYCLP/PB01U01S
SEU==>
SETMYLIBL
FMT
** ...+... 1 ...+... 2 ...+... 3 ...+...
4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.00 /* PROGRAM: SETMYLIBL */
0002.00 /* PURPOSE: TO SET LIBRARIES IN
LIBRARY LIST'*/
0003.00 /* PROGARMMER : PB01U01 */
0004.00 PGM
0004.01 MONMSG MSGID(CPF0000)
0005.00 ADDLIBLE LIB(PB01U01O) POSITION(*LAST)
0006.00 ADDLIBLE LIB(PB01U01D) POSITION(*LAST)
0007.00 ENDPGM
****************** End of data ****************************************
F3=Exit
F4=Prompt F5=Refresh F9=Retrieve
F10=Cursor F11=Toggle
F16=Repeat find F17=Repeat change F24=More keys
Press F3 & again complie the program
using ‘14’ option.
How to create user profile &
attach ‘CL’ program in your profile:
To create user profile ‘CRTUSRPRF’ on
command line & press F4, which gives you following, output:
Create User Profile
(CRTUSRPRF)
Type choices, press Enter.
User profile . . . . . . . . . . PB01U01 Name
User password
. . . . . . . . . PB1U01 Character value, *USRPRF...
Set
password to expired . . . . *NO
*NO, *YES
Status . . . . . . . . . . . . . *ENABLED
*ENABLED, *DISABLED
User class . . . . . . . . . . . *USER
*USER, *SYSOPR, *PGMR...
Assistance level . . . . . . . . *SYSVAL
*SYSVAL, *BASIC, *INTERMED...
Current library . . . . . . . . *CRTDFT
Name, *CRTDFT
Initial program to call . . . .
*NONE Name, *NONE
Library . . . . . . . . . .
. Name, *LIBL,
*CURLIB
Initial menu . . . . . . . . . . MAIN
Name, *SIGNOFF
Library . . . . . . . . . .
. *LIBL Name, *LIBL, *CURLIB
Limit capabilities . . . . . . . *NO
*NO, *PARTIAL, *YES
Text 'description' . . . . . . . *BLANK
Bottom
F3=Exit
F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
Press enter to create your profile having
name ‘PB01U01’ & same password as we
enter above.
Which gives you message at your message
area.
Now
use CHGUSRPRF on command line to attached your CL program to your
profile as shown below
Create User Profile
(CRTUSRPRF)
Type choices, press Enter.
User profile . . . . . . . . . . >
PB01U01S Name
User password
. . . . . . . . . *USRPRF Character value, *USRPRF...
Set
password to expired . . . . *NO
*NO, *YES
Status . . . . . . . . . . . . . *ENABLED
*ENABLED, *DISABLED
User class . . . . . . . . . . . *USER
*USER, *SYSOPR, *PGMR...
Assistance level . . . . . . . . *SYSVAL
*SYSVAL, *BASIC, *INTERMED...
Current library . . . . . . . . *CRTDFT
Name, *CRTDFT
Initial program to call . . . .
SETMYLIBL Name, *NONE
Library . . . . . . . . . .
. PB01U01O Name, *LIBL, *CURLIB
Initial menu . . . . . . . . . . MAIN
Name, *SIGNOFF
Library . . . . . . . . . .
. *LIBL Name, *LIBL, *CURLIB
Limit capabilities . . . . . . . *NO
*NO, *PARTIAL, *YES
Text 'description' . . . . . . . *BLANK
Bottom
F3=Exit
F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
Press enter which change your profile.
No comments:
Post a Comment