The SndMsgID procedure sends a program message to the specified invocation/program.
The SndMsgID procedure uses a message ID to send a message.
msgKey SndMsgID( szMsgID 7A Const szMsgFile 21A Const OPTIONS(*OMIT : *NOPASS) szMsgData 1024A Const OPTIONS(*OMIT : *NOPASS : *VARSIZE ) nMsgDataLen 10I 0 Const OPTIONS(*OMIT : *NOPASS) szMsgType 10A Const OPTIONS(*OMIT : *NOPASS : *VARSIZE ) szToPgmQ 10A Const OPTIONS(*OMIT : *NOPASS : *VARSIZE ) nRelInvocation 10I 0 Const OPTIONS(*OMIT : *NOPASS) ) |
|
See also: GetMsgText, GetMsgInfo |
*...v....1....v....2
'QCPFMSG *LIBL '
An alternative syntax is also supported for this object name. The alternate syntax allows you to specify the object name similar to that of an OS/400 CL command, that is it may be qualified using qualified name syntax, as follows:
*...v....1....v....2
'QSYS/QCPFMSG '
In addition, you may specified either *OMIT (unquoted) or '*' (quoted asterisk) to indicate that this parameter's default value should be used.
| Message Type | Description |
| '*COMP' | Completion message |
| '*DIAG' | Diagnostic message |
| '*ESCAPE' | Escape message |
| '*INFO' | Informational message |
| '*INQ' | Inquiry message (valid only when *EXT is specified for szToPgmQ |
| '*NOTIFY' | Notification message |
| '*STATUS' | Status message |
| '*' | If a quoted asterisk is used, the default value for this parameter is used. |
| To PgmQ | Description |
| '*' | The current program message queue |
| *SAME' | Same as * |
| '*CTLBDY' | Control boundary |
| '*EXT' | External program message queue (used for *STATUS messages) |
| '*PRVPGM' | Previous program message queue NOTE: If you want SNDMSGID to work similar to the SNDPGMMSG CL command, use *PRVPGM instead of *PRV when sending messages. |
| '*PRV' '*PRVPRC' '*PRVPROC' | Previous procedure message queue |
The return value is the message key of the message once it is sent.
H BNDDIR('XTOOLS/RPGLIB')
/COPY QCPYSRC,msg
D OBJ S 20A Inz('CUSTMAST QGPL')
C if NOT ChkObjExists(OBJ: '*FILE')
C callp SndMsgID('CPF9812' : '*' : OBJ : %size(OBJ) :
C '*DIAG' : '*PRVPGM')
C endif
In this example the message text 'File CUSTMAST in library QGPL not found.' is sent as a diagnostic message to the previous program. Note that '*' is used for the second parameter (message file) instead of 'QSYS/QCPFMSG' or *OMIT.