Académique Documents
Professionnel Documents
Culture Documents
Steps to Create an
IBM i CL Program
ISV Solutions
IBM Power Systems
Technical Sales Specialist
Advanced Technical Skills (ATS)
Version 3/8/2010
Parts of a CL Program
While each source statement entered as part of a CL program is actually a CL command, the source can be
divided into the basic parts that are used in many typical CL programs. The sequence, combination, and
extent of these components are determined by the logic and design of an application.
PGM command
PGM PARM(&A)
Optional PGM command beginning the procedure and identifying any parameters received.
Declare commands
(DCL, DCLF, COPYRIGHT, DCLPRCOPT)
Mandatory declaration of procedure variables when variables are used, and optional definition of the size of
the subroutine stack. The declare commands must precede all other commands except the PGM command.
CL processing commands
CHGVAR, SNDPGMMSG, OVRDBF, DLTF,
CL commands used as source statements to manipulate constants or variables (this is a partial list).
Logic control commands
IF, THEN, ELSE, DO, ENDDO, DOWHILE, DOUNTIL, DOFOR, LEAVE, ITERATE, GOTO, SELECT,
ENDSELECT, WHEN, OTHERWISE, CALLSUBR, SUBR, RTNSUBR, ENDSUBR
Commands used to control processing within the CL procedure.
Create a
library to
contain CL
programs
and their
source
Library
. . . . . . . . . . . . > SUNDT
Name
Library type . . . . . . . . . .
*TEST
*PROD, *TEST
Text 'description' . . . . . . .
Bottom
F3=Exit
F4=Prompt
F5=Refresh
F10=Additional parameters
F12=Cancel
F24=More keys
File . . . . . . . . . . . . . .
Library
. . . . . . . . . . .
Record length
. . . . . . . . .
QCLSRC
SUNDT
Name
Name, *CURLIB
92
Number
Member, if desired . . . . . . .
*NONE
Text 'description' . . . . . . .
Create a
source
physical
file to
contain CL
source
members
Bottom
F3=Exit
F4=Prompt
F5=Refresh
F10=Additional parameters
F12=Cancel
F24=More keys
There are
many ways
to get to
your CL
source
member
files
Selection or command
==>
F3=Exit
F4=Prompt
F9=Retrieve
F12=Cancel
F18=Change defaults
F10=Command entry
STRPDM
2010 IBM Corporation
Library
. . . . . . . . . . .
SUNDT
ASP number . . . . . . . . . .
*ALL
1-32, *ALL
ASP device . . . . . . . . . .
The
system will
remember
the library
name for
future
times
F3=Exit
F5=Refresh
F12=Cancel
2010 IBM Corporation
List type
. . . . . . .
*ALL
RATSI00
Position to . . . . .
3=Copy
4=Delete
5=Display
7=Rename
8=Display description
9=Save
10=Restore ...
Use option
12 to work
with the
library
ASP
Opt
Library
Type
12
SUNDT
*TEST
Device
Text
Dan Sundt Test Library
Bottom
Parameters or command
===>
F3=Exit
F4=Prompt
F5=Refresh
F6=Create
F9=Retrieve
F10=Command entry
F23=More options
F24=More keys
Have you tried the modern alternative to PDM? Press F1 for more details.
2010 IBM Corporation
Library . . . . .
SUNDT
RATSI00
Position to . . . . . . . .
Position to type
. . . . .
3=Copy
8=Display description
4=Delete
9=Save
5=Display
7=Rename
10=Restore
11=Move ...
Opt
Object
Type
Attribute
Text
12
QCLSRC
*FILE
PF-SRC
Use option
12 to work
with the
source
physical
file
Bottom
Parameters or command
===>
F3=Exit
F4=Prompt
F5=Refresh
F6=Create
F9=Retrieve
F10=Command entry
F23=More options
F24=More keys
Have you tried the modern alternative to PDM? Press F1 for more details.
2010 IBM Corporation
File
. . . . . .
RATSI00
QCLSRC
Library . . . .
SUNDT
Position to
. . . . .
3=Copy
8=Display description
Opt
Member
4=Delete 5=Display
9=Save
Type
13=Change text
6=Print
14=Compile
7=Rename
15=Create module.
Text
Parameters or command
===>
F3=Exit
F4=Prompt
F5=Refresh
F6=Create
F9=Retrieve
F10=Command entry
F23=More options
F24=More keys
Use
function
key F6 to
create a
new
member
Have you tried the modern alternative to PDM? Press F1 for more details.
2010 IBM Corporation
Source file
Library
. . . . . . . . . . > QCLSRC
. . . . . . . . . . . >
Source member
Source type
. . . . . . . . .
. . . . . . . . . .
Text 'description' . . . . . . .
SUNDT
Name, *PRV
Name, *LIBL, *CURLIB, *PRV
CLPGM1
CLP
Sample CL Program
Function
key F6
from the
previous
screen
issues the
STRSEU
command
Bottom
F3=Exit
F4=Prompt
F5=Refresh
F12=Cancel
F24=More keys
80
Edit
SUNDT/QCLSRC
SEU==>
CLPGM1
FMT **
'''''''
From here
start
entering
CL source
statements
and
commands
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
'''''''
F3=Exit
F4=Prompt
F16=Repeat find
F5=Refresh
F9=Retrieve
F17=Repeat change
F10=Cursor
F11=Toggle
F24=More keys
+
2010 IBM Corporation
80
Edit
SUNDT/QCLSRC
SEU==>
CLPGM1
FMT **
0001.00
PGM
/* Sample CL Program */
100308
I202.00
SNDPGMMSG
100308
0003.00
ENDPGM
100308
I2 will add
two new
empty lines
F3=Exit
F4=Prompt
F16=Repeat find
F5=Refresh
Press
function
key F4 to
prompt and
format a
CL
command
F9=Retrieve
F17=Repeat change
F10=Cursor
F11=Toggle
F24=More keys
(C) COPYRIGHT IBM CORP. 1981, 2007.
2010 IBM Corporation
Change/create member
Y=Yes, N=No
. . . . . . . . . . . . .
CLPGM1
. . . . . . . . . . . . . .
QCLSRC
Member
File
. . . . . . .
Library . . . . . . . . . . . .
Text
. . . . . . . . . . . . . .
Resequence member . . . . . . . .
SUNDT
Name
Sample CL Program
Y=Yes, N=No
Start . . . . . . . . . . . . .
0001.00
0000.01-9999.99
Increment . . . . . . . . . . .
01.00
00.01-99.99
. . . . . . . . . . .
Y=Yes, N=No
Return to editing . . . . . . . . .
Y=Yes, N=No
Go to member list . . . . . . . . .
Y=Yes, N=No
Print member
F3=Exit
F4=Prompt
F5=Refresh
Make sure
it says Y to
save any
changes
F12=Cancel
Have you tried the modern alternative to SEU? Press F1 for more details.
A Y here
will save
any
changes
and then
return back
to editing
2010 IBM Corporation
of
3 by
10
Column :
13
92 by 126
Control :
CMD ..+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9..
************Beginning of data**************
PGM
/* Sample CL Program */
<-End of
SNDPGMMSG
<-End of
ENDPGM
<-End of
************End of Data********************
EDTF does
not have
integrated CL
command
prompting
support
F2=Save F3=Save/Exit
F19=Left
F20=Right
F12=Exit
F15=Services
F16=Repeat find
F17=Repeat change
File
. . . . . .
RATSI00
QCLSRC
Library . . . .
SUNDT
Position to
. . . . .
3=Copy
8=Display description
4=Delete 5=Display
9=Save
13=Change text
Opt
Member
Type
Text
14
CLPGM1
CLP
Sample CL Program
6=Print
14=Compile
7=Rename
15=Create module...
You need
to compile
the
member to
create a
CL
program
Bottom
Parameters or command
===>
F3=Exit
F4=Prompt
F5=Refresh
F6=Create
F9=Retrieve
F10=Command entry
F23=More options
F24=More keys
2010 IBM Corporation
Program
. . . . . . . . . . . . > CLPGM1
Library
. . . . . . . . . . . >
Source file
Library
SUNDT
. . . . . . . . . . > QCLSRC
. . . . . . . . . . . >
Source member
SUNDT
. . . . . . . . . > CLPGM1
Text 'description' . . . . . . .
Name
Name, *CURLIB
Name
Name, *LIBL, *CURLIB
Name, *PGM
*SRCMBRTXT
Option 14
from the
previous
screen
issues the
CRTCLPGM
command
Additional Parameters
Replace program
. . . . . . . . > *NO
*YES, *NO
Bottom
F3=Exit
F4=Prompt
F5=Refresh
F10=Additional parameters
F12=Cancel
F24=More keys
Queue . . . . . :
Library . . . :
Severity
. . . :
SUNDT
System:
RATSI00
Program . . . . :
*DSPMSG
QUSRSYS
00
Library . . . :
Delivery
. . . :
*NOTIFY
You want
to see that
it
completed
normally
Bottom
F3=Exit
F11=Remove a message
F12=Cancel
F13=Remove all
F24=More keys
2=Change
8=Attributes
3=Hold
4=Delete
5=Display
6=Release
Device or
Opt
5
7=Messages
File
User
Queue
CLPGM1
SUNDT
QPRINT
User Data
Total
Cur
Sts
Pages
Page
RDY
Copy
View the
spooled file
using
option 5
Bottom
Parameters for options 1, 2, 3 or command
===>
F3=Exit
F10=View 4
F11=View 2
F12=Cancel
F22=Printers
F24=More keys
. . . . . :
CLPGM1
Page/Line
Control . . . . .
Find
Columns
1/26
1 - 130
. . . . . .
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9...
SEQNBR
100-
PGM
/* Sample CL Program */
200-
SNDPGMMSG
300-
ENDPGM
* * * * *
5761SS1 V6R1M0
080215
E N D
O F
S O U R C E
Control Language
* * * * *
SUNDT/CLPGM1
RATSI
Cross Reference
* CPD0792 10
5761SS1 V6R1M0
E N D
080215
O F
C R O S S
R E F E R E N C E
Control Language
* * *
SUNDT/CLPGM1
Message Summary
Severity
Total
1
0-9
10-19
20-29
30-39
40-49
50-59
60-69
70-79
80-89
90-99
E N D
* * * * *
O F
E N D
M E S S A G E
O F
You want
to see that
* *
the
RATSI
program
created
and
without
errors
S U M M A R Y
C O M P I L A T I O N
* *
* * * * *
2010 IBM Corporation
Library
. . . . . . :
SUNDT
Number of objects
. :
Type . . . . . . . . :
TEST
Create authority . . :
*SYSVAL
*SYSBAS
*SYSBAS
. :
Opt
Object
Type
Attribute
Size
Text
CLPGM1
*PGM
CLP
40960
Sample CL Program
QCLSRC
*FILE
PF
36864
Now you
have a
executable
CL
program
Bottom
F3=Exit
F12=Cancel
F17=Top
F18=Bottom
DSPLIB LIB(SUNDT)
2010 IBM Corporation
Library . . . . .
SUNDT
RATSI00
Position to . . . . . . . .
Position to type
. . . . .
3=Copy
8=Display description
4=Delete
9=Save
5=Display
7=Rename
10=Restore
11=Move ...
Opt
Object
Type
Attribute
Text
16
CLPGM1
*PGM
CLP
Sample CL Program
QCLSRC
*FILE
PF-SRC
You can
call a
program
from within
PDM using
option 16
Bottom
Parameters or command
===>
F3=Exit
F4=Prompt
F5=Refresh
F6=Create
F9=Retrieve
F10=Command entry
F23=More options
F24=More keys
2010 IBM Corporation
Program
. . . . . . . . . . . .
Library
. . . . . . . . . . .
CLPGM1
SUNDT
Name
Name, *LIBL, *CURLIB
Parameters . . . . . . . . . . .
Use CALL
from a
command
line or from
within a job
schedule
entry
Bottom
F3=Exit
F4=Prompt
F5=Refresh
F12=Cancel
F24=More keys
CALL PGM(SUNDT/CLPGM1)
2010 IBM Corporation
Queue . . . . . :
Library . . . :
Severity
. . . :
QSYSOPR
QSYS
System:
RATSI00
Program . . . . :
*DSPMSG
Library . . . :
99
Delivery
. . . :
*HOLD
ended abnormally.
. . . :
SUNDT
03/08/10
11:55:50
F3=Exit
F11=Remove a message
F12=Cancel
F13=Remove all
F24=More keys
Verifying
that my CL
program
ran
Bottom
successfully
DSPMSG MSGQ(QSYSOPR)
2010 IBM Corporation
http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/rbam6/rbam6clmain.htm
2010 IBM Corporation
Special notices
This document was developed for IBM offerings in the United States as of the date of publication. IBM may not make these offerings available in
other countries, and the information is subject to change without notice. Consult your local IBM business contact for information on the IBM offerings
available in your area.
Information in this document concerning non-IBM products was obtained from the suppliers of these products or other public sources. Questions on
the capabilities of non-IBM products should be addressed to the suppliers of those products.
IBM may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you
any license to these patents. Send license inquires, in writing, to IBM Director of Licensing, IBM Corporation, New Castle Drive, Armonk, NY 105041785 USA.
All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.
The information contained in this document has not been submitted to any formal IBM test and is provided "AS IS" with no warranties or guarantees
either expressed or implied.
All examples cited or described in this document are presented as illustrations of the manner in which some IBM products can be used and the
results that may be achieved. Actual environmental costs and performance characteristics will vary depending on individual client configurations and
conditions.
IBM Global Financing offerings are provided through IBM Credit Corporation in the United States and other IBM subsidiaries and divisions worldwide
to qualified commercial and government clients. Rates are based on a client's credit rating, financing terms, offering type, equipment type and
options, and may vary by country. Other restrictions may apply. Rates and offerings are subject to change, extension or withdrawal without notice.
IBM is not responsible for printing errors in this document that result in pricing or information inaccuracies.
All prices shown are IBM's United States suggested list prices and are subject to change without notice; reseller prices may vary.
IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless, our warranty terms apply.
Any performance data contained in this document was determined in a controlled environment. Actual results may vary significantly and are
dependent on many factors including system hardware configuration and software design and configuration. Some measurements quoted in this
document may have been made on development-level systems. There is no guarantee these measurements will be the same on generally-available
systems. Some measurements quoted in this document may have been estimated through extrapolation. Users of this document should verify the
applicable data for their specific environment.
Revised September 26, 2006
2010 IBM Corporation