Anda di halaman 1dari 11

CL Commands

The following is a list of commands that are frequently used in CL


procedures. You can use this list to select the appropriate command
for the function you want. IBM provides online information on how to
determine the command you might need. Refer to the CL section of
the Programming category in the iSeries Information Center for this
information. Familiarity with the function of these commands will help
you to understand subsequent topics in this chapter. Superscript 1
indicates the commands that you can use only in CL programs and
procedures.

System
Function Command Command Function

Change CALL (Call) Calls a program


Procedure
Control

CALLPRC (Call Calls a procedure.


Procedure) 1

RETURN (Return) Returns to the command


following the command that
caused a program or
procedure to be run

CL Procedure PGM (Program) 1 Indicates the start of CL


Limits procedure source

ENDPGM (End Indicates the end of CL


Program) 1 procedure source

CL Procedure IF (If) 1 Processes commands based


Logic on the value of a logical
expression
ELSE (Else) 1 Defines the action to be
taken for the else (false)
condition of an IF command

DO (Do) 1 Indicates the start of a Do


group

ENDDO (End Do) Indicates the end of a Do


1
group

GOTO (Go To) 1 Branches to another


command

CL Procedure CHGVAR Changes the value of a CL


Variables (Change variable
Variable)1

DCL (Declare) 1 Declares a variable

Conversion CHGVAR Changes the value of a CL


(Change variable
Variable)1

CVTDAT (Convert Changes the format of a date


Date) 1

Data Areas CHGDTAARA Changes a data area


(Change Data
Area)

CRTDTAARA Creates a data area


(Create Data
Area)

DLTDTAARA Deletes a data area


(Delete Data
Area)

DSPDTAARA Displays a data area


(Display Data
Area)

RTVDTAARA Copies the content of a data


(Retrieve Data area to a CL variable
Area) 1

Files ENDRCV (End Cancels a request for input


Receive) 1 previously issued by a
RCVF, SNDF, or SNDRCVF
command to a display file

DCLF (Declare Declares a display or


File) 1 database file

RCVF (Receive Reads a record from a


File) 1 display or database file

RTVMBRD Retrieves a description of a


(Retrieve Member specific member of a
Description) 1 database file

SNDF (Send File) Writes a record to a display


1
file

SNDRCVF Writes a record to a display


(Send/Receive file and reads that record
File) 1 after the user has replied

WAIT (Wait) 1 Waits for data to be received


from an SNDF, RCVF, or
SNDRCVF command issued
to a display file
Messages MONMSG Monitors for escape, status,
(Monitor and notify messages sent to
Message) 1 a program's message queue

RCVMSG Copies a message from a


(Receive message queue into CL
Message) 1 variables in a CL procedure

RMVMSG Removes a specified


(Remove message from a specified
Message) 1 message queue

RTVMSG Copies a predefined


(Retrieve message from a message
Message) 1 file into CL procedure
variables

SNDPGMMSG Sends a program message


(Send Program to a message queue
Message) 1

SNDRPY (Send Sends a reply message to


Reply) 1 the sender of an inquiry
message

SNDUSRMSG Sends an informational or


(Send User inquiry message to a display
Message) station or system operator

Miscellaneous CHKOBJ (Check Checks for the existence of


Commands Object) an object and, optionally, the
necessary authority to use
the object

PRTCMDUSG Produces a cross-reference


(Print Command listing for a specified group
Usage) of commands used in a
specified group of CL
procedures

RTVCFGSRC Generates CL command


(Retrieve source for creating existing
Configuration configuration objects and
Source) places the source in a
source file member

RTVCFGSTS Gives applications the


(Retrieve capability to retrieve
Configuration configuration status from
Status) 1 three configuration objects:
line, controller, and device.

RTVJOBA Retrieves the value of one or


(Retrieve Job more job attributes and
Attributes) 1 places the values in a CL
variable

RTVSYSVAL Retrieves a system value


(Retrieve System and places it into a CL
Value) 1 variable

RTVUSRPRF Retrieves user profile


(Retrieve User attributes and places them
Profile) 1 into CL variables

Program CRTCLMOD Creates a CL module


Creation (Create CL
Commands Module)

DLTMOD (Delete Deletes a module


Module)

DLTPGM (Delete Deletes a program


Program)
CRTBNDCL Creates a bound CL
(Create Bound program.
Control Language
Program)

CRTCLPGM Creates an OPM CL


(Create CL program.
Program)

CRTPGM (Create Creates a program from one


Program) or more modules.

CRTSRVPGM Creates a service program


(Create Service from one or more modules.
Program)
Using CL Procedures

CL programming is a flexible tool allowing you to perform a variety of


operations. Each of the following uses is described in greater detail in
individual sections later in this chapter. In general, you can:

• Use variables, logic control commands, expressions, and built-


in functions to manipulate and process data within a CL
procedure:
• PGM
• DCL &C *LGL
• DCL &A *DEC VALUE(22)
• DCL &B *CHAR VALUE(ABCDE)
• *
• *
• *
• CHGVAR &A (&A + 30)
• *
• *
• *
• IF (&A < 50) THEN(CHGVAR &C '1')
• *
• DSPLIB ('Q' || &B)
• *
• IF (%SST(&B 5 1)=E) THEN(CHGVAR &A
12)
• *
• *
• *
• ENDPGM
• Use a system value as a variable in a CL procedure.

• Use a job attribute as a variable in a CL procedure.

• Send and receive data to and from a display file with a CL


procedure.

• Create a CL procedure to monitor error messages for a job, and


take corrective action if necessary.
• PGM

• MONMSG MSGID(CPF0001)
EXEC(GOTO ERROR)
• CALL PROGA
• CALL PROGB
• RETURN
• ERROR: SNDPGMMSG MSG('A CALL command
failed') MSGTYPE(*ESCAPE)
• ENDPGM
• Control processing among procedures and programs and pass
parameters from a CL procedure to other procedures or
programs to override files.

Used as a controlling procedure, a CL procedure can call procedures


written in other languages. The following illustration shows how
control can be passed between a CL procedure and RPG IV* and ILE
COBOL procedures in an application. To use the application, a work
station user would request program A, which controls the entire
application. The illustration shows: The preceding example shows a
single bound program (PGMA) that is called using the CALL
command with PGMA. PGMA consists of:

• A CL procedure (PGMA) calling an RPG IV procedure (PGMB)


• An RPG IV procedure (PGMB) calling another RPG IV
procedure (PGMC)
• An RPG IV procedure (PGMB) calling a CL procedure (PGMD)
• A CL procedure (PGMA) calling an ILE COBOL procedure
(PGME)
• An ILE COBOL program (PGME) calling a CL procedure
(PGMF)

The procedures can be created as indicated in the following example.


You can enter source for procedures in separate source members.

CRTCLMOD PGMA
CRTRPGMOD PGMB
CRTRPGMOD PGMC
CRTCLMOD PGMD
CRTCBLMOD PGME
CRTCLMOD PGMF
CRTPGM PGM(PGMA) +
MODULE(PGMA PGMB PGMC PGMD PGME
PGMF) +
ENTMOD(*FIRST)

Anda mungkin juga menyukai