Read up on the full command with the IBM DOCUMENTATION. IF you still have issues understanding what is going on we will be glad to help when you can provide more details and any errors you are having .
Hi ToddN2000, I went through IBM documentation but still couldnt understand this part.
The trouble I have is, with the code below.
RTVJOBA TYPE(&TYPE)
IF COND(&TYPE *EQ '1') THEN(DO)
SNDPGMMSG MSGID() MSGF() +
TOPGMQ(*EXT) MSGTYPE(*STATUS)
ENDDO
SNDPGMMSG MSGID() MSGF() MSGTYPE(*ESCAPE)
As per last line of code, always *ESCAPE message should be thrown. But, sometimes i receive the message as *DIAGNOSTIC and other times, as *ESCAPE. Hence, i am not sure what is happening here.
What type of message are you looking to send and when? Under what conditions is the message to be sent? If you are looking to send a message to signify a job has completed, have you looked at using the SNDBRKMSG command?
I am not writing a new code. Existing code, I am trying to understand. As per existing code (below), the message should be sent as *ESCAPE type right? But, a customer reported that they received as *DIAGNOSTIC type. So, i dont understand how the below message would get sent as *DIAGNOSTIC instead of *ESCAPE.
Without seeing all the code, the larger sample you posted will send a different message type based on whether the job is running interactive or batch. This is based on the COND test being done.
Hi ToddN2000, appreciate your reply. So, if i understand correctly, the below statement can sometimes post message as *DIAGNOSTIC and other times, post message as *ESCAPE though it is quoted as *ESCAPE in the command?
Looking at the code the SNDPGMMSG commands are slightly different. One has a TOPGMQ variable and this will only be done when the &type is = 1. A character value of 0 indicates that the job is running as a batch job, and a 1 indicates an interactive job.
Is there any other code between enddo and the next SNDPGMMSG you are not showing?
When i debug the code, in some instances, line4 throws the message as DIAGNOSTIC, and in other instances line4 displays the message as ESCAPE. Once line4 is complete, I perform DSPJOBLOG and view the messages. There, I see diagnostic/escape types.
The program is huge one (say 500 lines). But, my only concern is, could there be something that can cause line4 to throw different messages on screen? (example: something like - if interactive, it will be thrown as DIAGNOSTIC. If batch, will be thrown as ESCAPE)
If you check out the IBM help text on the commands parameter message type you can see the differences in *STATUS and *ESCAPE.
Message type (MSGTYPE) - Help
Specifies which message type is assigned to this message
when it is sent by this program.
Notes:
1. Inquiry messages can be sent only to the external
queue or to a named message queue specified for the
TOUSR or TOMSGQ parameters. When sending an inquiry
with the TOMSGQ parameter, a second queue can be
specified if the value is *HSTLOG.
2. Completion, diagnostic, escape, notify, and status
messages can be sent only to a call message queue.
3. Escape messages cannot be sent to the external
message queue.
*INFO
The message is sent as an informational message.
*INQ
The message is sent as an inquiry message.
*COMP
A completion message is sent to a call message queue.
A completion message indicates the status of the work
that is successfully performed.
*DIAG
A diagnostic message is sent to a call message queue.
Diagnostic messages provide information about errors
detected by this program. The errors are either in
the input sent to it, or are those that occurred while
it was running the requested function. An escape or
notify message should also be sent to inform the
receiving program or procedure of the diagnostic
messages that are on its message queue.
*NOTIFY
A notify exception message is sent to a call message
queue. A notify message describes a condition for
which corrective action must be taken before the
sending program can continue. A reply message is sent
back to the sending program. After corrective action
is taken, the sending program can resume running and
can receive the reply message from its message queue.
*ESCAPE
An escape exception message is sent to a call message
queue. An escape message describes an irrecoverable
error condition. The sending program does not
continue to run.
*RQS
A request message is sent to a call message queue. A
request message allows request data received from
device files to pass from this program to another
program or procedure. An immediate message, specified
by the MSG parameter, must be used to send the
request.
*STATUS
A status exception message is sent to a call message
queue. The status message describes the status of
work performed by the sending program. The first 28
characters of message data in the MSGDTA parameter are
used as the comparison data for message monitors
(established by the Monitor Message (MONMSG) command).
If the status exception message is not being
monitored, control is returned to the sending program.
If a status message is sent to the external message
queue of an interactive job, the message is shown on
line 24, processing continues, and no response is
required.
Note: This value cannot be specified if the
Message text, or (MSG) parameter, is specified.
The *STATUS message should appear on an interactive job's message line until the program ends or another message replaces it or the message is cleared in some other way. It only indicates a program's "status" temporarily so that an interactive user knows what's happening at that time. It's not anywhere that you can access later.
The *ESCAPE message will cause the sending program to end (abnormally). Any *STATUS message will therefore disappear at that time. If you want the message to remain, send a *INFO message instead.
It's likely that the condition raised by the *ESCAPE is being "handled" and the message becomes a *DIAG message. Whether it's handled or not will depend on how the sending program is being run.
Describe exactly how the program is run for both *ESCAPE and *DIAG circumstances, and we'll try to explain the difference.
Hi TheRealRaven, if i understand correctly, the below line can post *DIAGNOSTIC message as well as *STATUS message depending upon scenarios. Is that correct?
Because my only doubt is, i am debugging the program and reach this particular line. Some instances, this gets posted as *DIAGNOSTIC and other instances, gets posted as *ESCAPE.
Discuss This Question: 11  Replies