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

326 lines
16 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="reference" />
<meta name="DC.Title" content="Example in ILE RPG: Using keys with List Spooled Files API" />
<meta name="abstract" content="This example shows the steps necessary to process keyed output from an API." />
<meta name="description" content="This example shows the steps necessary to process keyed output from an API." />
<meta name="DC.Relation" scheme="URI" content="opmScenario.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnKeysRPG.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnKeysRPG.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="cmnKeysILERPG" />
<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: Using keys with List Spooled Files API</title>
</head>
<body id="cmnKeysILERPG"><a name="cmnKeysILERPG"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE RPG: Using keys with List Spooled Files API</h1>
<div><p>This example shows the steps necessary to process
keyed output from an API.</p>
<div class="section"><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>
<p>Refer to Example in OPM RPG: Using keys with List
Spooled Files API for the original example.</p>
<pre> F***************************************************************
F***************************************************************
F*
F* Program: List Spooled Files for Current User
F*
F* Language: ILE RPG
F*
F* Description: This example shows the steps necessary to
F* process keyed output from an API.
F*
F* APIs Used: QUSLSPL - List Spooled Files
F* QUSCRTUS - Create User Space
F* QUSPTRUS - Retrieve Pointer to User Space
F*
F***************************************************************
F***************************************************************
F*
FQPRINT O F 132 PRINTER OFLIND(*INOF)
D*
D* Error Code parameter include
D*
D/COPY QSYSINC/QRPGLESRC,QUSEC <span class="uicontrol">(11)</span>
D*
DSPC_NAME S 20 INZ('SPCNAME QTEMP ')
DSPC_SIZE S 9B 0 INZ(2000) <span class="uicontrol">(2)</span>
DSPC_INIT S 1 INZ(X'00')
DLSTPTR S *
DLSTPTR2 S *
DSPCPTR S *
DARR S 1 BASED(LSTPTR) DIM(32767)
D DS
DPAGES# 1 4B 0
DPAGESA 1 4
DKEYS DS <span class="uicontrol">(7)</span>
D 9B 0 INZ(201) <span class="uicontrol">(8)</span>
D 9B 0 INZ(216)
D 9B 0 INZ(211)
DKEY# S 9B 0 INZ(3)
D*****************************************************************
D*
D* The following QUSGEN include from QSYSINC is copied into <span class="uicontrol">(11)</span>
D* this program so that it can be declared as BASED on SPCPTR
D*
D*****************************************************************
DQUSH0100 DS BASED(SPCPTR)
D* Qus Generic Header 0100
D QUSUA 1 64
D* User Area
D QUSSGH 65 68B 0
D* Size Generic Header
D QUSSRL 69 72
D* Structure Release Level
D QUSFN 73 80
D* Format Name
D QUSAU 81 90
D* API Used
D QUSDTC 91 103
D* Date Time Created
D QUSIS 104 104
D* Information Status
D QUSSUS 105 108B 0
D* Size User Space
D QUSOIP 109 112B 0
D* Offset Input Parameter
D QUSSIP 113 116B 0
D* Size Input Parameter
D QUSOHS 117 120B 0
D* Offset Header Section
D QUSSHS 121 124B 0
D* Size Header Section
D QUSOLD 125 128B 0
D* Offset List Data
D QUSSLD 129 132B 0
D* Size List Data
D QUSNBRLE 133 136B 0
D* Number List Entries
D QUSSEE 137 140B 0
D* Size Each Entry
D QUSSIDLE 141 144B 0
D* CCSID List Ent
D QUSCID 145 146
D* Country ID
D QUSLID 147 149
D* Language ID
D QUSSLI 150 150
D* Subset List Indicator
D QUSERVED00 151 192
D* Reserved
D*****************************************************************
D*
D* The following QUSLSPL include from QSYSINC is copied into
D* this program so that it can be declared as BASED
D*
D*****************************************************************
D******************************************************************
D*Prototype for calling List Spooled File API QUSLSPL
D******************************************************************
D QUSLSPL C 'QUSLSPL'
D******************************************************************
D*Type definition for the SPLF0200 format.
D*******
D*NOTE: The following type definition only defines the fixed
D* portion of the format. Any varying length field will
D* have to be defined by the user.
D******************************************************************
DQUSSPLKI DS 100 BASED(LSTPTR2)
D* Qus LSPL Key Info
D QUSLFIR02 1 4B 0
D* Len Field Info Retd
D QUSKFFFR00 5 8B 0
D* Key Field for Field Retd
D QUSTOD02 9 9
D* Type of Data
D QUSR300 10 12
D* Reserv3
D QUSDL02 13 16B 0
D* Data Length
D*QUSDATA08 17 17
D*
D* Varying length
D*QUSERVED34 18 18
D*
D* Varying length
DQUSF0200 DS BASED(LSTPTR)
D* Qus SPLF0200
D QUSNBRFR00 1 4B 0
D* Num Fields Retd
D*QUSKI00 18
D* QUSLFIR03 5 8B 0
D* QUSKFFFR01 9 12B 0
D* QUSTOD03 13 13
D* QUSR301 14 16
D* QUSDL03 17 20B 0
D* QUSDATA09 21 21
D* QUSERVED35 22 22
D*
D* Varying length
C*
C* Start of mainline
C*
C*
C* Set Error Code structure to use exceptions
C*
C Z-ADD 0 QUSBPRV <span class="uicontrol">(1)</span>
C*
C* Create a User Space for the List generated by QUSLSPL
C*
C CALL 'QUSCRTUS' <span class="uicontrol">(2)</span>
C PARM SPC_NAME
C PARM 'QUSLSPL ' EXT_ATTR 10
C PARM SPC_SIZE
C PARM SPC_INIT
C PARM '*ALL' SPC_AUT 10
C PARM *BLANKS SPC_TEXT 50
C PARM '*YES' SPC_REPLAC 10
C PARM QUSEC
C PARM '*USER' SPC_DOMAIN 10
C*
C* Call QUSLSPL to get all spooled files for *CURRENT user
C*
C CALL 'QUSLSPL' <span class="uicontrol">(3)</span>
C PARM SPC_NAME
C PARM 'SPLF0200' FORMAT 8 <span class="uicontrol">(4)</span>
C PARM '*CURRENT' USR_PRF 10
C PARM '*ALL' OUTQ 20
C PARM '*ALL' FORMTYP 10
C PARM '*ALL' USRDTA 10
C PARM QUSEC
C PARM JOBNAM 26
C PARM KEYS <span class="uicontrol">(5)</span>
C PARM KEY# <span class="uicontrol">(6)</span>
C*
C* Get a resolved pointer to the User Space for performance
C*
C CALL 'QUSPTRUS' <span class="uicontrol">(9)</span>
C PARM SPC_NAME
C PARM SPCPTR
C PARM QUSEC
C*
C* If valid information was returned
C*
C QUSSRL IFEQ '0100' <span class="uicontrol">(12)</span>
C QUSIS IFEQ 'C' <span class="uicontrol">(14)</span>
C QUSIS OREQ 'P'
C*
C* and list entries were found
C*
C QUSNBRLE IFGT 0 <span class="uicontrol">(16)</span>
C*
C* set LSTPTR to the first byte of the User Space
C*
C EVAL LSTPTR = SPCPTR
C*
C* increment LSTPTR to the first List entry
C*
C EVAL LSTPTR = %ADDR(ARR(QUSOLD + 1)) <span class="uicontrol">(18)</span>
C*
C* and process all of the entries
C*
C DO QUSNBRLE <span class="uicontrol">(20)</span>
C*
C* set LSTPTR2 to the first variable length record for this entry
C*
C Z-ADD 5 X 9 0
C EVAL LSTPTR2 = %ADDR(ARR(X)) <span class="uicontrol">(22)</span>
C DO QUSNBRFR00 <span class="uicontrol">(23)</span>
C*
C* process the data based on key type
C*
C QUSKFFFR00 CASEQ 201 FILNAM <span class="uicontrol">(24)</span>
C QUSKFFFR00 CASEQ 211 PAGES
C QUSKFFFR00 CASEQ 216 AGE
C CAS ERROR
C END
C*
C* increment LSTPTR2 to next variable length record
C*
C ADD QUSLFIR02 X
C EVAL LSTPTR2 = %ADDR(ARR(X))
C END
C EXCEPT PRTLIN <span class="uicontrol">(26)</span>
C*
C* after each entry, increment LSTPTR to the next entry
C*
C EVAL LSTPTR = %ADDR(ARR(QUSSEE + 1)) <span class="uicontrol">(27)</span>
C END
C END
C ELSE
C EXCEPT LSTERR <span class="uicontrol">(15)</span>
C END
C ELSE
C EXCEPT HDRERR <span class="uicontrol">(13)</span>
C END
C*
C* Exit the program
C*
C EVAL *INLR = '1' <span class="uicontrol">(28)</span>
C RETURN
C*****************************************************************
C FILNAM BEGSR
C*
C* extract spooled file name for report
C*
C MOVE *BLANKS PRTFIL 10
C EVAL PRTFIL = %SUBST(QUSSPLKI:17:QUSDL02) <span class="uicontrol">(25)</span>
C ENDSR
C*****************************************************************
C PAGES BEGSR
C*
C* extract number of pages for report
C*
C EVAL PAGESA = %SUBST(QUSSPLKI:17:QUSDL02) <span class="uicontrol">(25)</span>
C ENDSR
C*****************************************************************
C AGE BEGSR
C*
C* extract age of spooled file for report
C*
C MOVE *BLANKS OPNDAT 7
C EVAL OPNDAT = %SUBST(QUSSPLKI:17:QUSDL02) <span class="uicontrol">(25)</span>
C ENDSR
C*****************************************************************
C ERROR BEGSR
C QUSKFFFR00 DSPLY
C EVAL *INLR = '1'
C RETURN
C ENDSR
C*****************************************************************
OQPRINT E PRTLIN 1
O PRTFIL 10
O PAGES# 25
O OPNDAT 40
OQPRINT E LSTERR 1
O 22 'List data not valid'
OQPRINT E HDRERR 1
O 22 'Unknown Generic Header'</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="opmScenario.htm" title="This scenario demonstrates the use of an original program model (OPM) API in several different programs.">Scenario: Original Program Model (OPM) API</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="cmnKeysRPG.htm" title="This example shows the steps necessary to process keyed output from an API.">Example in OPM RPG: Using keys with List Spooled Files API</a></div>
</div>
</div>
</body>
</html>