CL Command Reference - ADDMSGD
CL Command List > ADDMSGD Reference
Description:
The Add Message Description (ADDMSGD) command describes a message and stores it in a message file for later use. The message description remains in the message file until the file is deleted or until the Remove Message Description (RMVMSGD) command is used to remove it from the file. To change any of the attributes of the message description, such as its message text or severity code, use the Change Message Description (CHGMSGD) command.
Substitution variables can be embedded both in the first-level and second-level message text. They can be replaced later by message data fields specified in the Retrieve Message (RTVMSG), Send User Message (SNDUSRMSG), and Send Program Message (SNDPGMMSG) commands.
Note: The type of message being defined is not specified in the ADDMSGD command. The type is specified in the command that actually sends the message.
If the message second-level text exceeds 512 characters, it will not fit because of the OS/400 Prompter limit. In this case, enter the command on the Command Entry panel or in a CL program.
Restrictions:
. To add a message description to a message file, you must have use (*USE) and add (*ADD) authorities for the message file.
Examples:
Example 1: Defining a Message
ADDMSGD MSGID(UIN0115) MSGF(INV)
MSG(¡¯Enter the name of user¡¯¡¯s department¡¯)
SECLVL(¡¯Valid departments: &B X12 &B X13 &B X14¡¯)
TYPE(*CHAR) LEN(3) DFT(¡¯ZZZ¡¯)
This command defines a message and stores it in a file named INV under the identifier UIN0115. The message supplies second-level message text by using the &B formatting character to show the three valid department names (X12, X13, and X14) each on a separate line. The reply requires validity checking so that a valid reply can only be a 3-character identifier. A default reply of ZZZ is also provided.
Example 2: Defining a Message Description
ADDMSGD MSGID(UPY0047) MSGF(PAYLIB/TIMECARD)
MSG(¡¯For week of &1, &2 time cards. Are there more?¡¯)
FMT((*CHAR 8) (*CHAR 3)) TYPE(*ALPHA) LEN(1)
VALUES(N Y) SPCVAL((YES Y)(NO N)) DFT(N)
This command defines a message description that is stored in the TIMECARD message file in the PAYLIB library. The program that processes the time cards can send a message (as an inquiry type message) telling how many time cards (in &2) have been processed for the week (specified in &1). To send this message to a user via a message queue, the program must use the SNDPGMMSG or SNDUSRMSG commands. In this example, the command specifies:
. The message identifier of this message (UPY0047)
. The file (TIMECARD) that contains this message
. The time card date in 8 characters (such as 09/15/88); this must be the first value in the MSGDTA parameter
. The number of time cards in no more than 3 digits (such as 125)
If a reply of YES is sent, it is accepted as a Y (SPCVAL parameter). If NO is sent, it is accepted as an N. If neither YES nor NO is sent, the reply is checked for validity by the TYPE, LEN, and VALUES parameters. If the user chooses, no reply is sent and the default reply (N) is assumed.
Example 3: Defining an Escape Message
ADDMSGD MSGID(UPY1234) MSGF(PAYLIB/TIMECARD)
MSG(¡¯Tax for employee &1 exceeds gross salary.¡¯)
SEV(75) FMT((*CHAR 6) (*DEC 9 2) (*CHAR 8))
DFTPGM(PAYLIB/BADTAX) DMPLST(1 2 3 *JOB)
This command defines an escape message. The sender of the message passes three data values, the first of which (employee serial number) is used as replacement text in the message. If this message is sent as an escape message and the program to which the message is sent does not monitor for message UPY1234, default system action is taken. This includes dumping the three data values that were passed and the job structure. After the dump is taken, program BADTAX is called.
See the Monitor Message (MONMSG) command for more about monitoring for messages.