ibm-information-center/dist/eclipse/plugins/i5OS.ic.apiref_5.4.0.1/exdqilerpg.htm

216 lines
9.2 KiB
HTML

<?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="reference" />
<meta name="DC.Title" content="Example in ILE RPG: Data queue" />
<meta name="abstract" content="This program illustrates how to use APIs to create and manipulate a *DTAQ." />
<meta name="description" content="This program illustrates how to use APIs to create and manipulate a *DTAQ." />
<meta name="DC.Relation" scheme="URI" content="ExTaskDataque.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="exdqilerpg" />
<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 in ILE RPG: Data queue</title>
</head>
<body id="exdqilerpg"><a name="exdqilerpg"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE RPG: Data queue</h1>
<div><p>This program illustrates how to use APIs to create and manipulate
a *DTAQ.</p>
<div class="section" id="exdqilerpg__HDRDQ3"><a name="exdqilerpg__HDRDQ3"><!-- --></a><p>Refer to <a href="exdqilec.htm">Example in ILE C: Data queue</a> for
the original example.</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> F***************************************************************
F***************************************************************
F*
F* Program Name: DQUEUEX
F*
F* Programming Language: ILE RPG
F*
F* Description: This program illustrates how to use APIs to
F* create and manipulate a *DTAQ.
F*
F* Header Files Included: QUSEC - Error Code Parameter
F* QCAPCMD - Process Command API
F*
F***************************************************************
F*
FQPRINT O F 132 PRINTER OFLIND(*INOF) USROPN
F***************************************************************
D*
D* Error Code parameter include
D*
D/COPY QSYSINC/QRPGLESRC,QUSEC
D*
D* Process Command API Include
D*
D/COPY QSYSINC/QRPGLESRC,QCAPCMD
D*
D* Command strings
D*
D
DCRTLIB C 'CRTLIB LIB(QUEUELIB)'
DDLTLIB C 'DLTLIB LIB(QUEUELIB)'
DCRTDQ C 'CRTDTAQ DTAQ(QUEUELIB/+
D EXAMPLEQ) MAXLEN(10)'
DDLTDQ C 'DLTDTAQ DTAQ(QUEUELIB/EXAMPLEQ)'
D*
D* Miscellaneous data structure
D*
DCMD_STR S 100
DLEN_STR S 9B 0
DCAP0100_SZ S 9B 0 INZ(%SIZE(QCAP0100))
DRCVVAR_SZ S 9B 0 INZ(0)
DAPI_NAME S 10
DFIRST_ERR S 1 INZ('0')
C*
C* Beginning of mainline
C*
C* Initialize the error code parameter. To signal exceptions to
C* this program by the API, you need to set the bytes provided
C* field of the error code to zero. Because this program has
C* exceptions sent back through the error code parameter, it sets
C* the bytes provided field to the number of bytes it gives the
C* API for the parameter.
C*
C EVAL QUSBPRV = %SIZE(QUSEC)
C*
C* Initialize QCAPCMD options control block for CL processing
C*
C EVAL QCACMDPT = 0
C EVAL QCABCSDH = '0'
C EVAL QCAPA = '0'
C EVAL QCACMDSS = '0'
C EVAL QCAMK = *BLANKS
C EVAL QCAERVED = *LOVAL
C*
C* Create library QUEUELIB
C*
C EVAL CMD_STR = CRTLIB
C EVAL LEN_STR = %SIZE(CRTLIB)
C*
C EXSR EXEC_CMD
C*
C* Create a data queue called EXAMPLEQ in library QUEUELIB. The
C* queue will have a maximum entry length set at 10, and will be
C* FIFO (first-in first-out).
C*
C EVAL CMD_STR = CRTDQ
C EVAL LEN_STR = %SIZE(CRTDQ)
C*
C EXSR EXEC_CMD
C*
C* Send information to the data queue.
C*
C CALL 'QSNDDTAQ'
C PARM 'EXAMPLEQ ' NAME_OF_Q 10
C PARM 'QUEUELIB ' NAME_OF_LB 10
C PARM 10 MSG_SZ 5 0
C PARM 'EXAMPLE ' MSG 10
C*
C* Retrieve information from the data queue.
C*
C CALL 'QRCVDTAQ'
C PARM 'EXAMPLEQ ' NAME_OF_Q
C PARM 'QUEUELIB ' NAME_OF_LB
C PARM 10 MSG_SZ
C PARM MSG_BACK 10
C PARM 0 WAIT_TIME 5 0
C*
C* Display the returned message
C*
C DSPLY MSG_BACK
C*
C* Delete the data queue
C*
C EVAL CMD_STR = DLTDQ
C EVAL LEN_STR = %SIZE(DLTDQ)
C*
C EXSR EXEC_CMD
C*
C* Delete the library
C*
C EVAL CMD_STR = DLTLIB
C EVAL LEN_STR = %SIZE(DLTLIB)
C*
C EXSR EXEC_CMD
C*
C EVAL *INLR = '1'
C RETURN
C*
C* End of MAINLINE
C*
C*****************************************************************
C*
C EXEC_CMD BEGSR
C*
C* Process the requested CL command
C*
C CALL 'QCAPCMD'
C PARM CMD_STR
C PARM LEN_STR
C PARM QCAP0100
C PARM CAP0100_SZ
C PARM 'CPOP0100' FORMAT 8
C PARM RCVVAR 1
C PARM 0 RCVVAR_SZ
C PARM RCVVAR_SZ
C PARM QUSEC
C*
C* If an exception occurs, the API returns the exception in the
C* error code parameter. The bytes available field is set to
C* zero if no exception occurs and greater than zero if an
C* exception does occur.
C*
C IF QUSBAVL &gt; 0
C EVAL API_NAME = 'QCAPCMD'
C EXSR ERRCOD
C ENDIF
C ENDSR
C*
C*****************************************************************
C*
C ERRCOD BEGSR
C*
C* Process errors returned from the API.
C*
C* If first error found, then open QPRINT *PRTF
C*
C IF FIRST_ERR = '0'
C OPEN QPRINT
C EVAL FIRST_ERR = '1'
C ENDIF
C*
C* Print the error and the API that received the error
C*
C EXCEPT BAD_NEWS
C*
C ENDSR
OQPRINT E BAD_NEWS 1
O 'Failed in API '
O API_NAME
O 'with error '
O QUSEI</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="ExTaskDataque.htm" title="Data queues and user queues both provide a means for one or more processes to communicate asynchronously. The queues can be processed FIFO (first-in first-out), LIFO (last-in first-out), or by key.">Examples: Using data queues or user queues</a></div>
</div>
</div>
</body>
</html>