Program Message

From MidrangeWiki
Revision as of 20:00, 29 March 2016 by DaveLClarkI (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A program message is a message sent from a program to either its user, and/or to the joblog, and/or to a different call stack level in the same job. It is sent using the SNDPGMMSG and SNDUSRMSG CL commands, or the DSPLY statement in RPG, or the QMHSNDPM API. Program messages are differentiated from nonprogram messages, which are sent to users or devices, using the SNDMSG command or the QMHSNDM API.

Program messages can be of several types:

  • *COMP - a completion message, indicating completion of an action
  • *DIAG - a diagnostic message, giving information on an error
  • *ESCAPE - an escape message, terminating a call level, or a job
  • *INFO - an informational message
  • *INQ - an inquiry message, requiring a response
  • *NOTIFY - a notify message
  • *RQS - a request message
  • *STATUS - a status message, reporting the status of an operation in progress

They can be sent to the job's external message queue, or (except for inquiry messages) to a call level message queue.

Escape, notify, or status messages must be sent as "predefined" messages, i.e., from a message file, while request messages must be sent as "immediate" messages. Completion, diagnostic, informational, and inquiry messages can be either. For programmer convenience, CPF9898 is defined in QCPFMSG, as one long field, followed by a period.

Examples

  • To put a transient status message on a terminal's message line, send a *STATUS message to the *EXT message queue, e.g.,
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('In progress') TOPGMQ(*EXT) MSGTYPE(*STATUS)
(A call to QMHSNDPM would be coded similarly)
  • To put a message into the joblog, without the user seeing it (possibly to copy a status message to the joblog), send a diagnostic, informational, or completion message to a call stack entry's message queue, e.g.,
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('To joblog') TOPGMQ(*PRV) MSGTYPE(*INFO)
(a call to QMHSNDPM would be coded with a call message queue of "*")
  • To bring up the "Display Program Messages" screen, send any of those types of messages to the external message queue, e.g.,
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('To joblog') TOPGMQ(*EXT) MSGTYPE(*INFO)
(Again, a call to QMHSNDPM would be coded similarly.)
Or from CL, use SNDUSRMSG, e.g.,
SNDUSRMSG MSG('I like spam.') MSGTYPE(*INFO)
Or from RPG, use a DSPLY statement with a blank result field (depending on what screen is showing at the time, this may stay up, blocking execution of your program, or it may disappear immediately).
  • To ask the user a question on the "Display Program Messages" screen, from CL use SNDUSRMSG, e.g.,
SNDUSRMSG MSG('I like spam. Do you?') MSGTYPE(*INQ) MSGRPY(&FOO)
where &FOO is the variable in which the reply is to be placed.
Or from RPG, use a DSPLY statement with a variable for the reply in the result field.