219 lines
8.9 KiB
HTML
219 lines
8.9 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 OPM 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="exdqopmrpg" />
|
||
|
<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 OPM RPG: Data queue</title>
|
||
|
</head>
|
||
|
<body id="exdqopmrpg"><a name="exdqopmrpg"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example in OPM RPG: Data queue</h1>
|
||
|
<div><p>This program illustrates how to use APIs to create and manipulate
|
||
|
a *DTAQ.</p>
|
||
|
<div class="section" id="exdqopmrpg__HDRDQ2"><a name="exdqopmrpg__HDRDQ2"><!-- --></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: OPM 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 UC
|
||
|
F***************************************************************
|
||
|
I*
|
||
|
I* Error Code parameter include
|
||
|
I*
|
||
|
I/COPY QSYSINC/QRPGSRC,QUSEC
|
||
|
I*
|
||
|
I* Process Command API Include
|
||
|
I*
|
||
|
I/COPY QSYSINC/QRPGSRC,QCAPCMD
|
||
|
I*
|
||
|
I* Command strings
|
||
|
I*
|
||
|
I DS
|
||
|
I I 'CRTLIB LIB(QUEUELIB)' 1 20 CRTLIB
|
||
|
I I 'DLTLIB LIB(QUEUELIB)' 21 40 DLTLIB
|
||
|
I I 'CRTDTAQ DTAQ(QUEUELI- 41 82 CRTDQ
|
||
|
I 'B/EXAMPLEQ) MAXLEN(1-
|
||
|
I '0)'
|
||
|
I I 'DLTDTAQ DTAQ(QUEUELI- 83 113 DLTDQ
|
||
|
I 'B/EXAMPLEQ)'
|
||
|
I*
|
||
|
I* Miscellaneous data structure
|
||
|
I*
|
||
|
I DS
|
||
|
I 1 100 CMDSTR
|
||
|
I B 101 1040LENSTR
|
||
|
I I 20 B 105 1080SIZE
|
||
|
I I 0 B 10901120RCVSIZ
|
||
|
I I '0' 113 113 FSTERR
|
||
|
I 114 123 APINAM
|
||
|
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 Z-ADD16 QUSBNB
|
||
|
C*
|
||
|
C* Initialize QCAPCMD options control block for CL processing
|
||
|
C*
|
||
|
C Z-ADD0 QCABCB
|
||
|
C MOVE '0' QCABCC
|
||
|
C MOVE '0' QCABCD
|
||
|
C MOVE '0' QCABCF
|
||
|
C MOVE *BLANKS QCABCG
|
||
|
C MOVE *LOVAL QCABCH
|
||
|
C*
|
||
|
C* Create library QUEUELIB
|
||
|
C*
|
||
|
C MOVELCRTLIB CMDSTR
|
||
|
C Z-ADD20 LENSTR
|
||
|
C*
|
||
|
C EXSR EXCCMD
|
||
|
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 MOVELCRTDQ CMDSTR
|
||
|
C Z-ADD42 LENSTR
|
||
|
C*
|
||
|
C EXSR EXCCMD
|
||
|
C*
|
||
|
C* Send information to the data queue.
|
||
|
C*
|
||
|
C CALL 'QSNDDTAQ'
|
||
|
C PARM 'EXAMPLEQ'QUENAM 10
|
||
|
C PARM 'QUEUELIB'LIBNAM 10
|
||
|
C PARM 10 MSGSZ 50
|
||
|
C PARM 'EXAMPLE' MSG 10
|
||
|
C*
|
||
|
C* Retrieve information from the data queue.
|
||
|
C*
|
||
|
C CALL 'QRCVDTAQ'
|
||
|
C PARM 'EXAMPLEQ'QUENAM 10
|
||
|
C PARM 'QUEUELIB'LIBNAM 10
|
||
|
C PARM 10 MSGSZ 50
|
||
|
C PARM MSGBCK 10
|
||
|
C PARM 0 WAITTM 50
|
||
|
C*
|
||
|
C* Display the returned message
|
||
|
C*
|
||
|
C DSPLY MSGBCK
|
||
|
C*
|
||
|
C* Delete the data queue
|
||
|
C*
|
||
|
C MOVELDLTDQ CMDSTR
|
||
|
C Z-ADD31 LENSTR
|
||
|
C*
|
||
|
C EXSR EXCCMD
|
||
|
C*
|
||
|
C* Delete the library
|
||
|
C*
|
||
|
C MOVELDLTLIB CMDSTR
|
||
|
C Z-ADD20 LENSTR
|
||
|
C*
|
||
|
C EXSR EXCCMD
|
||
|
C*
|
||
|
C SETON LR
|
||
|
C RETRN
|
||
|
C*
|
||
|
C* End of MAINLINE
|
||
|
C*
|
||
|
C*****************************************************************
|
||
|
C*
|
||
|
C EXCCMD BEGSR
|
||
|
C*
|
||
|
C* Process requested CL command
|
||
|
C*
|
||
|
C CALL 'QCAPCMD'
|
||
|
C PARM CMDSTR
|
||
|
C PARM LENSTR
|
||
|
C PARM QCABC
|
||
|
C PARM SIZE
|
||
|
C PARM 'CPOP0100'FORMAT 8
|
||
|
C PARM RCVVAR 1
|
||
|
C PARM 0 RCVSIZ
|
||
|
C PARM RCVSIZ
|
||
|
C PARM QUSBN
|
||
|
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 QUSBNC IFGT 0
|
||
|
C MOVEL'QCAPCMD' APINAM
|
||
|
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 FSTERR IFEQ '0'
|
||
|
C OPEN QPRINT
|
||
|
C MOVEL'1' FSTERR
|
||
|
C ENDIF
|
||
|
C*
|
||
|
C* Print the error and the API that received the error
|
||
|
C*
|
||
|
C EXCPTBADNEW
|
||
|
C*
|
||
|
C ENDSR
|
||
|
OQPRINT E 106 BADNEW
|
||
|
O 'Failed in API '
|
||
|
O APINAM
|
||
|
O 'with error '
|
||
|
O QUSBND</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>
|