CL Programming
On the iSeries server, communication between procedures or programs,
between jobs, between users, and between users and procedures or programs
occurs through messages. A message can be predefined or
immediate:
Your system comes with an extensive set of predefined messages that allow
communication between programs within the system and between the system and
its users. Each licensed program you order has a message file that is
stored in the same library as the licensed program it applies to. For
example, system messages are stored in the file QCPFMSG in the library
QSYS.
The system uniquely identifies each predefined message in a message file by
a 7-character code and defines it by a message description. The message
description contains information, such as message text and message help text,
severity level, valid and default reply values, and various other
attributes. See the Add Message Description (ADDMSGD) command
description in online help, or in the CL section of the
Programming category in the iSeries Information Center.
All messages that are sent or received in the system are transmitted
through a message queue. Messages that are issued in response to a
direct request, such as a command, are automatically displayed on the display
from which the request was made. For all other messages, the user,
program or procedure must receive the message from the queue or display
it. There are several IBM-supplied message queues in the system;
these message queues are described later in this chapter (see Types of Message Queues).
The system also writes some of the messages that are issued to logs.
A job log contains information related to requests entered for a job, the
history log contains job, subsystem, and device status information. See
Message Logging for more information on logging.
You can create your own message files and message descriptions. By
creating predefined messages, you can use the same message in several
procedures or programs but define it only once. You can also change and
translate predefined messages into languages other than English (based on the
user viewing the messages) without affecting the procedures and programs that
use them. If the messages were defined in the procedure or program, the
module or program would have to be recompiled when you change the
messages.
In addition to creating your own messages and message files, the system
message handling function allows you to:
- Create and change message queues (Create Message Queue
[CRTMSGQ], Change Message Queue [CHGMSGQ], and Work with
Message Queues [WRKMSGQ] commands)
- Create and change message files (Create Message File [CRTMSGF],
Change Message File [CHGMSGF] commands)
- Add message descriptions (Add Message Description [ADDMSGD]
command)
- Change message descriptions (Change Message Description
[CHGMSGD] command)
- Remove message descriptions (Remove Message Description
[RMVMSGD] command)
- Send immediate messages (Send Message [SNDMSG], Send Break
Message [SNDBRKMSG], Send Program Message [SNDPGMMSG], and
Send User Message [SNDUSRMSG] commands)
- Display messages and message descriptions (Display Messages
[DSPMSG], Display Message Description [DSPMSGD], Work with
Messages [WRKMSG], and Work with Message Descriptions
[WRKMSGD] commands)
- Use a CL procedure or program to:
- Send a message to a work station user or the system operator (Send User
Message [SNDUSRMSG] command)
- Send a message to a message queue (Send Program Message
[SNDPGMMSG] command)
- Receive a message from a message queue (Receive Message [RCVMSG]
command)
- Send a reply for a message to a message queue (Send Reply
[SNDRPY] command)
- Retrieve a message from a message file (Retrieve Message
[RTVMSG] command)
- Remove a message from a message queue (Remove Message [RMVMSG]
command)
- Monitor for escape, notify, and status messages that are sent to a call
message queue (Monitor Message [MONMSG] command)
- Use the system reply list to specify the replies for predefined inquiry
messages sent by a job (Add Reply List Entry [ADDRPYLE], Change
Reply List Entry [CHGRPYLE], Remove Reply List Entry
[RMVRPYLE], and Work with Reply List Entry [WRKRPYLE]
commands)
When a message is sent, it is defined as one of the following types:
- Informational (*INFO). A message that conveys information about the
condition of a function.
- Inquiry (*INQ). A message that conveys information but also asks
for a reply.
- Notify (*NOTIFY). A message that describes a condition for which a
procedure or program requires corrective action or a reply from its calling
procedure or program. A procedure or program can monitor for the
arrival of notify messages from the programs or procedures it calls.
- Reply (*RPY). A message that is a response to a received inquiry or
notify message.
- Sender's copy (*COPY). A copy of an inquiry or notify message
that is kept by the sender.
- Request (*RQS). A message that requests a function from the
receiving procedure or program. (For example, a CL command is a request
message.)
- Completion (*COMP). A message that conveys completion status of
work.
- Diagnostic (*DIAG). A message about errors in the processing of a
system function, in an application program, or in input data.
- Status (*STATUS). A message that describes the status of the work
done by a procedure or program. A procedure or program can monitor for
the arrival of status messages from the program or procedure it calls.
Status messages sent to the external message queue (*EXT) are shown at the
display station and can be used to inform the display station user of an
operation in progress.
- Escape (*ESCAPE). A message that describes a condition for which a
procedure or program must end abnormally. A procedure or program can
monitor for the arrival of escape messages from the program or procedure it
calls or from the machine. Control does not return to the sending
program after an escape message is sent.
This chapter describes:
- How to create your own message files
- How to add message descriptions to a message file
- Types of message queues
- How to create message queues
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.