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

192 lines
9.7 KiB
HTML
Raw Permalink 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 C: Accessing a field value (initial library list)" />
<meta name="abstract" content="This example shows how to access a field value returned from a retrieve API." />
<meta name="description" content="This example shows how to access a field value returned from a retrieve API." />
<meta name="DC.Relation" scheme="URI" content="opmScenario.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnFieldRPG.htm" />
<meta name="DC.Relation" scheme="URI" content="cmnFieldRPG.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="cmnFieldILEC" />
<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 a field value (initial library list)</title>
</head>
<body id="cmnFieldILEC"><a name="cmnFieldILEC"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE C: Accessing a field value (initial library list)</h1>
<div><p>This example shows how to access a field value returned
from a retrieve 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: Accessing a field
value (initial library list) for the original example.</p>
<pre>/***********************************************************************/
/***********************************************************************/
/* */
/*Program Name: JOBDAPI */
/* */
/*Programming Language: ILE C */
/* */
/*Description: This example shows how to access a field */
/* value returned from a retrieve API. */
/* */
/*Header Files Included: STDIO - Standard Input/Output */
/* STRING - String Functions */
/* QUSEC - Error Code Parameter */
/* QWDRJOBD - Retrieve Job Description API */
/* QLIEPT - Entry Point Table */
/* */
/***********************************************************************/
/***********************************************************************/
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;qusec.h&gt; /* Error Code Parameter Include for the APIs */
#include &lt;qwdrjobd.h&gt; /* Retrieve Job Description API Include */
#include &lt;qliept.h&gt; /* 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;
/***********************************************************************/
/* JOBD0100 Structure */
/* */
/* This shows how the user can define the variable-length portion of */
/* the JOBD0100 format. */
/* */
/***********************************************************************/
typedef struct {
Qwd_JOBD0100_t data;
char Lib_Data[5000]; <span class="uicontrol">(1)</span> <span class="uicontrol">(2)</span>
} JOBD0100;
main(int argc, char *argv[])
{
error_code_t error_code;
char library[10];
char qual_job_desc[20];
char *qual_job_ptr = qual_job_desc;
char rec_var[1000];
char *rec_ptr = rec_var;
char hold_value[10];
char message_id[7];
char command_string[49];
int i;
int num_libs;
int offset;
int rec_len = 5000;
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) &lt; 2) || ((argc - 1 &gt; 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;
/*********************************************************************/
/* Call the QWDRJOBD API. */
/*********************************************************************/
QWDRJOBD(rec_var, /* Receiver Variable */
rec_len, /* Receiver Length */
"JOBD0100", /* Format Name */
qual_job_desc, /* Qualified Job Description */
&amp;error_code); /* Error Code */
/*********************************************************************/
/* If an error was returned, send an error message. */
/*********************************************************************/
if(error_code.ec_fields.Bytes_Available &gt; 0)
{
/* In this example, nothing was done for the error condition. */
}
/*********************************************************************/
/* Let's tell everyone what the library value was for this job. */
/*********************************************************************/
else
{
num_libs = ((JOBD0100 *)rec_var)-&gt;data.Number_Libs_In_Lib_list;
offset = ((JOBD0100 *)rec_var)-&gt;data.Offset_Initial_Lib_List;
/*******************************************************************/
/* Advance receiver variable pointer to the location where the */
/* library list begins. */
/*******************************************************************/
rec_ptr += offset;
for(i=0; i&lt;num_libs; i++)
{
memcpy(library, rec_ptr, 10);
sprintf(command_string,
"SNDMSG MSG('LIBRARY %.10s') TOUSR(QPGMR)",
library);
system(command_string);
rec_ptr += 11;
if((offset + 10) &gt;= rec_len)
break;
offset += 11;
}
}
} /* 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="cmnFieldRPG.htm" title="This sample program shows the correct way of using the offset in a user space in RPG.">Example in OPM RPG: Accessing a field value (initial library list)</a></div>
</div>
</div>
</body>
</html>