176 lines
9.0 KiB
HTML
176 lines
9.0 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 C: 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="cmnAccessILEC" />
|
|
<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 C: Accessing the HOLD attribute</title>
|
|
</head>
|
|
<body id="cmnAccessILEC"><a name="cmnAccessILEC"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example in ILE C: 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.</p>
|
|
<pre>/***********************************************************************/
|
|
/***********************************************************************/
|
|
/* */
|
|
/*Program Name: JOBDAPI */
|
|
/* */
|
|
/*Programming Language: ILE C */
|
|
/* */
|
|
/*Description: This example shows how to print messages */
|
|
/* to spool files. */
|
|
/* */
|
|
/*Header Files Included: STDIO - Standard Input/Output */
|
|
/* STRING - String Functions */
|
|
/* QUSEC - Error Code Parameter */
|
|
/* QWDRJOBD - Retrieve Job Description API */
|
|
/* QLIEPT - Entry Point Table */
|
|
/* */
|
|
/***********************************************************************/
|
|
/***********************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <qusec.h> /* Error Code Parameter Include for the APIs */
|
|
#include <qwdrjobd.h> /* Retrieve Job Description API Include */
|
|
#include <qliept.h> /* Entry Point Table Include */
|
|
|
|
/***********************************************************************/
|
|
/* Error Code Structure */
|
|
/* */
|
|
/* This shows how the user can define the variable length portion of */
|
|
/* error code for the exception data. */
|
|
/* */
|
|
/***********************************************************************/
|
|
typedef struct {
|
|
Qus_EC_t ec_fields;
|
|
char Exception_Data[100];
|
|
} error_code_t;
|
|
|
|
main(int argc, char *argv[])
|
|
{
|
|
error_code_t error_code;
|
|
char qual_job_desc[20];
|
|
char *qual_job_ptr = qual_job_desc;
|
|
char rec_var[390];
|
|
char hold_value[10];
|
|
char message_id[7];
|
|
char command_string[25];
|
|
char message_string[29];
|
|
FILE *stream;
|
|
|
|
memset(hold_value, ' ', 10);
|
|
|
|
/*********************************************************************/
|
|
/* Make sure we received the correct number of parameters. The argc */
|
|
/* parameter will contain the number of parameters that was passed */
|
|
/* to this program. This number also includes the program itself, */
|
|
/* so we need to evaluate argc-1. */
|
|
/*********************************************************************/
|
|
|
|
if (((argc - 1) < 2) || ((argc - 1 > 2)))
|
|
/*********************************************************************/
|
|
/* We did not receive all of the required parameters so exit the */
|
|
/* program. */
|
|
/*********************************************************************/
|
|
{
|
|
exit(1);
|
|
}
|
|
|
|
/*********************************************************************/
|
|
/* Move the two parameter passed into qual_job_desc. */
|
|
/*********************************************************************/
|
|
memcpy(qual_job_ptr, argv[1], 10);
|
|
qual_job_ptr += 10;
|
|
memcpy(qual_job_ptr, argv[2], 10);
|
|
|
|
/*********************************************************************/
|
|
/* Set the error code parameter to 16. */
|
|
/*********************************************************************/
|
|
error_code.ec_fields.Bytes_Provided = 16;
|
|
|
|
/*********************************************************************/
|
|
/* Open QPRINT file so that data can be written to it. If the file */
|
|
/* cannot be opened, print a message and exit. */
|
|
/*********************************************************************/
|
|
if((stream = fopen("QPRINT", "wb")) == NULL)
|
|
{
|
|
printf("File could not be opened\n");
|
|
exit(1);
|
|
}
|
|
|
|
/*********************************************************************/
|
|
/* Call the QWDRJOBD API. */
|
|
/*********************************************************************/
|
|
QWDRJOBD(rec_var, /* Receiver Variable */
|
|
390, /* Receiver Length */
|
|
"JOBD0100", /* Format Name */
|
|
qual_job_desc, /* Qualified Job Description */
|
|
&error_code); /* Error Code */
|
|
|
|
/*********************************************************************/
|
|
/* If an error was returned, print the error message to the QPRINT */
|
|
/* spool file. */
|
|
/*********************************************************************/
|
|
if(error_code.ec_fields.Bytes_Available > 0)
|
|
{
|
|
memcpy(message_id, error_code.ec_fields.Exception_Id, 7);
|
|
sprintf(message_string,
|
|
"Failed. Error ID - %.7s",
|
|
message_id);
|
|
fprintf(stream, message_string);
|
|
}
|
|
/*********************************************************************/
|
|
/* Let's tell everyone what the hold value was for this job. */
|
|
/* The result will be printed in the QPRINT spool file. */
|
|
/*********************************************************************/
|
|
else
|
|
{
|
|
memcpy(hold_value, ((Qwd_JOBD0100_t *)rec_var)->Hold_Job_Queue, 10);
|
|
sprintf(command_string,
|
|
"HOLD value - %.10s",
|
|
hold_value);
|
|
fprintf(stream, command_string);
|
|
}
|
|
|
|
fclose(stream);
|
|
|
|
} /* main */</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> |