ibm-information-center/dist/eclipse/plugins/i5OS.ic.rbam6_5.4.0.1/sprmq.htm

159 lines
8.9 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="task" />
<meta name="DC.Title" content="Example: Receive messages from QSYSMSG" />
<meta name="abstract" content="This sample program receives messages from the QSYSMSG message queue." />
<meta name="description" content="This sample program receives messages from the QSYSMSG message queue." />
<meta name="DC.subject" content="sample program to receive message from QSYSMSG, example, receiving message from QSYSMSG, message, sample program to receive from QSYSMSG" />
<meta name="keywords" content="sample program to receive message from QSYSMSG, example, receiving message from QSYSMSG, message, sample program to receive from QSYSMSG" />
<meta name="DC.Relation" scheme="URI" content="qsysm.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="sprmq" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Receive messages from QSYSMSG</title>
</head>
<body id="sprmq"><a name="sprmq"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Receive messages from QSYSMSG</h1>
<div><p>This sample program receives messages from the QSYSMSG message
queue.</p>
<div class="section"> <p>The program consists of a single procedure which is receiving
messages and handling message CPF1269. The reason code in the CPF1269 message
is in binary format. This must be converted to a decimal value for the comparisons
to the 704 and 705 reason codes. The procedure issues the <span class="cmdname">End Mode
(ENDMOD)</span> command to prevent new jobs from being started until the
situation is understood. It then sends the same message to a user-defined
message queue to be reviewed by the security officer. It also sends a message
to the system operator to indicate what occurred. If a different message
is received, it is sent to the system operator.</p>
<p>A separate job would
be started to call this sample program. The job would remain active, waiting
for a message to arrive. The job could be ended using the <span class="cmdname">End Job
(ENDJOB)</span> command.</p>
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for
important legal information.</div>
<pre> /********************************************************************/
/* */
/* Sample program to receive messages from QSYSMSG */
/* */
/********************************************************************/
/* */
/* Program looks for message CPF1269 with a reason code of 704 */
/* or 705. If found then notify QSECOFR of the security failure. */
/* Otherwise resend the message to QSYSOPR. */
/* */
/* The following describes message CPF1269 */
/* */
/* CPF1269: Program start request received on communications */
/* device &amp;1 was rejected with reason codes &amp;6,; &amp;7; */
/* */
/* Message data from DSPMSGD CPF1269 */
/* */
/* Data type offset length Description */
/* */
/* &amp;1 *CHAR 1 10 Device */
/* &amp;2 *CHAR 11 8 Mode */
/* &amp;3 *CHAR 19 10 Job - number */
/* &amp;4 *CHAR 29 10 Job - user */
/* &amp;5 *CHAR 39 6 Job - name */
/* &amp;6 *BIN 45 2 Reason code - major */
/* &amp;7 *BIN 47 2 Reason code - minor */
/* &amp;8 *CHAR 49 8 Remote location name */
/* &amp;9 *CHAR 57 *VARY Unit of work identifier */
/* */
/********************************************************************/
PGM
DCL &amp;MSGID *CHAR LEN( 7)
DCL &amp;MSGDTA *CHAR LEN(100)
DCL &amp;MSG *CHAR LEN(132)
DCL &amp;DEVICE *CHAR LEN( 10)
DCL &amp;MODE *CHAR LEN( 8)
DCL &amp;RMTLOC *CHAR LEN( 8)
MONMSG CPF0000 EXEC(GOTO PROBLEM)
/**********************************************************/
/* Fetch messages from QSYSMSG message queue */
/**********************************************************/</pre>
<pre> LOOP: RCVMSG MSGQ(QSYS/QSYSMSG) WAIT(*MAX) MSGID(&amp;MSGID) +
MSG(&amp;MSG) MSGDTA(&amp;MSGDTA)
IF ((&amp;MSGID *EQ 'CPF1269') /* Start failed msg */ +
*AND ((%BIN(&amp;MSGDTA 45 2) *EQ 704) +
*OR (%BIN(&amp;MSGDTA 45 2) *EQ 705)) ) +
THEN(DO)
/********************************************************/
/* Report security failure to QSECOFR */
/********************************************************/
CHGVAR &amp;DEVICE %SST(&amp;MSGDTA 1 10) /* Extract device */
CHGVAR &amp;MODE %SST(&amp;MSGDTA 11 8) /* Extract mode */
CHGVAR &amp;RMTLOC %SST(&amp;MSGDTA 49 8) /* Get loc name */
ENDMOD RMTLOCNAME(&amp;RMTLOC) MODE(&amp;MODE)
SNDPGMMSG MSGID(&amp;MSGID) MSGF(QCPFMSG) MSGDTA(&amp;MSGDTA) +
TOMSGQ(QSECOFR)
SNDPGMMSG MSG('Device ' *CAT &amp;DEVICE *TCAT ' Mode ' +
*CAT &amp;MODE *TCAT ' had security failure, +
session max changed to zero') +
TOMSGQ(QSYSOPR)
ENDDO
ELSE DO
/********************************************************/
/* Other message - Resend to QSYSOPR */
/********************************************************/
SNDPGMMSG MSGID(&amp;MSGID) MSGF(QCPFMSG) MSGDTA(&amp;MSGDTA) +
TOMSGQ(QSYSOPR)
/* SNDPGMMSG would fail if the message does */
/* not have a MSGID or is not in QCPFMSG */
MONMSG MSGID(CPF0000) +
EXEC(SNDPGMMSG MSG(&amp;MSG) TOMSGQ(QSYSOPR))
ENDDO
GOTO LOOP /* Go fetch next message */
/**********************************************************/
/* Notify QSYSOPR of abnormal end */
/**********************************************************/
PROBLEM: SNDPGMMSG MSG('QSYSMSG job has abnormally ended') +
TOMSGQ(QSYSOPR)
MONMSG CPF0000
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) +
MSGDTA('Unexpected error occurred')
MONMSG CPF0000
ENDPGM</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="qsysm.htm" title="QSYSMSG is a queue that you can create if you plan to handle the list of serious messages that are sent to the queue.">Use QSYSMSG message queue</a></div>
</div>
</div>
</body>
</html>