ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaik_5.4.0.1/rzaiksoaaccessupdatesampl.htm

175 lines
7.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="Sample program: Accessing and updating data for iSeries objects" />
<meta name="DC.Relation" scheme="URI" content="rzaiksoaaccessupdatedata.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="soaaccessupdatesampl" />
<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>Sample program: Accessing and updating data for iSeries objects</title>
</head>
<body id="soaaccessupdatesampl"><a name="soaaccessupdatesampl"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Sample program: Accessing and updating data for iSeries™ objects</h1>
<div><div class="example"> <pre>#include &lt;windows.h&gt; // Windows APIs and datatypes
#include &lt;stdlib.h&gt; // For atoi
#include "cwbsoapi.h" // System Object Access APIs
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
CWBSO_LIST_HANDLE hList = CWBSO_NULL_HANDLE; // List handle
CWBSO_ERR_HANDLE hError = CWBSO_NULL_HANDLE; // Error handle
CWBSO_PARMOBJ_HANDLE hParmObject = CWBSO_NULL_HANDLE; // Parm object
CWBSO_OBJ_HANDLE hObject = CWBSO_NULL_HANDLE; // Object handle
unsigned int rc, setRC; // System Object Access return codes
unsigned long bytesNeeded = 0; // Bytes needed
unsigned short errorIndex = 0; // Error index (SetObjAttr)
char szString[100]; // Buffer for formatting
int totalPages = 0; // Total pages
int i = 0; // Loop counter
int nNbrChanged = 0; // Count of changed objects
MessageBox(GetFocus(), "Start of Processing", "PRIORITY", MB_OK);
//********************************************************************
// Create a list of spooled files. Set desired filter criteria.
//********************************************************************
// Create a list of spooled files on system SYSNAME
CWBSO_CreateListHandle("SYSNAME",
"APPNAME",
CWBSO_LIST_SFL,
&amp;hList);
// Only include spooled files for device P3812
CWBSO_SetListFilter(hList, CWBSO_SFLF_DeviceFilter, "P3812");
//*******************************************************************
// Open the list.
//*******************************************************************
// Create an error handle
CWBSO_CreateErrorHandle(&amp;hError);
// Open the list of spooled files
rc = CWBSO_OpenList(hList, hError);
// If an error occurred, display a message box
if (rc == CWBSO_ERROR_OCCURRED)
CWBSO_DisplayErrMsg(hError);
else
{
//*****************************************************************
// Set up to change output priority for all objects in the list.
//*****************************************************************
// Create a parameter object to hold the attribute changes
CWBSO_CreateParmObjHandle(&amp;hParmObject);
// Set the parameter to change the output priority to '9'
CWBSO_SetParameter(hParmObject,
CWBSO_SFL_OutputPriority,
"9",
hError);
//******************************************************************
// Loop through the list, changing the output priority for any
// files that have more than 10 total pages. Loop will
// terminate when CWBSO_WaitForObj
// returns CWBSO_BAD_LIST_POSITION, indicating that there
// are no more objects in the list.
//******************************************************************
// Wait for first object in the list
rc = CWBSO_WaitForObj(hList, i, hError);
// Loop through entire list
while (rc == CWBSO_NO_ERROR)
{
// Get the list object at index i
CWBSO_GetObjHandle(hList, i, &amp;hObject, hError);
// Get the total pages attribute for this spooled file
CWBSO_GetObjAttr(hObject,
CWBSO_SFL_TotalPages,
szString,
sizeof(szString),
&amp;bytesNeeded,;
hError);
totalPages = atoi(szString);
// Update the output priority if necessary
if (totalPages &gt; 10)
{
// Change the spool file's output priority to '9'
setRC = CWBSO_SetObjAttr(hObject, hParmObject, &amp;errorIndex, hError);
if (setRC == CWBSO_NO_ERROR)
nNbrChanged++;
}
// Delete the object handle
CWBSO_DeleteObjHandle(hObject);
// Increment list item counter
i++;
// Wait for next list object
rc = CWBSO_WaitForObj(hList, i, hError);
} /* end while */
// Parameter object no longer needed
CWBSO_DeleteParmObjHandle(hParmObject);
} /* end if */
// Display the number of spooled files that had priority changed
wsprintf (szString, "Number of spool files changed: %d", nNbrChanged);
MessageBox(GetFocus(), szString, "PRIORITY", MB_OK);
//********************************************************************
// Processing complete - clean up and exit.
//********************************************************************
// Close the list
CWBSO_CloseList(hList,hError);
// Clean up handles
CWBSO_DeleteErrorHandle(hError);
CWBSO_DeleteListHandle(hList);
//********************************************************************
// Return from WinMain.
//********************************************************************
return 0;
}</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaiksoaaccessupdatedata.htm" title="A list object for a list of iSeries spool files is created. After setting the desired filter criteria, the list is opened. A parameter object is created which will be used to change the output priority for each spooled file in the list.">Accessing and updating data for iSeries Objects</a></div>
</div>
</div>
</body>
</html>