181 lines
7.5 KiB
HTML
181 lines
7.5 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 COBOL: Retrieving the HOLD parameter (error code structure)" />
|
||
|
<meta name="abstract" content="This example shows how to make use of an error returned in the error code structure." />
|
||
|
<meta name="description" content="This example shows how to make use of an error returned in the error code structure." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="opmScenario.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="cmnRetrieveRPG.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="cmnRetrieveRPG.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="cmnRetrieveCOBOL" />
|
||
|
<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 COBOL: Retrieving the HOLD parameter (error code structure)</title>
|
||
|
</head>
|
||
|
<body id="cmnRetrieveCOBOL"><a name="cmnRetrieveCOBOL"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example in ILE COBOL: Retrieving the HOLD parameter (error code structure)</h1>
|
||
|
<div><p>This example shows how to make use of an error returned in the
|
||
|
error code structure.</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: Retrieving the HOLD
|
||
|
parameter (error code structure) for the original example. The following program
|
||
|
also works for OPM COBOL.</p>
|
||
|
<pre> IDENTIFICATION DIVISION.
|
||
|
*****************************************************************
|
||
|
*****************************************************************
|
||
|
*
|
||
|
*Program Name: JOBDAPI
|
||
|
*
|
||
|
*Programming Language: COBOL
|
||
|
*
|
||
|
*Description: This example shows how to make use of an
|
||
|
* error returned in the error code
|
||
|
* structure.
|
||
|
*
|
||
|
*Header Files Included: QUSEC - Error Code Parameter
|
||
|
* QWDRJOBD - Retrieve Job Description API
|
||
|
*
|
||
|
*****************************************************************
|
||
|
*****************************************************************
|
||
|
*
|
||
|
PROGRAM-ID. JOBDAPI.
|
||
|
*
|
||
|
ENVIRONMENT DIVISION.
|
||
|
CONFIGURATION SECTION.
|
||
|
SOURCE-COMPUTER. IBM-AS400.
|
||
|
OBJECT-COMPUTER. IBM-AS400.
|
||
|
*
|
||
|
DATA DIVISION.
|
||
|
WORKING-STORAGE SECTION.
|
||
|
*
|
||
|
* Error Code parameter include. As this sample program
|
||
|
* uses COPY to include the error code structure, only the first
|
||
|
* 16 bytes of the error code structure are available. If the
|
||
|
* application program needs to access the variable length
|
||
|
* exception data for the error, the developer should physically
|
||
|
* copy the QSYSINC include and modify the copied include to
|
||
|
* define additional storage for the exception data.
|
||
|
*
|
||
|
COPY QUSEC OF QSYSINC-QLBLSRC. <span class="uicontrol">(1)</span>
|
||
|
*
|
||
|
* Retrieve Job Description API Include
|
||
|
*
|
||
|
COPY QWDRJOBD OF QSYSINC-QLBLSRC.
|
||
|
*
|
||
|
* Command String Data Structure
|
||
|
*
|
||
|
01 COMMAND-STRING.
|
||
|
05 TEXT1 PIC X(26) VALUE 'SNDMSG MSG(''HOLD value is'.
|
||
|
05 HOLD PIC X(10).
|
||
|
05 TEXT2 PIC X(15) VALUE ''') TOUSR(QPGMR)'.
|
||
|
*
|
||
|
* Message Identifier Data Structure
|
||
|
*
|
||
|
01 MESSAGE-TWO.
|
||
|
05 MSG2A PIC X(43)
|
||
|
VALUE 'SNDMSG MSG(''Program failed with message ID'.
|
||
|
05 MSGIDD PIC X(7).
|
||
|
05 MSG2B PIC X(15) VALUE ''') TOUSR(QPGMR)'.
|
||
|
*
|
||
|
01 COMMAND-LENGTH PIC S9(10)V99999 COMP-3.
|
||
|
01 RECEIVER-LENGTH PIC S9(9) COMP-4.
|
||
|
01 FORMAT-NAME PIC X(8) VALUE 'JOBD0100'.
|
||
|
01 QCMDEXC PIC X(10) VALUE 'QCMDEXC'.
|
||
|
*
|
||
|
* Job Description and Library Name Structure
|
||
|
*
|
||
|
01 JOBD-AND-LIB-NAME.
|
||
|
05 JOB-DESC PIC X(10).
|
||
|
05 JOB-DESC-LIB PIC X(10).
|
||
|
*
|
||
|
LINKAGE SECTION.
|
||
|
*
|
||
|
* Two Parameters are being passed into this program.
|
||
|
*
|
||
|
01 JOBD PIC X(10).
|
||
|
01 JOBDL PIC X(10).
|
||
|
*
|
||
|
PROCEDURE DIVISION USING JOBD, JOBDL.
|
||
|
MAIN-LINE.
|
||
|
*
|
||
|
* Beginning of Mainline
|
||
|
*
|
||
|
* Move the two parameters passed into JOB-DESC and JOB-DESC-LIB.
|
||
|
*
|
||
|
MOVE JOBD TO JOB-DESC.
|
||
|
MOVE JOBDL TO JOB-DESC-LIB.
|
||
|
*
|
||
|
* Error Code Parameter is set to 16.
|
||
|
*
|
||
|
MOVE 16 TO BYTES-PROVIDED. <span class="uicontrol">(3)</span>
|
||
|
*
|
||
|
* Receiver Length Set to 390.
|
||
|
*
|
||
|
MOVE 390 TO RECEIVER-LENGTH.
|
||
|
*
|
||
|
* Call the QWDRJOBD API.
|
||
|
*
|
||
|
CALL QWDRJOBD USING QWD-JOBD0100, RECEIVER-LENGTH,
|
||
|
FORMAT-NAME, JOBD-AND-LIB-NAME, QUS-EC.
|
||
|
*
|
||
|
* See if any errors were returned in the error code parameter.
|
||
|
*
|
||
|
PERFORM ERRCOD.
|
||
|
*
|
||
|
* Move HOLD-JOB-QUEUE to HOLD so that we can display the value using
|
||
|
* the command string.
|
||
|
*
|
||
|
MOVE HOLD-JOB-QUEUE TO HOLD.
|
||
|
*
|
||
|
* Let's tell everyone what the hold value was for this job.
|
||
|
*
|
||
|
MOVE 51 TO COMMAND-LENGTH.
|
||
|
CALL QCMDEXC USING COMMAND-STRING, COMMAND-LENGTH.
|
||
|
*
|
||
|
STOP RUN.
|
||
|
*
|
||
|
* End of Mainline
|
||
|
*
|
||
|
*
|
||
|
* Subroutine to handle errors returned in the error code
|
||
|
* parameter.
|
||
|
*
|
||
|
ERRCOD.
|
||
|
*
|
||
|
IF BYTES-AVAILABLE OF QUS-EC > 0 <span class="uicontrol">(2)</span>
|
||
|
*
|
||
|
* Process errors returned from the API.
|
||
|
*
|
||
|
MOVE 65 TO COMMAND-LENGTH,
|
||
|
MOVE EXCEPTION-ID TO MSGIDD,
|
||
|
CALL QCMDEXC USING MESSAGE-TWO, COMMAND-LENGTH,
|
||
|
STOP RUN.</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="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>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|