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

188 lines
7.1 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 COBOL: Accessing the HOLD attribute" />
<meta name="abstract" content="This example shows how to print messages to spool files." />
<meta name="description" content="This example shows how to print messages to spool files." />
<meta name="DC.Relation" scheme="URI" content="opmScenario.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessRPG.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnAccessRPG.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="cmnAccessCOBOL" />
<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: Accessing the HOLD attribute</title>
</head>
<body id="cmnAccessCOBOL"><a name="cmnAccessCOBOL"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE COBOL: Accessing the HOLD attribute</h1>
<div><p>This example shows how to print messages to spool
files.</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: Accessing the HOLD
attribute for the original example. The following example also works for OPM
COBOL.</p>
<pre> IDENTIFICATION DIVISION.
*****************************************************************
*****************************************************************
*
*Program Name: JOBDAPI
*
*Programming Language: ILE COBOL
*
*Description: This example shows how to print messages
* to spool files.
*
*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.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
*
SELECT LISTING ASSIGN TO PRINTER-QPRINT
ORGANIZATION IS SEQUENTIAL.
*
DATA DIVISION.
FILE SECTION.
*
FD LISTING RECORD CONTAINS 132 CHARACTERS
LABEL RECORDS ARE STANDARD
DATA RECORD IS LIST-LINE.
01 LIST-LINE PIC X(132).
*
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.
*
* Retrieve Job Description API Include
*
COPY QWDRJOBD OF QSYSINC-QLBLSRC.
*
* Command String Data Structure
*
01 HOLD-VALUE.
05 TEXT1 PIC X(13) VALUE 'HOLD value - '.
05 HOLD PIC X(10).
*
* Error Message Text
*
01 MESSAGE-TEXT.
05 MSG1 PIC X(19) VALUE 'Failed. Error ID - '.
05 MSGID PIC X(7).
*
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.
*
* 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.
*
* If no bytes available, API was successful; print HOLD value
*
IF BYTES-AVAILABLE OF QUS-EC = 0 PERFORM GOOD.
*
* If some bytes available, API failed; print Error message ID
*
IF BYTES-AVAILABLE OF QUS-EC &gt; 0 PERFORM BAD.
*
STOP RUN.
*
* End of Mainline
*
*
* Subroutine to perform if no errors were encountered.
*
GOOD.
OPEN OUTPUT LISTING.
MOVE HOLD-JOB-QUEUE TO HOLD.
WRITE LIST-LINE FROM HOLD-VALUE.
*
* Subroutine to perform if an error was returned in error code.
*
BAD.
OPEN OUTPUT LISTING.
MOVE EXCEPTION-ID TO MSGID.
WRITE LIST-LINE FROM MESSAGE-TEXT.
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="cmnAccessRPG.htm" title="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.">Example in OPM RPG: Accessing the HOLD attribute</a></div>
</div>
</div>
</body>
</html>