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

  1. Program Structure
  2. PGM (&Parm1, & Parm2 ) …..Optional
  3. DCLF (Max. of One)
  4. DCL ……… Variable
  5. MONMSG (Program level monitor messages)
  6. Logic with CL Commands
  7. IF , ELSE
  8. CL COMMAND
  9. MONMSG (Command Level )
  10. ENDPGM

image

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

image

image

image

image

image

Comment Line

/* This is comment Line */

image

CHGVAR Command

image

image

image

image

image

Logical Operations

image

Logical Expression

image

image

GOTO Command

image

DO-ENDDO/IF-ELSE Command

image

image

CALL command and Passing Parameters

image

ENDPGM and RETURN Command

image

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.

image

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.

image