To use the program or procedure that runs the Send Program
Message (SNDPGMMSG) command as the base call stack entry, you can
use the TOPGMQ parameter.
If the TOPGMQ parameter specifies either TOPGMQ(*SAME *) or TOPGMQ(*PRV *),
the entry for the procedure using the
Send Program Message (SNDPGMMSG) command
is used as the base. If TOPGMQ(*SAME *) is specified, the procedure will send
a message to itself. If TOPGMQ(*PRV *) is specified, the procedure will
send a message to its caller.
Note: You should be aware of the following
information when a procedure sends a message to the caller by specifying TOPGMQ(*PRV *).
- When CLPROC4 and CLPROC2 send a message back to the callers, the message
does not leave the containing program. The message is sent between procedures
that are within the same program. If the objective is to send a message to
CLPGM1 which is the caller of the CLPGM2, specifying TOPGMQ(*PRV *) is
not the right choice to use.
- When CLPROC1 sends its message back to the caller, the Program Entry Procedure
is skipped. The message is sent to CLPGM1 even though the caller is the PEP.
When TOPGMQ(*PRV *) is specified, the PEP entry is not visible and
not included in the send operation. If TOPGMQ is specified in some other way,
the PEP is visible to the sender.
The figure illustrates the results when CLPROC1, CLPROC2, and CLPROC4 each
send a message previous of their procedure.
Figure 1. Example of TOPGMQ(*PRV *)
Note: The PEP is not visible to (*PRV *), so the message from
CLPROC1 will be sent to CLPGM1.