CL 400 - skill-at/AS-400-Training GitHub Wiki
Introduction to CL programming
- CL stands for Control Language
- Control language is the primary interface to the Operating System.
- CL programs can be used in batch or interactive processing
- CL programs are meant for system handling, system resources and strictly not for data handling
- CL is based on commands. All program statements are nothing more than command.
Programming Structure
- Program Structure
- PGM (&Parm1, & Parm2 ) …..Optional
- DCLF (Max. of One)
- DCL ……… Variable
- MONMSG (Program level monitor messages)
- Logic with CL Commands
- IF , ELSE
- CL COMMAND
- MONMSG (Command Level )
- ENDPGM
CL command names
It consists of a combination of verbs or actions followed by a noun or phrase.
Command = verb + object acted on
For Example: CRTLIB, DLTLIB, DSPLIB.
Limitations of CL programs and procedures
We cannot use CL programs and procedures for the following purposes:
- It cannot be used to update or add records in database files.
- It cannot use printer files.
- It cannot use sub files DSPF.
- We cannot declare more than one object (file) in a CL program ( In CLLE, we can use more than 1 file to read with OPENID concept).
Variable Declarations
Comment Line
/* This is comment Line */
CHGVAR Command
Logical Operations
Logical Expression
GOTO Command
DO-ENDDO/IF-ELSE Command
CALL command and Passing Parameters
ENDPGM and RETURN Command
Limitations of CL programs and procedures
We cannot use CL programs and procedures for the following purposes:
- It cannot be used to update or add records in database files.
- It cannot use printer files.
- It cannot use sub files DSPF.
- It cannot use the program described display files.
Using QCMDEXC API in CL program
- The Execute Command (QCMDEXC) API is an IBM-supplied program that executes/activates another single command.
- Values cannot be returned from the command fired through QCMDEXC. Therefore, RTV* commands cannot be fired through the QCMDEXC program.
Subroutines in CL
- SUBR (Subroutine) command is used in CL program to begin the subroutine block.
- ENDSUBR (End Subroutine) command is used in CL program to end the subroutine block.
- CALLSUBR(Call Subroutine) command is used in CL program to execute/call a subroutine.
- RTNSUBR command is used to return a value and exit the subroutine when RTNVAL is optional to use.