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

190 lines
10 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 OPM RPG: Accessing the HOLD attribute" />
<meta name="abstract" content="The following program prints out the name of the job description or prints an error if the API could not find the job description name specified." />
<meta name="description" content="The following program prints out the name of the job description or prints an error if the API could not find the job description name specified." />
<meta name="DC.Relation" scheme="URI" content="opmScenario.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnHoldRPG.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnRetrieveRPG.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessCOBOL.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessILEC.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessILERPG.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessCOBOL.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessILEC.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessILERPG.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="cmnAccessRPG" />
<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: Accessing the HOLD attribute</title>
</head>
<body id="cmnAccessRPG"><a name="cmnAccessRPG"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in OPM RPG: Accessing the HOLD attribute</h1>
<div><p>The following program prints out the name of the job description
or prints an error if the API could not find the job description
name specified.</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>The following is the RPG code used to access the
HOLD attribute. This is the same type of program as the RPG program examples
in Example in OPM RPG: Retrieving the HOLD parameter (exception message) and
example in OPM RPG: Retrieving the HOLD parameter (error code structure).
The program, named JOBDAPI, prints the value of HOLD if it is found, as shown
at <a href="#cmnAccessRPG__SPTFOTEEN">1</a>. If an error occurs, the
program prints a line that contains the error message ID to a spooled file
called QPRINT, as shown at <a href="#cmnAccessRPG__SPTFITEEN">2</a>.</p>
<pre> F*****************************************************************
F*****************************************************************
F*
F*Program Name: JOBDAPI
F*
F*Language: OPM RPG
F*
F*Descriptive Name: Get Job Description
F*
F*Description: The following program prints out the name of
F* the job description or prints an error if the
F* API could not find the job description name
F* specified.
F*
F*
F*Header Files Included: QUSEC - Error Code Parameter
F* QWDRJOBD - Retrieve Job Description API
F*
F*****************************************************************
F*****************************************************************
F* JOBDAPIR - Print value of HOLD parameter using API
F* Uses error-code data structure
F*
FQPRINT O F 132 OF PRINTER
I*
I* Error Code Parameter Include for the APIs
I*
I/COPY QSYSINC/QRPGSRC,QUSEC
I*
I* Retrieve Job Description API Include
I*
I/COPY QSYSINC/QRPGSRC,QWDRJOBD
I*
I*
I* Dummy data structure used to declare binary field <span class="uicontrol" id="cmnAccessRPG__SPTDUMMY"><a name="cmnAccessRPG__SPTDUMMY"><!-- --></a>(3)</span>
I*
I DS
I I 390 B 1 40RCVLEN
I I 'JOBD0100' 5 12FORMAT
C*
C* Beginning of Mainline
C*
C* Two parameters are being passed into this program.
C*
C *ENTRY PLIST Parm list
C PARM JOBD 10 Job descrp
C PARM JOBDL 10 Jobd library
C*
C* Move the two parameters passed into LFNAM.
C*
C JOBD CAT JOBDL LFNAM 20 Qlfd name
C*
C* Error code parameter is set to 16.
C*
C Z-ADD16 QUSBNB Bytes provid
C*
C* Instead of specifying 'QWCRJOBD', I could have used the
C* constant QWDBGB that was defined in the QWDRJOBD include.
C* Call the API
C*
C CALL 'QWDRJOBD' Parm list
C PARM QWDBH Receiver Var.
C PARM RCVLEN Length RCVVAR
C PARM FORMAT Format Name
C PARM LFNAM Qual. Job Desc
C PARM QUSBN Error Code
C* If no bytes available, API was successful; print HOLD value
C QUSBNC IFEQ 0
C EXCPTGOOD
C ENDIF
C* If some bytes available, API failed; print error message ID
C QUSBNC IFGT 0
C EXCPTBAD
C ENDIF
C* End of program
C SETON LR
C RETRN
C*
C* End of MAINLINE
C**********************************************************************
O*
OQPRINT E 106 GOOD
O 'HOLD value - '
O QWDBHN
OQPRINT E 106 BAD
O 'Failed. Error ID - '
O QUSBND
</pre>
<p>The following data structures are used:</p>
<dl><dt class="dlterm">Error-code data structure</dt>
<dd> <p>This defines the two binary fields used and the message ID that is
returned for error conditions.</p>
</dd>
<dt class="dlterm">Retrieve job description data structure</dt>
<dd> <p>This defines format JOBD0100, a 390-byte data structure with the hold
field in positions 77-86.</p>
</dd>
<dt class="dlterm">Dummy data structure</dt>
<dd> <p>This contains a field used for the length of the receiver variable.
The field is defined as binary and is in the first 4 bytes. The dummy data
structure, as shown at <a href="#cmnAccessRPG__SPTDUMMY">3</a>, also
contains the format field.</p>
<p>This data structure is used because RPG only
allows binary variables to be defined in the context of a data structure.</p>
</dd>
</dl>
<p>The program retrieves the parameter list that is passed
and initializes the fields to be passed to the API. The API is called and
places information into the receiver-variable data structure if information
is found. The API places the information in the error-code data structure
if an error occurred and if enough space was provided to receive the information.</p>
<p>The
program prints one of two different lines depending on whether any errors
were found:</p>
<pre>HOLD value - *NO <span class="uicontrol" id="cmnAccessRPG__SPTFOTEEN"><a name="cmnAccessRPG__SPTFOTEEN"><!-- --></a>(1)</span>
Failed. Error ID - CPF9801 <span class="uicontrol" id="cmnAccessRPG__SPTFITEEN"><a name="cmnAccessRPG__SPTFITEEN"><!-- --></a>(2)</span>
</pre>
<p>See the following for the same example in different languages:</p>
<ul><li>COBOL and ILE COBOL</li>
<li>ILE C</li>
<li>ILE RPG</li>
</ul>
</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="cmnHoldRPG.htm" title="This example expects errors to be sent as escape messages.">Example in OPM RPG: Retrieving the HOLD parameter (exception message)</a></div>
<div><a href="cmnRetrieveRPG.htm" title="This sample program shows exceptions being returned in the error code parameter.">Example in OPM RPG: Retrieving the HOLD parameter (error code structure)</a></div>
<div><a href="cmnAccessCOBOL.htm" title="This example shows how to print messages to spool files.">Example in ILE COBOL: Accessing the HOLD attribute</a></div>
<div><a href="cmnAccessILEC.htm" title="This example shows how to print messages to spool files.">Example in ILE C: Accessing the HOLD attribute</a></div>
<div><a href="cmnAccessILERPG.htm" title="This program retrieves the HOLD value from a job description and then prints the value. It expects errors to be returned via the error code parameter.">Example in ILE RPG: Accessing the HOLD attribute</a></div>
</div>
</div>
</body>
</html>