CL programs


CL programs and procedures

CL programs and procedures are created from source statements that consist entirely of CL commands.

A CL source program is the set of CL source statements that can be compiled into either an OPM program or ILE module that can be bound into programs made up of modules written in CL or other languages.

There are four types of CL programs and procedures: procedure, module, program, and service program:

CL procedure

A procedure is a set of self-contained high-level language statements that performs a particular task and then returns to the caller.

In CL, a procedure typically begins with a PGM statement and ends with an ENDPGM statement.

CL module

A module is the object that results from compiling high-level language source statements using an Integrated Language Environment (ILE) compiler.

A CL module is created by compiling CL source using the Create CL Module (CRTCLMOD) command.

A module must be bound into a program to run.

CL program

A control language (CL) program is a program that is created from source statements consisting entirely of CL commands.

The operating system supports two types of programs: ILE program and OPM CL program.

An ILE program is a program written in an Integrated Language Environment (ILE)-conforming high-level language.

ILE programs are IBM i objects that contain one or more modules.

Modules cannot be run until they are bound into programs. These programs must have a program entry procedure.

The CL compiler generates a program entry procedure in each module it creates.

A single-module ILE program can be created using the Create Bound CL Program (CRTBNDCL) command.

The Create Program (CRTPGM) command can be used to create an ILE program that contains module objects generated by different ILE compilers, including ILE CL.

An OPM CL program is a program that conforms to the original program model (OPM).

OPM CL programs are objects that result from compiling source using the Create CL Program (CRTCLPGM) command.

Service program

A service program is an IBM i object that contains one or more modules.

You can run programs that are not bound to service programs if they do not require any procedures from the service program.

However, you cannot run any procedures from a service program unless that service program is bound to a program.

In order to call procedures in a service program, you must export the procedure name.

A service program is created using the Create Service Program (CRTSRVPGM) command While a program has only one entry point, a service program can have multiple entry points. You cannot call service programs directly.

You can call procedures in a service program from other procedures in programs and service programs.

Post Comments