Académique Documents
Professionnel Documents
Culture Documents
http://www.adobe.com/prodindex/acrobat/readstep.html .
To view, print, and download the PDF version, select Client Access Express
programming (about 2.95 MB, or 1200 pages). Print the entire document, or select
and print a range of pages.
Access interface definition files for all Client Access Express C/C++ API groups in
the Client Access Express Toolkit.
How to access Express header files in the Toolkit:
1. Find the Express Toolkit icon in your IBM AS400 Client Access Express
program directory and launch it. If it is not displayed in the program
directory, install the Toolkit.
2. In the left navigation panel, select the appropriate API group.
Note: Names of some API categories in the Express Toolkit differ from
the names that are used in Express programming:
(General NLS)
National language cwbnlcnv.h cwbapi.lib cwbnl1.dll
support
(Conversion NLS)
National language cwbnldlg.h cwbapi.lib cwbnldlg.dll
support
(Dialog-box NLS)
AS/400 objects cwbobj.h cwbapi.lib cwbobj.dll
ODBC sql.h odbc32.lib odbc32.dll
sqlext.h
sqltypes.h
sqlucode.h
Database APIs cwbdb.h cwbapi.lib cwbdb.dll
(Optimized SQL)
OLE DB Provider ad400.h oledb.lib oledb32.dll
adoid.h oledbd.lib (for debug)
adoint.h See the OLE DB
da400.h Section of the
oledb.h Microsoft Universal
oledberr.h Data Access Web
transact.h
Site for more
information
Remote cwbrc.h cwbapi.lib cwbrc.dll
Command/Distributed
Program Call
Serviceability cwbsv.h cwbapi.lib cwbsv.dll
System Object cwbsoapi.h cwbapi.lib cwbsoapi.dll
Access
Note: To launch these components from a Windows PC, select Start –> Programs
–> IBM AS400 Client Access Express, and select the component. If you do
not see either of the components in your Client Access Express folder, they
are not installed. Run Selective Setup to install them. See the Client Access
Express for Windows - Setup book for related information.
Note: No portion of the Toolkit or the Client Access Express product may be
redistributed with the resulting applications.
Follow these links for instructions on how to install and launch the Express
Toolkit.
Launching the Express Toolkit: To launch the Express Toolkit, select Start –>
Programs –> IBM AS400 Client Access Express –> Express Toolkit.
Note: The Client Access Express installation program does not create the Toolkit
icon unless you have installed the Client Access Express Toolkit on your
personal computer. See “Installing the Express Toolkit” for instructions.
compiles to:
or:
or:
Note:
v Data transformation APIs (cwbDT_xxx) do not follow the ″A″ and ″W″
suffix conventions. The generic version of the APIs uses ″String″ as part of
the function name. The ANSI/OEM version uses ″ASCII″ as part of the
function name. The Unicode version uses ″Wide″ as part of the function
name. There is no difference between OEM and ANSI character sets in
cwbDT_xxx APIs, which handle numeric strings. Therefore, ANSI and
OEM versions of the relevant APIs are the same. For example:
cwbDT_HexToString();
compiles to:
or:
See the data transformation cwbdt.h header file for more details.
v For Unicode APIs that take a buffer and a length for passing strings (for
example, cwbCO_GetUserIDExW), the length is treated as the number of
bytes. It is not treated as the number of characters.
Using single and mixed API types:
You can write applications that use a single API type, or that combine
several API types. Link to the following topics for more information:
v “Using a single Client Access Express API type” on page 12
v “Using mixed Client Access Express API types” on page 12
Writing generic applications:
To ensure maximum portability of your applications, consider writing a
generic application. Link to the following topic for more information:
v “Writing a generic Client Access Express application” on page 12
For example, when writing a pure ANSI application, you specify both
CWB_ANSI_ONLY and CWB_ANSI. Refer to the individual Client Access Toolkit
header files for details of these pre-processor definitions and API names. See
“Express API groups, header files, import libraries, and DLLs” on page 7 for more
information.
4. MSDN Library
Following is a list, by function, of the obsolete Client Access APIs. For each
obsolete API, a link to the newer Express replacement API is provided, when
available.
Note: All of the APPC and License Management APIs are obsolete, and are not
supported for Client Access Express.
Obsolete Client Access APIs listing:
v “Obsolete Communications APIs”
v “Obsolete Data Queues APIs”
v “Obsolete LDAP APIs” on page 14
v “Obsolete Remote Command/Distributed Program Call APIs” on
page 14
v “Obsolete Security APIs” on page 14
v “Obsolete System Object Access (SOA) API” on page 15
Client Access Express logs error messages in the History Log, and on the AS/400
System.
Error messages in the History Log:
Client Access Express logs error messages in the History Log, which is
located in the Service folder.
Starting the History Log:
By default, the History Log is not active. To ensure that error
messages are written to this file, History logging must be started.
See the Express User’s Guide, which is shipped with Client Access
Express, for information on starting the History Log
Viewing logged messages:
To view messages that have been logged in the History Log, select
Start —> Programs —> IBM AS400 Client Access Express —>
Service —> History Log.
The entries in the History Log consist of messages with and without
message IDs. Messages with message IDs have online help available.
Messages without message IDs do not have online help available. To
display the cause and recovery information associated with a message that
has a message ID, double-click on it. You also can view any message that
has a message ID by selecting the Message topic in the online Express
User’s Guide.
Error messages on the AS/400 system:
Client Access Express also has associated messages that are logged on the
AS/400 system. These messages begin with PWS or IWS. To display a
specific PWSxxxx or IWSxxxx message, type the appropriate command at
the AS/400 command line prompt, where xxxx is the number of the
message:
DSPMSGD RANGE(IWSxxxx) MSGF(QIWS/QIWSMSG)
6058 CWBDB_WORK_QUEUE_START_ERROR
Unable to start server because of client work queue problem.
6059 CWBDB_WORK_QUEUE_CREATE_ERROR
Unable to start server because of client work queue problem.
6060 CWBDB_INITIALIZATION_ERROR
Unable to start server because of client initialization problem.
6061 CWBDB_SERVER_ATTRIBS_ERROR
Unable to start server because of server attribute problem.
6062 CWBDB_CLIENT_LEVEL_ERROR
Unable to start server because of set client level problem.
6063 CWBDB_CLIENT_LFC_ERROR
Unable to start server because of set client language feature
code problem.
6064 CWBDB_CLIENT_CCSID_ERROR
Unable to start server because of set client CCSID problem.
6065 CWBDB_TRANSLATION_INDICATOR_ERROR
Unable to start server because of set translation indicator error.
6066 CWBDB_RETURN_SERVER_ATTRIBS_ERROR
Unable to start server because of return server attribute problem.
6067 CWBDB_SERVER_ATTRIBS_REQUEST
Unable to start server because of missing server attributes request
object.
6068 CWBDB_RETURN_ATTRIBS_ERROR
Unable to start server because of return attribute problem.
6069 CWBDB_SERVER_ATTRIBS_MISSING
Unable to start server because returned server attributes too short
(missing data).
6070 CWBDB_SERVER_LFC_CONVERSION_ERROR
Unable to start server because of data conversion error on server
language feature code field of server attributes.
6071 CWBDB_SERVER_LEVEL_CONVERSION_ERROR
Unable to start server because of data conversion error on server
functional level field of server attributes.
6072 CWBDB_SERVER_LANGUAGE_TABLE_ERROR
Unable to start server because of data conversion error on server
language table ID field of server attributes.
6073 CWBDB_SERVER_LANGUAGE_LIBRARY_ERROR
Unable to start server because of data conversion error on server
language library ID field of server attributes.
6074 CWBDB_SERVER_LANGUAGE_ID_ERROR
Unable to start server because of data conversion error on server
language ID field of server attributes.
6075 CWBDB_COMM_DEQUEUE_ERROR
Unable to start server because of communications error.
6076 CWBDB_COMM_ENQUEUE_ERROR
6201 CWBNL_ERR_STR_TBL_INVALID
Message file not in a recognized format. It has been corrupted.
6202 CWBNL_ERR_STR_TBL_MISSING
Message file could not be found.
6203 CWBNL_ERR_STR_NOT_FOUND
The message file is missing a message.
6204 CWBNL_ERR_NLV_NO_CONFIG
The language configuration is missing.
6205 CWBNL_ERR_NLV_NO_SUBDIR
The language subdirectory is missing.
6206 CWBNL_DEFAULT_HOST_CCSID_USED
A default server CCSID (500) is used.
6301 CWBNL_ERR_LOC_TBL_INVALID
6302 CWBNL_ERR_LOC_TBL_MISSING
6303 CWBNL_ERR_LOC_NO_CONFIG
6304 CWBNL_ERR_LOC_NO_LOCPATH
6257 CWBSY_PWD_TOO_LONG
The new password contains too many characters. The maximum number of
characters allowed is defined by the AS/400 system value, QPWDMAXLEN.
6258 CWBSY_PWD_TOO_SHORT
The new password does not contain enough characters. The minimum
number of characters allowed is defined by the AS/400 system value,
QPWDMINLEN.
6259 CWBSY_PWD_REPEAT_CHARACTER
The new password contains a character used more than once. The AS/400
configuration (system value QPWDLMTREP) does not allow passwords to
contain a repeat character.
6260 CWBSY_PWD_ADJACENT_DIGITS
The new password contains two numbers next to each other. The AS/400
configuration (system value QPWDLMTAJC) does not allow passwords to
contain consecutive digits.
6261 CWBSY_PWD_CONSECUTIVE_CHARS
The new password contains a character repeated consecutively. The
AS/400 configuration (system value QPWDLMTREP) does not allow a
password to contain a character repeated consecutively.
6262 CWBSY_PWD_PREVIOUSLY_USED
The new password matches a previously used password. The AS/400
configuration (system value QPWDRQDDIF) requires new passwords to be
different than any previous password.
6263 CWBSY_PWD_DISALLOWED_CHAR
The new password uses an installation disallowed character. AS/400
configuration (system value QPWDLMTCHR) restricts certain characters
from being used in new passwords.
6264 CWBSY_PWD_NEED_NUMERIC
The new password must contain a number. The AS/400 configuration
(system value QPWDRQDDGT) requires new passwords contain one or more
numeric digits.
6266 CWBSY_PWD_MATCHES_OLD
The new password matches an old password in one or more character
positions. The AS/400 configuration (system value QPWDPOSDIF) does
not allow the same character to be in the same position as a
previous password.
6267 CWBSY_PWD_NOT_ALLOWED
The password was rejected.
6268 CWBSY_PWD_MATCHES_USERID
The password matches the user ID.
6269 CWBSY_PWD_PRE_V3
The old password was created on a pre-V3 system which used a
different encryption technique. Password must be changed manually on
the AS/400.
6270 CWBSY_LAST_INVALID_PASSWORD
The next invalid will disable the user profile.
0 CWBSO_NO_ERROR
No error occurred.
1 CWBSO_ERROR_OCCURRED
An error occurred. Use error handle for more information.
2 CWBSO_LOW_MEMORY
Not enough memory is available for the request.
3 CWBSO_BAD_LISTTYPE
The value specified for type of list is not valid.
4 CWBSO_BAD_HANDLE
The handle specified is not valid.
5 CWBSO_BAD_LIST_HANDLE
The list handle specified is not valid.
6 CWBSO_BAD_OBJ_HANDLE
The object handle specified is not valid.
7 CWBSO_BAD_PARMOBJ_HANDLE
The parameter object handle specified is not valid.
8 CWBSO_BAD_ERR_HANDLE
The error handle specified is not valid.
9 CWBSO_BAD_LIST_POSITION
The position in list specified does not exist.
10 CWBSO_BAD_ACTION_ID
An action ID specified is not valid for the type of list.
11 CWBSO_NOT_ALLOWED_NOW
The action requested is not allowed at this time.
12 CWBSO_BAD_INCLUDE_ID
The filter ID specified is not valid for this list.
13 CWBSO_DISP_MSG_FAILED
The request to display the message failed.
14 CWBSO_GET_MSG_FAILED
The error message text could not be retrieved.
15 CWBSO_BAD_SORT_ID
A sort ID specified is not valid for the type of list.
16 CWBSO_INTERNAL_ERROR
An internal processing error occurred.
17 CWBSO_NO_ERROR_MESSAGE
The error handle specified contains no error message.
18 CWBSO_BAD_ATTRIBUTE_ID
The attribute key is not valid for this object.
19 CWBSO_BAD_TITLE
The title specified is not valid.
20 CWBSO_BAD_FILTER_VALUE
The filter value specified is not valid.
21 CWBSO_BAD_PROFILE_NAME
The profile name specified is not valid.
22 CWBSO_DISPLAY_FAILED
The window could not be created.
23 CWBSO_SORT_NOT_ALLOWED
Sorting is not allowed for this type of list.
24 CWBSO_CANNOT_CHANGE_ATTR
Attribute is not changeable at this time.
25 CWBSO_CANNOT_READ_PROFILE
Cannot read from the specified profile file.
Express Toolkit:
The Client Access Express Toolkit provides Administration APIs
documentation, access to the cwbad.h header file, and links to sample
programs. To access this information, open the Express Toolkit and select
Client Information —> C/C++ APIs.
Express Administration APIs topics:
v Express Administration APIs listing
v “Example: Express Administration APIs” on page 37
v “Express Administration APIs return code” on page 20
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
Syntax:
Parameters:
unsigned long *version - output
Pointer to a buffer where the version level of the Client Access product is
returned.
unsigned long *release - output
Pointer to a buffer where the release level of the Client Access product is
returned.
unsigned long *modificationLevel - output
Pointer to a buffer where the modification level of the Client Access product is
returned.
Usage: If the return code is not CWB_OK, the values in version, release, and
modificationLevel are meaningless.
Syntax:
Parameters:
char *szBuffer - output
Buffer into which the product fix level string will be written.
unsigned long * ulBufLen - input/output
Size of szBuffer, including space for the NULL terminator. On output, will
contain the length of the fix level string, including the terminating NULL.
Usage: Returns the fix level of the Client Access product. Returns an empty string
if fixes have not been applied.
Syntax:
Parameters:
unsigned long ulComponentID - input
Must be set to one of the following component IDs:
CWBAD_COMP_SSL
Secure Sockets Layer
CWBAD_COMP_SSL_128_BIT
Secure Sockets Layer 128 bit
CWBAD_COMP_SSL_56_BIT
Secure Sockets Layer 56 bit
CWBAD_COMP_SSL_40_BIT
Secure Sockets Layer 40 bit
CWB_COMP_BASESUPPORT
Express required programs
CWBAD_COMP_OPTIONAL_COMPS
Express Optional Components
CWBAD_COMP_DIRECTORYUPDATE
Directory Update
CWBAD_COMP_IRC
Incoming Remote Command
CWBAD_COMP_MAPI
MAPI
CWBAD_COMP_OUG
Express Online User’s Guide
CWBAD_COMP_OPNAV
AS/400 Operations Navigator
CWBAD_COMP_DATA_ACCESS
Data Access
CWBAD_COMP_DATA_TRANSFER
Data Transfer
CWBAD_COMP_DT_BASESUPPORT
Data Transfer Base Support
CWBAD_COMP_DT_EXCEL_ADDIN
Data Transfer Excel Add-in
CWBAD_COMP_DT_WK4SUPPORT
Data Transfer WK4 file support
CWBAD_COMP_ODBC
ODBC
Syntax:
Parameters:
const char* szPluginName - input
Pointer to a null-terminated string that contains the name of the plug-in.
cwb_Boolean *bIndicator - output
Will contain CWB_TRUE if the plug-in is installed. Will return CWB_FALSE if
the component is not installed. Will not be set if an error occurs.
Usage: If the return value is not CWB_OK, the value in bIndicator is meaningless.
#include "cwbad.h"
/*
* This is the highest numbered component ID we know about (it is
* the ID of the last component defined in cwbad.h).
*/
#define LAST_COMPID_WE_KNOW_ABOUT (CWBAD_COMP_SSL_40_BIT)
/*
* Array of component names, taken from comments for component IDs
* in cwbad.h, so we can display human-readable component descriptions.
* In the compDescr array, the component ID for a component must match
* the index in the array of that component's description.
*
* For a blank or unknown component name, we provide a string to display
* an indication that the component ID is unknown, and what that ID is.
*/
static char* compDescr[ LAST_COMPID_WE_KNOW_ABOUT + 1 ] = {
"", // #0 is not used
"Express required programs",
"Express Optional Components",
"Directory Update",
"Incoming Remote Command",
"MAPI",
"Express Online User's Guide",
"AS400 Operations Navigator",
"Data Access",
"Data Transfer",
"Data Transfer Base Support",
"Data Transfer Excel Add-in",
"Data Transfer WK4 file support",
"ODBC",
"OLE DB Provider",
"AFP Workbench Viewer",
"AS400 Java Toolbox",
"5250 Display and Printer Emulator",
"Printer Drivers",
"AFP printer driver",
"SCS printer driver",
"AS400 Operations Console",
"Client Access Express Toolkit",
"Headers, Libraries, and Documentation",
"Visual Basic Wizards", // #24
"", "", "", "", "", //------------ #25-29
"", "", "", "", "", // #30-34
"", "", "", "", "", // #35-39
"", "", "", "", "", // #40-44
"", "", "", "", "", // #45-49
"", "", "", "", "", // not #50-54
"", "", "", "", "", // #55-59
"", "", "", "", "", // #60-64
"", "", "", "", "", // #65-69
"", "", "", "", "", // used #70-74
"", "", "", "", "", // #75-79
"", "", "", "", "", // #80-84
"", "", "", "", "", // #85-89
"", "", "", "", "", // #90-94
"", "", "", "", "", //------------ #95-99
"Operations Navigator Base Support", // #100
"Operations Navigator Basic Operations",
"Operations Navigator Job Management",
"Operations Navigator System Configuration",
/**************************************************************************
* Show the Client Access Version/Release/Modification level
**************************************************************************/
void showCA_VRM()
{
ULONG caVer, caRel, caMod;
UINT rc;
char fixlevelBuf[ MAX_PATH ];
ULONG fixlevelBufLen = sizeof( fixlevelBuf );
/**************************************************************************
* Call Client Access API to determine if the component is installed,
* and pass back:
* NULL if the component is not installed or an error occurs,
* OR
* A string indicating the component name is unknown if the
* component ID is higher than we know about OR the component
* description is blank,
* OR
* The human-readable component description if we know it.
**************************************************************************/
char* isCompInstalled( ULONG compID )
{
cwb_Boolean bIsInstalled;
char* pCompName;
/*
* Case 1: Error OR component not installed, return NULL to
* indicate not installed.
*/
if ( ( rc != CWB_OK ) || ( bIsInstalled == CWB_FALSE ) )
{
pCompName = NULL;
}
/*
* Case 2: Component IS installed, but we do not know its name,
* return component name unknown string.
*/
else if ( ( compID > LAST_COMPID_WE_KNOW_ABOUT ) ||
( compDescr[ compID ][ 0 ] == '\0' ) )
{
pCompName = unknownComp;
sprintf( pInsertID, "%lu", compID );
}
/*
* Case 3: Component IS installed, we have a name, return it
*/
else
{
pCompName = compDescr[ compID ];
}
return pCompName;
}
/**************************************************************************
* List the Client Access components that currently are installed.
**************************************************************************/
void showCA_CompInstalled()
{
ULONG compID;
char* compName;
/**************************************************************************
printf( "=======================================\n");
printf( "Client Access What's Installed Reporter\n" );
printf( "=======================================\n\n");
showCA_VRM();
showCA_CompInstalled();
/*
* Allow user to ask by name what plug-ins are installed.
*/
while ( TRUE ) /* REMINDER: requires a break to exit the loop! */
{
printf( "Enter plug-in to check for, or DONE to quit:\n" );
gets( pluginName );
if ( stricmp( pluginName, "DONE" ) == 0 )
{
break; /* exit from the while loop, we are DONE at user's request */
}
rc = cwbAD_IsOpNavPluginInstalled( pluginName, &bPluginInstalled; );
if ( rc == CWB_OK )
{
if ( bPluginInstalled == CWB_TRUE )
{
printf( "The plug-in '%s' is installed.\n\n", pluginName );
}
else
{
printf( "The plug-in '%s' is NOT installed.\n\n", pluginName );
}
}
else
{
printf(
"Error %u occurred when calling cwbAD_IsOpNavPluginInstalled.\n\n",
rc );
}
} // end while (TRUE)
Note: It is not necessary for you to explicitly configure new systems to add
them to the system list. They are added automatically when you connect
to a new system.
Express Toolkit:
The Client Access Express Toolkit provides Communications and Security
documentation, access to the cwbco.h and cwbcosys.h header files, and
links to sample programs. To access this information, open the Express
Toolkit and select Communications and Security —> C/C++ APIs.
Express Communications and Security topics:
v Express Communications and Security system object APIs listing
v Express Communications system list APIs listing
v “Example: Using Express communications APIs” on page 125
v “Express Communications APIs return codes” on page 21
v “Express Security APIs return codes” on page 27
v “Global Client Access return codes” on page 17
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
Most attributes can be changed until a successful signon has occurred (either as the
result of a successful call to “cwbCO_Signon” on page 95 or to “cwbCO_Connect”
on page 54). After the signon has taken place successfully, calling the cwbCO_Set
API to try to change the value of such an attribute will fail with return code
CWB_INV_AFTER_SIGNON. The only attribute that can be changed after a
successful signon is the Window Handle.
Some values and the ability to change them may be controlled via policies. Policies
are controls that a systems administrator can set up to mandate default attribute
values, and to prohibit changes to attributes. The default values that are specified
in the System object attributes listing topic (link below) are used under the
following conditions:
v If policies do not specify or suggest different values
v If a value for such an attribute has not been configured explicitly for the AS/400
system in the system list
If an attribute’s default value may be set by policy, this also is noted. If changing
an attribute’s value can be prohibited by policy, then:
v An API is provided to check for the attribute’s modifiability.
v A specific return code is provided by the attribute’s set method if the set fails
because of such a policy.
To view a listing of system object attributes:
See “System object attributes listing” on page 42
Note: The attributes’ settings apply ONLY to the system object for which they are
set, NOT to any other system objects, even if other system objects have the
same AS/400 system name.
AS/400 system name:
The AS/400 system with which to communicate and use by way of this
instance of a system object. This can be set only at the time
cwbCO_CreateSystem or cwbCO_CreateSystemLike is called. Note that the
system name is used as the unique identifier when validating security
information for a specific user ID: If two different system objects contain
different system names that represent the same physical AS/400 system,
the user ID and password require separate validation for the two system
objects. For example, this applies if the system names ″SYS1″ and
″SYS1.ACME.COM″ represent the same AS/400 system. This may result in
double prompting, and the use of different default user IDs when
connecting.
Get by using cwbCO_GetSystemName
Default:
There is no default, since this is explicitly set when the system
object is created.
User ID:
The user ID used to logon to the AS/400 system.
Get by using cwbCO_GetUserIDEx
Set by using cwbCO_SetUserIDEx
Default:
The first time that you connect to the AS/400 system which is
named in the system object, you may be prompted:
v To specify a default user ID
v To specify that the default user ID should be the same as your
Windows® user ID
v That no default will be used
On subsequent connection attempts, the default user ID that is
used will depend on which option you chose when prompted
during the first connection attempt.
Password:
The password used to signon to the AS/400 system.
Set by using cwbCO_SetPassword
Default:
Blank (no password set) if the user ID that is set in the system
object never has signed on to the AS/400 system that is named in
the system object. If a previous successful signon or connection has
been made to the AS/400 system that is named in the system
object, that password may be used for the next signon or
connection attempt.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean *canModify - output
Set to CWB_TRUE if this mode may be modified, otherwise set to
CWB_FALSE.
Usage: This value may not be modified if policy settings prohibit its modification,
or if a successful signon or connection that is using the specified system object
already has occurred. In these cases, canModify will be set to CWB_FALSE. The
results returned from this API are correct only at the time of the call.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean *canModify - output
Set to CWB_TRUE if the IP Address may be modified, otherwise set to
CWB_FALSE.
Usage: This value may not be modified if policy settings prohibit its modification,
or if a successful signon or connection by using the specified system object already
has occurred. In these cases, canModify will be set to CWB_FALSE. This value may
not be modified if the IP Address Lookup Mode is not
CWBCO_IPADDR_LOOKUP_NEVER, and policy settings prohibit modification of
the IP Address Lookup Mode. In that case, canModify will be set to CWB_FALSE.
The results returned from this API are correct only at the time of the call. If policy
settings are changed or a signon or connection is performed using this system
object, the results of this API could become incorrect. This must be considered and
managed, especially in a multi-threaded application.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean *canModify - output
Set to CWB_TRUE if this mode may be modified, otherwise set to
CWB_FALSE.
Usage: This value may not be modified if policy settings prohibit its modification,
or if a successful signon or connection using the specified system object already
has occurred. In these cases, canModify will be set to CWB_FALSE. The results
returned from this API are correct only at the time of the call.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean *canModify - output
Set to CWB_TRUE if this mode may be modified, otherwise set to
CWB_FALSE.
Usage: This value may not be modified if policy settings prohibit its modification,
or if a successful signon or connection by using the specified system object has
already occurred. In these cases, canModify will be set to CWB_FALSE. The results
returned from this API are correct only at the time of the call. If policy settings are
changed or a signon or connection is performed using this system object, the
results of this API could become incorrect. This must be considered and managed,
especially in a multi-threaded application.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean *canModify - output
Set to CWB_TRUE if this mode may be modified, otherwise set to
CWB_FALSE.
Usage: This value may not be modified if policy settings prohibit its modification,
or if a successful signon or connection by using the specified system object already
has occurred. In these cases, canModify will be set to CWB_FALSE. The results
returned from this API are correct only at the time of the call. If policy settings are
changed or a signon or connection is performed using this system object, the
results of this API could become incorrect. This must be considered and managed,
especially in a multi-threaded application.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean *canModify - output
Set to CWB_TRUE if the secure sockets use setting may be modified, otherwise
set to CWB_FALSE.
Usage: This value may not be modified if policy settings prohibit its modification,
or if a successful signon or connection using the specified system object has
already occurred. In these cases, canModify will be set to CWB_FALSE. The results
returned from this API are correct only at the time of the call. If policy settings are
changed or a signon or connection is performed using this system object, the
results of this API could become incorrect. This must be considered and managed,
especially in a multi-threaded application.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPCSTR userID - input
A pointer to an ASCIIZ string that contains the user ID. The maximum length
is CWBCO_MAX_USER_ID + 1 characters, including the null terminator.
LPCSTR oldPassword - input
A pointer to an ASCIIZ string that contains the old password. The maximum
length is CWBCO_MAX_PASSWORD + 1 characters, including the null
terminator.
LPCSTR newPassword - input
A pointer to an ASCIIZ string that contains the new password. The maximum
length is CWBCO_MAX_PASSWORD + 1 characters, including the null
terminator.
cwbSV_ErrHandle errorHandle - input/output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, or if the errorHandle is
invalid, no messages will be retrieved.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system to connect to.
cwbCO_Service service - input
The service to connect to on the AS/400 system. Valid values are those listed in
“Defines for cwbCO_Service” on page 101, except for the values
CWBCO_SERVICE_ANY and CWBCO_SERVICE_ALL. Only one service may
be specified for this API, unlike for cwbCO_Disconnect, which can disconnect
multiple services at once.
cwbSV_ErrHandle errorHandle - input/output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, or if the errorHandle is
invalid, no messages will be retrieved.
Note: Other return codes may be commonly returned as the result of a failed
security validation attempt. See the list of common return codes in the
comments for cwbCO_Signon.
Usage: If signon to the AS/400 system has not yet occurred, the signon will be
performed first when cwbCO_Connect is called. If you want the signon to occur at
a separate time, call cwbCO_Signon first, then call cwbCO_Connect at a later time.
If the AS/400 system as named in the specified system object does not exist in the
System List, and the system object Persistence Mode is set appropriately, then
when cwbCO_Connect or cwbCO_Signon is first successfully called, the AS/400
system, as named in the system object, will be added to the System List. For more
information about the Persistence Mode, see the comments for
cwbCO_SetPersistenceMode.
Each time cwbCO_Disconnect is called for the same service, the usage count will
be decremented. When the usage count reaches zero, the actual connection is
ended.
Therefore, it is VERY IMPORTANT that for every call to the cwbCO_Connect API
there is a later paired call to the cwbCO_Disconnect API, so that the connection
can be ended at the appropriate time. The alternative is to call the
cwbCO_Disconnect API, specifying CWBCO_SERVICE_ALL, which will disconnect
all existing connections to ALL services madethrough the specified system object,
and reset all usage counts to 0.
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the NULL-terminated name of the AS/400
system. This can be its host name, or the AS/400 system’s dotted-decimal IP
address itself. It must not be zero length and must not contain blanks. If the
name specified is not a valid AS/400 system host name or IP address string (in
the form ″nnn.nnn.nnn.nnn″), any connection attempt or security validation
attempt will fail.
cwbCO_SysHandle *system - output
The system object handle is returned in this parameter.
Usage: When you are done using the system object, you must call
cwbCO_DeleteSystem to free resources the system object is using. If you want to
create a system object that is like one you already have, use
cwbCO_CreateSystemLike.
Syntax:
Parameters:
cwbCO_SysHandle systemToCopy - input
Handle that was returned by a previous call to either cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system. This is the object
that will be ″copied.″
LPCSTR systemName - input
Pointer to a buffer that contains the NULL-terminated name of the AS/400
system to use in the new system object. If NULL or the empty string is passed,
the name from the given system object is copied into the new system object. If
a system name is specified, it can be the host name, or the AS/400 system’s
dotted-decimal IP address. If the name that is specified is not a valid AS/400
system host name or IP address string (in the form ″nnn.nnn.nnn.nnn″), any
connection attempt or security validation attempt will fail.
cwbCO_SysHandle *newSystem - output
The system object handle of the new system object is returned in this
parameter.
The state of the new system object might not be the same as that of the given
system object, since user ID and password validation has not been performed yet
for the new one. Also, the new system object has no connections associated with it,
whereas the given system object may. Because of this, even though you might not
be able to change attributes of the given system object because of its state, you
might be able to change the attributes of the new system object because of its
possibly different state.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that was returned by a previous call to either cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
Usage: Before the system object resources are freed, if there are any connections
that were made using the specified system object, they will be ended, forcefully if
necessary. To determine if there are active connections, call cwbCO_IsConnected. If
you want to know whether disconnecting any existing connections was successful,
call cwbCO_Disconnect explicitly before calling this API.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that was returned by a previous call to either cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system from which to
disconnect.
cwbCO_Service service - input
The service from which to disconnect on the AS/400 system. Valid values are
those listed at the start of this file, except for the value
CWBCO_SERVICE_ANY. If CWBCO_SERVICE_ALL is specified, the
connections to ALL connected services will be ended, and all connection usage
counts reset back to zero.
cwbSV_ErrHandle errorHandle - input/output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, or if the errorHandle is
invalid, no messages will be retrieved.
If any service specified cannot be disconnected, the return code will indicate this
error. If more than one error occurs, only the first one will be returned as the API
return code.
Usage Notes for individual service disconnect:
This function will cause the usage count for this system object’s specified
service to be decremented, and may or may not end the actual connection.
For more information, read the Usage Notes for the cwbCO_Connect API.
Disconnecting a service that is not currently connected results in
CWB_NOT_CONNECTED.
An individual service is gracefully disconnected.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_DefaultUserMode * mode - output
Returns the default user mode for this system object. See comments for
cwbCO_SetDefaultUserMode for the list of possible values and their meanings.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
PUSHORT numberFailedAttempts - output
A pointer to a short that will contain the number of failed logon attempts if
this call is successful.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
PULONG pCCSID - output
The host CCSID is copied into here if successful.
Usage: This API does not make or require an active connection to the host system
to retrieve the associated CCSID value.However, it does depend on a prior
successful connection to the host system by using the same user ID as is set in the
specified system object. This is because the CCSID that is returned is the one from
the specific user profile, NOT the AS/400 system’s default CCSID. To retrieve a
host CCSID without requiring a user ID, call cwbNL_GetHostCCSID.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
PULONG version - output
Pointer to a buffer where the version level of the system is returned.
PULONG release - output
Pointer to a buffer where the release level of the system is returned.
Usage: The host version is retrieved and saved whenever a connection is made to
the AS/400 system. If no connection has been made yet to this AS/400 system in
the currently-active environment, this information will not be available, and the
error code CWB_NOT_CONNECTED will be returned. If you know that a
connection to the AS/400 system recently was made successfully, it is likely that
the version and release levels returned are current. If you want to make sure that
the values are available and recently have been retrieved, call cwbCO_Signon or
cwbCO_Connect for this system object first, then call cwbCO_GetHostVersionEx.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned by cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPSTR IPAddress - output
Pointer to a buffer that will contain the NULL-terminated IP address in
dotted-decimal notation (in the form ″nnn.nnn.nnn.nnn″ where each ″nnn″ is in
the range of from 0 to 255).
PULONG length - input/output
Pointer to the length of the IPAddress buffer. If the buffer is too small to hold
the output, including room for the terminating NULL, the size of the buffer
needed will be filled into this parameter and CWB_BUFFER_OVERFLOW will
be returned.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned by cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_IPAddressLookupMode * mode - output
Returns the IP address lookup mode that currently is in use. See comments for
“cwbCO_SetIPAddressLookupMode” on page 84 for possible values and their
meanings.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_DateTime * expirationDateTime - output
A pointer to a structure that contains the date and time at which the password
will expire for the current user ID, in the following format:
Bytes Content
1-2 Year (Example: 1998 = 0x07CF)
3 Month (January = 0x01)
4 Day (First day = 0x01;31st day = 0x1F)
5 Hour (Midnight = 0x00;23rd hour = 0x17)
6 Minute (On the hour = 0x00; 59th minute = 0x3B)
7 Second (On the minute = 0x00; 59th second = 0x3B)
8 One-hundredth of a second (on the second = 0x00; maximum = 0x63)
Note: On a given day, the maximum time is 23 hours, 59 minutes, and 59.99
seconds. Midnight is 0 hours, 0 minutes, and 0.0 seconds on the
following day.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_PersistenceMode * mode - output
Returns the persistence mode. See comments for cwbCO_SetPersistenceMode
for possible values and their meanings.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned by cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_PortLookupMode * mode - output
Returns the host service port lookup mode. See comments for
cwbCO_SetPortLookupMode for possible values and their meanings.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem
orcwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_DateTime * signonDateTime - output
A pointer to a structure that contains the date and time at which the previous
signon occurred, in the following format:
Bytes Content
1-2 Year (Example: 1998 = 0x07CF)
3 Month (January = 0x01)
4 Day (First day = 0x01;31st day = 0x1F)
5 Hour (Midnight = 0x00;23rd hour = 0x17)
6 Minute (On the hour = 0x00; 59th minute = 0x3B)
7 Second (On the minute = 0x00; 59th second = 0x3B)
8 One-hundredth of a second (on the second = 0x00; maximum = 0x63)
Note: On a given day, the maximum time is 23 hours, 59 minutes, and 59.99
seconds. Midnight is 0 hours, 0 minutes, and 0.0 seconds on the
following day.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_PromptMode * mode - output
Returns the prompt mode. See comments for cwbCO_SetPromptMode for
possible values and their meanings.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_DateTime * signonDateTime - output
A pointer to a structure that will contain the date and time at which the
current signon occurred, in the following format:
Bytes Content
1-2 Year (Example: 1998 = 0x07CF)
3 Month (January = 0x01)
4 Day (First day = 0x01;31st day = 0x1F)
5 Hour (Midnight = 0x00;23rd hour = 0x17)
6 Minute (On the hour = 0x00; 59th minute = 0x3B)
7 Second (On the minute = 0x00; 59th second = 0x3B)
8 One-hundredth of a second (on the second = 0x00; maximum = 0x63)
Note: On a given day, the maximum time is 23 hours, 59 minutes, and 59.99
seconds. Midnight is 0 hours, 0 minutes, and 0.0 seconds on the
following day.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPSTR sysName - output
Pointer to a buffer that will contain the NULL-terminated system name. The
name will be CWBCO_MAX_SYS_NAME characters long at most, not
including the terminating NULL.
PULONG length - input/output
Pointer to the length of the sysName buffer. If the buffer is too small to hold
the system name, including room for the terminating NULL, the size of the
buffer needed will be filled into this parameter and
CWB_BUFFER_OVERFLOW will be returned.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPSTR userID - output
Pointer to a buffer that will contain the NULL-terminated user ID. The user ID
will be at most CWBCO_MAX_USER_ID characters long.
PULONG length - input/output
Pointer to the length of the userID buffer. If the buffer is too small to hold the
user ID, including space for the terminating NULL, the size of the buffer
needed will be filled into this parameter.
Usage: The user ID may or may not have been validated on the AS/400 system
yet. To make sure it has been, call cwbCO_Signon or cwbCO_Connect before
calling this API.
If no user ID has been set and a signon has not occurred for the system object, the
returned user ID will be the empty string, even if a default user ID has been
configured for the AS/400 system.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_ValidateMode * mode - output
Returns the validate mode. See comments for cwbCO_SetValidateMode for
possible values and their meanings.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
HWND * pWindowHandle - output
Returns the window handle associated with the system object, or NULL if no
window handle is associated with it.
Usage: None.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean * signedOn - output
A pointer to a cwb_Boolean into which is stored the indication of
″signed-on-ness.″ If the specified system object has signed on, it will be set to
CWB_TRUE, otherwise it will be set to CWB_FALSE. (On error it will be set to
CWB_FALSE as well.)
Usage: A returned indication of CWB_TRUE does not mean that the user ID and
password have been validated within a certain time period, but only that since the
system object’s creation, a signon has occurred. That signon may not have caused
or included a connection and security validation flow to the AS/400 system. This
means that, even if CWB_TRUE is returned, the next call to the system object that
requires a successful signon might connect and attempt to re-validate the user ID
and password, and that validation, and hence the signon, may fail. The signedOn
indicator reflects the results of the most-recent user ID and password validation. If
user ID and password validation (signon) has occurred successfully at one time,
but since then this validation has failed, signedOn will be set to CWB_FALSE.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_Service service - input
The service to check for a connection. Any of the cwbCO_Service values listed
in “Defines for cwbCO_Service” on page 101 are valid. To find out if ANY
service is connected, specify CWBCO_SERVICE_ANY. To find out how many
services are connected using this system object, specify
CWBCO_SERVICE_ALL.
PULONG numberOfConnections - output
Used to return the number of connections active for the service(s) that are
specified. If the service specified is not CWBCO_SERVICE_ALL, the value
returned will be either 0 or 1, since there can be at most one active connection
per service per system object. If CWBCO_SERVICE_ALL is specified, this could
be from zero to the possible number of services, since one connection per
service might be active.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean * inUse - output
Returns whether Client Access is using, or will try to use, secure sockets for
communication:
CWB_TRUE
IS in use or would be if connections active.
CWB_FALSE
NOT in use, would not try to use it.
Usage: This flag is an indication of what Client Access will TRY to do for any
future communications. If CWB_TRUE is returned, then any attempt to
communicate to the AS/400 system that cannot be performed using secure sockets
will fail.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_DefaultUserMode mode - input
Specifies what will be done with the default user ID. Possible values are:
CWBCO_DEFAULT_USER_MODE_NOT_SET
No default user mode is currently in use. When this mode is active,
and the Prompt Mode setting does not prohibit prompting, the user
will be prompted at signon or connect time to select which of the
remaining default user modes should be used from then on. The
signon or connect cannot succeed until one of these other mode values
is selected. Setting the Default User Mode back to this value will cause
the prompt to appear the next time a default user ID is needed by
Client Access.
CWBCO_DEFAULT_USER_USE
When no user ID has explicitly been set (by using
cwbCO_SetUserIDEx) and a signon is to occur, use the default user ID
that is configured for the AS/400 system as named in the system
object.
CWBCO_DEFAULT_USER_IGNORE
Specifies never to use a default user ID. When a signon takes place and
no user ID has explicitly been set for this system object instance, the
user will be prompted to enter a user ID if the Prompt Mode allows it
(see cwbCO_SetPromptMode comments), and no initial value for the
user ID will be filled in in the prompt.
CWBCO_DEFAULT_USER_USEWINLOGON
The user ID that is used when logging on to Windows will be used as
the default if no user ID explicitly has been set for this system object
(by using cwbCO_SetUserIDEx).
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object. The default
user mode set with this API will be ignored if a user ID has been set explicitly
with the cwbCO_SetUserIDEx API.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPCSTR IPAddress - input
Specifies the IP address as a character string, in dotted-decimal notation
(″nnn.nnn.nnn.nnn″), where each ″nnn″ is a decimal value ranging from 0 to
255. The IPAddress must not be longer than CWBCO_MAX_IP_ADDRESS
characters, not including the terminating NULL character.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object.
Use this API to force use of a specific IP address whenever any connection is made
using the specified system object. Since the IP Address Lookup Mode is set to
NEVER lookup the IP address, the address specified always will be used, unless
before a connect or signon occurs, the IP Address Lookup Mode is changed by
calling cwbCO_SetIPAddressLookupMode.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_IPAddressLookupMode mode - input
Specifies when the dynamic address lookup can occur. Possible values are:
CWBCO_IPADDR_LOOKUP_ALWAYS
Every time a connection is to occur, dynamically lookup the AS/400
system’s IP address.
CWBCO_IPADDR_LOOKUP_1HOUR
Lookup the IP address dynamically if it has been at least one hour
since the last lookup for this AS/400 system.
CWBCO_IPADDR_LOOKUP_1DAY
Lookup the IP address dynamically if it has been at least one day since
the last lookup for this AS/400 system.
CWBCO_IPADDR_LOOKUP_1WEEK
Lookup the IP address dynamically if it has been at least one week
since the last lookup for this AS/400 system.
CWBCO_IPADDR_LOOKUP_NEVER
Never dynamically lookup the IP address of this AS/400 system,
always use the IP address that was last used for this AS/400 system on
this PC.
CWBCO_IPADDR_LOOKUP_AFTER_STARTUP
Lookup the IP address dynamically if Windows has been re-started
since the last lookup for this AS/400 system.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPCSTR password - input
Pointer to a buffer that contains the NULL-terminated password. The
password must not be longer than CWBCO_MAX_PASSWORD characters, not
including the terminating NULL character.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object. A password set
with this API will not be used unless a corresponding user ID has been set with
cwbCO_SetUserIDEx.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle returned previously from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_PersistenceMode mode - input
Specifies the persistence mode. Possible values are:
CWBCO_MAY_MAKE_PERSISTENT
If the system that is named in the specified system object is not yet in
the System List, add it to the list once a successful signon has
completed. This will make the system, as defined by this system object,
available for selection by this AND other applications running, now or
in the future, on this personal computer (until the system is deleted
from this list).
CWBCO_MAY_NOT_MAKE_PERSISTENT
The system that is named in the specified system object (along with its
attributes) may NOT be added to the System List.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object.
If the system as named in the system object already is in the System List, this
setting has no effect.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned by cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_PortLookupMode mode - input
Specifies port lookup method. Possible values are:
CWBCO_PORT_LOOKUP_SERVER
Lookup of a host server port will be done by contacting the host
(AS/400) server mapper each time the connection of a service is to be
made when one does not yet exist. The server mapper returns the port
number that is then used to connect to the desired service on the
AS/400 system.
CWBCO_PORT_LOOKUP_LOCAL
Lookup of a host server port will be done by lookup in the SERVICES
file on the PC itself.
CWBCO_PORT_LOOKUP_STANDARD
The ″standard″ port—that set by default for a given host server and in
use if no one has changed the services table on the AS/400 system for
that service—will be used to connect to the desired service.
The latter two modes eliminate the AS/400 server mapper connection and its
associated delay, network traffic, and load on the AS/400 system.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_PromptMode - input
Specifies the prompt mode. Possible values are:
CWBCO_PROMPT_IF_NECESSARY
Client Access will prompt if either the user ID or password have not
been explicitly set or cannot be retrieved from the persistent
configuration for this system, the password cache (if enabled), or by
some other means.
If the Default User Mode has not been set, and if for this AS/400
system the user has not been prompted yet for default user ID, Client
Access will prompt for it at cwbCO_Connect or cwbCO_Signon time
CWBCO_PROMPT_ALWAYS
Client Access will always prompt when a signon is to occur for the
specified system object, even if a successful signon using the same user
ID to the same AS/400 system has occurred using a different system
object. Since a signon can occur only once for a system object, this
means that exactly one prompt per system object will occur. Additional
explicit signon calls will do nothing (including prompt). See two
exceptions to using this mode in the usage notes below.
CWBCO_PROMPT_NEVER
Client Access never will prompt for user ID and password, or for
default user ID. When this mode is used, a call to any API that
requires a signon for completion (for example, cwbCO_Signon or
cwbCO_Connect) will fail if either the user ID or password have not
been set and cannot be programmatically retrieved (from the AS/400
password cache). This mode should be used when either
v Client Access is running on a PC that is unattended or for some
other reason cannot support end-user interaction.
v The application itself is prompting for or otherwise fetching the user
ID and password, and explicitly setting them by using
cwbCO_SetUserIDEx and cwbCO_SetPassword.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object. Setting the
prompt mode to CWBCO_PROMPT_ALWAYS will not prompt the user in the
following two cases:
v A user ID and password explicitly have been set with the cwbCO_setUserIDEx
and cwbCO_SetPassword APIs.
v Use Windows logon info (CWBCO_DEFAULT_USER_USEWINLOGON) has
been set with the cwbCO_SetDefaultUserMode API.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPCSTR userID - input
Pointer to a buffer that contains the NULL-terminated user ID. The user ID
must not be longer than CWBCO_MAX_USER_ID characters, not including the
terminating NULL character.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object. Setting a user
ID explicitly with this API will cause any default user mode set with the
cwbCO_SetDefaultUserMode API to be ignored.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbCO_ValidateMode mode - input
Specifies the validate mode. Possible values are:
CWBCO_VALIDATE_IF_NECESSARY
If validation of this user ID on this AS/400 system has occurred from
this PC within the last 24 hours, and the validation was successful,
then use the results of the last validation and do not connect to
validate at this time. There may be other scenarios where re-validation
will occur; Client Access will re-validate as needed.
CWBCO_VALIDATE_ALWAYS
Communication with the AS/400 system to validate user ID and
password will occur every time this validation is requested or required.
Setting this mode forces the validation to occur (when the system
object is not signed on yet). Once a system object is signed on, this
setting is ignored.
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
HWND windowHandle - input
Specifies the window handle to associate with the system object. If NULL, no
window handle is associated with the system object.
Usage: This API may be used any time to change the window handle for the
specified system object, even after a successful signon.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwbSV_ErrHandle errorHandle - input/output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, or if the errorHandle is
invalid, no messages will be retrieved.
For more information about the Persistence Mode, see the comments for
cwbCO_SetPersistenceMode. If successful, and AS/400 password caching is
enabled, the password will be stored for the resulting user ID in the PC’s AS/400
password cache.
See also:
v “Differences between cwbCO_Signon and cwbCO_VerifyUserIDPassword” on
page 101
v “Similarities between cwbCO_Signon and cwbCO_VerifyUserIDPassword” on
page 101
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
cwb_Boolean useSecureSockets - input
Specifies whether to require secure sockets use when communicating with the
AS/400 system that the specified system object handle represents. Use the
appropriate value:
CWB_TRUE
Require secure sockets use for communication
CWB_FALSE
Do not use secure sockets for communication
Usage: This API cannot be used after a successful signon has occurred for the
specified system object. A signon has occurred if either cwbCO_Signon or
cwbCO_Connect has been called successfully for this system object. If you specify
that secure sockets must be used, any attempt to communicate with the AS/400
system that cannot be completed using secure sockets will fail.
Client Access may or may not be able to detect at the time this API is called if
Secure Sockets will be available for use at connect time for this AS/400 system.
Even if CWB_SECURE_SOCKETS_NOTAVAIL is NOT returned, it may be
determined at a later time that secure sockets is not available.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle previously returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system to which to verify
connectability.
cwbCO_Service service - input
The service to verify connectability to on the AS/400 system. Valid values are
those listed in “Defines for cwbCO_Service” on page 101, except for the value
CWBCO_SERVICE_ANY. To verify connectability of ALL services, specify
CWBCO_SERVICE_ALL.
cwbSV_ErrHandle errorHandle - input/output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, or if the errorHandle is
invalid, no messages will be retrieved.
Usage: This API does not require user ID and password to be set, nor will it
cause a signon to occur, thus it will never prompt for this information. It does not
change the state of the system object in any way.
Since this API does not establish a usable connection, it automatically will
disconnect when the verification is complete; therefore, do NOT call
cwbCO_Disconnect to end the connection.
Syntax:
Parameters:
cwbCO_SysHandle system - input
Handle that previously was returned from cwbCO_CreateSystem or
cwbCO_CreateSystemLike. It identifies the AS/400 system.
LPCSTR userID - input
Pointer to a buffer that contains the NULL-terminated user ID, which must not
exceed CWBCO_MAX_USER_ID characters in length, not including the
terminating NULL.
LPCSTR password - input
Pointer to a buffer that contains the NULL-terminated password, which must
not exceed CWBCO_MAX_PASSWORD characters in length, not including the
terminating NULL.
cwbSV_ErrHandle errorHandle - input/output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, or if the errorHandle is
invalid, no messages will be retrieved.
Function APIs
Create a list of configured systems, either cwbCO_CreateSysListHandle
in the currently active environment or in a cwbCO_CreateSysListHandleEnv
different environment. Retrieve the number cwbCO_GetSysListSize
of entries in the list, and each entry in cwbCO_GetNextSysName
succession. cwbCO_DeleteSysListHandle
Obtain information about individual cwbCO_GetDefaultSysName
systems that are configured or connected in cwbCO_GetConnectedSysName
the current process. Unless the environment cwbCO_IsSystemConfigured
name is passed as a parameter, these APIs cwbCO_IsSystemConfiguredEnv*
work only with the currently active cwbCO_IsSystemConnected
environment: cwbCO_GetUserID
cwbCO_GetActiveConversations
cwbCO_GetHostVersion
Obtain the names of environments that cwbCO_GetNumberOfEnvironments
have been configured. cwbCO_GetEnvironmentName
cwbCO_GetActiveEnvironment
Determine if the calling application can cwbCO_CanConnectNewSystem
modify environments and connection cwbCO_CanSetActiveEnvironment
information. cwbCO_CanModifyEnvironmentList
cwbCO_CanModifySystemList
cwbCO_CanModifySystemListEnv
Syntax:
Parameters: None
Syntax:
Parameters:
None
Syntax:
Parameters:
None
Usage: This API indicates whether systems within the active environment can be
manipulated. To see if environments can be manipulated see the
cwbCO_CanModifyEnvironmentList API.
Syntax:
Parameters:
char *environmentName - input
Pointer to a string that contains the desired environment name. If this pointer
is NULL, or if it points to an empty string, the currently active environment is
used.
Syntax:
Parameters:
None
Usage: None
Syntax:
Parameters:
cwbCO_SysListHandle *listHandle - output
Pointer to a list handle that will be passed back on output. This handle is
needed for other calls using the list.
cwbSV_ErrorHandle errorHandle - input
If the API call fails, the message object that is associated with this handle will
be filled in with message text that describes the error. If this parameter is zero,
no messages will be available.
Syntax:
Parameters:
cwbCO_SysListHandle *listHandle - output
Pointer to a list handle that will be passed back on output. This handle is
needed for other calls that are using the list.
cwbSV_ErrorHandle errorHandle - input
If the API call fails, the message object that is associated with this handle will
be filled in with message text that describes the error. If this parameter is zero,
no messages will be available.
LPCSTR pEnvironment
Pointer to a string containing the desired environment name. If pEnvironment
is the NULL pointer, or points to the NULL string (″\0″), the system list of the
current active environment is returned.
Syntax:
Parameters:
cwbCO_SysListHandle - listHandle
A handle to the system name list to delete.
Usage: Use this API to delete the list created with the
cwbCO_CreateSysListHandle or cwbCO_CreateSysListHandleEnv API.
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the system name.
Usage: This API returns the number of conversations active for the specified
AS/400 system within the CURRENT PROCESS ONLY. There may be other
conversations active within other processes running on the PC.
Syntax:
Parameters:
char *environmentName - output
Pointer to a buffer into which will be copied the name of the active
environment, if the buffer that is passed is large enough to hold it. The buffer
should be large enough to hold at least CWBCO_MAX_ENV_NAME + 1
characters, including the terminating NULL character.
unsigned long * bufferSize - input/output
input Size of the buffer pointed to by *environmentName.
output
Size of buffer needed.
Usage:
Syntax:
Parameters:
char *systemName - output
Pointer to a buffer that will contain the system name. This buffer should be
large enough to hold at least CWBCO_MAX_SYS_NAME + 1 characters,
including the terminating NULL character.
unsigned long * bufferSize - input/output
input Size of the buffer pointed to by *systemName.
output
Size of buffer needed.
unsigned long index
Indicates which connected system to retrieve the name for. The first connected
system’s index is 0, the second index is 1, and so on.
Usage: Connections for which system names can be retrieved are those within the
current process only.
Syntax:
Parameters:
char *defaultSystemName - output
Pointer to a buffer that will contain the NULL-terminated system name. This
buffer should be large enough to hold at least CWBCO_MAX_SYS_NAME + 1
characters, including the terminating NULL character.
unsigned long bufferSize - input
Size of input buffer.
unsigned long *needed - output
Number of bytes needed to hold entire system name including the terminating
NULL.
cwbSV_ErrorHandle errorhandle - input
If the API call fails, the message object associated with this handle will be
filled in with message text that describes the error. If this parameter is zero, no
messages will be available.
Usage:
Syntax:
Parameters:
char *environmentName - output
Pointer to a buffer that will contain the environment name. This buffer should
be large enough to hold at least CWBCO_MAX_ENV_NAME + 1 characters,
including the terminating NULL character.
unsigned long * bufferSize - input/output
input Size of the buffer pointed to by *environmentName.
output
Size of buffer needed, if the buffer provided was too small.
unsigned long index - input
0 corresponds to the first environment.
Usage:
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the system name.
unsigned int * version - output
Pointer to a buffer where the version level of the system is returned.
unsigned int * release - output
Pointer to a buffer where the release level of the system is returned.
Usage: The host version is retrieved and saved whenever a connection is made to
the system; this API does not go to the host to get it on each call. The system must
have been connected previously, though not necessarily at the time the API is
called. Host information can only be retrieved for systems configured in the
currently active environment.
Syntax:
Parameters:
cwbCO_SysListHandle handleList - input
Handle to a list of systems.
char *systemName - output
Pointer to a buffer that will contain the system name. This buffer should be
large enough to hold at least CWBCO_MAX_SYS_NAME + 1 characters,
including the terminating NULL character.
unsigned long bufferSize - input
Size of the buffer pointed to by systemName.
unsigned long *needed - output
Number of bytes needed to hold entire system name.
Usage: If the system list passed in was created using the API
cwbCO_CreateSystemListHandle, then the system returned is configured in the
currently active environment, unless between these API calls the user has removed
it or switched to a different environment. If cwbCO_CreateSysListHandleEnv was
called to create the system list, then the system returned is configured in the
environment passed to that API, unless the user has since removed it.
Syntax:
Parameters:
unsigned long *numberOfEnv - output
On output this will be set to the number of environments.
Usage: None.
Syntax:
Parameters:
cwbCO_SysListHandle listHandle - input
Handle of the list of systems.
unsigned long *listSize - output
On output this will be set to the number of systems in the list.
Usage: None.
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the system name.
char *userID - output
Pointer to a buffer where the desired userID of the system is returned. This
buffer should be large enough to hold at least CWBCO_MAX_USER_ID + 1
characters, including the terminating NULL character.
unsigned int userID_Type - input
Specify whether current user ID of connected system
(CWBCO_CURRENT_USER_ID) or default user ID of configured system
(CWBCO_DEFAULT_USER_ID) is to be returned.
unsigned long * bufferSize - input/output
Pointer to a value that indicates the size of the userID buffer. If the buffer is
not big enough, the value needed is returned.
Usage: If the default user ID is specified, and none was entered when the
connection was configured, CWB_OK will be returned and the user ID sent back to
the caller will be the empty string, ″\0″. The user ID retrieved will be that of the
specified system from the currently active environment.
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the system name.
Usage: None
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the system name.
LPCSTR pEnvironment - input
Pointer to a buffer that contains the environment name. If pEnvironment is
NULL, or if it points to an empty string, the environment currently in use is
checked.
Usage: None
Syntax:
Parameters:
LPCSTR systemName - input
Pointer to a buffer that contains the system name.
Usage: This API indicates connection status within the current process only. The
system may be connected within a different process, but this has no effect on the
output of this API.
#include <windows.h>
#include <stdio.h>
/*
* Node in a singly-linked list to hold a system object
* handle. (The system name is retrievable from the
* system object by calling cwbCO_GetSystemName().)
* Note that the creator of an instance of this node must
* allocate the space to hold the system name himself,
* only a pointer is supplied here.
*/
typedef struct sysListNodeStruct SYSLISTNODE, *PSYSLISTNODE;
struct sysListNodeStruct
{
cwbCO_SysHandle hSys;
PSYSLISTNODE next;
} ;
pNewSys->next = *ppSysList;
*ppSysList = pNewSys;
return SUCCESS;
}
/****************************************************************************
* Clear the list of system names and clean up used storage.
****************************************************************************/
void clearList( SYSLISTNODE* pSysList )
{
PSYSLISTNODE pCur, pNext;
UINT apiRC;
pCur = pSysList;
/****************************************************************************
/****************************************************************************
* Build the list of systems as it is currently configured in Client
* Access.
****************************************************************************/
UINT buildSysList(
SYSLISTNODE** ppSysList )
{
cwbSV_ErrHandle hErrs;
cwbCO_SysListHandle hList;
char sysName[ CWBCO_MAX_SYS_NAME + 1 ];
ULONG bufSize = sizeof( sysName );
ULONG needed;
UINT apiRC;
UINT myRC = SUCCESS;
/* Get each successive system name and add the system to our
* internal list for later use.
*/
while ( ( CWB_OK == apiRC ) && ( myRC == SUCCESS ) )
{
apiRC = cwbCO_GetNextSysName( hList, sysName, bufSize, &needed );
/*
* Free the FAILURE handle if one was created
*/
if ( hErrs != 0 ) /* (non-NULL if it was successfully created) */
{
apiRC = cwbSV_DeleteErrHandle( hErrs );
if ( CWB_INVALID_HANDLE == apiRC )
{
printf("Failure: FAILURE handle invalid, could not delete!\n");
myRC = FAILURE;
}
}
return myRC;
}
/****************************************************************************
* Get a system object given an index into our list of systems.
****************************************************************************/
UINT getSystemObject(
UINT sysNum,
SYSLISTNODE* pSysList,
cwbCO_SysHandle* phSys )
{
SYSLISTNODE* pCur;
UINT myRC = SUCCESS;
pCur = pCur->next;
}
return myRC;
}
/****************************************************************************
* Allow the user to select a system from the list we have.
****************************************************************************/
UINT selectSystem(
UINT* pNumSelected,
SYSLISTNODE* pSysList,
BOOL refreshList )
{
UINT myRC = SUCCESS;
SYSLISTNODE* pCur;
UINT sysNum, numSystems;
char choiceStr[ 20 ];
UINT apiRC;
char sysName[ CWBCO_MAX_SYS_NAME + 1 ];
ULONG sysNameBufLen = sizeof( sysName );
/* If the user wants the list refreshed, clear any existing list
* so we can rebuilt it from scratch.
*/
if ( refreshList )
{
clearList( pSysList );
pSysList = NULL;
}
if ( SUCCESS == myRC )
{
return myRC;
}
/****************************************************************************
* Display a single attribute and its value, or a failing return code
* if one occurred when trying to look it up.
****************************************************************************/
void dspAttr(
char* label,
char* attrVal,
UINT lookupRC,
cwb_Boolean* pCanBeModified,
UINT canBeModifiedRC )
{
if ( CWB_OK == lookupRC )
{
printf( "%-25s : %-30s ", label, attrVal );
if ( CWB_OK == canBeModifiedRC )
{
if ( pCanBeModified != NULL )
{
printf( "%s\n", cwbBoolStr[ *pCanBeModified ] );
}
else
{
printf( "(N/A)\n" );
}
}
else
{
printf( "(Error, rc=%u)\n", canBeModifiedRC );
/****************************************************************************
*
* Load the host/version string into the buffer specified. The
* buffer passed in must be at least 7 bytes long! A pointer to
* the buffer itself is passed back so that the output from this
* function can be used directly as a parameter.
*
****************************************************************************/
char* hostVerModeDescr(
ULONG ver,
ULONG rel,
char* verRelBuf )
{
char* nextChar = verRelBuf;
if ( verRelBuf != NULL )
{
*nextChar++ = 'v';
if ( ver < 10 )
{
*nextChar++ = '0' + (char)ver;
}
else
{
*nextChar++ = '?';
*nextChar++ = '?';
}
*nextChar++ = 'r';
if ( rel < 10 )
{
*nextChar++ = '0' + (char)rel;
}
else
{
*nextChar++ = '?';
*nextChar++ = '?';
}
*nextChar = '\0';
}
return verRelBuf;
}
/****************************************************************************
* Display all attributes of the system whose index in the passed list
* is passed in.
****************************************************************************/
void dspSysAttrs(
SYSLISTNODE* pSysList,
UINT sysNum )
{
cwbCO_SysHandle hSys;
UINT rc;
printf("\n\n");
printf("-----------------------------------------------------------\n");
printf(" S y s t e m A t t r i b u t e s \n");
printf("-----------------------------------------------------------\n");
printf("\n");
printf( "%-25s %-30s %s\n", "Attribute", "Value", "Modifiable" );
printf( "%-25s %-30s %s\n", "---------", "-----", "----------" );
printf("\n");
printf("\n\n");
}
/****************************************************************************
* Display connectability to all Client Access services that are
* possible to connect to.
****************************************************************************/
void dspConnectability(
PSYSLISTNODE pSysList,
UINT sysNum )
{
UINT rc;
UINT apiRC;
cwbCO_Service service;
cwbCO_SysHandle hSys;
printf("\n");
}
/****************************************************************************
* MAIN PROGRAM BODY
****************************************************************************/
void main(void)
{
PSYSLISTNODE pSysList = NULL;
UINT numSelected;
UINT rc;
char choiceStr[10];
UINT choice;
rc = buildSysList( &pSysList );
if ( SUCCESS != rc )
do
{
printf( "\n" );
printf( "Select one of the following options:\n" );
printf( " (1) Display current system attributes\n");
printf( " (2) Display service connectability for a system\n");
printf( " (3) Refresh the list of systems\n" );
printf( " (9) Quit\n" );
gets( choiceStr );
printf( "\n" );
choice = atoi( choiceStr );
switch ( choice )
{
// ---- Display current system attributes ---------------
case 1 :
{
rc = selectSystem( &numSelected, pSysList, FALSE );
if ( SUCCESS == rc )
{
dspSysAttrs( pSysList, numSelected );
}
break;
}
break;
}
default :
{
printf("Invalid choice. Please make a different selection.\n");
}
}
} while ( choice != 9 );
Express provides both Structured Query Language (SQL) and record-level access
interfaces. The SQL interfaces provide access to DB2 Universal Database (UDB) for
AS/400 database files and stored procedures. The record-level access interface
provides the fastest access to single records within a file. The IBM DB2 UDB for
AS/400 SQL Programming book contains detailed information.
How to access the book:
Follow these steps to view a hypertext markup language (HTML) online
version of the DB2 UDB for AS/400 SQL Programming book, and to print a
PDF version:
1. Link to the DB2 Universal Database™ for AS/400 books online topic in
the AS/400 Information Center
2. Select SQL Programming Concepts
Express ODBC
What is ODBC?
ODBC stands for open database connectivity. It consists of:
v A well-defined set of functions (application programming interfaces)
v Standards for SQL syntax (that are recommended but not imposed)
v Error codes
v Data types
ODBC drivers return standard error codes and translate data types to a common
(ODBC) standard. ODBC allows the application developer to obtain integrated
database error information, and to avoid some of the most complex problems that
are involved with making applications portable.
What you can do with ODBC:
Use ODBC to:
v Send SQL requests to the database management system (DBMS).
v Use the same program to access different database management system
(DBMS) products without re-compiling.
v Create an application that is independent of the data communications
protocol.
v Handle data in a format convenient to the application.
The flexibility of Express ODBC APIs allows you to use them in transaction-based,
line-of-business applications (where the SQL is predefined). They also can use
them in query tools such as Lotus® Approach® or Microsoft® Query (where the
select statement is created at run time).
The Client Access Express ODBC driver has the following conformance levels:
API conformance level:
Level 2
SQL grammar conformance level:
Core, with support for most Extended grammar
Note: Client Access Express ODBC driver supports ODBC version 2.5
specifications.
Express ODBC driver topics:
v “Setting up the Express ODBC driver”
v “Express ODBC driver: related information” on page 159
v “ODBC core conformance APIs” on page 194
v “ODBC level-1 conformance APIs” on page 195
v “ODBC level-2 conformance APIs” on page 196
Setting up the Express ODBC driver: By using the Client Access Express ODBC
driver, you enable your ODBC client applications to effectively share data with
each other and with the AS/400.
To set up the Express ODBC driver:
1. Add the local AS/400 system to the relational database (RDB) directory.
2. Select the Client Access ODBC driver.
3. Set up the ODBC data source.
Adding the local AS/400 system to the RDB directory: To use ODBC, the local AS/400
must appear in the RDB directory.
To add the local AS/400 system to the RDB directory:
1. From the AS/400 command prompt, send the CL command Add
Relational Database Directory Entry (ADDRDBDIRE).
2. When the ADDRDBDIRE screen prompts you for values, enter the
name of the AS/400 as the Relational Database parameter.
3. Enter *LOCAL as the Remote Location parameter.
Selecting the Client Access ODBC driver: To access data, you must select an ODBC
driver.
To select the Client Access ODBC Driver:
1. To start ODBC Administration from the Windows Taskbar, select Start
and choose Programs –> IBM AS400 Client Access Express –> ODBC
Administration.
Tip: You also can double-click the IBM AS400 Client Access Express
icon on the desktop, if you have one, and then select ODBC
Administration.
2. Select the tab for the type of DSN you want. See “ODBC components”
on page 191 for an explanation of DSN types.
3. In the Data Source Administrator dialog, select Add....
Note: If you selected the User DSN or System DSN tabs, the ODBC
Administrator calls the ConfigDSN ODBC function. This
function is in the CWBSTP.DLL setup DLL.
4. In the Create New Data Source dialog, select Client Access ODBC
Driver [32-bit] from the Installed ODBC Drivers selection box.
5. Select Finish to complete the selection and to activate the Client Access
ODBC Setup [32-bit] dialog.
What to do next:
Set up the ODBC data source
Setting up the ODBC data source: You must set up the data source for your
application to access and manipulate data.
To set up the ODBC data source:
1. Enter the required information that is in the General tab of the Client
Access ODBC Setup [32-bit] dialog.
Note: If you complete only the General tab, the Client Access ODBC
driver supplies default values for the information in the remaining
tabs. See “Configuring ODBC data-source options” on page 145 for
additional information.
To set up the Client Access ODBC Driver:
1. Enter a descriptive Data source name in the textbox. This is required
information that enables the Client Access ODBC driver to access
AS/400 data.
2. Enter a Description of the data that is found in the data source. This
information is optional but useful in identifying the data source when
changing attributes at a later time.
3. Type a system name or select a previously configured AS/400 System
that contains the data source. Select the drop-down arrow to choose
Note: When you select the Connection Options button, the system
name that you specified is verified. If the verification fails, an
error-message alert displays.You must enter a valid system name.
The following options can be configured:
Signon information
Specifies what default user ID to use, if any. See “ODBC
connection APIs prompting considerations” on page 143 for
additional information.
Use Windows user name and password, no prompting
Specifies to use your Windows user name and
password without any prompting every time you sign
on to the AS/400 system.
Use default user ID, prompt as needed
Specifies to use your default user ID that you must
specify in the field provided. Otherwise, you will be
prompted for the information.
Prompt every time
Specifies to prompt you for the signon information
every time you connect to this AS/400.
Use Operations Navigator default
Specifies to use the current Operations Navigator
setting.
Security
Specifies whether you want to use Secure Sockets Layer (SSL),
or use the same security as specified in the Operations
Navigator connection.
Note: When you select OK, the AS/400 system verifies the names that
you specified.
What to do next:
Configure formatting and performance options for the ODBC data source
SQLConnect:
User ID and password passed in:
The signon prompt appears only if an error occurs, and the user
indicates to retry the signon.
User ID not passed in:
The signon setting is retrieved from the connection string, or from
the DSN.
No user ID specified:
Configuring ODBC data-source options: After you specify General tab data-source
options, use the remaining tabs (Server, Packages, Performance, Language, Other,
Translation, and Format) to configure additional data-source options. The Client
Access Express ODBC driver supplies default values for those options that are not
changed.
Configuring ODBC data-source options topics:
v “Configuring Server options”
v “Configuring Package(s) options” on page 147
v “Configuring Performance options” on page 149
v “Configuring Language options” on page 151
v “Configuring Other options” on page 152
v “Configuring Translation options” on page 153
v “Configuring Format options” on page 154
Note: See “ODBC data-source options” on page 155 for detailed information.
Configuring Server options: The Server options tab allows you to set the default
library or libraries, the level of commitment control, and the maximum threshold
field data size.
Detail:
v To replace the current default library list or to add libraries
within an existing list, specify the complete library names.
v To add a library to the front or end of an existing user library
list, use *USRLIBL to specify the existing user library list.
Add the new libraries in the appropriate order.
Examples:
a. LIB1, LIB2, LIB3 replaces the user library list with the
three specified libraries. The default collection is LIB1.
b. , LIB1, *USRLIBL, LIB2 adds LIB1 to the front of the
user library list, adds LIB2 to the end of the list and
specifies no default collection.
2. Use the Commit mode default value, or select another Commit mode
by using the drop-down list. See Commitment control in the “Server
options” on page 155 topic for more information.
3. Specify the Maximum field data returned by selecting a value from the
drop-down list. This option allows you to specify, in kilobytes, the
threshold field length, thereby optimizing your ODBC connection to the
server. If a field is greater than this value, the information for that field
will be returned on additional calls to the AS/400 system.
Configuring Package(s) options: The Package(s) options tab allows you to enable
and control implementation of extended dynamic support. See also “Configuring
Package(s) options for multiple users” on page 149.
Detail: The following options are set initially when a client ODBC
application is run for the first time after enabling extended
dynamic support. After you set these options for an application,
you may change them at any time by using the Client Access
Express ODBC Setup [32-bit] dialog.
3. Select the Application name for which you want to customize the
package options. Select the down arrow to select from available
applications.
Note: There is a physical size limit to the SQL package: The maximum
number of stored statements might actually be less than 9999,
depending on the complexity of the stored SQL statements. The
physical size of an SQL package cannot exceed approximately
15MB.
7. Select Cache package locally if you want to cache a copy of the SQL
package on your PC. By caching the package locally, you can improve
performance for some applications. See Local package caching in the
“Package options” on page 156 topic for more information.
8. Select a Package usage option to specify how the ODBC driver uses the
package for this application. Select from the following options:
Disable
The ODBC driver will not use a package for this application.
Use The ODBC driver uses an existing package in read-only mode.
Use/Add
The ODBC driver uses an existing package (or creates a
package if one does not exist), adds new statements to the
package, and reuses existing statements.
9. Select an Unusable package option to specify the kind of return code
and message that are returned by the ODBC driver when the package
is not usable:
Error The ODBC driver returns an error when a package is unusable.
Warning
The ODBC driver returns a warning when a package is
unusable.
Ignore The ODBC driver does not return a message when a package is
unusable.
Detail: Be sure to select the same Application name, enter the same
Package library and Package name and select Use under
Package Usage.
Configuring Performance options: The Performance tab allows you to set ODBC
options for the AS/400 database server that can enhance the performance of ODBC
applications.
Detail: In general, this option should be left at the default setting. See
OS/400 library view in the “Performance options” on page 158
topic for more information.
Configuring Language options: The Language tab allows you to set options for the
ODBC driver that affects certain types of sorting and matching that are based on
language.
Configuring Other options: The Other options tab allows you to select the type of
connection, type of object description, and cursor preferences.
Some client applications expect that the cursors they use are
scrollable, but the AS/400 normally treats a cursor with a
rowset size of 1 as non-scrollable. Select Always scrollable to
force all cursors, including those with a rowset size of 1, to be
scrollable. This applies only to SQLExtendedFetch.
Configuring Translation options: The Translation options affect how the AS/400 and
the ODBC driver translate data.
Detail: This option tells the SQL/400 parser how to interpret time data
that is embedded as a constant within an SQL statement.
4. Under the Time option, select the Separator for the hh:mm:ss (*HMS)
time format. This setting is disabled when the time format is anything
but *HMS.
5. Under the Date option, select the Format that the ODBC driver uses to
transfer date data to and from the AS/400 system. The default is
yyyy-mm-dd. Select the down arrow to specify a different setting.
Detail: This option directs the SQL/400 parser how to interpret date
data that is embedded as a constant within an SQL statement.
6. Under the Date option, select the Separator for the following date
formats: mm/dd/yy (*MDY), dd/mm/yy (*DMY), and yy/mm/dd
(*YMD). Select the down arrow to specify a different setting.
Server options:
Default libraries:
A library list has three portions: a system portion, a current library
(designated in the user’s AS/400 profile) and a user portion. The Default
libraries option changes only the user portion.
Specify only the libraries that you need to access. Returning information
for all the AS/400 libraries during a catalog request is unnecessary and
decreases performance.
The first library that is listed is the default collection. If you do not want a
default collection, start the library list with a comma.
When using the *SQL naming convention, the default collection is normally
the only collection that is used to satisfy unqualified table names in an
SQL collection. For example, SELECT * FROM MYTABLE is treated as
SELECT * FROM default_collection.MYTABLE. If no default collection is
specified, the library with the same name as the user profile of the ODBC
job is used for unqualified table names. The request will fail if the library
does not exist.
Package options:
Translation options:
CCSID 65535 translation:
The coded character set identifier (CCSID) is a 2-byte binary (hexadecimal)
identifier. The AS/400 identifies the CCSID in which character data is
coded for each column in a database.
The CCSID of a field determines which conversion table is required for
converting the data, for example, from EBCDIC to ASCII. A CCSID of
65535 often identifies raw data, such as bitmapped graphics.
Selecting Translate CCSID 65535 allows translation of CCSID 65535 data to
the same CCSID of the job. Choosing this option may cause translation of
data that is meant to remain untranslated. The administrator should set
these options for users.
Translation DLL:
This option specifies the translation Dynamic Link Library (DLL) that is
used to translate the data that is passed between the ODBC driver and the
Note: Connection data is not translated. The translation DLL is not loaded
until after the application has connected to the data source.
Translation option:
Translation option specifies a 32-bit integer translation option that is passed
to the translation DLL. The translation DLL determines the meaning of this
option. Refer to the documentation that is provided with the translation
DLL for more information. This parameter is optional.
Express ODBC driver: related information: See the following topics for ODBC
driver-related information:
v “ODBC connection strings and keywords”
v “Using large objects (LOBs) and DataLinks with Express ODBC” on page 216
v “ODBC-to-AS/400 data mapping” on page 163
v “SQL statements, grammar and limitations” on page 164
v “Client Access ODBC error messages” on page 165
v “Sample: ODBC trace” on page 165
v “Enabling table and file updates” on page 182
v “Express ODBC security” on page 185
v “Client Access ODBC APIs implementation issues and requirements” on
page 200
Use connection strings to set defaults for the connection to a data source through
SQLDriverConnect. As an example, the user ID and password for connection to
the data source can be supplied here. They override the user ID and password that
are supplied as part of the Client Access logon procedure, and provide greater or
less authority as required.
ODBC-to-AS/400 data mapping: The table below shows the default data-type
mapping that the Client Access ODBC driver provides. Refer to this table when
you code the SQLBindParameter function. It helps you understand more clearly
how data—particularly numeric and date/time types—are represented in the PC
program and in the database.
Table 2. ODBC-to-AS/400 data mapping
SQL data type DB2 UDB for AS/400 SQL data type
SQL_BINARY CHAR FOR BIT DATA
SQL_CHAR CHAR or DATALINK or UDT
SQL_DATE DATE
SQL_DECIMAL PACKED DECIMAL
SQL_DOUBLE FLOAT (8 byte)
SQL_FLOAT FLOAT (8 byte)
SQL_INTEGER LARGE INTEGER
SQL_LONGVARBINARY CHAR FOR BIT DATA or BLOB
SQL_LONGVARCHAR VARCHAR or CLOB or DBCLOB
SQL_NUMERIC ZONED DECIMAL
SQL_REAL FLOAT (4 byte)
SQL_SMALLINT SMALL INTEGER
SQL_TIME TIME
Note: All conversions in the Microsoft ODBC Software Development Kit and
Programmer’s Reference, Version 3.0 ISBN 1-57231-516-4. are supported for
these ODBC SQL data types.
For more information:
See the DB2 Universal Database for AS/400 topic in the Information
Center.
SQL statements, grammar and limitations: The Client Access Express ODBC Driver
supports core SQL grammar, as well as SQL statements that are supported by
AS/400 SQL and most extended-grammar SQL statements.
The same limitations that exist with DB2 Universal Database for AS/400 are
imposed on the ODBC SQL grammar. The SQL Reference book contains additional
information. To view an HTML online version of the book, or print a PDF version,
link to the DB2 Universal Database for AS/400 books online topic in the AS/400
Information Center.
SQL statements, grammar and limitations topics:
v “Unsupported ODBC SQL grammar”
v “Implementation of the ODBC SQL grammar”
Unsupported ODBC SQL grammar: The Client Access Express ODBC Driver
supports SQL statements and clauses in both the core and extended ODBC
grammars, except for the following statements:
Integrity Enhancement Facility (IEF):
The CASCADE and RESTRICT clauses in the DROP TABLE, DROP VIEW,
and REVOKE statements are not supported.
The DEFAULT, REFERENCES CHECK, UNIQUE, PRIMARY KEY and
FOREIGN KEY clauses in the CREATE TABLE statement are not
supported. The REFERENCES clause in the GRANT statement is not
supported.
Implementation of the ODBC SQL grammar: Whenever the table name is not
qualified, the Client Access ODBC Driver uses the library list. Name the default
library either by specifying the DBQ parameter if SQLDriverConnect API or
SQLBrowseConnect APIs are called, or by setting it in the Client Access ODBC
Driver Setup dialog box.
Libraries can be added to the current server job’s library list, or they can replace
the list entirely. To replace the list, specify a list of library names. To add to the
existing list, add a special entry, *USRLIBL, to the list of libraries. All libraries
listed before *USRLIBL are added to the front of the library list. All libraries listed
after *USRLIBL are added to the end of the list. The first library in the list is used
as the default collection. If you do not want a default collection, start the list with
a comma.
For example:
replaces the server job’s library list with the three libraries specified. The default
collection is LIB1. However,
DefaultLibraries=LIB1, *USRLIBL, LIB2 ;
adds LIB1 to the front of the server job’s library list and add LIB2 to the end of the
list. The default collection is LIB1.
Client Access ODBC error messages: When an error occurs, the Client Access ODBC
Driver returns the SQLSTATE (an ODBC error code) and an error message. The
driver obtains this information both from errors that are detected by the driver and
from errors that are returned by the AS/400 DBMS.
For errors that occur in the data source, the Client Access ODBC Driver maps the
returned native error to the appropriate SQLSTATE. When both the Client Access
ODBC Driver and the Microsoft Driver Manager detect an error, they generate the
appropriate SQLSTATE. The Client Access Express ODBC Driver returns an error
message based on the message returned by the AS/400 DBMS.
For errors that occur in the Client Access 400® ODBC Driver or the Microsoft
Driver Manager, the Client Access ODBC Driver returns an error message based on
the text associated with the SQLSTATE.
The prefixes in brackets ([]) identify the source of the error. The following table
shows the values of these prefixes returned by the Client Access ODBC Driver.
When the error occurs in the data source, the [vendor] and [ODBC-component]
prefixes identify the vendor and name of the ODBC component that received the
error from the data source.
Table 3. ODBC Error Messages
Error Source Prefix Value
Driver Manager [vendor] [Microsoft]
[ODBC-component] [ODBC Driver Manager]
[data-source] [N/A]
Client Access [vendor] [IBM]
Express ODBC [ODBC-component] [Client Access Express ODBC Driver (32-bit)]
Driver (32–bit) [data-source] N/A
AS/400 DBMS1 [vendor] [IBM]
[ODBC-component] [Client Access Express ODBC Driver (32-bit)]
[data-source] [DB2 UDB for AS/400][Host message:]
1
See “Communication errors” on page 283 for detailed information.
Sample: ODBC trace: The following is the SQL.LOG (trace) of an ODBC connection
to an AS/400 data source. This record was generated by using the tracing facility
of Microsoft ODBC Administrator. It records a sample ODBC conversation from
Microsoft Query. See “Collecting an SQL.LOG (ODBC Trace)” on page 288 for more
information.
***SQLSetConnectOption is used to attempt to set a login timeout value. The Client Access Express
ODBC driver does not support this, but it will be noticed that an error is not returned on this until
SQLDriverConnect is called.***
***SQLDriverConnectW is used to connect to the Client Access Express ODBC driver. The return code is
SQL_SUCCESS_WITH_INFO because the driver connected successfully but does not support the
SQLSetConnectOption for SQL_LOGIN_TIMEOUT.***
***SQLTablesW is used to retrieve information on the list of catalog names stored in a specific da
***SQLColumns is used to retrieve the list of column names for a specified table.***
***SQLSpecialColumnsW is used to retrieve the columns that uniquely identify each row in the table
***SQLSetStmtOption is used in attempting to enable asynchronous support. However, the Client Acc
driver does not support this. This is why SQL_ERROR is returned.***
DIAG [S1C00] [IBM][Client Access Express ODBC Driver (32-bit)]Driver not capable. (0)
DIAG [S1C00] [IBM][Client Access Express ODBC Driver (32-bit)]Driver not capable. (0)
***SQLColAttributes is used to retrieve additional information about a column in the result set.***
Enabling table and file updates: ODBC enables for queries and reports, but
eventually you may need to update some of your data. Because the Client Access
Express ODBC driver is a read/write driver, table updates are possible. All that is
required is some setup work.
Enabling table and file updates topics:
v “Table update requirements”
v “PC application locking” on page 183
v “Creating a unique index” on page 184
v “Authorization for physical files” on page 184
v “Troubleshooting table update errors” on page 185
Table update requirements: Most PC applications require that a table have a unique
key to be updatable. It is important to note that it is not a requirement of the
Client Access ODBC driver, of the ODBC API, or of the AS/400 database. It is a
requirement of the PC applications. Many of these PC applications use a
keyset-driven cursor model to allow the application fast, easy, random access to all
rows in the table.
See “Types of unique key tables, files, and indexes” on page 183 for more
information.
The application queries the file once for data, and queries it a second time to
determine if there is a unique key over the table. If a unique key is identified, the
application opens the dataset in read/write mode. If it is not, the application opens
the dataset in read-only mode. The PC then reads the unique keys for ALL
RECORDS and stores the information on the PC. All further updates/deletes/reads
are done using the local copy of the keys.
An example of a database engine that uses the keyset-driven cursor model is the
Microsoft Jet database engine used by both MS Access and Microsoft Visual Basic.
Jet issues the ODBC API call SQLStatistics to return any unique keys that are
available for the table. If one or more unique index is available, Jet selects the first
index that is returned to be the primary key, and allows the table to be updatable.
Microsoft documents this along with the Jet Engine requirement for a unique key
in the Microsoft White Paper: Jet Database Engine 3.0: ODBC Connectivity. Other
types of PC database engines may have different criteria for selecting an index to
use.
Note: DB2 Universal Database (UDB) for AS/400 treats logical files similar to an
SQL view. At this time, the OS/400 database server does not return
information to a request for unique key, or return catalog information on the
constraints that a logical inherits from a physical file. Because no unique key
information is reported to the client, most applications do not consider a
logical file to be updatable. This capability is under consideration for future
releases. Newer versions of MS Access let you work around this.
If the DDS description does not contain the keyword ″unique,″ then it is not a
unique key. In SQL terms, a DDS key is similar to an index.
00070A CUST
00080A NAME
00090A ADDR
00100A K CUST
PC application locking: Most PC applications read data from the file that the user
has specified for read-only data. The application then queries the database to
determine if the file has a unique index defined over it. If there is a unique index
on the table, the application allows data editing because optimistic locking is
allowed. To lock a record with Optimistic locking so that it can be edited or
deleted later, the original record has to be refound in the table and then locked for
update.
If there was not a unique index on this table, this type of locking would not work.
It would not be able to query the database and update a single record.
Data versioning:
The update that you attempted would fail with a ″Record not found″ message. You
would not be informed that another user had updated that record. You would not
be prompted to display the new version of the record as it was updated by the
other user. You would be required to reread in the table to discover what might
have changed to cause the error.
Creating a unique index: To create a unique index on the AS/400, use interactive
SQL or the RUNSQLSTM command.
To use interactive SQL:
1. Type in STRSQL to start interactive SQL.
2. Type in the command
CREATE UNIQUE INDEX indexname ON libraryname/tablename
(fieldname).
To use the RUNSQLSTM command:
1. Create a source file.
2. Create a member that contains the command
CREATE UNIQUE INDEX indexname
ON libraryname/tablename (fieldname)
3. Run the RUNSQLSTM command against the source file and member
that you defined in the previous steps.
Once either of these methods is used to create a unique index, or if you create a
logical file with a unique key, you will be able to see and use the index from any
ODBC application. Once this index is visible to ODBC applications, optimistic
locking can occur, and your data can be edited.
Authorization for physical files: When querying data files, the authorization to a file
is checked only if the file is being directly used. Here is an example to illustrate:
You have a physical file that has authority of public *use. You have a logical over
that physical that has public *exclude. A user with public authority could
successfully run a query defined on the physical file since it requires authority to
the physical file only, even though all logicals would be reviewed to return the
results of the query. However, a user with public authority would get a not
authorized error on a query defined on the logical file described above.
In addition to querying data files, ODBC applications also query the DB2 Universal
Database (UDB) for AS/400 catalog tables and views for information on the tables
and columns available on the AS/400 system. Applications issue the ODBC API
calls SQLTables and SQLColumns to return listings of tables and columns on the
AS/400 system. For both calls, DB2 UDB for AS/400 returns information on
physicals files that the user has authority to, along with information on any
logicals or views over the physical. Here again, the user does not need to have
specific authority to these logicals, only to the physical files they are based on.
The exception to this is the ODBC API SQLStatistics. This call returns information
on the indexes or logicals available for a specific table. Applications use the
SQLStatistics call to determine whether there are unique indexes available for a
table to be updatable. The ODBC host code returns this information from the
OS/400 file descriptions. Here, the user does need to have authority to the indexes
or logicals over the file. If the user is not authorized, DB2 UDB for AS/400 issues a
CPF2207 Not authorized to use object xxxxLF in library xxxx.
Determine if there are any logical files created over the physical by using the
AS/400 DSPDBR command and by checking under Files Dependent on
Specified File. Then do a DSPFD on each of these files to determine if any
contain a unique key.
ODBC retrieves this information from the AS/400 system catalog tables.
QSYS/QADBXREF stores the unique keyed and number of key fields
information. QSYS/QADBXFLD stores additional information on each key
field. QSYS/QADBFCST has unique and primary key information for SQL
Tables only.
2. Use the MS SDK ODBC Administrator’s tracing facility to trace your query, and
to view information about indexes that are returned by the ODBC API
SQLStatistics call.
3. Verify that the user is trying to update the physical file and not a logical file
over it.
4. Move the file that you are unable to update to a separate library along with the
unique index if it is a separate file. Then set this test library as your default
library in the ODBC datasource. This allows you to isolate the file from other
logicals that may be over the file, for testing purposes.
Object-level security: Object-level security allows you to define who can use an
object and how that object can be used. Object-level security cannot be
circumvented. OS/400 checks authority every time that the object is accessed.
Here’s an example of the object security on a file:
Object ----------Object-----------
User Group Authority Opr Mgt Exist Alter Ref
ADMIN1 *ALL X X X X X
*PUBLIC *USE X
Object ---------------Data---------------
User Authority Read Add Update Delete Execute
ADMIN1 *ALL X X X X X
*PUBLIC *USE X X
The SQL Reference book contains additional information. iew an HTML online
version of the book, or print a PDF version, from the DB2 Universal Database for
AS/400 books online AS/400 Information Center topic.
ODBC program security strategies: Consider the following ODBC program security
strategies:
Restricting program access to the database
System administrators often need to limit access to particular files, to a
certain program, or to set of programs. A ″green-screen″ programmer
would carry out restrictions by using program-adopted authority. A similar
method can be used with ODBC.
Stored procedures allow ODBC programmers to implement
program-adopted authority. The programmer may not want users to be
able to manipulate database files by using desktop applications such as
Microsoft Access or Lotus 1-2-3®. Instead, the programmer may want to
limit database updates to only the programmer’s application. To implement
this, user access to the database must be restricted with object-level
Other information resources for ODBC security: In-depth security reviews and
assistance to implement the strategies above is available through IBM Consultline
(1-800-274-0015). Please review the following IBM books for in-depth information
on specific topics:
v Client Access Express Host Servers
v OS/400 Security - Reference
v OS/400 Backup and Recovery
The DB2 Universal Database for AS/400 books online topic in the AS/400
Information Center contains additional database books that cover ODBC security,
including Distributed Data Management and Database Programming. Link to the topic
to view HTML online versions, or to print PDF versions, of the books.
Note: Scrollable cursors enable the ability to scroll forward and backward in a
result set. For example, with scrollable cursors, if you fetch two rows of
data, you can view row 1, row 2, and then scroll back to view row 1
again. With a forward-only cursor, if you viewed row 1, and then viewed
row 2, you could not scroll back to view row 1: you would have to
perform another data fetch.
The database is capable of supporting the extended functionality (for example, DB2
for OS/400). However, the ODBC driver should support the highest level (current
level 2) of functionality.
ODBC interface topics:
v “ODBC requirements”
v “ODBC components”
v “ODBC APIs: General concepts” on page 192
v “ODBC API return codes” on page 193
The ODBC interface defines a set of calls that are used for each of these application
steps. For example, SQLAllocEnv allocates the ODBC environment. Each of these
For additional information, see “Coding directly to ODBC APIs” on page 216.
ODBC APIs: General concepts: The following general concepts apply to ODBC
APIs:
Environments:
The environment in which Windows makes available some memory for
ODBC to monitor its run-time information. There only is one environment
per ODBC application.
Connections:
Within the environment there can be multiple connections, each to a data
source. The connections may be to different physical systems, to the same
system, or any combination of both.
Statements:
Within each connection, multiple statements can be run, in some cases in
parallel (if the database and driver supports asynchronous runs of
statements).
Handles:
Handles are identifiers for storage areas that are allocated by the Driver
Manager or individual drivers. The three types of handles are:
Environment handle:
Global information, that includes other handles. One handle is
allowed per application.
Connection handle:
Information about connection to a data source. Multiple connection
handles are allowed per environment.
Statement handle:
Information about a particular SQL statement. Multiple statement
handles are allowed per connection.
ODBC API return codes: Every ODBC API function returns a value of type
SQLRETURN (a short integer). There are seven possible return codes, and
associated with each is a manifest constant. The following list provides an
explanation of each particular code. Some return codes can be interpreted as an
error on the function call. Others indicate success. Still others indicate that more
information is needed or pending.
A particular function may not return all possible codes. See the Microsoft ODBC 3.0
Software Development Kit and Programmer’s Reference, Version 3.0 ISBN 1-57231-516-4.
for possible values, and for the precise interpretation for that function.
Pay close attention to return codes in your program, particularly those that are
associated with the processing of SQL statements processing and with data source
data access. In many instances the return code is the only reliable way of
determining the success of a function.
SQL_SUCCESS
Function has completed successfully; no additional information available.
SQL_SUCCESS_WITH_INFO
Function completed successfully; possibly with a nonfatal error. The
application can call “SQLError” on page 198 to retrieve additional
information.
SQL_NO_DATA_FOUND
All rows from the result set have been fetched.
SQL_ERROR
Function failed. The application can call “SQLError” on page 198 to retrieve
error information.
SQL_INVALID_HANDLE
Function failed due to an unusable environment, connection, or statement
handle. Programming error.
SQL_NEED_DATA
The driver is asking the application to send parameter data values.
sqlext.h
sqltypes.h
sqlucode.h
Express Toolkit:
The Client Access Express Toolkit provides ODBC documentation, and
links to sample programs and related information. To access this
information, open the Express Toolkit and select Database —> ODBC.
Express ODBC APIs listing: Client Access Express ODBC APIs are listed
according to their conformance level:
v “ODBC core conformance APIs”
v “ODBC level-1 conformance APIs” on page 195
v “ODBC level-2 conformance APIs” on page 196
Related topics:
v “Parameter markers” on page 197
v “SQLBindCol and SQLFetch” on page 198
v “SQLFetch and SQLGetData” on page 198
v “SQLError” on page 198
ODBC core conformance APIs: The following ODBC core conformance APIs allow
you to:
v Allocate and free environment, connection, and statement handles
v Connect to data sources and use multiple statements on a connection
v Prepare and run SQL statements, and run SQL statements immediately
v Assign storage for parameters in an SQL statement and result columns
v Retrieve data from a result set and retrieve information about a result set
v Commit or roll back transactions
v Retrieve error information
SQLAllocConnect
Obtains a connection handle.
SQLAllocEnv
Obtains an environment handle. One environment handle is used for one
or more connections.
SQLAllocStmt
Allocates a statement handle.
SQLBindCol
Assigns storage for a result column and specifies the data type. See
“SQLBindCol and SQLFetch” on page 198 for additional information.
SQLBindParameter
Assigns storage for a parameter in an SQL statement. See “Parameter
markers” on page 197 for additional information.
SQLCancel
Cancels an SQL statement.
SQLColAttributes
Describes attributes of a column in the result set.
SQLConnect
Connects to a specific driver by data source name, user ID, and password.
SQLDescribeCol
Describes a column in the result set.
ODBC level-1 conformance APIs: ODBC level-1 conformance APIs allow you to:
v Manage core API functionality
v Connect to data sources with driver-specific dialog boxes
v Set and inquire values of statement and connection options
v Send part or all of a parameter value (useful for long data)
v Retrieve part or all of a result column value (useful for long data)
v Retrieve catalog information (columns, special columns, statistics, and tables)
v Retrieve information about driver and data source capabilities, such as
supported data types, scalar functions, and ODBC functions
SQLColumns
Returns the list of column names in specified tables.
SQLDriverConnect
Connects to a specific driver by connection string or requests that the
ODBC level-2 conformance APIs: ODBC level-2 conformance APIs allow you to:
v Control core and Level-1 API functionality
v Browse connection information and list available data sources
v Send arrays of parameter values. Retrieve arrays of result column values
v Retrieve the number of parameters and describe individual parameters
v Use a scrollable cursor
v Retrieve the original form of an SQL statement
v Retrieve catalog information (privileges, keys, and procedures)
v Call a translation DLL
SQLBrowseConnect
Returns successive levels of connection attributes and valid attribute
Parameter markers: Parameter markers act as place holders for values that are
supplied by the program when you instruct the data source to run the SQL
statement. When you use SQLPrepare, the statement that contains the parameter
markers is passed to the data source to be prepared by the SQL “Optimizer” on
page 214. The Optimizer builds a plan of the statement and holds it for later
reference. Each parameter marker must be associated with a program variable
(strictly, a pointer to a program variable), and SQLBindParameter is used for this
purpose.
After you have prepared the statement and bound the parameters, use
SQLExecute to set to the data source the current values of the associated variables.
Using strings in Visual Basic is not recommended. One way to avoid this problem
is to use byte arrays. Byte arrays are of a fixed size and are not subject to
movement in memory.
Returns
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA_FOUND, SQL_ERROR,
or SQL_INVALID_HANDLE.
v “Using SQLError”
v “Client Access ODBC error messages” on page 165
v “Sample use of SQLError with Visual Basic”
v “Example: Visual Basic general error handler” on page 200
Using SQLError:
v SQLError can be used after any ODBC function call:
v To obtain error information after a function returns
– SQL_ERROR
– SQL_SUCCESS_WITH_INFO
v Functions can post multiple errors
– Keep calling SQLError while it returns SQL_SUCCESS
Sample use of SQLError with Visual Basic: This is a simple example of using
SQLError to determine whether the attempt to insert a new row has been
successful. Note that SQLState of S1000 indicates a General Error. It may not be
the result of a duplicate key value being detected. An alternate method is to query
the data source for the number of rows that were affected by the previous function.
Do this by calling the function SQLRowCount.
Dim result As Integer
Dim SQLState As String * 5
Dim NativeErrorCode As Long
Dim ErrorMsg As String * SQL_MAX_MESSAGE_LENGTH
Dim pcbErrorMsg As Integer
The routine is designed to be called after any ODBC function has failed to return
SQL_SUCCESS. It will retrieve any stacked error information and display it in a
message box.
Client Access ODBC APIs implementation issues and requirements: See the
following table for:
v Descriptions of how the Express ODBC Driver implements specific API functions
v API function requirements and options
Table 4. Implementation of ODBC API functions
Function Description
SQLConnect The data source name is required. Other values are optional.
SQLBrowseConnect Uses all keywords. See “ODBC connection strings and keywords”
on page 159. Only DSN is required. Other values are optional.
SQLDriverConnect Uses all keywords. See “ODBC connection strings and keywords”
on page 159. Only DSN is required. Other values are optional.
SQLSpecialColumns If called with the SQL_BEST_ROWID option, returns all indexed
columns of that table.
Related topic:
“ODBC API restrictions and unsupported functions”
ODBC API restrictions and unsupported functions: The way in which some functions
are implemented in the Client Access Express ODBC Driver does not meet the
Typically, response time is the critical performance issue for users of a system.
Utilization frequently is important to the administrators of a system. Maximum
throughput is indicative of the performance bottleneck, and may not be a concern.
While all of these characteristics are interrelated, the following summarizes system
performance:
v Every computing system has a bottleneck that governs performance:
throughput.
v When system utilization increases, response time degrades.
In many systems, capacity is considerable, and is not an issue with users. In others,
it is the primary performance concern. Response time is critical. One of the most
important questions for administrators is: How far can the system be degraded while
users are added, or utilization is increased, before users begin objecting?
Instead, when a client requests processing time and data from the server, it
transmits the request on the network. The request travels to the server and waits in
a queue until the server is able to process it. The performance characteristics of this
type of architecture degrade exponentially as the number of requests increase. In
other words, response times increase gradually as more requests are made, but
then increase dramatically at some point, which is known as the ″knee of the
The performance architecture of the Client Access Express ODBC driver: For the Client
Access Express ODBC driver, all of the internal data flows between the client and
the server are chained together, and transmit only when needed. This reduces
server utilization because communications-layer resources are allocated only once.
Response times improve correspondingly.
These types of enhancements are transparent to the user. But other enhancements
are externalized as configuration entries in the ODBC registry.
For additional information:
v “Setting up the Express ODBC driver” on page 138
v “ODBC registry settings”
ODBC registry settings: When you edit the configuration parameters in the ODBC
registry, the Client Access Express ODBC driver also is configured. This registry
file is in the directory where Windows is installed on your system. Do not edit the
registry directly. Instead, tune Client Access Express ODBC performance through
the Client Access Express ODBC Setup (32-bit) dialog.
For a description of these parameters and their allowed values, see “Setting up the
Express ODBC driver” on page 138. This topic explains the performance
implications of some of the more important parameters.
ODBC registry settings topics:
v “Selecting a stringent level of commitment control” on page 204
v “Fine-tuning record blocking” on page 204
v “Using Extended Dynamic SQL” on page 205
Many third-party tools use this approach, which is why they often require a
unique index to be defined for updatable tables. This allows the record update to
be made by fully qualifying the entire record contents. Consider the following
example:
UPDATE table SET C1=new_val1, C2=new_val2, C2=new_val3
WHERE C1=old_val1 AND C2=old_val2 AND C3=old_val3
This statement would guarantee that the desired row is accurately updated, but
only if the table contained only three columns, and each row was unique. A
better-performing alternative would be:
UPDATE table SET C1=new_val1, C2=new_val2, C3=CURRENT_TIMESTAMP
WHERE C3=old_timestamp
This only works, however, if the table has a timestamp column that holds
information on when the record was last updated. Set the new value for this
column to CURRENT_TIMESTAMP to guarantee row uniqueness.
Note: This technique does not work with any object model that uses automation
data types (for example, Visual Basic, Delphi, scripting languages). The
variant DATE data type has a timestamp precision of approximately one
millisecond. The AS/400 timestamp is either truncated or rounded off, and
the WHERE clause fails.
If commitment control is required, use the lowest level of record locking possible.
For example, use *CHG: over *CS when possible, and never use *ALL when *CS
provides what you require.
For more information on commitment control:
See the DB2 Universal Database for AS/400 and DB2 Universal Database
for AS/400 books online topics under the Database and File Systems
heading in the AS/400 Information Center.
Using Extended Dynamic SQL: Traditional SQL interfaces used an embedded SQL
approach. SQL statements were placed directly in an application’s source code,
along with high-level language statements written in C, COBOL, RPG, and other
programming languages. The source code then was precompiled, which translated
the SQL statements into code that the subsequent compile step could process. This
method sometimes was referred to as static SQL. One performance advantage to
this approach is that SQL statements were optimized in advance, rather than at
runtime while the user was waiting.
ODBC, however, is a call level interface (CLI) that uses a different approach.
Using a CLI, SQL statements are passed to the database management system
(DBMS) within a parameter of a runtime API. Because the text of the SQL
statement is never known until runtime, the optimization step must be performed
each time an SQL statement is run. This approach commonly is referred to as
dynamic SQL.
There are many more tools available than are on this list, and every tool in the
marketplace has its own strengths, weaknesses, and performance characteristics.
But most have one thing in common: support for ODBC database servers.
However, because ODBC serves as a common denominator for various database
management systems, and because there are subtle differences from one ODBC
driver to the next, many tool providers write to the more common ODBC and SQL
interfaces. By doing this, they avoid taking advantage of a unique characteristic of
a particular database server. This may ease programming efforts, but it often
degrades overall performance.
Examples of ODBC performance-degrading tools:
“Examples: Common tool behaviors that degrade ODBC performance”
Examples: Common tool behaviors that degrade ODBC performance: The following
examples demonstrate performance problems that are associated with writing SQL
and ODBC calls that do NOT take advantage of a unique feature of a particular
ODBC driver or the server database management system.
To view the examples:
v “Example: Query tool A”
v “Example: Query tool B” on page 207
v “Example: Query tool C” on page 207
Example: Query tool A: Query Tool A makes the following ODBC calls to process
SELECT statements:
SqlExecDirect("SELECT * FROM table_name")
WHILE there_are_rows_to_fetch DO
SqlFetch()
FOR every_column DO
SqlGetData( COLn )
END FOR
...process the data
END WHILE
This tool does not make use of ODBC bound columns, which can help
performance. A faster way to process this is as follows:
SqlExecDirect("SELECT * FROM table_name")
FOR every_column DO
SqlBindColumn( COLn )
END FOR
WHILE there_are_rows_to_fetch DO
SqlFetch()
...process the data
END WHILE
If a table contained one column, there would be little difference between the two
approaches. But for a table with a 100 columns, you end up with 100 times as
many ODBC calls in the first example, for every row fetched. You also can optimize
the second scenario because the target data types specified by the tool will not
change from one FETCH to the next, like they could change with each SqlGetData
call.
SqlAllocStmt()
SqlExecDirect("UPDATE...SET COLn='literal'...WHERE COLn='oldval'...")
SqlFreeStmt( SQL_DROP )
END LOOP
The first thing to note is that the tool performs a statement allocation-and-drop for
every row. Only one allocate statement is needed, and the free-statement call could
be changed to SqlFreeStmt( SQL_CLOSE ) after each SqlExecDirect. This change
would save the overhead of creating and destroying a statement handle for every
operation. Another performance concern is the use of SQL with literals instead of
with parameter markers. The SqlExecDirect() call causes an SqlPrepare and
SqlExecute every time. Because the UPDATE uses only literals, ExtendedDynamic
will not help because the statement is discarded after the SQL_DROP. A faster way
to perform this operation would be as follows:
SqlAllocStmt()
SqlPrepare("UPDATE...SET COL1=?...WHERE COL1=?...")
SqlBindParameter( new_column_buffers )
SqlBindParameter( old_column_buffers )
FOR every_row_updated DO
END LOOP
These sets of ODBC calls will outperform the original set by a large factor when
you are using the Client Access ODBC driver. The server CPU utilization will
decrease to 10 percent of what it was, which pushes the scaling threshold out a lot
farther.
That you did not have to write this complex query is advantageous, but beware
that your tool may not actually process this statement. For example, one tool might
pass this statement directly to the ODBC driver, while another splits up the query
into many individual queries, and processes the results at the client, like this:
SQLExecDirect("SELECT * FROM A")
SQLFetch() all rows from A
SQLExecDirect("SELECT * FROM B")
SQLFetch() all rows from B
This approach can lead to excessive amounts of data being passed to the client,
which will adversely affect performance. In one real-world example, a programmer
thought that a 10-way inner/outer join was being passed to ODBC, with four rows
being returned. What actually was passed, however, was 10 simple SELECT
statements and all the FETCHes associated with them. The net result of four rows
was achieved only after 81,000 ODBC calls were made by the tool. The
programmer initially thought that ODBC was responsible for the slow
performance, until the ODBC trace was revealed.
SQL performance: Good application design includes the efficient use of machine
resources. To run in a manner that is acceptable to the end user, an application
program must be efficient in operation, and must run with adequate response time.
“SQL performance general considerations”
Shows you when to consider performance, what resources to optimize, and
how to design for performance.
“Database design” on page 209
Describes general AS/400 database design and how it affects SQL
performance.
“Optimizer” on page 214
Optimizer is the facility that decides how to gather data that should be
returned to the program. This topic covers some of the techniques and
rules that are used by Optimizer.
The primary goal in using SQL is to obtain the correct results for your database
request, and in a timely manner.
Before you start designing for performance, review the following considerations:
When to consider performance:
v Database with over 10,000 rows - Performance impact: noticeable
v Database with over 100,000 rows - Performance impact: concern
v When repetitively using complex queries
v When using multiple work stations with high transaction rates
What resource to optimize:
v I/O usage
v CPU usage
v Effective usage of indexes
v OPEN/CLOSE performance
v Concurrency (COMMIT)
How to design for performance:
Database design:
– Table structure
– Indexes
The SQL Reference book contains additional information. You can view an HTML
online version of the book, or print a PDF version, from the DB2 Universal
Database for AS/400 books online AS/400 Information Center topic.
The following graphic illustrates that the proportion of redundant data to the
number of tables affects performance:
For example:
The set level (or mass operation) nature of SQL significantly lessens the danger of
a certain redundant data form. For example, the ability to update a set of rows
with a single SQL statement greatly reduces this risk. In the following example, the
job title Engineer must be changed to Technician for all rows that match this
condition.
Example: Use SQL to update JOBTITLE:
UPDATE EMPLOYEE
SET JOBTITLE = "Technician"
WHERE JOBTITLE = "Engineer"
Table size: The size of the tables that your application program accesses has a
significant impact on the performance of the application program. Consider the
following:
Large row length:
For sequenially accessed tables that have a large row length because of
many columns (100 or more), you may improve performance by dividing
the tables into several smaller ones, or by creating a view. This assumes
that your application is not accessing all of the columns. The main reason
for the better performance is that I/O may be reduced because you will get
more rows per page. Splitting the table will affect applications that access
all of the columns because they will incur the overhead of joining the table
back together again. You must decide where to split the table based on the
nature of the application and frequency of access to various columns.
Large number of rows:
If a table has a large number of rows, construct your SQL statements so
that the “Optimizer” on page 214 uses an index to access the table. The use
of indexes is very important for achieving the best possible performance.
Using indexes: The use of indexes can improve significantly the performance of
your applications. This is because the “Optimizer” on page 214 uses them for
performance optimization. Indexes are created in five different ways:
Manage the number of indexes to minimize the extra system cost of maintaining
the indexes during update operations. Below are general rules for particular types
of tables:
Primarily read-only tables:
Create indexes over columns as needed. Consider creating an index only if
a table is greater than approximately 1,000 rows or is going to be used
with ORDER BY, GROUP BY, or join processing. Index maintenance could
be costlier than occasionally scanning the entire table.
Primarily read-only table, with low update rate:
Create indexes over columns as needed. Avoid building indexes over
columns that are updated frequently. INSERT, UPDATE, and DELETE will
cause maintenance to all indexes related to the table.
High update-rate tables:
Avoid creating many indexes. An example of a table that has a high
update rate is a logging or a history table.
Matching attributes of join fields: Columns in tables that are joined should have
identical attributes: the same column length, same data type (character, numeric),
and so forth. Nonidentical attributes result in temporary indexes being built, even
though indexes over corresponding columns may exist.
In the following example, join will build a temporary index and ignore an existing
one:
SELECT EMPNO, LASTNAME, DEPTNAME
FROM TEMPL, TDEPT
WHERE TEMPL.DEPTNO = TDEPT.DEPTNO
Cost estimation: At runtime, the Optimizer chooses an optimal access method for
the query by calculating an implementation cost based on the current state of the
database. The Optimizer models the access cost of each of the following:
v Reading rows directly from the table (dataspace scan processing)
v Reading rows through an access path (using either key selection or key
positioning)
v Creating an access path directly from the dataspace
v Creating an access path from an existing access path (index-from-index)
v Using the query sort routine (if conditions are satisfied)
Note: This is the default if you do not use OPTIMIZE FOR n ROWS.
The time limit factor controls how much time is spent choosing an implementation.
It is based on how much time has been spent and the current best implementation
cost found. Dynamic SQL queries are subject to Optimizer time restrictions. Static
SQL queries optimization time is not limited.
For small tables, the query Optimizer spends little time in query optimization. For
large tables, the query Optimizer considers more indexes. Generally, Optimizer
considers five or six indexes (for each table of a join) before running out of
optimization time.
Coding directly to ODBC APIs: Many PC applications make ODBC calls that
allow the user to seamlessly access data on different platforms. Before you begin
developing your own application with ODBC APIs, you should understand how
an ODBC application connects to and exchanges information with a database
server.
Example: Using the BLOB data type: The following is a partial C program that uses
the BLOB data type:
unsigned int blob_len = 20, char_len = 10;
strcpy(szCol1,"1234567890");
strcpy(szCol2, "abcdefghijklmnopqrst");
cbCol2 = 20;
rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, blob_len, 0,
}
// Execute the 'Insert' statement to put a row of data into the table
rc = SQLExecute(hstmt);
// At this point szRecCol1 should contain the CHAR data and szRecCol2 should contain the BLOB data th
Preparing the statement is performed at the server. The SQL statements are
compiled and the access plans are built. This allows the statements to be executed
much more efficiently. When compared to using dynamic SQL to execute the
statements, the result is much closer to static SQL. When the database server
prepares the statements, it saves some of them in a special AS/400 object called a
package (*SQLPKG). This approach is called Extended Dynamic SQL. Packages
are created automatically by the driver; an option is provided to turn off Package
Support. This is covered in “The performance architecture of the Client Access
Express ODBC driver” on page 203.
SQLPrepare
Prepares an SQL statement for execution:
HSTMT s_insert;
SQLAllocStmt(hdbc,&s_insert);
UCHAR sqlstr[ ] "INSERT INTO NAMEID VALUES (?,?)";
SQLPrepare(s_insert,sqlstr,SQL_NTS);
SQLBindParameter(s_insert,1,SQL_PARAM_INPUT,
SQL_C_CHAR,SQL_CHAR,
4,0,0,0&,4,cbvalue)
SQLBindParameter(s_insert,2,SQL_PARAM_INPUT,
SQL_C_CHAR,SQL_CHAR,
4,0,0,0&,4,cbvalue)
SQLExecute(s_insert)
SQLParamData(s_insert, &token) ' Param 1
SQLPutData(s_insert, Byval s_parm(1), Len (s_parm(1)))
SQLParamData(s_insert, &token) ' Param 2
SQLPutData(s_insert, Byval s_parm(2), Len (s_parm(2)))
SQLParamData(s_insert, &token) '* No more params, it will execute
Notes:
1. These two statements operate together to to supply unbound
parameter values when the statement is executed.
2. Each call to SQLParamData moves the internal pointer to the next
parameter for SQLPutData to supply data to. After the last
parameter is filled, SQLParamData must be called again for the
statement to be executed.
3. If SQLPutData supplies data for parameter markers, the parameter
must be bound. Use the cbValue parameter set to a variable whose
value is SQL_DATA_AT_EXEC when the statement is executed.
Converting strings and arrays of byte: The following Visual Basic functions can assist
in converting strings and arrays of byte:
Public Sub Byte2String(InByte() As Byte, OutString As String)
'Convert array of byte to string
OutString = StrConv(InByte(), vbUnicode)
End Sub
Dim I As Integer
Dim SizeOutByte As Integer
SizeOutByte = UBound(OutByte)
SizeInString = Len(InString)
'Verify sizes if desired
String2Byte = True
End Function
Dim S As String
Dim I As Integer
On Error GoTo VBANext
End Sub
Retrieving results: Running some SQL statements returns results to the application
program. Running an SQL SELECT statement returns the selected rows in a result
set. The SQLFetch API then sequentially retrieves the selected rows from the result
set into the application program’s internal storage. In order to work with all of the
rows in a result set, call the SQLFetch API until no more rows are returned.
You also may issue a Select statement where you do not specify what columns you
want returned. For example, Select * from RWM.DBFIL selects all columns. You
may not know what columns or how many columns will be returned.
SQLNumResultCols
Returns the number of columns in a result set.
v A storage buffer that receives the information is passed as a parameter.
SQLNumResultCols(hstmt, &nresultcols);
SQLDescribeCol
Returns the result descriptor for one column in a result set.
v Column name
v Column type
v Column size
This is used with SQLNumResultCols to retrieve information about the
columns returned. Using this approach, as opposed to hard coding the
information in the program, makes for more flexible programs.
Note: If you use this with Visual Basic, it is recommended that you use an
array of Byte data type in place of String data types.
SQLFetch
Each time SQLFetch is called, the driver fetches the next row. Bound
columns are stored in the locations specified. Data for unbound columns
may be retrieved using SQLGetData.
SQLFetch(hstmt);
Visual Basic does not directly support pointers or fixed memory location
ANSI character null-terminated strings. For this reason, it is best to use
another method to bind Character and Binary parameters. One method is
to convert Visual Basic String data types to/from an array of Byte data
types and bind the array of Byte. Another method is to use the
SQLGetData function instead of SQLBindCol.
SQLGetData
Retrieves data for unbound columns after a fetch. In this example, four
columns are returned and SQLGetData is used to move them to the
correct storage location.
SQLFetch(s_Customer1)
SQLGetData(s_Customer1, 1, SQL_C_CHAR,
szName, 16, 0&)
SQLGetData(s_Customer1, 2, SQL_C_FLOAT,
&iDiscount, 0, 0&)
SQLGetData(s_Customer1, 3, SQL_C_CHAR,
szCredit, 2, 0&)
SQLGetData(s_Customer1, 4, SQL_C_FLOAT,
&iTax, 0, 0&)
Calling stored procedures: Use stored procedures to improve the performance and
function of an ODBC application. Any AS/400 program can act as a stored
procedure. AS/400 stored procedures support input, input/output and output
parameters. They also support returning result sets, both single and multiple. The
stored procedure program can return a result set by specifying a cursor to return
(from an embedded SQL statement) or by specifying an array of values. See
“Stored procedures” on page 253 for more information.
Detail: CREATE PROCEDURE should be executed only once for the life of the
stored procedure. DECLARE PROCEDURE also can be used, but this
method has several disadvantages. The Database Programming book
contains additional information about DECLARE PROCEDURE. View
an HTML online version of the book, or print a PDF version, from the
DB2 Universal Database for AS/400 books online topic in the AS/400
Information Center.
2. Prepare the call of the stored procedure by using SQLPrepare.
3. Bind the parameters for input and output parameters.
4. Execute the call to the stored procedure.
5. Retrieve the result set (if one is returned)
ret=SQLBindParameter(s_StoredProc,2,SQL_PARAM_OUTPUT,
SQL_C_CHAR,SQL_VARCHAR, 30,0,
szName, 31, NULL);
strcpy (szCustId,"0000012345");
// Execute the stored procedure
ret=SQLExecute(s_StoredProc);
Calling stored procedures using result sets: Using result sets allows the client
program to easily retrieve large amounts of information returned by the stored
procedure. Instead of retrieving data from a large array of values in an output
parameter, the client can use the same methods that are used to retrieve data from
a SELECT statement. This results in a more SQL-like interface.
This result sets example calls an RPG program and receives the data as a result set
array.
The program on the PC can issue the DROP PROCEDURE and CREATE
PROCEDURE statements before issuing a CALL procedure. After returning from
the call, do an ODBC SQLBindCol to set the variables to return data into. Then do
ODBC SQLFetch to get the data.
The following is a piece of code that shows the ODBC client calls:
#include "sql.h"
#include "sqlext.h"
#include "string.h"
/* declare the variables */
#define ROW_COUNT 20
UCHAR fetch_all[106];
SDWORD cbcol;
static HENV henv;
static HDBC hdbc;
static HSTMT hstmt;
char stmt[4000];
int ii;
RETCODE rc;
/* connect to a data source */
rc = SQLAllocEnv(&henv);
rc = SQLAllocConnect(henv, &hdbc);
rc = SQLConnect(hdbc, "SystemA", SQL_NTS,
"JohnB", SQL_NTS,
"Sesame", SQL_NTS);
The RPG program that is called by the procedure should declare an array to hold
the data. It then can open files and read the data into the array and do whatever
other processing needs to be done. Finally it can return the data in the array by
using the SQL SET RESULT SETS function.
Extended fetch: Extended fetch and block inserts can be used to enhance the
performance of an ODBC application. They allow you to retrieve or insert entire
rows in blocks, rather than individually. This reduces the data flows and line
turnaround between the client and the server.
Extended fetch:
v Returns a block of data (one row set) in the form of an array for each
bound column.
v Scrolls through the result set according to the setting of a scroll type
argument; forward, backward, or by row number.
v Works in conjunction with the SQLSetStmtOption.
ret = SQLAllocStmt(hdbc,&s_Item1);
strcpy(Query,"Select IID, INAME, IPRICE, IDATA from ITEM ");
strcat(Query,"where IID in ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?)");
// For extended fetch
ret=SQLSetStmtOption(s_Item1,SQL_CONCURRRENCY,SQL_CONCUR_READ_ONLY);
ret=SQLSetStmtOption(s_Item1,SQL_CURSOR_TYPE,SQL_CURSOR_FORWARD_ONLY);
ret=SQLSetStmtOption(s_Item1,SQL_ROWSET_SIZE,15);
ret=SQLBindParameter(s_Item1, 1,SQL_PARAM_INPUT,SQL_C_CHAR,
SQL_CHAR,6,0,s_parm[ 1],6,NULL);
ret=SQLBindParameter(s_Item1, 2,SQL_PARAM_INPUT,SQL_C_CHAR,
SQL_CHAR,6,0,s_parm[ 2],6,NULL);
.
.
ret=SQLBindParameter(s_Item1,15,SQL_PARAM_INPUT,SQL_C_CHAR,
SQL_CHAR,6,0,s_parm[15],6,NULL);
The next example is a Visual Basic block insert that is significantly faster than a
″parameterized″ insert.
Dim hStmt As Long
Dim cbNTS(BLKSIZE - 1) As Long 'NTS array
'These will be passed as sz string so size must include room for null
Dim szInit(3, BLKSIZE - 1) As Byte 'Size for field length + null
Dim szStreet(13, BLKSIZE - 1) As Byte 'Size for field length + null
Dim szCity(6, BLKSIZE - 1) As Byte 'Size for field length + null
Dim szState(2, BLKSIZE - 1) As Byte 'Size for field length + null
Dim szZipCod(5, BLKSIZE - 1) As Byte 'Size for field length + null
rc = SQLAllocStmt(ghDbc, hStmt)
If (Not (rc = SQL_SUCCESS Or rc = SQL_SUCCESS_WITH_INFO)) Then GoTo errBlockInsert
rc = SQLPrepare(hStmt, _
"INSERT INTO QCUSTCDT ? ROWS VALUES (?,?,?,?,?,?,?,?,?,?,?)", _
SQL_NTS)
If (Not (rc = SQL_SUCCESS Or rc = SQL_SUCCESS_WITH_INFO)) Then GoTo errBlockInsert
rc = String2Byte2D("DXD", szInit, I)
'Vary the length of the street
S = Mid("1234567890123", 1, ((I Mod 13) + 1))
rc = String2Byte2D(S, szStreet, I)
rc = String2Byte2D("Roches", szCity, I)
rc = String2Byte2D("MN", szState, I)
rc = String2Byte2D("55902", szZipCod, I)
fCdtLmt(I) = I
fChgCod(I) = 1
fBalDue(I) = 2 * I
fCdtDue(I) = I / 2
Next I
rc = SQLExecute(hStmt)
If (rc = SQL_ERROR) Then
S = "Error on Row: " & Str(irow) & Chr(13) & Chr(10)
MsgBox S, , gAppName
GoTo errBlockInsert
End If
'// Only commit every 50000 records?
'//if ((lNumRows % 50000) == 0) {
'rc = SQLTransact(ghEnv, ghDbc, SQL_COMMIT )
'// if (Not (rc = SQL_SUCCESS OR rc = SQL_SUCCESS_WITH_INFO)) then goto
'// errBlockInsert;
'// S="Committed 50,000:"
errBlockInsert:
Call PrintError(ghDbc, hStmt)
rc = SQLTransact(ghEnv, ghDbc, SQL_ROLLBACK)
rc = SQLFreeStmt(hStmt, SQL_DROP)
Screen.MousePointer = 0
StatusBar1.Panels.Item(1).Text = "Block Insert Failed"
Dim I As Integer
Dim SizeOutByte As Integer
Dim SizeInString As Integer
SizeInString = Len(InString)
SizeOutByte = UBound(OutByte, 1)
Ending ODBC functions: The last procedure that must be completed before ending
an ODBC application is to free the resources and memory allocated by the
application. This must be done so that they are available when the application is
run the next time.
SQLFreeStmt
Stops processing associated with a specific statement handle.
SQLFreeStmt(hstmt,option); // option can be SQL_CLOSE
SQL_DROP
SQL_UNBIND
VB 5.0: The compromise between Jet and ODBC APIs: While the database objects are
easy to code, they sometimes can adversely affect performance. Coding to the APIs
and to stored procedures can be a frustrating endeavor.
Fortunately, if you are using Visual Basic 5.0 Enterprise Edition in the Windows 95
environment, there are additional options. These options are a good compromise
between the usability of database objects and the high performance of APIs:
Remote Data Objects (RDO) and Remote Data Control (RDC).
RDO is a thin layer over the ODBC APIs. It provides a simple interface to
advanced ODBC functionality without requiring programming to the API level. It
does not have all of the overhead of the Jet Engine controlled Data Access Object
(DAO) or its SQL optimizer. Yet it maintains a nearly identical programming
interface as the DAOs. If you understand programming to the DAO, then
switching over to the RDO is relatively simple compared to trying to switch over
to API calls.
The RDC is a data control similar to the standard data control. This means that
where ever you might have used a data control, and the Jet engine, you now can
Some of the advanced ODBC functionality the RDO allows is prepared SQL
statements, multiple result sets, and stored procedures. When Jet executes a SQL
statement dynamically it is a two-step process on the AS/400. In the first step, the
AS/400 looks at the statement and determines the best plan to retrieve the data
requested based on the current database schema. In the second step, that plan is
used to actually retrieve the data. Creating that plan can be expensive in terms of
time because the AS/400 has to evaluate many alternatives and determine the best
way to access the data. There is an alternative to forcing the AS/400 to re-create
the access plan every time a SQL statement is run. The CreatePreparedStatement
method of the rdoConnection object allows you to compile a data access plan on
the AS/400 for an SQL statement without executing it. You can even include
parameters in prepared statements, so you can pass new selection criteria every
time you run the select statement.
The following sample Visual Basic code will show how to prepare a SQL statement
with a parameter marker and run it multiple times with different values.
Label A shows where the SQL statement is defined. Notice that the statement does
not include a specific for the CUSTNUM, but has a question mark for the value.
The question mark signifies that this value is a parameter of the prepared
statement. Before you can create a result set with the prepared statement, you must
set the value of any parameters in the statement.
Before you can requery a prepared statement on the AS/400, you have to make
sure that the cursor has been completely processed and closed. Label C shows the
MoreResults method of the rdoResultSet being used to do this. The MoreResults
method queries the database. It determines if there is any more data in the result
set to be processed, or if the result set has been processed completely. Once the
cursor has been fully processed you can reset the parameter value and run the
ReQuery method of the rdoResultSet to open a new result set.
The three forms of INSERT statements that can be executed from ODBC are:
v INSERT with VALUES using constants
v INSERT with VALUES using parameter markers
v blocked INSERT
The INSERT with VALUES using constants statement is the least efficient method
of performing inserts. For each request, a single INSERT statement is sent to the
server where it is prepared, the underlying table is opened, and the record is
written.
Example:
The INSERT with VALUES using parameter markers statement performs better
than the statement that uses constants. This form of the INSERT statement allows
for the statement to be prepared only once and then reused on subsequent
executions of the statement. It also allows the table on the server to remain open,
thus removing the overhead of opening and closing the file for each insert.
Example:
The blocked INSERT statement most efficiently performs inserts into a table when
multiple records can be cached on the client and sent at once. The advantages with
blocked INSERT are:
v The data for multiple rows is sent in one communication request rather than one
request per row.
v The server has an optimized path built into the database support for blocked
INSERT statements.
Example:
INSERT INTO TEST.TABLE1 ? ROWS VALUES (?, ?, ?, ?)
ret=SQLBindParameter(s_Ordlin1, 1,SQL_PARAM_INPUT,SQL_C_LONG,SQL_DECIMAL,
9,0,lOrderNum,0,NULL); //order id
ret=SQLBindParameter(s_Ordlin1, 2,SQL_PARAM_INPUT,SQL_C_SHORT,SQL_DECIMAL,
3,0,uiDistrict,0,NULL); //district id
ret=SQLBindParameter(s_Ordlin1, 3,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,4,0,
szWid[0],5,NULL); //warehouse id
ret=SQLBindParameter(s_Ordlin1, 4,SQL_PARAM_INPUT,SQL_C_SHORT,SQL_DECIMAL,
3,0,&uiOI_ctr,0,NULL); //number of order lines
ret=SQLBindParameter(s_Ordlin1, 5,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,4,0,
szSplyWid,5,NULL); //supplying wrhs id
ret=SQLBindParameter(s_Ordlin1, 6,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,6,0,
szIid,7,NULL); //item id
ret=SQLBindParameter(s_Ordlin1, 7,SQL_PARAM_INPUT,SQL_C_SHORT,SQL_NUMERIC,3,0,
uiOlQty,0,NULL); //quantity
ret=SQLBindParameter(s_Ordlin1, 8,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_NUMERIC,7,2,
szOlAmt,10,NULL); //A float for $ amount or purchase
ret=SQLBindParameter(s_Ordlin1,10,SQL_PARAM_INPUT,SQL_C_SHORT,SQL_NUMERIC,6,0,
uiZero,0,NULL); //Delivery time (set to zero)
ret=SQLBindParameter(s_Ordlin1,11,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,24,0,
szDistrctInfo,25,NULL); //District data waste space
// Use SQLParamOptions to set the row count for the Blocked Insert.
// The row count field is passed in a separate variable.
// Fill the parameters for the Blocked Insert by moving the data
// from the input array to the parameters.
for(ol_ctr=1;ol_ctr<=NewOrd_IO->m_OrderCount;ol_ctr++)
{
lOrderNum[ol_ctr-1] = NewOrd_IO->m_OrderNum;
uiDistrict[ol_ctr-1] = NewOrd_IO->m_District;
sprintf(s_parm[3],"%04u",NewOrd_IO->m_Warehouse);
strcpy(szWid[ol_ctr-1],s_parm[3]);
uiOl_ctr[ol_ctr-1] = ol_ctr;
sprintf(s_parm[5],"%04u",*NewOrd_IO->m_OrdLines
[ol_ctr].Supp_W);
strcpy(szSplyWid[ol_ctr-1], s_parm[5]);
sprintf(s_parm[6],"%06ld",*NewOrd_IO->m_OrdLines
[ol_ctr].Item_ID);
strcpy(szIid[ol_ctr-1], s_parm[6]);
uiOlQty[ol_ctr-1] = *NewOrd_IO->m_OrdLines
[ol_ctr].Qty;
sprintf(s_parm[8],"%+09.2f",*NewOrd_IO->m_OrdLines
[ol_ctr].Amount);
strcpy(szOlAmt[ol_ctr-1], s_parm[8]);
sprintf(s_parm[13],"%s",txttemp[
NewOrd_IO->m_District]);
strcpy(szDistrctInfo[ol_ctr-1], s_parm[13]);
} // end of for loop
To process ODBC SQLTable requests, logical files are built over the system cross
reference file QADBXREF in library QSYS. QADBXREF is a database file for
database-maintained cross-reference information that is part of the dictionary
function for the system.
The following are the actions for SQLTable when Table_Type is set to the
following:
NULL Selects all LOGICAL and PHYSICAL files and SQL TABLES and VIEWS.
TABLE
Selects all PHYSICAL files, and SQL TABLES that are not system files
(cross reference or data dictionary).
VIEW Selects all LOGICAL files and SQL VIEWS that are not system files (cross
reference or data dictionary).
Non-relational files (files with more than one format) are not selected. Also not
selected are indexes, flat files and IDDU-defined files.
The result sets returned by the catalog functions are ordered by table type. In
addition to the TABLE and VIEW types, the AS/400 has the data source-specific
type identifiers of PHYSICAL and LOGICAL files. The PHYSICAL type is handled
as a TABLE, and the LOGICAL type is handled as a VIEW. Though they appear as
type TABLE or VIEW, PHYSICAL and LOGICAL are sorted on their true type. The
sort order is
1. Logical files
2. Physical files
3. Table
4. Views
To process ODBC SQLColumn requests, a logical file is built over the system
cross-reference file QADBIFLD in the QSYS library. This logical file selects all
relational database files except for indexes. QADBIFLD is a database file for
database-maintained cross-reference information that is part of the dictionary
function for the system. Specifically, this includes database file column and field
information.
For additional information:
Appendix G of the SQL Reference book contains additional information.
View an HTML online version of the book, or print a PDF version, from
the DB2 Universal Database for AS/400 books online AS/400 Information
Center topic.
Exit programs: When you specify an exit program, the servers pass the following
two parameters to the exit program before running your request:
v A 1-byte return code value.
v A structure containing information about your request. This structure is different
for each of the exit points.
These two parameters allow the exit program to determine whether your request is
allowed. If the exit program sets the return code to X'F0', the server rejects the
request. If the return code is set to anything else, the server allows the request.
The same program can be used for multiple exit points. The program can
determine what function is being called by looking at the data in the second
parameter structure.
Examples: User exit programs: The following examples do not show all of the
programming considerations or techniques. Review the examples before you begin
application design and coding.
See the Client Access Express Host Servers book for additional user exit program
examples.
v “Example: ILE C/400® user exit program for exit point QIBM_QZDA_INIT (part
1)”
v “Example: ILE C/400 user exit program for exit point QIBM_QZDA_INIT (part
2)” on page 239
v “Example: CL user exit program for exit point QIBM_QZDA_INIT (part 1)” on
page 239
v “Example: CL user exit program for exit point QIBM_QZDA_INIT (part 2)” on
page 240
v “Example: ILE C/400 Program for exit point QIBM_QZDA_SQL1 (part 1)” on
page 240
v “Example: ILE C/400 program for exit point QIBM_QZDA_SQL1 (part 2)” on
page 241
v “Example: ILE C/400 program for exit point QIBM_QZDA_ROI1 (part 1)” on
page 242
v “Example: ILE C/400 Program for exit point QIBM_QZDA_ROI1 (part 2)” on
page 242
v “Example: ILE C/400 program for exit point QIBM_QZDA_ROI1 (part 3)” on
page 243
Example: ILE C/400® user exit program for exit point QIBM_QZDA_INIT (part 1):
/*--------------------------------------------------------------------------
* OS/400 Servers - Sample Exit Program
*
* Exit Point Name : QIBM_QZDA_INIT
*
* Description : The following ILE C/400 program handles
* ODBC security by rejecting requests from
* certain users.
* It can be used as a shell for developing
* exit programs tailored for your
* operating environment.
Example: ILE C/400 user exit program for exit point QIBM_QZDA_INIT (part 2):
/*========================================================================
* Start of mainline executable code
*========================================================================*/
int main (int argc, char *argv[])
{
ZDAI0100_fmt_t input; /* input format record */
Example: CL user exit program for exit point QIBM_QZDA_INIT (part 1):
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* OS/400 Servers - Sample Exit Program */
/* */
/* Exit Point Name : QIBM_QZDA_INIT */
/* */
/* Description : The following Control Language program */
/* handles ODBC security by rejecting */
/* requests from certain users. */
/* It can be used as a shell for developing */
/* exit programs tailored for your */
/* operating environment. */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
PGM PARM(&STATUS &REQUEST)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Parameter declares */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
DCL VAR(&USER) TYPE(*CHAR) LEN(10) /* User profile name calling server*/
DCL VAR(&SRVID) TYPE(*CHAR) LEN(10) /* database server value (*SQL) */
DCL VAR(&FORMAT) TYPE(*CHAR) LEN(8) /* Format name (ZDAI0100) */
DCL VAR(&FUNC) TYPE(*CHAR) LEN(4) /* function being preformed (0) */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Extract the various parameters from the structure */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
CHGVAR VAR(&USER) VALUE(%SST(&REQUEST 1 10))
CHGVAR VAR(&SRVID) VALUE(%SST(&REQUEST 11 10))
CHGVAR VAR(&FORMAT) VALUE(%SST(&REQUEST 21 8))
CHGVAR VAR(&FUNC) VALUE(%SST(&REQUEST 28 4))
View part 2 of the CL user exit program for exit point QIBM_QZDA_INIT
example:
“Example: CL user exit program for exit point QIBM_QZDA_INIT (part 2)”
Example: CL user exit program for exit point QIBM_QZDA_INIT (part 2):
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Begin main program */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
EXIT:
ENDPGM
Example: ILE C/400 Program for exit point QIBM_QZDA_SQL1 (part 1):
/*--------------------------------------------------------------------------
* OS/400 Servers - Sample Exit Program
*
* Exit Point Name : QIBM_QZDA_SQL1
*
* Description : The following ILE C/400 program will
* reject any UPDATE request for user GUEST.
* It can be used as a shell for developing
* exit programs tailored for your
* operating environment.
*
* Input : A 1-byte return code value
* X'F0' server rejects the request
* anything else server allows the request
* Structure containing information about the
* request. The format used by this program
* is ZDAQ0100.
*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* Includes
*------------------------------------------------------------------------*/
#include <string.h> /* string functions */
#include <stdio.h> /* standard IO functions */
Example: ILE C/400 program for exit point QIBM_QZDA_SQL1 (part 2):
/* initialize return variable to indicate ok status */
strncpy(argv[1],"1",1);
/**********************************************************************/
/* Address parameter structure for SQL exit program and move local */
/* parameters into local variables. */
/* (note : this is not necessary to evaluate the arguments passed in). */
/**********************************************************************/
sptr = (_Packed struct zdaq0100 *) argv[2];
/**********************************************************************/
/* check for user GUEST and an UPDATE statement */
/* if found return an error */
/**********************************************************************/
if (! (strncmp(stx.name, "GUEST ", 10)) )
{
for (i=0; i<6; i++)
stx.stmttxt[i] = toupper(stx.stmttxt[i]);
if (! strncmp(stx.stmttxt, "UPDATE", 6) )
/* Force error out of SQL user exit pgm */
strncpy(argv[1], "0", 1);
else;
Example: ILE C/400 program for exit point QIBM_QZDA_ROI1 (part 1):
/*--------------------------------------------------------------------------
* OS/400 Servers - Sample Exit Program
*
* Exit Point Name : QIBM_QZDA_ROI1
*
* Description : The following ILE C/400 program logs all
* requests for catalog functions to the
* ZDALOG file in QGPL.
* It can be used as a shell for developing
* exit programs tailored for your
* operating environment.
*
* Input : A 1-byte return code value
* X'F0' server rejects the request
* anything else server allows the request
* Structure containing information about the
* request. The format used by this program
* is ZDAR0100.
*
* Dependencies : The log file must be created using the
* following command:
* CRTPF FILE(QGPL/ZDALOG) RCDLEN(132)
*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* Includes
*------------------------------------------------------------------------*/
#include <recio.h> /* record IO functions */
#include <string.h> /* string functions */
/*------------------------------------------------------------------------
* User Types
*------------------------------------------------------------------------*/
typedef struct { /* Exit Point QIBM_QZDA_ROI1 format ZDAR0100 */
char User_profile_name[10]; /* Name of user profile calling server*/
char Server_identifier[10]; /* database server value (*RTVOBJINF) */
char Exit_format_name[8]; /* User exit format name (ZDAR0100) */
long Requested_function; /* function being preformed */
char Library_name[20]; /* Name of library */
char Database_name[36]; /* Name of relational database */
char Package_name[20]; /* Name of package */
char File_name[256]; /* Name of file */
char Member_name[20]; /* Name of member */
char Format_name[20]; /* Name of format */
} ZDAR0100_fmt_t;
View part 2 of the ILE C/400 Program for exit point QIBM_QZDA_ROI1
example:
“Example: ILE C/400 Program for exit point QIBM_QZDA_ROI1 (part 2)”
Example: ILE C/400 Program for exit point QIBM_QZDA_ROI1 (part 2):
/*========================================================================
* Start of mainline executable code
*========================================================================*/
int main (int argc, char *argv[])
{
_RFILE *file_ptr; /* pointer to log file */
char output_record[132]; /* output log file record */
ZDAR0100_fmt_t input; /* input format record */
/* set return code to allow the request. */
memcpy( argv[1], "1", 1);
/* open the log file for writing to the end of the file */
Example: ILE C/400 program for exit point QIBM_QZDA_ROI1 (part 3):
case 0X1804: /* Retrieve file information */
sprintf(output_record,
"%10.10s retrieved library %20.20s file %40.40s",
input.User_profile_name, input.Library_name, input.File_name);
break;
case 0X1805: /* Retrieve file member information */
sprintf(output_record,
"%10.10s retrieved library %20.20s member %20.20s file %40.40s",
input.User_profile_name, input.Library_name,
input.Member_name, input.File_name);
break;
case 0X1806: /* Retrieve record format information */
sprintf(output_record,
"%10.10s retrieved library %20.20s format %20.20s file %40.40s",
input.User_profile_name, input.Library_name,
input.Format_name, input.File_name);
break;
case 0X1807: /* Retrieve field information */
sprintf(output_record,
"%10.10s retrieved field info library %20.20s file %40.40s",
input.User_profile_name, input.Library_name, input.File_name);
break;
case 0X1808: /* Retrieve index information */
sprintf(output_record,
"%10.10s retrieved index info library %20.20s file %40.40s",
input.User_profile_name, input.Library_name, input.File_name);
Exit program parameter formats: The exit points for native database and retrieving
object information have two formats that are defined: QIBM_QZDA_SQL1 and
QIBM_QZDA_SQL2. Depending on the type of function that is requested, one of
the formats is used.
The QIBM_QZDA_SQL2 exit point is defined to run an exit point for certain SQL
requests that are received for the database server. This exit point takes precedence
over the QIBM_QZDA_SQL1 exit point. If a program is registered for the
QIBM_QZDA_SQL2 exit point, it will be called, and a program for the
QIBM_QZDA_SQL1 exit point will not be called.
Functions that cause the exit program to be called
v Prepare
v Open
v Execute
v Connect
v Create package
v Clear package
v Delete package
v Stream fetch
v Execute immediate
v Prepare and describe
v Prepare and execute or prepare and open
v Open and fetch
v Execute or open
Parameter fields and their descriptions for exit programs with different exit
points and formats:
v “Parameter fields for exit point QIBM_QZDA_SQL2 format ZDAQ0200”
on page 245
v “Parameter fields for exit point QIBM_QZDA_INIT format ZDAI0100”
on page 246
v “Parameter fields for exit point QIBM_QZDA_NDB1 format ZDAD0100”
on page 247
v “Parameter fields for exit point QIBM_QZDA_NDB1 format ZDAD0200”
on page 248
v “Parameter fields for exit point QIBM_QZDA_SQL1 format ZDAQ0100”
on page 249
Parameter fields for exit point QIBM_QZDA_SQL2 format ZDAQ0200: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_SQL2 with the ZDAQ0200 format:
Table 6. Exit point QIBM_QZDA_SQL2 format ZDAQ0200
Offset
Dec Hex Type Field Description
0 0 CHAR(10) User profile The name of the user profile that
name is calling the server.
10 A CHAR(10) Server identifier The value is *SQLSRV for this exit
point.
20 14 CHAR(8) Format name The user exit format name being
used. For QIBM_QZDA_SQL1,
the format name is ZDAQ0100.
28 1C BINARY(4) Requested The function being performed.
function
This field contains one of the
following:
X’1800’ - Prepare
X’1803’ - Prepare and describe
X’1804’ - Open/describe
X’1805’ - Execute
X’1806’ - Execute immediate
X’1809’ - Connect
X’180C’ - Stream fetch
X’180D’ - Prepare and execute
X’180E’ - Open and fetch
X’180F’ - Create package
X’1810’ - Clear package
X’1811’ - Delete package
X’1812’ - Execute or open
32 20 CHAR(18) Statement name Name of the statement used for
the prepare or execute functions.
50 32 CHAR(18) Cursor name Name of the cursor used for the
open function.
68 44 CHAR(2) Prepare option Option used for the prepare
function.
70 46 CHAR(2) Open attributes Option used for the open
function.
72 48 CHAR(10) Extended Name of the extended dynamic
dynamic package.
package name
82 52 CHAR(10) Package library Name of the library for extended
name dyanmic SQL package.
Parameter fields for exit point QIBM_QZDA_INIT format ZDAI0100: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_INIT using the ZDAI0100 format:
Table 7. Exit point QIBM_QZDA_INIT format ZDAI0100
Offset
Dec Hex Type Field Description
0 0 CHAR(10) User profile The name of the user profile that
name is calling the server.
10 A CHAR(10) Server identifier The value is *SQL for this exit
point.
20 14 CHAR(8) Format name The user exit format name being
used. For QIBM_QZDA_INIT the
format name is ZDAI0100.
28 1C BINARY(4) Requested The function being performed.
function
The only valid value for this exit
point is 0.
Note: This format is defined by member EZDAEP in files H, QRPGSRC, QRPGLESRC,
QCBLSRC and QCBLLESRC in library QSYSINC.
The QIBM_QZDA_NDB1 exit point is defined to run an exit program for native
database requests for the database server. Two formats are defined for this exit
point.
Note: Format ZDAD0200 is used when a request is received to add libraries to the
library list.
Parameter fields for exit point QIBM_QZDA_NDB1 format ZDAD0100: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_NDB1 using the ZDAD0100 format:
Table 8. Exit point QIBM_QZDA_NDB1 format ZDAD0100
Offset
Dec Hex Type Field Description
0 0 CHAR(10) User profile The name of the user profile that
name is calling the server.
10 A CHAR(10) Server identifier For this exit point the value is
*NDB.
20 14 CHAR(8) Format name The user exit format name being
used.
Parameter fields for exit point QIBM_QZDA_NDB1 format ZDAD0200: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_NDB1 by using the ZDAD0200 format:
Table 9. Exit point QIBM_QZDA_NDB1 format ZDAD0200
Offset
Dec Hex Type Field Description
0 0 CHAR(10) User profile The name of the user profile that
name is calling the server.
10 A CHAR(10) Server identifier For this exit point the value is
*NDB.
20 14 CHAR(8) Format name The user exit format name being
used. For the add to library list
function the format name is
ZDAD0200.
28 1C BINARY(4) Requested The function being performed.
function X’180C’ - Add library list
32 20 BINARY(4) Number of The number of libraries (the next
libraries field)
36 24 CHAR(10) Library name The library names for each library
Note: This format is defined by member EZDAEP in files H, QRPGSRC, QRPGLESRC,
QCBLSRC and QCBLLESRC in library QSYSINC.
The QIBM_QZDA_SQL1 exit point is defined to run an exit point for certain SQL
requests that are received for the database server. Only one format is defined for
this exit point.
Functions that use format ZDAD0200:
v Prepare
v Open
Parameter fields for exit point QIBM_QZDA_SQL1 format ZDAQ0100: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_SQL1 using the ZDAQ0100 format.
Table 10. Exit point QIBM_QZDA_SQL1 format ZDAQ0100
Offset
Dec Hex Type Field Description
0 0 CHAR(10) User profile The name of the user profile that
name is calling the server.
10 A CHAR(10) Server identifier For this exit point the value is
*SQLSRV.
20 14 CHAR(8) Format name The user exit format name being
used. For QIBM_QZDA_SQL1 the
format name is ZDAQ0100.
28 1C BINARY(4) Requested The function being performed.
function
This field contains one of the
following:
X’1800’ - Prepare
X’1803’ - Prepare and describe
X’1804’ - Open/Describe
X’1805’ - Execute
X’1806’ - Execute immediate
X’1809’ - Connect
X’180D’ - Prepare and execute
or prepare and open
X’180E’ - Open and fetch
X’180F’ - Create package
X’1810’ - Clear package
X’1811’ - Delete package
X’1812’ - Execute or open
32 20 CHAR(18) Statement name Name of the statement used for
the prepare or execute functions.
50 32 CHAR(18) Cursor name Name of the cursor used for the
open function.
68 44 CHAR(2) Prepare option Option used for the prepare
function.
70 46 CHAR(2) Open attributes Option used for the open
function.
The QIBM_QZDA_ROI1 exit point is defined to run an exit program for the
requests that retrieve information about certain objects for the database server. It is
also used for SQL catalog functions.
Parameter fields for exit point QIBM_QZDA_ROI1 format ZDAR0100: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_ROI1 using the ZDAR0100 format.
Parameter fields for exit point QIBM_QZDA_ROI1 format ZDAR0200: The following
table shows parameter fields and their descriptions for the exit program called at
exit point QIBM_QZDA_ROI1 using the ZDAR0200 format.
Table 12. Exit point QIBM_QZDA_ROI1 format ZDAR0200
Offset
Dec Hex Type Field Description
0 0 CHAR(10) User profile The name of the user profile that
name is calling the server.
10 A CHAR(10) Server identifier For the database server the value
is *RTVOBJINF.
20 14 CHAR(8) Format name The user exit format name being
used. For the following functions,
the format name is ZDAR0200.
28 1C BINARY(4) Requested The function being performed.
function
This field contains one of the
following:
X’1809’ - Retrieve foreign key
information
X’180A’ - Retrieve primary
key information
32 20 CHAR(10) Primary key The name of the library that
table library contains the primary key table
name used when retrieving primary
and foreign key information.
42 2A CHAR(128) Primary key The name of the table that
table name (alias contains the primary key used
name) when retrieving primary or
foreign key information.
170 AA CHAR(10) Foreign key The name of the library that
table library contains the foreign key table
name used when retrieving foreign key
information.
180 64 CHAR(128) Foreign key The name of the table that
table name (alias contains the foreign key used
name) when retrieving foreign key
information.
Note: This format is defined by member EZDAEP in files H, QRPGSRC, QRPGLESRC,
QCBLSRC and QCBLLESRC in library QSYSINC.
The illustration below shows an application where one transaction consists of four
separate I/O operations, each that requires an SQL statement to be processed. In
the client/server environment, this requires a minimum of eight messages between
the server and the client, as shown. This can represent significant overhead,
especially where the communication speed is slow (for example over a dial-up
line), or where the turnaround speed for the connection is slow (for example over
a satellite link).
The following illustration shows the same transaction by a stored procedure on the
server. As illustrated, the communications traffic has been reduced to a single
message pair. There are additional benefits. For example, the procedure can
arrange to send back only the data that is absolutely required (for example, just a
few characters from a long column). A DB2 for OS/400 stored procedure can be
any AS/400 program, and does not have to use SQL for data access.
Examples: Stored procedures: For information regarding specific SQL commands that
are used in the examples of stored procedures listed below, see the SQL Reference
book. View an HTML online version of the book, or print a PDF version, from the
DB2 Universal Database for AS/400 books online AS/400 Information Center topic.
Stored procedures examples:
v “Example: Stored procedure calls from C with return values”
v “Example: Stored procedure calls from C with result sets” on page 255
v “Example: Host RPG source” on page 256
v “Example: Running CL commands using SQL stored procedures and
ODBC” on page 257
v “Example: Stored procedure calls from Visual Basic with return values”
on page 258
v “Examples: Calling an AS/400 stored procedure by using Visual Basic”
on page 262
Additional resources for examples of calling stored procedures:
For more ODBC programming examples of calling stored procedures
(Visual Basic 4.0, Visual Basic 5.0, C++, and Lotus Script programming
environments), see:
v “Express ODBC programming examples” on page 265
UCHAR col1[CHAR_COL_LEN+1];
/*************************************/
/* Execute the CALL statement */
/*************************************/
returncode = SQLExecute(hstmt);
if(returncode != SQL_SUCCESS)
{
/* Handle error here */
}
else
{
/* Process returned value here */
}
Example: Stored procedure calls from C with result sets: This result-sets example calls
an RPG program and receives the data as a result-set array. The program on the
PC can issue the DROP PROCEDURE and CREATE PROCEDURE statements
before issuing a CALL procedure. After returning from the call, execute ODBC
SQLBindCol to set the variables into which to return data. Then execute ODBC
SQLFetch to get the data.
Example: Host RPG source: The RPG program that is called by the procedure
should declare an array to hold the data. It then can open files and read the data
in to the array and perform necessary processing. The SQL SET RESULT SETS
statement identifies the number of rows and attributes of the array result set.
*-------------------------------------------------------------*
* *
* RPG PROGRAM: RPGARY *
* *
* PURPOSE: THIS RPG PROGRAM IS CALLED BY AN ODBC STORED *
* PROCEDURE. IT READS DATA INTO AN ARRAY AND *
* RETURNS THE RESULTS BY USING THE SET RESULT *
* SETS SQL FUNCTION *
* *
*-------------------------------------------------------------*
* FILE DESCRIPTION SPECIFICATIONS *
*-------------------------------------------------------------*
FPERF IF E DISK
*-------------------------------------------------------------*
* INPUT SPECIFICATIONS *
*-------------------------------------------------------------*
IPERFE E DSPERF
IARR DS 20
I 01 105 VAR1
ILCLVAR DS
I B 01 040L#
*-------------------------------------------------------------*
C* ** START OF PROGRAM ** *
*-------------------------------------------------------------*
Example: Running CL commands using SQL stored procedures and ODBC: Stored
procedure support provides a means to run AS/400 Control Language (CL)
commands by using the SQL CALL statement.
Use CL commands when:
v Performing an override for files
v Initiating debug
v Using other commands that can affect the performance of subsequent
SQL statements
The following examples show cases where a CL command is run on the AS/400 by
using the CALL statement, which calls the program that processes CL commands.
That program (QCMDEXC in library QSYS) expects two parameters:
1. A string that contains the command text to execute
2. A decimal (15,5) field that contains the length of the command text
The parameters must include these attributes for the command to be interpreted
properly. The second parameter on the CALL statement must have characters
explicitly specified for all places of the decimal (15,5) field.
The code for performing this command by using ODBC APIs is as follows:
SQLAllocStmt(hdbc,&hstmt);
strcpy(stmt,"call qsys.qcmdexc('OVRDBF FILE(TESTER) TOFILE(JMBLIB/");
strcat(stmt,"TESTER) MBR(NO2) OVRSCOPE(*JOB)',0000000065.00000)");
SQLExecDirect(hstmt,stmt,SQL_NTS);
Statements now run against file jmblib/tester will reference member number 2
rather than the first member.
Another CL command that you might find useful to run against a database server
job is the STRDBG command. This command forces SQL to generate completion
messages for all SQL statements run. In addition, the query Optimizer generates
messages indicating how the queries run in the job were optimized. This
information can be used to troubleshoot queries that are performing poorly. All of
the messages are written to the joblog of the server job running on the AS/400.
This joblog can then be studied to identify problem queries or operations.
The code for performing this command by using ODBC APIs is as follows:
SQLAllocStmt(hdbc,&hstmt);
strcpy(stmt,"call qsys.qcmdexc('STRDBG UPDPROD(*YES)',");
strcat(stmt,"0000000020.00000)");
SQLExecDirect(hstmt,stmt,SQL_NTS);
SQL statements run in the job will generate completion messages and Optimizer
debug messages.
Example: Stored procedure calls from Visual Basic with return values: Visual Basic is
able to call external functions that are found in a DLL. Since all ODBC drivers are
DLLs, Visual Basic can be used to code directly to the ODBC APIs. By coding
directly to the ODBC APIs a Visual Basic application can call an AS/400 stored
procedure and return result values. See “Coding directly to ODBC APIs” on
page 216 for more information.
The following example of Visual Basic source code shows how to call an AS/400
stored procedure and then retrieve the returned values into Visual Basic variables.
'***********************************************************************
'* *
'* Because of the way Visual Basic stores and manages the String data *
'* type, it is recommended that you use an array of Byte data type *
'* instead of a String variable on the SQLBindParameter API. *
'* *
'***********************************************************************
'***********************************************************************
'* *
'* Initialize the variables needed on the API calls *
'* *
'***********************************************************************
link(1) = 6
link(2) = Ubound(abCustname) +1
link(3) = Ubound(abAddress) +1
link(4) = Ubound(abCity) +1
link(5) = Ubound(abState) +1
link(6) = Ubound(abPhone) +1
link(7) = 1
RC = 0
nullx = 0
lpSQL_NTS = SQL_NTS ' -3 means passed as sz string
'Ignore error assuming that any error would be from procedure already
'created.
'***********************************************************************
'* *
'* Prepare the call of the procedure to the AS/400. *
'* For best performance, prepare the statement only one time and
'* execute many times.
'* *
'***********************************************************************
'***********************************************************************
'* *
'* Bind all of the columns passed to the stored procedure. This will *
'* set up the variable's data type, input/output characteristics, *
'* length, and initial value. *
'* The SQLDescribeParam API can optionally be used to retrieve the
'* parameter types.
'* *
'* To properly pass an array of byte to a stored procedure and receive *
'* an output value back, you must pass the first byte ByRef. *
'* *
'***********************************************************************
'***********************************************************************
'* *
'* The Prepare and Bind only needs to be execute once. The Stored
'* procedure can now be called multiple times by just changing the data
'* *
'***********************************************************************
Do While
'***********************************************************************
'* Read in a customer number *
'* *
'***********************************************************************
Custnum = Val(input.text)
'***********************************************************************
'* *
'* Execute the call of the procedure to the AS/400. *
'* *
'***********************************************************************
RC = SQLExecute(Connection.hstmt)
frmMain.Status.Caption = "Ran Stored Proc" & RTrim$(Tag)
'***********************************************************************
'* *
'* Set text labels to display the output data *
'* You must convert the array of Byte back to a String
'* *
'***********************************************************************
Loop
View the COBOL stored procedures source code:
“Example: COBOL source code”
Example: COBOL source code: The following is the COBOL source code to the
stored procedures that are used in “Example: Stored procedure calls from Visual
Basic with return values” on page 258:
0031.00
0032.00 IDENTIFICATION DIVISION.
0033.00
0034.00 PROGRAM-ID. STOREDP2.
0035.00 ENVIRONMENT DIVISION.
0036.00 CONFIGURATION SECTION.
0037.00 SOURCE-COMPUTER. IBM-AS400.
0038.00 OBJECT-COMPUTER. IBM-AS400.
0039.00
0040.00 INPUT-OUTPUT SECTION.
Examples: Calling an AS/400 stored procedure by using Visual Basic: The Visual Basic
programming examples listed below show a stored procedure call being prepared.
Two statements are shown:
1. A statement for the creation of the stored procedure
2. A statement to prepare the call
Create the stored procedure only once. The definition that it provides is available
to ODBC applications, as well as to integrated OS/400 applications.
Read this topic first for useful information:
“Tips: Running and calling AS/400 stored procedures by using Visual
Basic”
View the Visual Basic stored procedures examples:
v “Example: Visual Basic - Calling an AS/400 stored procedure (1 of 2)” on
page 263
v “Example: Using arrays of byte” on page 263
v “Example: Visual Basic - Calling an AS/400 stored procedure (2 of 2)” on
page 264
Tips: Running and calling AS/400 stored procedures by using Visual Basic:
Running a stored procedure on the AS/400:
ODBC provides a standard interface for calling stored procedures. The
implementation of stored procedures differs significantly across various
databases. This simple example follows the recommended approach for
running a stored procedure on the AS/400:
1. Set up a create procedure statement for the stored procedure and create
it. The creation of the stored procedure only needs to be done once it
does not have to done through ODBC. The definition that it provides is
available to all ODBC as well as integrated OS/400 applications. This
step can also help performance, as the Optimizer knows in advance the
data type, the direction of the parameters, and the language of the
procedure.
2. Prepare the stored procedure call.
3. Bind the parameters of the procedure, indicating whether each
parameter is to be used for input to the procedure, output from the
procedure, or input/output.
4. Call the stored procedure.
Calling AS/400 stored procedures using Visual Basic:
Use care in coding the SQLBindParameter functions. Never use Visual
Basic strings as a buffer when binding either columns (SQLBindCol) or
parameters (SQLBindParameter). Instead, use byte arrays, which–unlike
Example: Using arrays of byte: Because of the way Visual Basic stores and manages
the String data type, using an array of Byte data type instead of a String variable is
recommended for the following parameter types:
v Input/output parameters
v Output parameters
v Any parameter that contains binary data (rather then standard ANSI characters)
v Any input parameter that has a variable address which is set once, but refered
to many times
The last case would be true for the “Example: Visual Basic - Calling an AS/400
stored procedure (2 of 2)” on page 264 sample if the application made multiple
calls to SQLExecute, while modifying Parm1 between each call. The following
Visual Basic functions assist in converting strings and arrays of byte:
Public Sub Byte2String(InByte() As Byte, OutString As String)
'Convert array of byte to string
OutString = StrConv(InByte(), vbUnicode)
Dim I As Integer
Dim SizeOutByte As Integer
Dim SizeInString As Integer
SizeOutByte = UBound(OutByte) + 1
SizeInString = Len(InString)
String2Byte = True
End Function
Dim S As String
Dim I As Integer
On Error GoTo VBANext
S = "Length: " & Str(UBound(Data) - LBound(Data) + 1) & " Data (in hex):"
For I = LBound(Data) To UBound(Data)
If (I Mod 8) = 0 Then
S = S & " " 'add extra space every 8th byte
End If
S = S & Hex(Data(I)) & " "
VBANext:
Next I
MsgBox S, , Title
End Sub
The two examples that are provided here apply to ODBC programs. The first
example enables the powerful SQL tracing facility that writes data into the joblog
for the job running the SQL (in this case, the OS/400 server job). This feature is
described in “Collecting an SQL.LOG (ODBC Trace)” on page 288.
The second example overcomes a restriction in SQL: its limited ability to work
with multi-member files. You cannot create a multi-member file through CREATE
TABLE. However, the following example shows you how to access with ODBC
anything but the first member of a file that is created through DDS:
Note: To access ODBC programming samples (Visual Basic 4.0, Visual Basic 5.0,
C++, and Lotus Script programming environments), link to the IBM ftp site
on the
Express ODBC Web. Select examples:
programming vbODBCT3.zip to download the samples.
v “C++ Example: ODBC simple query”
v “Visual Basic example: ODBC simple query” on page 271
v “Example: Visual C++ - Accessing and returning data by calling a stored
procedure” on page 274
v “Example: Visual Basic - Accessing and returning data by calling a
stored procedure” on page 276
v “Examples: RPG - Host code for ODBC stored procedures” on page 277
C++ Example: ODBC simple query: This sample code that follows uses ODBC in
a Visual C++ V 4.0 project to perform simple inquiry operations on a database file
that is called PARTS.
Only part of the code is shown: the ODBC calls that relate to a single-part inquiry.
C++ Example: ODBC simple query topics:
v “ODBC query C++ example: Prompting for the data source”
v “ODBC query C++ example: Data declarations”
v “ODBC query C++ example: The Part Record class” on page 267
v “ODBC query C++ example: Making the AS/400 connection” on
page 267
v “ODBC query C++ example: Preparing the statements” on page 268
v “ODBC query C++ example: Binding columns and parameters” on
page 269
v “ODBC query C++ example: Getting a row” on page 269
v “ODBC query C++ example: Mapping the data” on page 270
v “ODBC query C++ example: Ending the connection” on page 270
ODBC query C++ example: Prompting for the data source: When the program starts, it
prompts for the data source name. All of the available ODBC data sources display.
To run this program, you must set up a data source to access the server AS/400
system. Set the default library to APILIB, and the *SQL naming convention that is
used.
ODBC query C++ example: Data declarations: This example shows the declarations
for the ODBC functions and buffers that are used for input, output, and data
storage:
// Parameters for ODBC function calls
HENV m_henv; // ODBC environment handle
HDBC m_hdbc; // ODBC connection handle
HSTMT m_Shstmt; // ODBC statement handle for single record request
HSTMT m_Mhstmt; // ODBC statement handle for multi-record request
RETCODE rc; // Return code
ODBC query C++ example: The Part Record class: The CPartRecord class is used in
this example to create part objects. Getters and Setters are used to retrieve or set
information from the part object.
class CPartRecord : public CObject {
public:
CPartRecord();
// Attributes
protected:
long m_lPartNo;
CString m_szPartDesc;
long m_lPartQty;
double m_dPartPrice;
CString m_szPartDate;
// Operations
public:
// Getters
long GetPartNo() const;
CString GetPartDesc() const;
long GetPartQty() const;
double GetPartPrice() const;
CString GetPartDate() const;
// Setters
void SetPartNo(long lPartNo);
void SetPartDesc(CString szPartDesc);
void SetPartQty(long lPartQty);
void SetPartPrice(double dPartPrice);
void SetPartDate(CString szPartDate);
};
ODBC query C++ example: Making the AS/400 connection: The following code
example uses ODBC calls to connect to an ODBC data source. The examples use
SQLDriverConnect to prompt for the data source name. The function that is
shown, MakeAS400Connection, is called from within the C++ example.
/***********************************************************
* Function: MakeAS400Connection
* Arguments: None
* Return: Unsigned integer
* Notes: Initialize the connection with the AS/400
**************************************************************/
UINT CAPISampDoc::MakeAS400Connection()
{
// Initialize the ODBC environment
SQLCHAR szConnStrIn[] = ""; // Input connection string
SQLSMALLINT cbConnStrIn = 0; // Length of input connection string
SQLCHAR szConnStrOut[257]; // Buffer for ODBC connection string
SQLSMALLINT cbConnStrOut; // Number of bytes ConnStrOut
SDWORD lc bBuffer = 0;
// Allocate an environment handle
rc = SQLAllocEnv(&m_henv);;
if(rc != SQL_SUCCESS) {
DisplayError(rc, "Unable to allocate ODBC environment");
return APIS_INIT_ERROR;
}
ODBC query C++ example: Preparing the statements: This section of code shows how
to allocate statement handles and prepare statements for later processing. For any
ODBC statement that will be runmore than once, this technique provides enhanced
performance. The statement is prepared once, but runs multiple times.
rc = SQLAllocStmt(m_hdbc, &m_Mhstmt);;
if(rc != SQL_SUCCESS) {
DspSQLError(m_henv, m_hdbc, SQL_NULL_HSTMT);
return APIS_INIT_ERROR;
}
ODBC query C++ example: Getting a row: This example shows how to set the input
parameter value and run the statement. If the processing of the select is successful,
the result will be placed in an SQL result set.SQLFetch is used to retrieve the
selected rows from the result set. The column values for each row that are
retrieved from the result set will be placed in the storage area to which the
columns are bound.
m_lInPartNo = PartNo;
ODBC query C++ example: Mapping the data: The following example uses the
Setters to map the data to the part object. The statement handle then is freed, so
that it can be run again.
// First format the data to a character string
sprintf(m_szSPartDate, "%4d-%02d-%02d", m_dsSPartDate.year,
m_dsSPartDate.month, m_dsSPartDate.day);
ODBC query C++ example: Ending the connection: This example demonstrates
ending the ODBC connection. First the ODBC statements are freed (by using
SQL_Drop). Next, the ODBC data source is disconnected and the connection
handle and ODBC environment handle are freed .
/***********************************************************
* Function: EndAS400Connection
* Arguments: None
* Return: Unsigned integer
* Notes: End the connection with the AS/400
**************************************************************/
UINT CAPISampDoc::EndAS400Connection()
{
// End the ODBC connections and free environment
RETCODE rc;
rc = SQLFreeStmt(m_Mhstmt, SQL_DROP);
if (rc != SQL_SUCCESS) {
DspSQLError(m_henv, m_hdbc, SQL_NULL_HSTMT);
return APIS_END_ERROR;
}
Visual Basic example: ODBC simple query: The sample code in the example that
follows uses ODBC in a Visual Basic V 4.0 project to perform simple enquiry
operations on a database file that is called PARTS.
Only part of the code is shown here: the ODBC calls that relate to a single part
inquiry.
Example: Visual Basic - ODBC simple query topics:
v “ODBC query Visual Basic example: Prompting for the data source”
v “ODBC query Visual Basic example: Making the connection (1 of 2)”
v “ODBC query Visual Basic example: Making the connection (2 of 2)” on
page 272
v “ODBC query Visual Basic example: Preparing the statements” on
page 272
v “ODBC query Visual Basic example: Binding the parameter” on page 272
v “ODBC query Visual Basic example: Getting a row” on page 273
v “ODBC query Visual Basic example: Ending the connection” on page 274
ODBC query Visual Basic example: Prompting for the data source: When starting the
application, select the System menu option and then select Connect from the
pulldown menu. All the available ODBC data sources display. To run this program,
you must set up a data source to access the server AS/400 system. Set the default
library to APILIB and use the *SQL naming convention. This is the standard
dialog box that is displayed with SQLDriverConnect.
ODBC query Visual Basic example: Making the connection (1 of 2): This section shows
the declaration for the ODBC functions and buffers that are used for input, output,
and data storage.
Dim szConnStrIn As String 'Input connection string
Dim cbConnStrIn As Integer 'Length of input connection string
Dim szConnStrOut As String * 257 'Buffer for ODBC connection string
Dim cbConnStrOut As Integer 'Number of bytes ConnStrOut
Dim cbConnStrOutMax As Integer 'Max length of ConnStrOut buffer
Dim szSSQLStmt As String 'SQL stmt to select single record
Dim szMSQLStmt As String 'SQL stmt to select all parts
Dim lcbBuffer As Long 'pcbValue
Dim rc As Integer 'Return code
'***********************************
ODBC query Visual Basic example: Making the connection (2 of 2): This section
demonstrates an example of using ODBC calls to connect to an ODBC data source.
The examples use SQLDriverConnect to prompt for the data source name.
'* Connect to the data source, prompting for its name
ODBC query Visual Basic example: Preparing the statements: This section of code
shows how to allocate statement handles and prepare statements for later
processing. For any ODBC statement that will be run more than once, this
technique provides more enhanced performance. The statement is prepared once,
but runs multiple times.
'* Allocate statement handles
rc = SQLAllocStmt(hdbc, lShstmt)
If rc <> SQL_SUCCESS Then
Call DisplayError(rc, "SQLAllocStmt failed.")
Call DspSQLError(henv, SQL_NULL_HDBC, SQL_NULL_HSTMT)
End If
rc = SQLAllocStmt(hdbc, lMhstmt)
If rc <> SQL_SUCCESS Then
Call DisplayError(rc, "SQLAllocStmt failed.")
Call DspSQLError(henv, SQL_NULL_HDBC, SQL_NULL_HSTMT)
End If
'* Prepare the select statements
szSSQLStmt = "select * from parts where partno = ?"
rc = SQLPrepare(lShstmt, szSSQLStmt, SQL_NTS)
If rc <> SQL_SUCCESS And rc <> SQL_SUCCESS_WITH_INFO Then
Call DisplayError(rc, "SQLPrepare failed.")
Call DspSQLError(henv, hdbc, lShstmt)
End If
szMSQLStmt = "select * from parts"
rc = SQLPrepare(lMhstmt, szMSQLStmt, SQL_NTS)
If rc <> SQL_SUCCESS And rc <> SQL_SUCCESS_WITH_INFO Then
Call DisplayError(rc, "SQLPrepare failed.")
Call DspSQLError(henv, hdbc, lShstmt)
End If
ODBC query Visual Basic example: Binding the parameter: In this example,
SQLBindParameter is used to connect parameter 1 (the only parameter) for
ODBC query Visual Basic example: Getting a row: This example shows how to set the
input parameter value and run the statement. If the processing of the select is
successful, the result will be placed in an SQL result set. SQLFetch is used to
retrieve the selected rows from the result set.
SQLGetData is used to move the information from the result set to the storage
areas.
Dim rc As Integer 'Return code
Dim lcbBuffer As Long
Dim sSDescription As String * 25 'Description for single record
Dim lSQuantity As Long 'Quantity for single record
Dim dSPrice As Double 'Price for single record
Dim sSReceivedDate As String * 10 'Received date for single record
'*****************************************
If Len(txtPartNumber.Text) = 0 Then
Beep
MsgBox "A Part# must be specified", vbOK, "Send Data Queue"
Else
lSPartNumber = Val(txtPartNumber)
txtStartTime = Time 'Record start time
ODBC query Visual Basic example: Ending the connection: This programming
example shows how to end the ODBC connection. First the ODBC statements are
freed (by using SQL_Drop). Next, you disconnect from the ODBC data source and
then free the connection handle and ODBC environment handle.
If hdbc <> SQL_NULL_HDBC Then
' Drop the statement handles
rc = SQLFreeStmt(lShstmt, SQL_DROP)
If rc <> SQL_SUCCESS Then
Call DspSQLError(henv, hdbc, SQL_NULL_HSTMT)
End If
rc = SQLFreeStmt(lMhstmt, SQL_DROP)
If rc <> SQL_SUCCESS Then
Call DspSQLError(henv, hdbc, SQL_NULL_HSTMT)
End If
' Disconnect from the data source
rc = SQLDisconnect(hdbc)
If rc <> SQL_SUCCESS Then
Call DspSQLError(henv, hdbc, SQL_NULL_HSTMT)
End
End If
Only the code relevant to the stored procedure call has been included, as the
connect/disconnect routines are identical to the earlier example
Examples: RPG - Host code for ODBC stored procedures: This program,
SPROC2, is called from the client as a stored procedure via ODBC. It returns data
to the client from the PARTS database file.
ILE-RPG example:
* This example is written in ILE-RPG
*
* Define option and part as integer
D#opt s 10i 0
D#part s 10i 0
* Define part as packed 5/0
Dpart s 5p 0
C *entry plist
Under normal conditions, the program is evoked transparently, and the user is not
required to take action except to verify that the proper subsystems and
communication protocols are running. See the Client Access Express Host Servers
book in the IBM BookManager BookServer online library for details on
administration of host server jobs.
Checking the server status: The Client Access Express for Windows product has a
special command to verify status of host servers:
CWBPING systemname
If the servers are not active, continue to “Verifying that host server program is
installed”.
Verifying that host server program is installed: The Database Server is installed as
part of the operating system. If all PCs are still unable to connect to the server or
the QSERVER subsystem is not on the system, then verify that product xxxxSS1,
option Host Servers is installed where xxxx is the OS/400 lpp (license program
product) for the version current version of OS/400.
To have the subsystem start automatically at IPL, then modify the AS/400 IPL Start
up procedure (the default is QSYS/QSTRUP) to include the STRSBS QSERVER
command.
Verifying that prestart jobs are running: IBM ships the QSERVER subsystem
configured to use prestart jobs to improve performance at job initialization/start
up. When prestart jobs are configured in the subsystem, the job MUST be active to
connect. The prestart job used for a TCP/IP connection is:
v QZDASOINIT - Server program
v QZDASRVSD - Server Daemon program
Additional TCP/IP considerations: Verify that TCP/IP is started with the following
command:
NETSTAT *CNN
Use the command STRTCP to start the desired protocol if it is not running.
Verify the necessary daemons are running by browsing the information returned
from the NETSTAT *CNN command:
Remote Remote Local
Address Port Port Idle Time State
* * as-cent > 000:09:31 Listen
* * as-signon 000:09:41 Listen
* * as-svrmap 002:57:45 Listen
* * as-data > 002:57:45 Listen
The PC locates the socket used by the database server by connecting to the server
mapper socket. It retrieves the socket used by as-database. It then connects to the
proper socket which is being monitored by the file server daemon, QZDASRVSD.
The server daemon will attach the client’s connection to a QZDASOINIT prestart
job in QSERVER. After validating the user profile and password and swapping the
user profile into the prestart job, the job will run similar to the QZDAINIT job. If
this is the first connection made to the AS/400 for this PC, then two other servers
are used: Central server for licensing and Signon server for userid/password
validation.
Generating a joblog: Some internal errors cause the job to immediately end. To
isolate these types of errors, use the CHGJOB command to modify the existing
database server job and to generate a joblog. Modify the job description to change
all new jobs. To modify the default job description, enter the following command
prior to recreating the error:
CHGJOBD JOBD(QDFTJOBD) LOG(4 00 *SECLVL)
If the job description is not changed back, other jobs on the system will force
joblogs to be written, and system storage will fill up rapidly.
An alternative way of finding the joblog is to use the WRKSPLF command. Use
the following command:
WRKSPLF USERID
Common errors:
SQL errors:
v “MSGSQL0113 - Name &1 not allowed.”
v “MSGSQL0114 - Relational database &1 not the same as current &2 server”
v “MSGSQL0122 - Column &1 or function specified in SELECT...”
v “MSGSQL0204 - MYSYSCONF not found” on page 284
v “MSGSQL0900 - Application process not in a connected state” on page 284
v “MSGSQL5001 - Column qualifier or table &2 undefined.” on page 284
v “MSGSQL5016 - Object name &1 not valid for naming convention” on page 284
v “MSGSQL0104 - Token &1 was not valid. Valid tokens: &2” on page 284
v “MSGSQL7008 &1 in &2 not valid for operation. The reason code is 3” on
page 285
MSGSQL0113 - Name &1 not allowed.: See “MSGSQL0114 - Relational database &1
not the same as current &2 server”.
MSGSQL0114 - Relational database &1 not the same as current &2 server: It is likely
that the system name is not in the Remote Database Directory. Run the Add
Relational Database Directory Entry command:
ADDRDBDIRE RDB(SYSNAME) RMTLOCNAME(*LOCAL)
Where SYSNAME is the name of your system’s Default Local Location name (as
specified in the DSPNETA command).
Another common cause for this error is a period (.) in a table or library name.
Although valid in AS/400 naming conventions, in order to use it within an SQL
statement, enclose the name within double quotes. A short term circumvention
may be to build a logical file over the desired physical file, using the SQL naming
syntax.
Note: You can view an HTML online version of the Database Management book, or
print a PDF version, from the DB2 Universal Database for AS/400 books
online topic in the AS/400 Information Center.
For example:
″SELECT workdept, salary from employee GROUP BY workdept″ files because
salary is not in the GROUP BY.
″SELECT field1, DATE(field2) from T1 GROUP BY field1″ fails because field2 is
not in a column function or the GROUP BY.
″SELECT workdept, AVG(salary) from employee GROUP BY workdept order by
2″ completes because workdept is a grouping column and salary is specified in
a column function (AVG).
MSGSQL0204 - MYSYSCONF not found: Usually only joblogs for jobs using the
Microsoft Jet Engine (MS ACCESS or MS Visual Basic applications) contain this
message. The MS Jet Engine always checks for an optional table on the server that
is called MSYSCONF. The applications ignore this warning. For further information
see the MS Jet Database Engine Connectivity white paper or contact Microsoft.
MSGSQL5016 - Object name &1 not valid for naming convention: Your ODBC Data
Source Name (DSN) configuration uses the wrong naming convention. Use the
ODBC Administrator to change your DSN to use the proper (*SQL or *SYS)
naming convention. Always use *SQL unless your application design specifically
expects *SYS.
Stored procedure errors: The following are typical stored procedure errors:
v “Internal driver error (DB2 UDB for AS/400 SQL)”
v “SQL0444 - External program &A in &B not found (DB2 UDB for AS/400 SQL)”
v “No data returned on OUTPUT and INPUT_OUTPUT parameters”
v “MSGSQL0501 - Cursor CRSR000x not open” on page 286
v “No data returned on result set” on page 286
Internal driver error (DB2 UDB for AS/400 SQL): Preparing or executing a stored
procedure when the server is unable to find a valid declaration of the stored
procedure generates this error. Stored procedures should be defined to DB2
Universal Database (UDB) for AS/400 by using either the DECLARE PROCEDURE
or CREATE PROCEDURE SQL statement. The internal driver error occurs during
the prepare when the SQL statement contains parameter markers and the database
server is unable to locate the definition of the parameters.
When using the older DECLARE PROCEDURE, you must use extended dynamic
support to return output or input/output parameters. You must also store the call
of the stored procedure in the active package. Use PRTSQLINF on the package to
verify the package contents. Delete the SQL package after making any change to
DECLARE PROCEDURE. Parameter descriptions are stored in the package as part
of the call entry, not the declare entry.
SQL0444 - External program &A in &B not found (DB2 UDB for AS/400 SQL): The
SQL0444 is generated on an execute or execute direct when the database server is
unable to locate the program. Remember that SQL does not perform a library list
search. The stored procedure name (the procedure name parameter that is used on
the CREATE PROCEDURE statement) must be in the default collection.
PowerBuilder (3.0 and 4.0) only supports input parameters on store procedures.
You must use the PowerBuilder Remote Program Call (RPC) to work with
input/output or output parameters. See the ODBC User’s Guide for an example.
When using Visual Basic to make direct ODBC API calls, verify that Visual Basic
has not changed the address of the parameter that was set on the
SQLBindParameter API. This usually occurs when binding a String data type and
results in damageed data or an irrecoverable exception.
MSGSQL0501 - Cursor CRSR000x not open: To return data when using embedded
SQL in ILE programs, you must specify the compile option ACTGRP(*CALLER)
and not the default of *NEW.
When the stored procedure program executes an exit instead of a return, you must
set the Close SQL Cursor option to *ENDACTGRP. If the Close SQL Cursor option
is set to *ENDMOD, the cursor will be closed before data is retrieved.
Also verify that the CREATE PROCEDURE specifies the correct number of result
sets. This is especially important when using array result sets.
No data returned on result set: See “MSGSQL0501 - Cursor CRSR000x not open”.
ODBC incorrect output and unpredictable errors: Ensure that the Client Access
Express ODBC driver and the database server program are at matching code
levels. Check for PTF corequisite requirements on any PTF that you order or in the
readme.txt file of the Client Access Service Pack. If problems continue, verify that
you have disabled the prefetch option in the ODBC Data Source. The prefetch
option should be used only with applications that use the Fetch API, not the
Extended Fetch API.
Note that stored procedure result set cursors are forward only, read only.
Binary or hexadecimal data instead of ASCII characters
The default value of the Translation parameter is Do Not Translate
CCSID 65535. The AS/400 attaches a character set identifier (CCSID) to files, tables and even
Translate CCSID 65535 ensures that the raw data is not damaged.
Setting the Translation parameter to Translate CCSID 65535 updates the
CCSID that is attached to the data to the CCSID of the job. This parameter
setting can cause damage to the data, if the data is truly binary.
Gathering information for IBM Support: So the IBM Support staff can offer you
the best service, please have certain information available when you open a
problem record to IBM Support. To gather this information, complete the following
tasks:
1. Record the OS/400 version and cumulative PTF level.
2. Record the version of the Client Access ODBC driver.
3. Record the version of the ODBC driver manager.
4. Collect an ODBC trace (SQL.log)
Recording the OS/400 version and cumulative PTF level: To receive optimal support,
you will need to record the OS/400 version and cumulative PTF level for your
AS/400 system. Record this information by completing the following steps:
1. Issue the display PTF command on an AS/400 terminal emulation command
line:
DSPPTF
2. Record the OS/400 release information that has the format VxRxMx.
3. Verify that the IPL source is ##MACH#B.
4. Press F5 to display the PTF details.
5. Record the first PTF ID in the list. It will have the format Tzxxyyy where xx is
the year, yyy the Julian date and z is either L or C.
Recording the version of the Client Access Express for Windows ODBC driver: To
receive optimal support, you will need to record the version for your Client Access
Express for Windows ODBC driver. Record this information by completing the
following steps:
1. From the Task bar select Start –> Settings –> Control Panel.
2. Double-click the Client Access Properties icon.
3. The General tab of the Client Access Properties dialog will display by default.
Record the Client Access version and service pack levels.
Recording the version of the 32–bit ODBC driver manager: To record the version for
your 32-bit ODBC driver manager, complete the following steps:
1. From the Task bar, select Start –> Find –> Files or Folders.
2. Enter ODBC32.DLL as the file name and select Find.
3. Note the size and date of the file.
4. Right-mouse on the file name and select Properties.
5. Select the Version tab and record the file version.
Name and version of the PC application: Record the name and version of the PC
application that was used when the error was generated.
The PC application provides an error message. Include the exact text and error
numbers in the error message. When a printer is unavailable, the image of the
error message can be captured by pressing the print screen key. Print screen copies
a bitmap of the current screen to the clipboard. Use your preferred application to
access and store the error bitmap in a folder for future reference.
ODBC defines a standard, layered error handling protocol. Include the return code,
the identity of the error source, the actual error text, and the ODBC SQLSTATE in
the ODBC error message. Client Access ODBC uses the following format to
identify the source of the error:
[IBM][Client Access Express ODBC Driver (32-bit)][DB2 UDB for AS/400 SQL]
Entry Definition
[IBM] The vendor identifier. If this value is anything except IBM, the failure did
not occur in IBM code. An error starting with [Microsoft] [ODBCxxx
DLL] implies the failure was at the ODBC driver manager.
[Client Access Express ODBC Driver 32-bit)]
The component that is reporting the error. When the Client Access Express
ODBC Driver reports the error and the [DB2 UDB for AS/400 SQL] field
does not follow, then the error occured on the PC. The request was never
sent to the AS/400.
[DB2 UDB for AS/400 SQL]
The AS/400. This field, when included, means that the failure originated
from the AS/400. The AS/400 joblog may contain additional information
for these types of errors.
For more information, see “Client Access ODBC error messages” on
page 165.
Note: Some programming languages encapsulate the ODBC APIs within their own
object structure. Examples include Microsoft DAO, RDO, and ADO. These
objects usually return their own error or return code. The programmer must
retrieve the actual ODBC error message. The ODBC error message may be
held in an error object.
Error message help: All of the Client Access error messages can be found either on
the AS/400 or in a Client Access help. For errors that begin with SQL, use the
following OS/400 command to view the message text:
DSPMSGD RANGE(SQLxxxx) MSGF(QSQLMSG)
ODBC trace utilities: ODBC 3.0 includes its own trace utility. Available retail
utilities can be more robust, providing detailed entry and exit point tracing of
ODBC API calls. These tracing utilities include Trace Tools (Dr. DeeBee) and SST
Trace Plus (Systems Software Technology).
AS/400 communications trace: The OS/400 communications trace facility will trace
and format any communications type that has a line description (token ring and
Ethernet).
This is a great tool for isolating many problems. It also is a useful aid for
diagnosing where a performance delay is occurring. Use the timestamp and
eye-catcher fields to measure how long the AS/400 takes to process a request.
AS/400 job traces: The OS/400 job trace can help isolate most host problems and
many performance issues. A service job must first be started on the job to be
traced. Locate the fully qualified job name of the ODBC job. From any 5250
emulation session, start a service job on this QZDASOINIT job by using the
STRSRVJOB command. Then choose one of two traces, depending on the
information needed:
Trace job
Traces the internal calls made by the host server. Run the TRCJOB *ON
command.
Debug trace
Used to review the performance of your application and to determine the
cause of a particular problem.
The STRDBG command can be run against an active service job. This command
logs the decisions made by the query Optimizer to the joblob of the debug session.
It records estimated query times, access paths used, cursor errors, etc. Use the
following command:
STRDBG UPDPROD(*YES)
AS/400 performance tools: AS/400 performance toolkit provides reports and utilities
that can be used to create an in—depth analysis of your application performance.
The toolkit provides information about CPU utilization, disk arm utilization,
memory paging and much more. Although the base operating system includes the
ability to collect performance data, you will need the separately licensed program
Performance Tools/400 to analyze the results.
AS/400 job log: The ODBC joblog can record all errors that occur on the AS/400.
When the job is in debug mode (see “AS/400 job traces”), the joblog also will
contain performance-related information.
Client Access Express database APIs provide a superset of the function that is
provided in the ODBC interface. All of the ODBC function is provided, along with
extensions that allow an application developer to take advantage of unique AS/400
functions. The Express database APIs provide access to AS/400 database files
through a call-level interface.
Express database APIs required files:
Express Toolkit:
The Client Access Express Toolkit provides Database documentation, access
to the cwbdb.h header file, and links to sample programs. To access this
information, open the Express Toolkit and select Database —> C/C++
APIs.
Express database APIs topics:
“Express database APIs overview”
“Typical use of Express database APIs” on page 293
“Objects that process data on the PC or AS/400” on page 295
“Code page support in Windows” on page 295
Database APIs listing
“Example: Using SQL to access database functions” on page 467
“Express Database (Optimized SQL) APIs return codes” on page 21
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
The Express Database APIs are built on an object-oriented base. Handles are used
to provide an application access to the following classes of objects:
v “Connection object”
v “Catalog request object” on page 292
v “Native database (NDB) request object” on page 292
v “SQL request” on page 292
v “Data format object” on page 293
v “Parameter marker format object” on page 293
v “Data object” on page 293
Catalog request object: This class of object is used to retrieve information about
database and other SQL objects (SQL packages) from the AS/400. Information that
pertains to the following is available through the catalog request:
Fields
Files
Foreign keys
Indices
Libraries
Members
Primary keys
Relational databases (RDBs)
Record formats
SQL packages
Statements that are stored in SQL packages
Special columns
By using the catalog request, an application can control both the type of
information that is to be returned and the objects for which the information is to
be returned. For example, you can use a catalog request to return the name and
description of all files whose names start with the letter Q in the QIWS library.
Native database (NDB) request object: This class of object is used to manipulate
database file objects on the AS/400. This includes member manipulation (add,
clear, remove) as well as creating and duplicating database files. In addition, by
using NDB requests in association with SQL requests, an application can access
data in members other than the first member of a file using SQL as the access
method.
See “Native Database (NDB) request APIs” on page 294 for more information.
The SQL request object allows an application to set various parameters that
control the processing of SQL statements on the AS/400 system. Among these
parameters are the library and SQL package name that allows the application to
use ″extended dynamic″ SQL. When extended dynamic SQL is used, SQL
statements only need to be prepared once. The prepared statement is stored in the
specified package and can be reused at a later time.
Data format object: This class of object describes data that is contained in a result
set (for example, the result of a select statement or the result of a catalog request).
The data format contains a description for each item in the result set. That
description includes: data type, data length, precision, scale, CCSID, and column
name.
Since NDB requests do not return data, this class is not used in conjunction with
NDB requests.
See “Objects that process data on the PC or AS/400” on page 295 for more
information.
Parameter marker format object: This class of objects describes data that
corresponds to parameter markers that are contained in SQL statements.
The parameter marker format contains a description for each parameter marker in
a prepared SQL statement. That description includes: data type, data length,
precision, scale, and CCSID.
See “Objects that process data on the PC or AS/400” on page 295 for more
information.
Data object: This class is used to return result data to the calling application.
Using a data object removes the responsibility from the calling application to
create buffers large enough to contain result data. The data object itself manages
how much storage is needed to contain the data.
See “Objects that process data on the PC or AS/400” on page 295 for more
information.
Once the connection is created and the server is started, requests and other related
objects can be created and processed. The AS/400 will not return any data until it
is requested (by using one of the cwbDB_Return* APIs—see “cwbDB_ReturnData”
on page 398). This, along with the ability to store parameters for a request on the
AS/400, allows an application to perform processing in an asynchronous manner.
Catalog request APIs: The catalog request APIs consist of a group of APIs that
allow an application to specify what object for which information is being
requested. For example, if the application needs information that pertains to
members of a database file, the following APIs likely would be called:
cwbDB_SetLibraryName
This qualifies the library for which the information will be retrieved. This may
contain wildcard values (QIWS*) or special values such as *LIBL, *USRLIBL,
and so on.
cwbDB_SetFileName
This qualifies the file for which the member information will be retrieved. This
may contain wildcard characters.
cwbDB_SetMemberName*
This is optional and may contain wild-card characters.
cwbDB_ReturnData
This is required for data to be sent to the PC from the AS/400. If this API is
not used, the data will be kept on the AS/400 until it is requested, or until the
next operation is performed.
cwbDB_RetrieveMemberInformation
One of the parameters on this API is a bitmap that indicates what information
is to be returned. The following information can be returned for members:
v Library name
v File name
v Member name
v Member description
Once the information has been retrieved, the application will use the data format
and the data object to process the data that has been retrieved. See “Objects that
process data on the PC or AS/400” on page 295 for more information.
Native Database (NDB) request APIs: Native database (NDB) requests are used
to manipulate database objects on the AS/400. For example, the override database
function can be used in conjuction with an SQL request to allow SQL to access
members other than the first member in a file. The following NDB APIs would be
used to accomplish this:
cwbDB_SetFileName
This is the file (table) that will be used in the SQL statement.
cwbDB_SetOverrideInformation*
This will indicate the file and member to be accessed.
cwbDB_ReturnHostErrorInfo
Since no data is available to be returned, this will provide status as to the
result of the override request.
cwbDB_OverrideFile
This actually does the override request.
SQL request APIs: SQL requests are used to perform SQL operations on the
AS/400. There are some operations for which a combined function API is
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The
cwbDB_AddLibraryToList API may be called after setting the position in the
library list at which the library is to be added using the
cwbDB_SetAddLibraryPosition API. The cwbDB_AddLibraryToList API should
be called after setting the library name in the request via the
cwbDB_SetAddLibraryName API. This API will result in a request datastream
flowing to the AS/400 server and, if requested, a response to the request flowing
back to the client. A call to cwbDB_ReturnHostErrorInfo is needed in order
determine the success of the operation for this API. Calling
cwbDB_ReturnHostErrorInfo prior to calling this API will result in a synchronous
operation (the application will not get control back until the result is returned to
the PC from the AS/400).
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The cwbDB_AddMember
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Purpose: Activates the changes that were made to server attributes by previous
calls - (naming convention, commitment control, etc.) Use this to change server
attributes after the server has been started.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is only needed if the server attributes are changed after the server
has been started (cwbDB_StartServer).
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The cwbDB_ClearMember
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The
cwbDB_ClearPackage API should be called after setting the desired values in the
request. This API will result in a request datastream flowing to the AS/400 server
and if requested, a response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Close API
should be called after setting the desired values in the request. This API will result
in a request datastream flowing to the AS/400 server and if requested, a response
to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Commit
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Connect
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to the connection which will be used when servicing the request.
cwbDB_RequestHandle *request - output
Pointer to a cwbDB_RequestHandle where the handle of the Request will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
char *systemName - input
Pointer to an ASCIIZ string that contains the name of the system from which
database requests will be serviced.
cwbDB_ConnectionHandle *connection - output
Pointer to a cwbDB_ConnectionHandle where the handle of the connection
will be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbCO_SysHandle sysHandle - input
Handle to a system object.
cwbDB_ConnectionHandle *connection - output
Pointer to a cwbDB_ConnectionHandle where the handle of the connection
will be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
cwbDB_FormatHandle *format - output
Pointer to a cwbDB_FormatHandle where the handle of the data format will
be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_DataHandle *dataHandle - output
Pointer to a cwbDB_DataHandle where the handle of a data object will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwb_Boolean copyDataIndicator - input
Boolean value that indicates whether the data from the base file is to be copied
into the duplicate file.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
This API is not valid for List or SQL requests. The cwbDB_CreateDuplicateFile
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to the connection which will be used when servicing the request.
cwbDB_RequestHandle *request - output
Pointer to a cwbDB_RequestHandle where the handle of the Request will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandleAPI. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The
cwbDB_CreatePackage API should be called after setting the desired values in the
request. This API will result in a request datastream flowing to the AS/400 server
and if requested, a response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
cwbDB_FormatHandle *format - output
Pointer to a cwbDB_FormatHandle where the handle of the parameter marker
format will be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandleAPI. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The
cwbDB_CreateSourcePhysicalFile API should be called after setting the desired
values in the request. This API will result in a request datastream flowing to the
AS/400 server and if requested, a response to the request flowing back to the
client.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to the connection which will be used when servicing the request.
cwbDB_RequestHandle *request - output
Pointer to a cwbDB_RequestHandle where the handle of the Request will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_DataHandle dataHandle - input
Handle to a data object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The cwbDB_DeleteFile API
should be called after setting the desired values in the request. This API will result
in a request datastream flowing to the AS/400 server and if requested, a response
to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The
cwbDB_DeletePackage API should be called after setting the desired values in the
request. This API will result in a request datastream flowing to the AS/400 server
and if requested, a response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a parameter marker format object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Describe
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Describe
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Purpose: This API will prepare a select statement, open a cursor and fetch all
resulting data. The row data will be returned to the application in blocks, the size
of which will be optimized for the communication mechanism. To get additional
blocks, use the cwbDB_MoreStreamData API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *statementText - input
Pointer to an ASCIIZ string containing select text.
cwbDB_DataHandle data - input
Handle to a data object into which the returned data will be placed.
cwbDB_DataHandle indicators - input
Handle to a data object into which the returned data indicators will be placed.
There is one indicator value for each column value of each row of data that is
returned from the AS/400. The indicator will be a negative number if the value
for the column is NULL. If an error occurs while converting the data, a
character ’E’ will be placed in that column’s indicator field.
cwbDB_FormatHandle formatHandle - input
Handle to a data format that contains a description of the returned data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Cancel the stream fetch operation before all the data has been returned.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Execute
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The
cwbDB_ExecuteImmediate API should be called after setting the desired values in
the request. This API will result in a request datastream flowing to the AS/400
server and if requested, a response to the request flowing back to the client.
Purpose: This API will perform a stream fetch (see previous API) for a statement
that is already prepared in an SQL package.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *libraryName - input
Pointer to an ASCIIZ string containing library name.
char *packageName - input
Pointer to an ASCIIZ string containing package name.
char *statementName - input
Pointer to an ASCIIZ string containing statement name.
cwbDB_DataHandle data - input
Handle to a data object into which the returned data will be placed.
cwbDB_DataHandle indicators - input
Handle to a data object into which the returned data indicators will be placed.
There is one indicator value for each column value of each row of data that is
returned from the AS/400. The indicator will be a negative number if the value
for the column is NULL. If an error occurs while converting the data, a
character ’E’ will be placed in that column’s indicator field.
cwbDB_FormatHandle formatHandle - input
Handle to a data format that contains a description of the returned data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Fetch API
should be called after setting the desired values in the request. This API will result
in a request datastream flowing to the AS/400 server and if requested, a response
to the request flowing back to the client. Please note that fetched data will not be
returned unless the data is requested (using the cwbDB_ReturnData API).
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Purpose: Returns the Coded Character Set Identifier (CCSID) for a specified
column of data.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long columnPosition - input
Specifies the relative position of the column.
unsigned short *dataCCSID - output
Pointer to a short integer to contain the CCSID for the specified column.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Purpose: Returns the number of columns of data that are described by the data
format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long *columnCount - output
Pointer to an unsined long integer which will contain the column count.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Returns the length (in bytes) of the data for a specified column.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long columnPosition - input
Specifies the relative position of the column.
unsigned long *dataLength - output
Pointer to short integer to contain the data length.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Purpose: Returns the column name (if it exists) for a column of data.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long columnPosition - input
Specifies the relative position of the column.
cwbDB_DataHandle columnHandle - input
handle to a data object which will contain the column name
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long columnPosition - input
Specifies the relative position of the column.
unsigned short *dataPrecision - output
Pointer to short integer to contain the data precision.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long columnPosition - input
Specifies the relative position of the column.
unsigned short *dataScale - output
Pointer to short integer to contain the data scale.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long columnPosition - input
Specifies the relative position of the column.
signed short *dataType - output
Short integer which will contain the data type.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
If the system information is requested, the type returned is the SQL type. If the
local information is requested, see the defined values:
CWBDB_PCNOCONVERSION
CWBDB_PCSTRING
CWBDB_PCLONG
CWBDB_PCSHORT
CWBDB_PCFLOAT
CWBDB_PCDOUBLE
CWBDB_PCPACKED
CWBDB_PCZONED
CWBDB_PCINVALIDTYPE
CWBDB_PCVARSTRING
CWBDB_PCGRAPHIC
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short *commitmentLevel - output
Pointer to an unsigned short where the current value will be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
CWBDB_NONE
CWBDB_CURSOR_STABILITY
CWBDB_CHANGE
CWBDB_ALL
Purpose: Gets the indicator that says whether data is to be converted between the
client and host format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
cwb_Boolean *conversionIndicator - output
CWB_FALSE indicates that no conversion CWB_TRUE indicates conversion
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Get the requested data from the host. This data can include the selected
data, data format, host return code, and SQLCA.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_GetData API should be called after requesting the desired
data (using the cwbDB_Return* APIs). This API will result in a request datastream
flowing to the AS/400 server and if requested, a response to the request flowing
back to the client.
Syntax:
Parameters:
cwbDB_DataHandle dataHandle - input
Handle to a data object.
unsigned long *dataLength - output
Unsigned long integer to contain the length of the data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_DataHandle dataHandle - input
Handle to a data object.
char **data - output
Pointer to pointer to the data buffer.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Get the current date format. See cwbDB_SetDateFormat for additional
information about date formats.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short *dateFormat - output
Pointer to an unsigned short where the current date format value will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
Format name Date format constant Value
--------------- --------------------- ------
Julian CWBDB_DATE_FMT_JUL 0
month day year CWBDB_DATE_FMT_MDY 1
day month year CWBDB_DATE_FMT_DMY 2
year month day CWBDB_DATE_FMT_YMD 3
USA CWBDB_DATE_FMT_USA 4
ISO CWBDB_DATE_FMT_ISO 5
IBM Japan CWBDB_DATE_FMT_JIS 6
IBM Europe CWBDB_DATE_FMT_EUR 7
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short *dateSeparator - output
Pointer to an unsigned short where the current date data separator value will
be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
Date separator Date separator constant
--------------- ------------------------
Slash CWBDB_DATE_SEP_SLASH
Dash CWBDB_DATE_SEP_DASH
Period CWBDB_DATE_SEP_PERIOD
Comma CWBDB_DATE_SEP_COMMA
Blank CWBDB_DATE_SEP_BLANK
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short *decimalSeparator - output
Pointer to an unsigned short where the current decimal separator value will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
Time separator Time separator constant
--------------- ------------------------
Period CWBDB_DECIMAL_SEP_PERIOD
Comma CWBDB_DECIMAL_SEP_COMMA
Purpose: Get the current setting for the decimal data error indicator.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short *ignoreDecimalError - output
Pointer to an unsigned short where the current value will be returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value returned will be one of the following:
CWBDB_IGNORE_ERROR
CWBDB_CORRECT_ERROR
Purpose: Get the naming convention (SQL or native AS/400) that is in effect for
the specified connection.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short *namingConvention - output
Pointer to an unsigned short where the current naming convention will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
CWBDB_PERIOD_NAME_CONV
CWBDB_SLASH_NAME_CONV
Purpose: Returns the Coded Character Set Identifier (CCSID) for a specified
parameter.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
unsigned short *dataCCSID - output
Pointer to a short integer to contain the CCSID for the specified parameter.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Purpose: Returns the number of parameters that are described by the data format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long *parameterCount - output
Pointer to an unsined long integer which will contain the parameter count.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Returns the length (in bytes) of the data for a specified parameter.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
unsigned long *dataLength - output
Pointer to short integer to contain the data length.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
unsigned short *dataPrecision - output
Pointer to short integer to contain the data precision.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
unsigned short *dataScale - output
Pointer to short integer to contain the data scale.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
signed short *dataType - output
Short integer which will contain the data type.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
If the system information is requested, the type returned is the SQL type. If the
local information is requested, see the defined values:
CWBDB_PCNOCONVERSION
CWBDB_PCSTRING
CWBDB_PCLONG
CWBDB_PCSHORT
CWBDB_PCFLOAT
CWBDB_PCDOUBLE
CWBDB_PCPACKED
CWBDB_PCZONED
CWBDB_PCINVALIDTYPE
CWBDB_PCVARSTRING
CWBDB_PCGRAPHIC
Purpose: Returns the size (in bytes) of the data described by the data format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long *rowSize - output
Pointer to an unsigned long integer which will contain the row size.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
char * serverFunctionalLevel - output
Pointer to buffer 11 characters long to receive the server’s functional level.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data.
Purpose: Returns the size (in bytes) of the input data described by parameter
marker format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a parameter marker format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long *inputSize - output
Pointer to an unsigned long integer which will contain the row size.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Purpose: Returns the size (in bytes) of the output data described by parameter
marker format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a parameter marker format object.
unsigned long location - input
Indicates whether the system or local information is to be returned.
unsigned long *outputSize - output
Pointer to an unsigned long integer which will contain the row size.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandleAPI. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the location parameter, use one of the defined values:
CWBDB_SYSTEM
CWBDB_LOCAL
Purpose: Get the current time format. See cwbDB_SetTimeFormat for additional
information about time formats.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short *timeFormat - output
Pointer to an unsigned short where the current time format value will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
Format name Time format constant
--------------- -----------------------
Hours minutes seconds CWBDB_TIME_FMT_HMS
USA CWBDB_TIME_FMT_USA
ISO CWBDB_TIME_FMT_ISO
IBM Europe CWBDB_TIME_FMT_EUR
IBM Japan CWBDB_TIME_FMT_JIS
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short *timeSeparator - output
Pointer to an unsigned short where the current time separator value will be
returned.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_StartServer API must be called before this API can return
valid data. The value that is returned will be one of the following:
Time separator Time separator constant
--------------- ------------------------
Colon CWBDB_TIME_SEP_COLON
Period CWBDB_TIME_SEP_PERIOD
Comma CWBDB_TIME_SEP_COMMA
Blank CWBDB_TIME_SEP_BLANK
Purpose: Returns a Boolean value indicating whether the parameter is input only.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a parameter marker format object.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
cwb_Boolean *parameterIsInput - output
Pointer to a Boolean indicating if the parameter is input only.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Returns a Boolean value indicating whether the parameter is input and
output.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a parameter marker format object.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
cwb_Boolean *parameterIsInputOutput - output
Pointer to a Boolean indicating if the parameter is input and output.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: This API will get the next block of stream fetch data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbDB_DataHandle data - input
Handle to a data object into which the returned data will be placed.
cwbDB_DataHandle indicators - input
Handle to a data object into which the returned data indicators will be placed.
There is one indicator value for each column value of each row of data that is
returned from the AS/400. The indicator will be a negative number if the value
for the column is NULL. If an error occurs while converting the data, a
character ’E’ will be placed in that column’s indicator field.
cwbDB_FormatHandle formatHandle - input
Handle to a data format that contains a description of the returned data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned char openOptions - input
Input value for open options indicator.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
This API is not valid for NDB or catalog requests. The cwbDB_Open API should
be called after setting the desired values in the request. This API will result in a
request datastream flowing to the AS/400 server and if requested, a response to
the request flowing back to the client.
Purpose: This API combines the open, describe and fetch operations. This
combined function is valuable when the statement is already prepared (extended
dynamic SQL).
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned char openOptions - input
Input value for open options indicator.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The cwbDB_OverRideFile
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Purpose: Prepares an SQL statement. If an SQL package has been set, this API will
prepare a statement into the package.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Prepare
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Purpose: This API combines the prepare and describe operations. The advantage of
using this API is that the SQL component is called only once.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The
cwbDB_PrepareDescribe API should be called after setting the desired values in
the request. This API will result in a request datastream flowing to the AS/400
server and if requested, a response to the request flowing back to the client.
Purpose: This API combines the prepare, describe, open, and fetch operations. By
combining these operations, performance will improve because only one call is
made to the SQL component on the host.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned char openOptions - input
Input value for open options indicator.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The cwbDB_RemoveMember
API should be called after setting the desired values in the request. This API will
result in a request datastream flowing to the AS/400 server and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The
cwbDB_RemoveOverRide API should be called after setting the desired values in
the request. This API will result in a request datastream flowing to the AS/400
server and if requested, a response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the fields.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveFieldInformation( requestHandle,
CWBDB_GET_FLD_FILE |
CWBDB_GET_FLD_NAME |
CWBDB_GET_FLD_DATA_TYPE |
CWBDB_GET_FLD_PREC |
CWBDB_GET_FLD_SCALE,
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the files.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveFileInformation( requestHandle,
CWBDB_GET_FILE_NAME |
CWBDB_GET_FILE_ATTRIB |
CWBDB_GET_FILE_DESC |
CWBDB_GET_FILE_COL_CNT |
CWBDB_GET_FILE_AUTH,
errorHandle );
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for foreign keys.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrievePrimaryKeyInformation( requestHandle,
CWBDB_GET_FG_PRKEY_LIB |
CWBDB_GET_FG_PRKEY_FILE |
CWBDB_GET_FG_PRKEY_COL_ID |
CWBDB_GET_FG_KEY_LIB |
CWBDB_GET_FG_KEY_FILE |
CWBDB_GET_FG_KEY_COL_ID |
CWBDB_GET_FG_KEY_SEQ |
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the indices.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveIndexInformation( requestHandle,
CWBDB_GET_IDX_TBL_NAME |
CWBDB_GET_IDX_UNIQUE |
CWBDB_GET_IDX_IDX_LIB |
CWBDB_GET_IDX_IDX_NAME |
CWBDB_GET_IDX_COL_CNT, errorHandle );
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the libraries.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveLibraryInformation( requestHandle,
CWBDB_GET_LIBRARY_NAME |
CWBDB_GET_LIBRARY_DESC, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the members.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveMemberInformation( requestHandle,
CWBDB_GET_MBR_LIB |
CWBDB_GET_MBR_FILE |
CWBDB_GET_MBR_NAME |
CWBDB_GET_MBR_DESC, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the SQL
statements.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrievePackageStatementInformation( requestHandle,
CWBDB_GET_SQLSTMT_NAME |
CWBDB_GET_SQLSTMT_TYPE |
CWBDB_GET_SQLSTMT_TEXT, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for primary keys.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrievePrimaryKeyInformation( requestHandle,
CWBDB_GET_PR_KEY_LIB |
CWBDB_GET_PR_KEY_FILE |
CWBDB_GET_PR_KEY_COL_ID |
CWBDB_GET_PR_KEY_COL_SEQ, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the relational
database.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveRDBInformation( requestHandle,
CWBDB_GET_RDB_NAME |
CWBDB_GET_RDB_RMTLOC |
CWBDB_GET_RDB_RMTNET |
CWBDB_GET_RDB_TPNAME |
CWBDB_GET_RDB_DESC, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Purpose: Get information about the record formats for an AS/400 file.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the record
formats.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveRecordFormatInformation( requestHandle,
CWBDB_GET_FMT_LIB |
CWBDB_GET_FMT_FILE |
CWBDB_GET_FMT_NAME |
CWBDB_GET_FMT_REC_LEN |
CWBDB_GET_FMT_DESC, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the columns.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveSpecialColumnInformation( requestHandle,
CWBDB_GET_SP_COL_LIB |
CWBDB_GET_SP_COL_TABLE |
CWBDB_GET_SP_COL_COL_NAME |
CWBDB_GET_SP_COL_DATA_TYPE |
CWBDB_GET_SP_COL_PRECISION |
CWBDB_GET_SP_COL_LENGTH |
CWBDB_GET_SP_COL_SCALE, errorHandle );
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long retrieveInformation - input
Bitmap that indicates what information is to be retrieved for the SQL packages.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
rc = cwbDB_RetrieveSQLPackageInformation( requestHandle,
CWBDB_GET_SQLPKG_LIB |
CWBDB_GET_SQLPKG_NAME |
CWBDB_GET_SQLPKG_DESC, errorHandle );
A call to the cwbDB_ReturnData API is needed prior to calling this API if the
application is to process the data immediately. If the application is to operate
asynchronously, then the call to cwbDB_ReturnData and subsequently
cwbDB_GetData are needed after this API in order to get the data that result from
this API call. Once the data is returned, information in the data format handle is
used to determine how to parse the data.
Purpose: Instructs the API to return the data that is in the result set for the
operation.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbDB_DataHandle data - input
Handle for the data being returned. This address is returned when the data is
received from the AS/400 on completion of a function request.
cwbDB_DataHandle indicators - input
Handle which will be used to return the address of the null value/error
indicators being returned. There is one indicator value for each column value
that is to be returned (for each column of each row) The indicator will be a
negative number if the value for the column is NULL. If an error occurs while
converting the data, a character ’E’ will be placed in that columns indicator
field. This address is returned when the data is received from the AS/400 on
completion of a function request.
cwbDB_FormatHandle formatHandle - input
Handle to a data format that contains a description of the returned data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Instructs the API to return the format of the data to be returned.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbDB_FormatHandle formatHandle - input
Handle to a data format that contains a description of the returned data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Instructs the API to return host error information when a function is
performed on the host server.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short *hostErrorClass - input
Pointer to location where the error class will be returned. This class indicates
which database server module encountered an error.
v 0 - no error
v 1 - SQL functional error
v 2 - SQL parameter error
v 3 - List functional error
v 4 - List parameter error
v 5 - NDB functional error
v 6 - NDB parameter error
v 7 - General server error
v 8 - User exit error
signed long *hostErrorCode - input
Pointer to location where the return code from the server module will be
placed.
cwbDB_DataHandle hostMsgID - input
Handle to a data object that will contain the host message identifier. If this
parameter is set to 0, the host message identifier will not be retrieved.
cwbDB_DataHandle firstLevelMessageText - input
Handle to a data object that will contain the host first level message text. If this
parameter is set to 0, the first level message text will not be retrieved.
cwbDB_DataHandle secondLevelMessageText - input
Handle to a data object that will contain the host second level message text. If
this parameter is set to 0, the second level message text will not be retrieved.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Instructs the API to return the format of the parameter marker data for
an SQL statement.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbDB_FormatHandle formatHandle - input
Handle to a parameter marker format that will contain the description of
parameter data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Instructs the API to return the SQL Communication Area (SQLCA).
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
struct cwbDB_SQLCA *sqlca - input
Pointer to a structure that will contain SQLCA returned from the host.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or catalog requests. The cwbDB_Rollback
API should be called after setting the desired values in the request. This API
results in a request datastream flowing to the AS/400 server, and if requested, a
response to the request flowing back to the client.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
const char *addLibraryName - input
The name of the library to be added to the library list.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The cwbDB_AddLibrary API should be called after calling this API. The
cwbDB_SetAddLibraryPosition API may be called before or after this API is
called, but before cwbDB_AddLibrary is called. This API is not valid for List or
SQL requests.
Purpose: Sets the position at which to add a library to the library list via the
cwbDB_AddLibraryToList API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
const unsigned short position - input
The position in the library list to add the library name set via
cwbDB_SetAddLibraryName. Use one of the following defined constants:
DB_ADD_LIBRARY_TO_FRONT - Add library to front of list
DB_ADD_LIBRARY_TO_END - Add library to end of list
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for List or SQL requests. The cwbDB_AddLibrary
API should be called after calling this API.
Purpose: Set the public authority for a file that will be created through the API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short authority - input
Long integer that indicates the public authority for a newly created file.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the name of a base file for creating a new file with the same format
through the API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *baseLibraryName - input
Pointer to an ASCIIZ string that contains the base library name to be used
when creating a new file.
char *baseFileName - input
Pointer to an ASCIIZ string that contains the base file name to be used when
creating a new file.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the number of rows to be blocked together when fetching data.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long blockCount - input
Input value for block count.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Sets the information for a column description for string data.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long columnPosition - input
Specifies the relative position of the column.
signed short columnType - input
Specifies the numeric type to be used.
unsigned long columnLength - input
Only used if the type is zoned or packed decimal
unsigned short columnPrecision - input
Only used if the type is zoned or packed decimal
unsigned short columnScale - input
Only used if the type is zoned or packed decimal
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the columnType parameter, use one of the defined values:
CWBDB_PCLONG
CWBDB_PCSHORT
CWBDB_PCFLOAT
CWBDB_PCDOUBLE
CWBDB_PCPACKED
CWBDB_PCZONED
Purpose: Sets the information for a column description for string data.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long columnPosition - input
Specifies the relative position of the column.
signed short columnType - input
Specifies the string type to be used.
unsigned long columnLength - input
Specifies the column length to be used.
unsigned short columnCCSID - input
Specifies the column CCSID (Coded Character Set Identifier) to be used.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the columnType parameter, use one of the defined values:
CWBDB_PCSTRING
CWBDB_PCVARSTRING
CWBDB_PCGRAPHIC
CWBDB_PCVARGRAPHIC
Purpose: Sets the CCSID (Coded Character Set ID) for the client. The new CCSID
value will be used when converting EBCDIC data from the AS/400. Use
cwbDB_SetClientHostErrorCCSID to set the CCSID used when converting host
error information.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short clientCCSID - input
Specifies the CCSID (Coded Character Set Identifier to be used.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be called any time after a connection handle has been
created.
Purpose: Sets the CCSID (Coded Character Set Identifier) for data being input such
as file names, SQL statement text, and so on. The new CCSID value will be used
when converting EBCDIC data from the AS/400. Use
cwbDB_SetClientHostErrorCCSID to set the CCSID used when converting host
error information.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short inputCCSID - input
Specifies the CCSID to be used.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be called any time after a connection handle has been
created.
Purpose: Sets the CCSID (Coded Character Set ID) for the client. The new CCSID
value will be used when converting EBCDIC server messages. Use
cwbDB_SetClientDataCCSID to change the CCSID used for converting data.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short clientHostErrorCCSID - input
Specifies the CCSID (Coded Character Set Identifier to be used.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be called any time after a connection handle has been
created.
Purpose: Sets the information for a parameter description for string data.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
signed short parameterType - input
Specifies the numeric type to be used.
unsigned long parameterLength - input
Only used if the type is zoned or packed decimal
unsigned short parameterPrecision - input
Only used if the type is zoned or packed decimal
unsigned short parameterScale - input
Only used if the type is zoned or packed decimal
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the parameterType parameter, use one of the defined values:
CWBDB_PCLONG
CWBDB_PCSHORT
CWBDB_PCFLOAT
CWBDB_PCDOUBLE
CWBDB_PCPACKED
CWBDB_PCZONED
Purpose: Sets the information for a parameter description for string data.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
unsigned long parameterPosition - input
Specifies the relative position of the parameter.
signed short parameterType - input
Specifies the string type to be used.
unsigned long parameterLength - input
Specifies the parameter length to be used.
unsigned short parameterCCSID - input
Specifies the parameter CCSID (Coded Character Set Identifier) to be used.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For the parameterType parameter, use one of the defined values:
CWBDB_PCSTRING
CWBDB_PCVARSTRING
CWBDB_PCGRAPHIC
CWBDB_PCVARGRAPHIC
Purpose: Set the commitment level for the database server to use when accessing
data.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short commitmentLevel - input
Indicates the commitment level for server operations.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Sets the indicator that says whether data is to be converted between the
client and host format.
Syntax:
Parameters:
cwbDB_FormatHandle format - input
Handle to a data format object.
cwb_Boolean conversionIndicator - input
CWB_FALSE indicates no conversion. CWB_TRUE indicates conversion.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Sets the indicator that says whether data marked with CCSID 65535 is to
be converted between ASCII and EBCDIC. Data tagged with CCSID 65535 are
binary data. Selecting to convert this this data may cause conversion errors and
possible data integrity problems. USE THIS API AT YOUR OWN RISK. Having
stated that, it is important to note that some older data may have text data tagged
with CCSID 65535. Also, some AS/400 tools still write data to files using CCSID
65535. Therefore, there may be appropriate times to use this API.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to a connection object.
ccwb_Boolean convert65535indicator - input
CWB_FALSE indicates no conversion of binary data. CWB_TRUE indicates
conversion of data will take place.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *cursorName - input
Pointer to an ASCIIZ string containing the cursor name being used for an SQL
request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the format for date data returned from the AS/400. Date data on the
AS/400 are stored encoded and are returned to the client as character strings.
These character strings can be formatted in eight different ways:
Format name Format Example
--------------- ---------- ---------------
Julian yy/ddd 87/253
month day year mm/dd/yy 10/12/87
day month year dd/mm/yy 12/10/87
year month day yy/mm/dd 87/10/12
USA mm/dd/yyyy 10/12/1987
ISO yyyy-mm-dd 1987-10-12
IBM Japan yyyy-mm-dd 1987-10-12
IBM Europe dd.mm.yyyy 12.10.1987
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short dateFormat - input
Indicates the format of date data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: It is not valid to call this API after calling the cwbDB_StartServer API. Use
one of the defined values:
Format name Date format constant Value
--------------- -------------------- ------
Julian CWBDB_DATE_FMT_JUL 0
month day year CWBDB_DATE_FMT_MDY 1
day month year CWBDB_DATE_FMT_DMY 2
year month day CWBDB_DATE_FMT_YMD 3
USA CWBDB_DATE_FMT_USA 4
ISO CWBDB_DATE_FMT_ISO 5
IBM Japan CWBDB_DATE_FMT_JIS 6
IBM Europe CWBDB_DATE_FMT_EUR 7
Purpose: Set the character which separates the elements of date data returned from
the AS/400. Date data on the AS/400 are stored encoded and are returned to the
client as character strings. These character strings can have one of five different
date separator characters:
Date separator Character Example
--------------- ---------- ---------------
Slash / 03/17/94
Dash - 03-17-94
Period . 03.17.94
Comma , 03,17,94
Blank 03 17 94
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short dateSeparator - input
Indicates the separator character for date fields.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: It is not valid to call this API after calling the cwbDB_StartServer API. Use
one of the defined values:
Date separator Date separator constant
--------------- -----------------------
Slash CWBDB_DATE_SEP_SLASH
Dash CWBDB_DATE_SEP_DASH
Period CWBDB_DATE_SEP_PERIOD
Comma CWBDB_DATE_SEP_COMMA
Blank CWBDB_DATE_SEP_BLANK
Purpose: Set the character which separates the elements of decimal data returned
from the AS/400.
Decimal separator Character Example
----------------- ---------- ---------------
Period . 123.45
Comma , 123,45
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short decimalSeparator - input
Indicates the desired decimal separator character.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: It is not valid to call this API after calling the cwbDB_StartServer API. Use
one of the defined values:
Time separator Time separator constant
--------------- --------------------------
Period CWBDB_DECIMAL_SEP_PERIOD
Comma CWBDB_DECIMAL_SEP_COMMA
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short describeOption - input
Long integer specifying the type of data to be returned on a describe
operation.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short scrollType - input
Indicates type of scrolling to be performed.
unsigned long relativeDistance - input
If the scrollType indicates scrolling relative to the current cursor position, this
parameter indicates the relative distance. For other scrollType values, this
parameter is ignored.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *fieldName - input
Pointer to an ASCIIZ string containing the field name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is not valid for NDB or SQL requests.
Purpose: Set the file attributes to be used as a qualifier for a list request.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short fileAttributes - input
Long integer that indicates attributes of files to be retrieved for a catalog
request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call. Use one of the
defined values:
CWBDB_ALL_FILES_ATTRIBUTES
CWBDB_PHYSICAL_FILES_ATTRIBUTES
CWBDB_LOGICAL_FILES_ATTRIBUTES
CWBDB_ODBC_TABLES_ATTRIBUTES
CWBDB_ODBC_VIEWS_ATTRIBUTES
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long infoOrdering - input
Long integer that indicates how the returned information is to be ordered.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call. Use one of the
defined values:
CWBDB_DEFAULT_CATALOG_ORDERING
CWBDB_ODBC_TABLE_ORDERING
CWBDB_ODBC_TABLE_PRIVILEGE_ORDER
Purpose: Set the file name to be used as a qualifier for a list request. This is the
short file name (system name).
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *fileName - input
Pointer to an ASCIIZ string containing the file name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call. This API is
not valid for SQL requests.
Purpose: Set the text description for a file that will be created through the API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *fileText - input
Pointer to an ASCIIZ string that contains the text description to be used when
creating a file.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the file type to be used as a qualifier for a list request.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short fileAttribute - input
Long integer that indicates type of files to be retrieved for a catalog request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call. Use one of the
defined values:
CWBDB_ALL_FILES
CWBDB_SOURCE_FILES
CWBDB_DATA_FILES
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *fileName - input
Pointer to an ASCIIZ string containing the foreign key file name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is not valid for NDB or SQL requests.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *libName - input
Pointer to an ASCIIZ string containing the foreign key library name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is not valid for NDB or SQL requests.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *formatName - input
Pointer to an ASCIIZ string containing the record format name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is not valid for NDB or SQL requests.
Purpose: This API instructs SQL how to treat active statements (open cursors and
prepared dynamic SQL statements) when a commit or rollback operation is
performed. CWBDB_HOLD indicates that open cursors and prepared dynamic SQL
statements will be preserved. CWBDB_WORK will cause open cursors to be closed
and prepared dynamic SQL statement to be destroyed.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short holdIndicator - input
Input value for hold indicator.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set an indicator that says whether to ignore or correct zoned decimal
data errors.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short ignoreDecimalError - input
Indicates how decimal data errors will be treated.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short indexType - input
Long integer that indicates index rule to be retrieved for a catalog request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. Use one of the defined values:
CWBDB_UNIQUE_INDEX
CWBDB_DUPLICATE_INDEX
CWBDB_DUP_NULL_INDEX
Purpose: Set the library name to be used for the current database request.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *libraryName - input
Pointer to an ASCIIZ string containing the library name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: For SQL requests, this is the library that is used when locating an SQL
package to be used for stored statements. For List and Native Database requests,
this is the library containing objects on which to be operated.
Purpose: Set the long file name to be used as a qualifier for a list request.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *longFileName - input
Pointer to an ASCIIZ string containing the long file name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call. This API is
not valid for NDB or SQL requests.
Purpose: Set the maximum number of members for creating a file through the API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
signed short maxMembers - input
Input value for maximum number of members. A value of -1 for this
parameter indicates no maximum.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *memberName - input
Pointer to an ASCIIZ string containing the member name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is also used for NDB requests when operating on a database file
member. This API is not valid for SQL requests.
Purpose: Set the text description for a member at will be added through the API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *memberText - input
Pointer to an ASCIIZ string that contains the text description to be used when
adding a member.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the naming convention (SQL or AS/400 system) to be used by the
database access server.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server
unsigned short newNamingConvention - input
Indicates the type of naming convention to use. SQL naming convention
(library.table) or AS/400 native naming convention (library/table).
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Sets the National Language Sort Sequence (NLSS) attribute of the Data
Access server.
Syntax:
Parameters:
cwbDB_ConnectionHandle - input
Connection through which the attribute is to be set
unsigned short NLSSTypeID - input
The type of NLSS attribute. Possible values:
CWBDB_NLSS_SORT_HEX
CWBDB_NLSS_SORT_SHARED
CWBDB_NLSS_SORT_UNIQUE
CWBDB_NLSS_SORT_USER
char *tableOrLangID - input
Depends on value of the NLSSType parameter (above).
CWBDB_NLSS_SORT_HEX
This parameter is not used
CWBDB_NLSS_SORT_SHARED or CWBDB_NLSS_SORT_UNIQUE
This parameter represents the language feature code attribute ID for
the server. It is a required parameter.
CWBDB_NLSS_SORT_USER
This parameter represents the NLSS table name attribute. It is a
required parameter.
char *library - input
Depends on value of the NLSSType parameter (above).
CWBDB_NLSS_SORT_HEX
This parameter is not used.
CWBDB_NLSS_SORT_SHARED or CWBDB_NLSS_SORT_UNIQUE
This parameter is not used
CWBDB_NLSS_SORT_USER
This parameter represents the NLSS library name attribute. It is an
optional parameter.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextAPI. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short nullableInd - input
Integer that indicates whether special column is null capable.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call. Use one of the
defined values:
CWBDB_NOT_NULLABLE
CWBDB_NULLABLE
Purpose: Set the overriding library, file, and member for an override database
operation.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *overrideLibraryName - input
Pointer to an ASCIIZ string that contains the overriding library name.
char *baseFileName - input
Pointer to an ASCIIZ string that contains the overriding file name.
char *overrideMemberName - input
Pointer to an ASCIIZ string that contains the overriding member name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is used in preparation for cwbDB_OverrideFile. This API is not
valid for List or SQL requests.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *packageName - input
Pointer to an ASCIIZ string containing the SQL package name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Provides the data to be used for the parameter markers contained in a
prepared statement for a block of rows.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long numberOfRows - input
Number of sets of parameter marker data that is in the dataBuffer.
cwbDB_FormatHandle format - input
Handle to the format of the data being provided.
void *dataBuffer - input
Pointer to a buffer containing the data to be used for the parameter markers.
signed short *indicators - input
Pointer to a buffer containing the null indicators. If the value of the indicator is
less than zero, the value for the corresponding parameter marker is null.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Provides the data to be used for the parameter markers contained in a
prepared statement.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbDB_FormatHandle *format - input
Handle to the format of the data being provided.
void *dataBuffer - input
Pointer to a buffer containing the data to be used for the parameter markers.
signed short *indicators - input
Pointer to a buffer containing the null indicators. If the value of the indicator is
less than zero, the value for the corresponding parameter marker is null.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the option for doing a normal or enhanced prepare. Doing an
enhanced prepare will search the specified SQL package for the given statement. If
it is found, the statement will be used. If not, the statement will be prepared.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short prepareOption - input
Long integer specifying the type of prepare to be performed.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *fileName - input
Pointer to an ASCIIZ string containing the primary key file name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is not valid for NDB or SQL requests.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *libName - input
Pointer to an ASCIIZ string containing the primary key library name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API may be used prior to a cwbDB_Retrieve* API call for a catalog
request. This API is not valid for NDB or SQL requests.
Purpose: Set the Relational Database (RDB) name for a catalog request. This is the
RDB for which information is being requested.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *RDBName - input
Pointer to an ASCIIZ string containing the RDB name.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the record length in preparation for creating a file through the API.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned long recordLength - input
Length of records to be contained in the file to be created.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short scrollIndicator - input
Input value for scroll indicator.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *statementName - input
Pointer to an ASCIIZ string containing the statement name being used for an
SQL request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
char *statementText - input
Pointer to an ASCIIZ string containing the statement text being used for an
SQL request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the type of SQL statement for which information is being requested.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short statementType - input
Long integer that indicates type of SQL statement being used for a catalog
request.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Purpose: Set the number of 32Kb blocks sent from the server to the client during a
stream fetch before a synchronizing handshake is required.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
unsigned short syncCount - input
Unsigned short integer that indicates how many 32Kb flows from the server
will happen before a synchronizing handshake will happen.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is not valid for NDB or Catalog requests. This API must be called
before the cwbDB_DynamicStreamFetch or the
cwbDB_ExtendedDynamicStreamFetch API is called.
Purpose: Set the format for time data returned from the AS/400. Time data on the
AS/400 are stored encoded and are returned to the client as character strings.
These character strings can be formatted in five different ways:
Format name Format Example
--------------- ---------- ---------------
Hours minutes seconds hh:mm:ss 13:30:05
USA hh:mm AM or PM 1:30 PM
ISO hh.mm.ss 13:30:05
IBM Europe hh.mm.ss 13:30:05
IBM Japan hh:mm:ss 13:30:05
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short timeFormat - input
Indicates the format of time data.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: It is not valid to call this API after calling the cwbDB_StartServer API. Use
one of the defined values:
Format name Time format constant
--------------- -----------------------
Hours minutes seconds CWBDB_TIME_FMT_HMS
USA CWBDB_TIME_FMT_USA
ISO CWBDB_TIME_FMT_ISO
IBM Europe CWBDB_TIME_FMT_EUR
IBM Japan CWBDB_TIME_FMT_JIS
Purpose: Set the character which separates the elements of time data returned from
the AS/400. Time data on the AS/400 are stored encoded and are returned to the
client as character strings. These character strings can have one of four different
time separator characters:
Date separator Character Example
--------------- ---------- ---------------
Colon : 11:10:03
Period . 11.10.03
Comma , 11,10,03
Blank 11 10 03
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned short timeSeparator - input
Indicates the time data separator character.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: It is not valid to call this API after calling the cwbDB_StartServer API. Use
one of the defined values:
Time separator Time separator constant
--------------- -----------------------
Colon CWBDB_TIME_SEP_COLON
Period CWBDB_TIME_SEP_PERIOD
Comma CWBDB_TIME_SEP_COMMA
Blank CWBDB_TIME_SEP_BLANK
Purpose: Starts the communication between the client and the AS/400 server.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Starts the communication between the client and the AS/400 server.
Returns a more detailed return code than cwbDB_StartServer, but otherwise the
same.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
unsigned long *returnCode - output
Pointer to an unsigned long to receive the detailed return code.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None.
Purpose: Ends the communication between the client and the AS/400 server.
Syntax:
Parameters:
cwbDB_ConnectionHandle connection - input
Handle to connection to AS/400 database access server.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: None
Purpose: Sends the current parameters to the AS/400 to the stored by the database
access server. Those parameters can then be used by the request on subsequent
function calls.
Syntax:
Parameters:
cwbDB_RequestHandle request - input
Handle to a request object.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrievable.
Usage: This API is used to store a set of parameters in a buffer on the AS/400.
This is useful if there is a set of common parameters that are to be used for
multiple functions. The API allows the application to reduce the amount of data
that needs to flow in order to perform all of the requests.
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <limits.h>
if ( argc > 1 )
{
for( unsigned int i = 0; i<=strlen(argv[1]); i++ )
sys[i] = (char) toupper(argv[1][i]);
}
if ( argc > 2 )
{
block = atoi(argv[2]);
}
if ( argc > 3 )
{
limit = atoi(argv[3]);
}
scene18(sys, block, limit);
return;
}
cwbDB_FormatHandle myFmt;
cwbDB_ConnectionHandle Conn;
cwbSV_ErrHandle errorHandle;
cwbDB_RequestHandle SQLReq;
int count = 0;
if ( (infile = fopen("prftst.qry","r")) != NULL) {
while ( (ch = getc(infile)) != EOF &&; ch != '\n' &&; count < MAXSIZE ) {
statementText[count] = ch;
count++;
}
count++;
statementText[count] = '\n';
} else {
cout << "Need input query parameter in prftst.qry." << endl;
return;
}
cout << "Block Fetch with data conversion" << endl << endl;
cwbDB_CreateDataHandle(&myData,; errorHandle);
cwbDB_CreateDataHandle(&ind,; errorHandle);
cwbDB_CreateDataHandle(&first,; errorHandle);
cwbDB_CreateDataHandle(&sec,; errorHandle);
cwbSV_CreateErrHandle(&errorHandle);;
cwbDB_SetConversionIndicator(myFmt, 1, errorHandle);
cout << "Fetching a block of " << dec << blockSize << "." << endl;
break;
}
else
{
cout << "Fetch call ENDED." << endl;
rowCount+=blockSize;
cout << "Total rows fetched so far: "<< dec << rowCount << "." << endl << endl;
if (blockSize <= 10) {
char *theData = NULL;
char **pmyData = &theData;
unsigned long len;
cwbDB_GetDataPointer(myData, pmyData, errorHandle);
cwbDB_GetDataLength(myData, &len,; errorHandle);
cout << "Fetched data: " << endl;
cout.write( theData, len );
cout << endl;
}
}
} // end while
cwbDB_DeleteDataHandle(ind, errorHandle);
cwbDB_DeleteDataHandle(msgid, errorHandle);
cwbDB_DeleteDataHandle(first, errorHandle);
cwbDB_DeleteDataHandle(sec, errorHandle);
cwbDB_DeleteDataFormatHandle(myFmt, errorHandle);
cwbDB_DeleteConnectionHandle(Conn, errorHandle);
cwbDB_DeleteSQLRequestHandle(SQLReq, errorHandle);
cwbSV_DeleteErrHandle(errorHandle);
}
Express Toolkit:
The Client Access Express Toolkit provides Data Queues documentation,
access to the cwbdq.h header file, and links to sample programs. To access
this information, open the Express Toolkit and select Data Queues —>
C/C++ APIs.
Express Data Queues APIs topics:
v “Data queues” on page 470
Data queues
A data queue is a system object that exists on the AS/400 system.
Benefits of using data queues:
Data queues provide many benefits to PC developers and AS/400
applications developers, including:
v They are a fast and efficient means of communication on the AS/400.
v They have low system overhead and require very little setup.
v They are efficient because a single data queue can be used by a batch job
to service several interactive jobs.
v The contents of a data queue message are free-format (fields are not
required), providing flexibility that is not provided by other system
objects.
v Access data queues through an AS/400 API and through CL commands,
which provides a straight-forward means of developing client/server
applications.
Use the following AS/400 system interfaces to work with data queues:
OS/400 commands:
CRTDTAQ
Creates a data queue and stores it in a specified library
DLTDTAQ
Deletes the specified data queue from the system
OS/400 application programming interfaces:
Because this interface does not require communications programming, use it either
for synchronous or for asynchronous (disconnected) processing.
Objects
An application that uses the data queue function uses four objects. Each of these
objects is identified to the application through a handle. The objects are:
Queue object:
This object represents the AS/400 data queue.
Attribute:
This object describes the AS/400 data queue.
Data: Use these objects to write records to, and to read records from, the AS/400
data queue.
Read object:
Use this object only with the asynchronous read APIs. It uniquely identifies
a request to read a record from the AS/400 data queue. This handle is used
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
cwbDQ_Data data - input
The data object to be read from the AS/400 data queue.
signed long waitTime - input
Length of time in seconds to wait for data, if the data queue is empty. A wait
time of -1 indicates to wait forever.
cwbDQ_ReadHandle * readHandle - output
Pointer to where the cwbDQ_ReadHandle will be written. This handle will be
used in subsequent calls to the cwbDQ_CheckData API.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This function requires that you have previously issued the following APIs:
cwbDQ_Open or cwbDQ_OpenEx
cwbDQ_CreateData
Syntax:
Parameters:
cwbDQ_ReadHandle readHandle - input
The handle that was returned by the AsyncRead API.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This function requires that you have previously issued the following APIs:
cwbDQ_Open or cwbDQ_OpenEx
cwbDQ_CreateData
cwbDQ_AsyncRead
Syntax:
Parameters:
cwbDQ_ReadHandle readHandle - input
The handle that was returned by the AsyncRead API.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This function requires that you have previously issued the following APIs:
cwbDQ_Open or cwbDQ_OpenEx
cwbDQ_CreateData
cwbDQ_AsyncRead
If a time limit was specified on the AsyncRead, this API will return
CWBDQ_NO_DATA until data is returned (return code will be CWB_OK), or the
time limit expires (return code will be CWBDQ_TIMED_OUT).
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
unsigned char * key - input
Pointer to the key. The key may contain embedded NULLs, so it is not an
ASCIIZ string.
unsigned short keyLength - input
Length of the key in bytes.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open or
cwbDQ_OpenEx function. This identifies the AS/400 data queue object.
Usage: This function requires that you previously issued the following APIs:
cwbDQ_Openor cwbDQ_OpenEx
Syntax:
Parameters:
char * queue - input
Pointer to the data queue name contained in an ASCIIZ string.
char * library - input
Pointer to the library name contained in an ASCIIZ string. If this pointer is
NULL then the current library will be used (set library to ″*CURLIB″).
char * systemName - input
Pointer to the system name contained in an ASCIIZ string.
cwbDQ_Attr queueAttributes - input
Handle to the attributes for the data queue.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages are
retrieved.
Usage: This function requires that you have previously issued the following APIs:
cwbDQ_CreateAttr
cwbDQ_SetMaxRecLen
Syntax:
Parameters:
cwbCO_SysHandle sysHandle - input
Handle to a system object
const char * queue - input
Pointer to the data queue name contained in an ASCIIZ string.
const char * library - input
Pointer to the library name contained in an ASCIIZ string. If this pointer is
NULL then the current library will be used (set library to ″*CURLIB″).
cwbDQ_Attr queueAttributes - input
Handle to the attributes for the data queue.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This function requires that you have previously issued the following APIs:
cwbDQ_CreateSystem
cwbDQ_CreateAttr
cwbDQ_SetMaxRecLen
Syntax:
Parameters:
None
Usage: None
Syntax:
Parameters:
None
Usage: None
Syntax:
Parameters:
char * queue - input
Pointer to the data queue name contained in an ASCIIZ string.
char * library - input
Pointer to the library name contained in an ASCIIZ string. If this pointer is
NULL then the current library will be used (set library to ″*CURLIB″).
char * systemName - input
Pointer to the system name contained in an ASCIIZ string.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: None
Syntax:
Parameters:
cwbCO_SysHandle - input
Handle to a system object.
const char * queue - input
Pointer to the data queue name contained in an ASCIIZ string.
const char * library - input
Pointer to the library name contained in an ASCIIZ string. If this pointer is
NULL then the current library will be used (set library to ″*CURLIB″).
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned short * authority - output
Pointer to an unsigned short to where the authority will be written. This value
will be one of the following defined types:
CWBDQ_ALL
CWBDQ_EXCLUDE
CWBDQ_CHANGE
CWBDQ_USE
CWBDQ_LIBCRTAUT
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
cwb_Boolean * convert - output
Pointer to a Boolean where the convert flag will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * data - output
Pointer to the data. The data may contain embedded NULLs, so it is not an
ASCIIZ string.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * * data - output
Pointer to where the buffer address will be written.
Usage: Use this function to retrieve the address of the location where the data is
stored. The data address must be set with the cwbDQ_SetDataAddr API,
otherwise, the return code CWBDQ_ADDRESS_NOT_SET will be returned.
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned long * dataLength - output
Pointer to an unsigned long where the length of the data will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
char * description - output
Pointer to a 51 character buffer where the description will be written. The
description is an ASCIIZ string.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
cwb_Boolean * forceToStorage - output
Pointer to a Boolean where the force-to-storage indicator will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * key - output
Pointer to the key. The key may contain embedded NULLS, so it is not an
ASCIIZ string.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned short * keyLength - output
Pointer to an unsigned short where the length of the key will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned short * keySize - output
Pointer to an unsigned short where the key size will written.
Usage: None
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
char * libName - output
Pointer to a buffer where the library name will be written.
Usage: This function requires that you have previously issued cwbDQ_Open.
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a call to cwbDQ_CreateAttr.
unsigned long * maxRecordLength - output
Pointer to an unsigned long where the maximum record length will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned short * order - output
Pointer to an unsigned short where the order will be written. Possible values
are:
CWBDQ_SEQ_LIFO
CWBDQ_SEQ_FIFO
CWBDQ_SEQ_KEYED
Usage: None
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
cwbDQ_Attr queueAttributes - input/output
The attribute object. This was the output from the cwbDQ_CreateAttr call. The
attributes will be filled in by this function, and you should call the
cwbDQ_DeleteAttr function to delete this object when you have retrieved the
attributes from it.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This function requires that you have previously issued the following APIs:
cwbDQ_Open or cwbDQ_OpenEx
cwbDQ_CreateAttr
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
char * queueName - output
Pointer to a buffer where the queue name will be written.
Usage: This function requires that you have previously issued cwbDQ_Open.
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned long * retDataLength - output
Pointer to an unsigned long where the length of the data returned will be
written.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * retKey - output
Pointer to the returned key. The key may contain embedded NULLs, so it is
not an ASCIIZ string.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned short * retKeyLength - output
Pointer to an unsigned short where the length of the key will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned short * searchOrder - output
Pointer to an unsigned short where the order will be written. Possible values
are:
CWBDQ_NONE
CWBDQ_EQUAL
CWBDQ_NOT_EQUAL
CWBDQ_GT_OR_EQUAL
CWBDQ_GREATER
CWBDQ_LT_OR_EQUAL
CWBDQ_LESS
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes that are returned by a previous call to
cwbDQ_CreateAttr.
cwb_Boolean * senderID - output
Pointer to a Boolean where the sender ID indicator will be written.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * senderInfo - output
Pointer to a 36 character buffer where the sender information will be written.
This buffer contains:
Job Name (10 bytes)
User Name (10 bytes)
Job ID ( 6 bytes)
User Profile (10 bytes)
Usage: None
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
char *systemName - output
Pointer to a buffer where the system name will be written.
Usage: This function requires that you previously have issued cwbDQ_Open or
cwbDQ_OpenEx.
Syntax:
Parameters:
char * queue - input
Pointer to the data queue name contained in an ASCIIZ string.
char * library - input
Pointer to the library name that is contained in an ASCIIZ string. If this pointer
is NULL, the library list will be used (set library to ″*LIBL″).
char * systemName - input
Pointer to the system name that is contained in an ASCIIZ string.
cwbDQ_QueueHandle * queueHandle - output
Pointer to a cwbDQ_QueueHandle where the handle will be returned. This
handle should be used in all subsequent calls.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: None
Syntax:
Parameters:
cwbCO_SysHandle sysHandle - input
Handle to a system object.
const char * queue - input
Pointer to the data queue name contained in an ASCIIZ string.
const char * library - input
Pointer to the library name that is contained in an ASCIIZ string. If this pointer
is NULL, the library list will be used (set library to ″*LIBL″).
cwbDQ_QueueHandle * queueHandle - output
Pointer to a cwbDQ_QueueHandle where the handle will be returned. This
handle should be used in all subsequent calls.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open API. This
identifies the AS/400 data queue object.
cwbDQ_Data data - input
The data object to be read from the AS/400 data queue.
signed long waitTime - input
Length of time in seconds to wait for data, if the data queue is empty. A wait
time of -1 indicates to wait forever.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open function.
This identifies the AS/400 data queue object.
cwbDQ_Data data - input
The data object to be read from the AS/400 data queue.
long waitTime - input
Length of time in seconds to wait for data, if the data queue is empty. A wait
time of -1 indicates to wait forever.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned short authority - input
Authority that other users on the AS/400 system have to access the data
queue. Use one of the following defined types for authority:
CWBDQ_ALL
CWBDQ_EXCLUDE
CWBDQ_CHANGE
CWBDQ_USE
CWBDQ_LIBCRTAUT
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
cwb_Boolean convert - input
Flag indicating if data written to and read from the queue will be CCSID
converted.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * dataBuffer - input
Pointer to the data. The data may contain embedded NULLS, so it is not an
ASCIIZ string.
unsigned long dataLength - input
Length of the data in bytes.
Usage: Use this function if you want to write a small amount of data or you do
not want to manage the memory for the data in your application. Data will be
copied and this may affect your application’s performance.
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * dataBuffer - input
Pointer to the data. The data may contain embedded NULLS, so it is not an
ASCIIZ string.
unsigned long dataLength - input
Length of the data in bytes.
Usage: This function is better for large amounts of data, or if you want to manage
memory in your application. Data will not be copied so performance will be
improved.
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
char * description - input
Pointer to an ASCIIZ string that contains the description for the data queue.
The maximum length for the description is 50 characters.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
cwb_Boolean forceToStorage - input
Boolean indicator of whether each record is forced to auxiliary storage when it
is enqueued.
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned char * key - input
Pointer to the key. The key may contain embedded NULLS, so it is not an
ASCIIZ string.
unsigned short keyLength - input
Length of the key in bytes.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned short keySize - input
Size in bytes of the key. This value should be zero if the order is LIFO or FIFO,
and between 1 and 256 for KEYED.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned long maxLength - input
Maximum length for a data queue record. This value must be between 1 and
31744.
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
unsigned short order - input
Order in which new entries will be enqueued. Use one of the following
defined types for order:
CWBDQ_SEQ_LIFO
CWBDQ_SEQ_FIFO
CWBDQ_SEQ_KEYED
Usage: None
Syntax:
Parameters:
cwbDQ_Data data - input
Handle of the data object that was returned by a previous call to
cwbDQ_CreateData.
unsigned short searchOrder - input
Order to use when reading from a keyed queue. Possible values are:
CWBDQ_NONE
CWBDQ_EQUAL
CWBDQ_NOT_EQUAL
CWBDQ_GT_OR_EQUAL
CWBDQ_GREATER
CWBDQ_LT_OR_EQUAL
CWBDQ_LESS
Usage: None
Syntax:
Parameters:
cwbDQ_Attr queueAttributes - input
Handle of the data queue attributes returned by a previous call to
cwbDQ_CreateAttr.
cwb_Boolean senderID - input
Boolean indicator of whether information about the sender is kept with record
on the queue.
Usage: None
Syntax:
Parameters:
cwbDQ_QueueHandle queueHandle - input
Handle that was returned by a previous call to the cwbDQ_Open or
cwbDQ_OpenEx functions. This identifies the AS/400 data queue object.
cwbDQ_Data data - input
The data object to be written to the AS/400 data queue.
cwb_Boolean commit - input
Boolean flag indicating if the data should be committed on write.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This function requires that you previously have issued cwbDQ_Open or
cwbDQ_OpenEx, and cwbDQ_CreateData.
#ifdef UNICODE
#define _UNICODE
#endif
#include <windows.h>
/**********************************************************************/
void main()
{
cwbDQ_Attr queueAttributes;
cwbDQ_QueueHandle queueHandle;
cwbDQ_Data queueData;
return;
Express Toolkit:
The Client Access Express Toolkit provides data transformation
documentation, access to the cwbdt.h header file, and links to sample
programs. To access this information, open the Express Toolkit and select
Data Manipulation —> C/C++ APIs.
Express data transformation APIs topics:
v Express data transformation APIs listing
v “Example: Using data transformation APIs” on page 556
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
See “OEM, ANSI, and Unicode considerations” on page 10 and the cwbdt.h
header file for details.
Syntax:
Parameters:
char * target - output
Pointer to the target (4 byte integer).
char * source - input
Pointer to the source (11 byte ASCII).
Usage: The target data will be stored with the Most Significant Byte first. This is
the format that the AS/400 uses and is the opposite of the format that is used by
the Intel x86 processors. Valid formats for the ASCII source data are as follows:
[blankspaces][sign][blankspaces][digits] or
[sign][blankspaces][digits][blankspaces]
Examples:
" + 123"
"- 123 "
" +123 "
" 123"
" -123"
"+123 "
Syntax:
Parameters:
char * target - output
Pointer to the target (2 byte integer).
char * source - input
Pointer to the source (6 byte ASCII).
Usage: The target data will be stored with the Most Significant Byte first. This is
the format that the AS/400 uses and is the opposite of the format that is used by
Intel x86 processors. Valid formats for the ASCII source data are as follows:
[blankspaces][sign][blankspaces][digits] or
[sign][blankspaces][digits][blankspaces]
Examples:
" + 123"
"- 123 "
" +123 "
" 123"
" -123"
"+123 "
Purpose: Translates data from ASCII packed format to packed decimal. This
function can be used for translating data from ASCII files to the AS/400 system
format.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: The caller must make sure that there is adequate space to hold the target
information. This function checks that each half-byte of the packed decimal data is
in the range of 0 to 9. The only exception is the last half-byte which contains the
sign indicator (which can be 0x3 or 0xb).
Purpose: Translates data from ASCII (hex representation) to binary. One byte is
stored in the target for each two bytes in the source.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source (ASCII hex) data.
unsigned long length - input
Number of bytes of source data to translate/2.
Usage: For ’length’ bytes of source data ’length’/2 bytes of target data will be
stored. The caller must make sure that there is adequate space to hold the target
information.
Purpose: Translates ASCII numeric data to packed decimal format. This function
can be used for translating ASCII text data for use on the AS/400.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data. Must be zero terminated.
unsigned long length - input
Number of bytes of target data to translate.
unsigned long decimalPosition - input
Position of the decimal point.
Usage: The caller must make sure that there is adequate space to hold the target
information. The sign half-byte will be set to 0xd to indicate a negative number
and hex 0xc to indicate a positive number. 0 <= decimalPosition < (length * 2).
Valid formats for the ASCII numeric data are as follows:
[blankspaces][sign][blankspaces][digits] or
[sign][blankspaces][digits][blankspaces] or
[sign][digits][.digits][blankspaces] or
[blankspaces][sign][digits][.digits][blankspaces]
Examples:
" + 123\0"
"- 123 \0"
" +123 \0"
" 123\0"
" -12.3\0"
"+1.23 \0"
Purpose: Translates ASCII numeric data to EBCDIC zoned decimal format. This
function can be used for translating ASCII text data for for use on the AS/400.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data. Must be zero terminated.
unsigned long length - input
Number of bytes of target data to translate.
unsigned long decimalPosition - input
Position of the decimal point.
Usage: The caller must make sure that there is adequate space to hold the
information. The sign half-byte will be set to 0xd to indicate a negative number
and hex 0xc to indicate a positive number. 0 <= decimalPosition <= length. Valid
formats for the ASCII numeric data are as follows:
[blankspaces][sign][blankspaces][digits] or
[sign][blankspaces][digits][blankspaces] or
[sign][digits][.digits][blankspaces] or
[blankspaces][sign][digits][.digits][blankspaces]
Examples:
" + 123\0"
"- 123 \0"
" +123 \0"
" 123\0"
" -12.3\0"
"+1.23 \0"
Purpose: Translates data from ASCII zoned decimal format to EBCDIC zoned
decimal. This function can be used for translating data from ASCII files for use on
the AS/400.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: The left half of each byte (0x3) in the ASCII zoned decimal format will be
converted to 0xf in the left half-byte of the EBCDIC zoned data except for the last
byte (sign). This function checks that the left half of each byte in the ASCII zoned
decimal data must be 0x3 except for the last byte. The high half of the last byte
must be 0x3 or 0xb. The right half of each byte in the ASCII zoned decimal data
must be in the range 0-9.
Purpose: Translates a 2-byte integer stored most significant byte first to (exactly) 6
ASCII numeric characters. (The target will not be zero terminated.) This function
can be used for translating numeric data from an AS/400 to ASCII.
Syntax:
Parameters:
char * target - output
Pointer to the target (6 byte) area.
char * source - input
Pointer to the source (2 byte integer).
Usage: The source data is assumed to be stored with the Most significant Byte
first. This is the format that the AS/400 uses and is the opposite of the format used
by the Intel x86 processes.
Purpose: Reverses the order of bytes in a 2-byte integer. This function can be used
for translating a 2-byte integer to or from the AS/400 format.
Syntax:
Parameters:
char * target - output
Pointer to the target (2 byte integer).
char * source - input
Pointer to the source (2 byte integer).
Usage: The source data and the target data must not overlap. The following
example shows the result of the translation:
Source data: 0x1234
Target data: 0x3412
Purpose: Translates a 4-byte integer stored most significant byte first to (exactly) 11
ASCII numeric characters. (The target will not be zero terminated.) This function
can be used for translating numeric data from an AS/400 to ASCII.
Syntax:
Parameters:
char * target - output
Pointer to the target (11 byte) area.
char * source - input
Pointer to the source (4 byte integer).
Usage: The source data is assumed to be stored with the Most Significant Byte
first. This is the format that the AS/400 uses and is the opposite of the format used
by the Intel x86 processors.
Purpose: Reverses the order of bytes in a 4-byte integer. This function can be used
for translating a 4-byte integer to or from the AS/400 format.
Syntax:
Parameters:
char * target - output
Pointer to the target (4 byte integer).
char * source - input
Pointer to the source (4 byte integer).
Usage: The source data and the target data must not overlap. The following
example shows the result of the translation:
Source data: 0x12345678
Target data: 0x78563412
Purpose: ’Translates’ (copies unless character value less than 0x40 is encountered)
EBCDIC data to EBCDIC.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of target data to translate.
Usage: The caller must make sure that there is adequate space to hold the target
information.
Purpose: Translates binary data to the ASCII hex representation. Two ASCII
characters are stored in the target for each byte of source data.
Syntax:
Parameters:
char * target - output
Pointer to the target (ASCII hex) data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: For ’length’ bytes of source data ’length’*2 bytes of target data will be
stored. The caller must make sure that there is adequate space to hold the target
information.
Purpose: Translates data from packed decimal format to ASCII numeric data. This
function can be used for translating data from the the AS/400 for use in ASCII text
format.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
unsigned long decimalPosition - input
Position of the decimal point.
Usage: The caller must make sure that there is adequate space to hold the target
information. This function checks that each half-byte of the packed decimal data is
in the range of 0 to 9. The only exception is the last half-byte which contains the
sign indicator. 0 <= decimalPosition < (length * 2).
Purpose: Translates data from packed decimal format to ASCII packed format. This
function can be used for translating data from the AS/400 for use in ASCII format.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: The caller must make sure that there is adequate space to hold the target
information. This function checks that each half-byte of the packed decimal data is
in the range of 0 to 9. The only exception is the last half-byte which contains the
sign indicator (which can be 0-9, 0xd, or 0xb).
Purpose: Translates packed decimal data to packed decimal. This function can be
used for transferring data from the AS/400 system to no-conversion files and back.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: The caller must make sure that there is adequate space to hold the target
information. This function checks that each half-byte of the packed decimal data is
in the range of 0 to 9. The only exception is the last half-byte which contains the
sign indicator.
Purpose: Translates EBCDIC zoned decimal data to ASCII numeric format. This
function can be used for translating data from the AS/400 for use in ASCII text
format.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
unsigned long decimalPosition - input
Position of the decimal point.
Usage: The caller must make sure that there is adequate space to hold the target
information. The high half of the last byte of the zoned data indicates the sign of
the number. If the high half-byte is 0xb or 0xd, then a negative number is
indicated. Any other value indicates a positive number. This function checks that
the high half of each byte of zoned data must be 0xf except for the last byte. The
low half of each byte of zoned data must be in the range 0-9. 0 <= decimalPosition
< length.
Purpose: Translates data from EBCDIC zoned decimal format to ASCII zoned
decimal format. This function can be used for translating data from the AS/400 for
use in ASCII files.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: The caller must make sure that there is adequate space to hold the target
information. The left half-byte (0xf) in the EBCDIC zoned decimal data will be
converted to 0x3 in the left half-byte of the ASCII zoned decimal data except for
the last byte (sign). The high half of the last byte of the EBCDIC zoned decimal
data indicates the sign of the number. If the high half-byte is 0xb or 0xb then a
negative number is indicated, any other value indicates a positive number. This
function checks that the high half of each byte of EBCDIC zoned decimal data
must be 0xf except for the last byte. The low half of each byte of EBCDIC zoned
decimal data must be in the range 0-9.
Purpose: Translates data from zoned decimal format to zoned decimal. This
function can be used for translating data from the AS/400 for use in no-conversion
files and vice-versa.
Syntax:
Parameters:
char * target - output
Pointer to the target data.
char * source - input
Pointer to the source data.
unsigned long length - input
Number of bytes of source data to translate.
Usage: The caller must make sure that there is adequate space to hold the target
information. The high half of the last byte of the zoned data indicates the sign of
the number. If the high half-byte is 0xb or 0xb then a number is indicated, any
other value indicates a positive number. This function checks that the high half of
each byte of zoned data must be 0xf except for the last byte. The low half of each
byte of zoned data must be in the range 0-9.
#include <iostream.h>
#include "cwbdt.h"
void main()
{
unsigned int returnCode;
long source,
target;
}; /* endwhile */
All AS/400 systems use a common set of program code, regardless of which
language you use on the system. For example, the program code on a U.S. English
AS/400 system and the program code on a Spanish AS/400 system are identical.
Different sets of textual data are used, however, for different languages. Textual
data is a collective term for menus, displays, lists, prompts, options, on-line help
information, and messages. This means that you see Help for the description of the
function key for on-line help information on a U.S. English system, while you see
Ayuda on a Spanish system. Using the same program code with different sets of
textual data allows the AS/400 system to support more than one language on a
single system.
Express Toolkit:
The Client Access Express Toolkit provides NLS documentation, access to
the NLS APIs header files, and links to sample programs. To access this
information, open the Express Toolkit and select Data Manipulation —>
C/C++ APIs.
Express NLS APIs topics:
v “Coded character sets”
v Express NLS APIs listing
v “Example: Express NLS APIs” on page 587
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
Code pages are classified into many types according to the encoding scheme. Two
important encoding schemes for Client Access are the Host and PC code pages.
Unicode also is becoming an important encoding scheme. Unicode is a 16-bit
worldwide character encoding scheme that is gaining popularity on both the Host
and the personal computer.
v Host code pages are encoded in accordance with IBM Standard of Extended
BCD Interchange Code (EBCDIC) and usually used by S/390 and AS/400.
v PC Code pages are encoded based on ANSI X3.4, ASCII and usually used by
IBM Personal Computers.
Express general NLS APIs list: Client Access Express is translated into many
languages. One or more of these languages can be installed on the personal
computer. The following Express general NLS APIs allow an application to:
v Get a list of installed languages
v Get the current language setting
v Save the language setting
cwbNL_FindFirstLang
Syntax:
Parameters:
char * mriBasePath - input
Pointer to the mriBasePath, e.g. C:\Program Files\IBM\ClientAccess/400 If
NULL, the mriBasePath of the ClientAccess/400 product is used.
char * resultPtr - output
Pointer to the buffer to contain the result.
unsigned short resultLen - input
Length of the result buffer. Recommended size is CWBNL_MAX_LANG_SIZE.
unsigned short * requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
unsigned long * searchHandle - output
Search handle to be passed on subsequent calls to cwbNL_FindNextLang.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle() API The messages may be retrieved through the
cwbSV_GetErrText() API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
char * resultPtr - output
Pointer to the buffer to contain the result.
unsigned short resultLen - input
Length of the result buffer. Recommended size is CWBNL_MAX_LANG_SIZE.
unsigned short * requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
unsigned long * searchHandle - output
Search handle to be passed on subsequent calls to cwbNL_FindNextLang.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle() API. The messages may be retrieved through the
cwbSV_GetErrText() API. If the parameter is set to zero, no messages will be
retrievable.
Syntax:
Parameters:
char * mriBasePath - input
Pointer to the mriBasePath, e.g. C:\Program Files\IBM\ClientAccess/400. If
NULL, the mriBasePath of the ClientAccess/400 product is used.
char * resultPtr - output
Pointer to the buffer to contain the result.
unsigned short resultLen - input
Length of the result buffer. Recommended size is CWBNL_MAX_LANG_SIZE.
unsigned short * requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle() API. The messages may be retrieved through the
cwbSV_GetErrText() API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The result buffer will contain the name of the language subdirectory. This
language subdirectory contains the language-specific files. This language
subdirectory name also can be passed to cwbNL_GetLangName.
Syntax:
Parameters:
char * lang - input
Address of the ASCIIZ string representing the language.
char * resultPtr - output
Pointer to the buffer to contain the result.
unsigned short resultLen - input
Length of the result buffer. Recommended size is CWBNL_MAX_NAME_SIZE.
unsigned short * requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle() API. The messages may be retrieved through the
cwbSV_GetErrText() API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The language must be a value returned from one of the following APIs:
cwbNL_GetLang
cwbNL_FindFirstLang
cwbNL_FindNextLang
Syntax:
Parameters:
char * mriBasePath - input
Pointer to the mriBasePath, for example C:\Program
Files\IBM\ClientAccess/400. If NULL, the mriBasePath of the
ClientAccess/400 product is used.
char * resultPtr - output
Pointer to the buffer to contain the result.
unsigned short resultLen - input
Length of the result buffer. Recommended size is CWBNL_MAX_PATH_SIZE.
unsigned short * requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle() API. The messages may be retrieved through the
cwbSV_GetErrText() API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The result buffer will contain the complete path of the language
subdirectory. Language files should be loaded from this path.
Syntax:
Parameters:
char * lang - input
Address of the ASCIIZ string representing the language.
cwbSV_ErrHandle errorHandle - input
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle() API. The messages may be retrieved through the
cwbSV_GetErrText() API. If the parameter is set to zero, no messages will be
retrievable.
Usage: The language must be a value returned from one of the following APIs:
cwbNL_GetLang
cwbNL_FindFirstLang
cwbNL_FindNextLang
Syntax:
Parameters:
unsigned long CCSID - input
CCSID to convert to a code page.
unsigned long * codePage - output
The resulting code page.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: None
Syntax:
Parameters:
unsigned long codePage - input
Code page to convert to a CCSID.
unsigned long * CCSID - output
The resulting CCSID.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbNL_Converter theConverter - output
Handle to the previously opened converter.
unsigned long sourceLength - input
Length of the source buffer.
unsigned long targetLength - input
Length of the target buffer. If converting from an ASCII code page that
contains DBCS characters, note that the resulting data could contain shift-out
and shift-in bytes. Therefore, the targetBuffer may need to be larger than the
sourceBuffer.
char *sourceBuffer - input
Buffer containing the data to convert.
char *targetBuffer - output
Buffer to contain the converted data.
unsigned long *numberOfErrors - output
Contains the number of characters that could not be converted properly.
unsigned long *firstErrorIndex - output
Contains the offset of the first character in the source buffer that could not be
converted properly.
unsigned long *requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: None
Purpose: Convert strings from one code page to another. This API combines the
following three converter APIs for the default conversion:
v cwbNL_CreateConverter
v cwbNL_Convert
v cwbNL_DeleteConverter
Syntax:
Parameters:
unsigned long sourceCodePage - input
Code page of the data in the source buffer.
unsigned long targetCodePage - input
Code page to which the data should be converted.
unsigned long sourceLength - input.
Length of the source buffer
unsigned long targetLength - input.
Length of the target buffer
char *sourceBuffer - input
Buffer containing the data to convert.
char *targetBuffer - output
Buffer to contain the converted data.
unsigned long *numberOfErrors - output
Contains the number of characters that could not be converted properly.
unsigned long *positionOfFirstError - output
Contains the offset of the first character in the source buffer that could not be
converted properly.
unsigned long *requiredLen - output
Actual length of the result. If requiredLen > resultLen, the return value will be
CWB_BUFFER_OVERFLOW.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: The following values may be specified on the sourceCodePage and the
targetCodePage parameters:
Value Meaning
CWBNL_CP_UNICODE_F200 UCS2 Version 1.1 UNICODE
CWBNL_CP_UNICODE UCS2 Current Version UNICODE
CWBNL_CP_AS400 AS/400 host code page
CWBNL_CP_CLIENT_OEM OEM client code page
CWBNL_CP_CLIENT_ANSI ANSI client code page
CWBNL_CP_CLIENT Generic client code page. Default is
CWBNL_CP_CLIENT_OEM. CWBNL_CP_CLIENT is set to
CWBNL_CP_CLIENT_ANSI when CWB_ANSI is defined, to
CWBNL_CP_CLIENT_UNICODE when CWB_UNICODE is
defined and to CWBNL_CP_CLIENT_OEM when
CWB_OEM is defined.
Syntax:
Parameters:
unsigned long sourceCodePage - input
Code page of the source data.
unsigned long targetCodePage - input
Code page to which the data should be converted.
cwbNL_Converter * theConverter - output
The newly created converter.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
unsigned long shiftInShiftOutStatus - input
Indicates whether the shift-in and shift-out bytes are part of the input or
output data. 0 - False, no shift-in and shift-out bytes are part of the data string.
1 - True, shift-in and shift-out characters are part of the data string.
unsigned long padLength - input
Length of pad characters. 0 - No pad characters for this conversion request 1 -
1 byte of pad character. This is valid only if the target code page is either SBCS
or DBCS code page 2 - 2 bytes of pad characters. This is valid only if the code
page is not a single-byte code page.
char * pad - input
The character or characters for padding.
Usage: The following values may be specified on the sourceCodePage and the
targetCodePage parameters:
Value Meaning
CWBNL_CP_UNICODE_F200 UCS2 Version 1.1 UNICODE
CWBNL_CP_UNICODE UCS2 Current Version UNICODE
CWBNL_CP_AS400 AS/400 host code page
CWBNL_CP_CLIENT_OEM OEM client code page
CWBNL_CP_CLIENT_ANSI ANSI client code page
CWBNL_CP_CLIENT Generic client code page. Default is
CWBNL_CP_CLIENT_OEM. CWBNL_CP_CLIENT is set to
CWBNL_CP_CLIENT_ANSI when CWB_ANSI is defined, to
CWBNL_CP_CLIENT_UNICODE when CWB_UNICODE is
defined and to CWBNL_CP_CLIENT_OEM when
CWB_OEM is defined.
Syntax:
Parameters:
cwbNL_Converter theConverter - input
A previously created converter.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle0 API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: None
Syntax:
Parameters:
unsigned long * codePage - output
Returns the current code page of the client system or the OEM code page
character conversion override value, if one is specified on the Language tab of
the Client Access Properties dialog.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: None
Purpose: Get the current ANSI code page of the client system.
Syntax:
Parameters:
unsigned long * codePage - output
Returns the current ANSI code page of the client system or the ANSI code
page character conversion override value, if one is specified on the Language
tab of the Client Access Properties dialog.
cwbSV_ErrHandle errorHandle - output
Handle to an error object. Any returned messages will be written to this object.
It is created with the cwbSV_CreateErrHandle API. The messages may be
retrieved with the cwbSV_GetErrText API. If the parameter is set to zero, no
messages will be retrievable.
Usage: None
Purpose: Returns the associated CCSID of a given host system or the managing
system or the EBCDIC code page character conversion override value, if one is
specified on the Language tab of the Client Access Properties dialog.
Syntax:
Parameters:
char * system - input
The name of the host system. If NULL, the managing system is used.
unsigned * CCSID - output
Length of the result buffer.
Usage: This API does not make or require an active connection to the host system
to retrieve the associated CCSID value. However, it does depend on a prior
successful connection to the host system. If no prior successful connection was
made to the host system, the API determines the most appropriate associated host
CCSID by using an internal mapping table.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the control for which to calculate the growth factor.
HDC hDC - input
Device context. Used by GetTextExtentPoint32 to determine extent needed for
the translated string in the control.
float* growthFactorX - output
+/- growth to the width needed to contain the string for the control.
float* growthFactorY - output
+/- growth to the height needed to contain the string for the control.
Usage: It is assumed that the translated text has been loaded into the control prior
to calling this function. A control that does not contain text will return a 1.00
growth factor. This means that it does not need to change size.
Purpose: Routine to calculate the growth factor of a dialog box. All of the controls
within the dialog box will looked at to determine how much the dialog-box size
needs to be adjusted.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the dialog box for which to calculate the growth factor.
float* growthFactorX - output
+/- growth to the width needed to contain the string for all of the controls in
the dialog box.
float* growthFactorY - output
+/- growth to the height needed to contain the string for all of the controls in
the dialog box.
Usage: It is assumed that the translated text has been loaded into the controls
prior to calling this function.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the control to be resized.
HWND parentWindowHandle - input
Window handle of the dialog box that contains the controls.
float growthFactorX - input
Multiplication factor for growing the width of the control. 1.00 = Stay same
size. 1.50 = 1 1/2 times original size.
float growthFactorY - input
Multiplication factor for growing the height of the control. 1.00 = Stay same
size. 1.50 = 1 1/2 times original size.
cwb_Boolean growAllControls - input
CWB_TRUE = All controls will be resized by the growthFactor. CWB_FALSE =
Only controls with text will be resized.
Usage: Care should be used to not pass in a growth factor that will cause a control
to not fit on the physical display.
Purpose: Internal routine to growth the dialog box and its controls proportionally
based off of a growth factor that is input.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the window owning the controls.
float growthFactorX - input
Multiplication factor for growing the dialog box, ie. 1.00 = Stay same size, 1.50
= 1 1/2 times original size.
float growthFactorY - input
Multiplication factor for growing the dialog box, ie. 1.00 = Stay same size, 1.50
= 1 1/2 times original size.
cwb_Boolean growAllControls - input
CWB_TRUE = All controls will be resized by the growthFactor, CWB_FALSE =
Only controls with text will be resized.
Usage: It is assumed that the translated text has been loaded into the controls
prior to calling this function. The dialog-box frame will not be allowed to grow
larger than the desktop window size.
Purpose: This routine will control the replacement of translatable text within a
dialog box. This includes dialog control text as well as the dialog-box caption.
Syntax:
Parameters:
HINSTANCE MRIHandle - input
Handle of the module containing the strings for the dialog.
HWND windowHandle - input
Window handle of the dialog box.
int nCaptionID - input
ID of the caption string for the dialog box
USHORT menuID - input
ID of the menu for the dialog box.
HINSTANCE menuLibHandle - input
Handle of the module containing the menu for the dialog.
cwb_Boolean growAllControls - input
CWB_TRUE = All controls will be resized by the growthFactor CWB_FALSE =
Only controls with text will be resized.
Usage: This process begins by enumerating, replacing the text of, and horizontally
adjusting, all dialog controls within the dialog box, and finally right-adjusting the
dialog box itself, relative to the adjusted controls therein. These adjustments are
made only if the current window extents do not fully encompass the expansion
space required for the text or all controls. After all of the text substitution has been
completed, if a menu ID has been passed, it will be loaded and attached to the
dialog box. It is suggested that this routine is called for every dialog-box procedure
as the first thing done during the INITDLG message processing.
Purpose: This routine will control the loading of the given menu from a module
and replacing the translatable text within the menu.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the dialog box that contains the menu.
HINSTANCE menuResourceHandle - input
Handle of the resource dll containing the menu.
USHORT menuID - input
ID of the menu for the dialog box.
HINSTANCE MRIHandle - input
Handle of the resource dll containing the strings for the menu.
Usage: None
Purpose: This routine will control the replacement of translatable text within a
menu.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the dialog box that contains the menu.
HMODULE menuHandle - input
Handle of the menu for the dialog.
HMODULE MRIHandle - input
Handle of the resource DLL containing the strings for the menu.
Usage: None
Purpose: This routine will control the sizing of the dialog box and its child
controls. The expansion amount is based off of the length of the text extent and the
length of each control. The growth of the dialog box and its controls will be
proportional. By setting the growAllControls to FALSE, only controls with text will
expand or contract. This allows the programmer the flexibility of non-translatable
fields to remain the same size. This may be appropriate for dialogs that contain
drop-down lists, combo-boxes, or spin buttons.
Syntax:
Parameters:
HWND windowHandle - input
Window handle of the window owning the controls.
cwb_Boolean growAllControls - input
CWB_TRUE = All controls will be resized by the growthFactor, CWB_FALSE =
Only controls with text will be resized.
Usage: This routine assumes that the translated text has already been loaded into
the dialog-box controls. If the text has not been loaded into the controls, use
cwbNL_LoadDialog.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CWBNL.H"
#include "CWBNLCNV.H"
#include "CWBSV.H"
cwbSV_ErrHandle errhandle;
void main(void){
/* define some variables
-------------------- */
int SVrc = 0;
int NLrc = 0;
char *myloadpath = "";
char *resultPtr;
char *mylang;
unsigned short resultlen;
unsigned short reqlen;
unsigned long searchhandle;
unsigned long codepage;
unsigned long trgtpage;
char *srcbuf = "Change this string";
char *trgtbuf;
unsigned long srclen;
unsigned long trgtlen;
unsigned long nmbrerrs;
unsigned long posoferr;
unsigned long rqdlen;
unsigned long ccsid;
cwbSV_DeleteErrHandle(errhandle);
Note: Express Directory Update APIs do not actually perform the updates.
They are for configuration purposes only. The task of updating files
is handled exclusively by the Directory Update application.
IMPORTANT: The Express client does not include support for network drives or
for universal naming conventions. This now is provided by the
AS/400 NetServer function. Network drives that you previously
mapped by using Client Access should be mapped by using
AS/400 NetServer support. Set up the AS/400 NetServer that
comes with OS/400 V4R2 and beyond in order to perform file
serving to the AS/400.
Express Toolkit:
The Client Access Express Toolkit provides Directory Update
documentation, access to the cwbup.h header file, and links to sample
programs. To access this information, open the Express Toolkit and select
Directory Update —> C/C++ APIs.
Express Directory Update APIs topics:
v “Typical use of Express Directory Update APIs”
v “Requirements for Directory Update entries”
v “Options for Directory Update entries” on page 590
v “Directory Update package files syntax and format” on page 591
v Express Directory Update APIs listing
v “Directory Update sample program” on page 592
v “Express Directory Update APIs return codes” on page 25
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
For example, files on the AS/400 system might contain customer names and
addresses. The files on your AS/400 system are your master files that are updated
as new customers are added, deleted, or have a name or address change. The same
files on your networked personal computers are used to perform selective market
mailings (by zip code, state, age, number of children and so on). The files on the
AS/400 system are your master files, and you want them secure, but you need to
provide the data for work.
You could write a program that uses Directory Update APIs to create and
configure update entries, which would update the files located on your networked
personal computers.
or
\\myserver\mysource
Target path:
The path of the files with which you wish to keep synchronized with the
master files. For example:
C:\mytarget
Note: Text must start in the first row and column of the file. Each package file
must begin with the PKGF keyword.
Package files format:
Package files consist of the following elements:
PKGF description (optional):
This identifier indicates that the file is a package file. If this tag is
not found in the first four characters of the file, Directory Update
will not process the file while searching for files to update. A
description is optional.
MBRF filename:
This identifies a file as part of the package to be updated. A path
name also can be specified; this indicates that the file is in a
subdirectory of the source directory.
The path should not contain the drive letter, or begin with a
back-slash character (\). When you begin the update function, you
The following Express Directory Update APIs are listed alphabetically, and are
grouped by function:
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or
cwbUP_FindEntry.
char * entryPackage - input
Pointer to a null-terminated string that contains the name of a package file to
be added to the update entry. Do not include the path for this file. The
package file must exist in the source and target paths.
Usage: None
Syntax:
Parameters:
char * entryDescription - input
Points to a null-terminated string that contains a description to identify the
update entry.
char * entrySource - input
Points to a null-terminated string that contains the source for the update entry.
This can be either a drive and path, or a UNC name.
char * entryTarget - input
Points to a null-terminated strings that contains the target for the update entry.
This can be either a drive and path, or a UNC name.
cwbUP_EntryHandle * entryHandle - input/output
Pointer to a cwbUP_EntryHandle where the handle will be returned. This
handle must be used in subsequent calls to the update entry APIs.
Usage: When you use this call, and have completed your processing of the update
entry, you must call cwbUP_FreeEntryHandle. This call will ″unlock″ the entry,
and free resources that are associated with it.
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or
cwbUP_FindEntry.
Usage: After this call, you do not need to call cwbUP_FreeEntryHandle. The
entry is ″freed″ when the entry is successfully deleted. If you retrieved the first
update entry by using the cwbUP_GetEntryHandle API, and then called this API
to delete the entry, all of the update entries would shift one position to fill the slot
left by the delete. So, if you then wanted to get the next update item, you would
pass the same index that you did on the previous cwbUP_GetEntryHandle API
call.
Syntax:
Parameters:
char * entrySource - input
Points to a null-terminated string that contains the source for the update entry.
This can be either a drive and path, or a UNC name. This string will be used
to search for a */ matching update entry.
char * entryTarget - input
Points to a null-terminated string that contains the target for the update entry.
This can be either a drive and path, or a UNC name. This string will be used
to search for a matching update entry.
unsigned long * searchStart - input/output
Pointer to an index into the list of update entries to begin the search at. This
would be used in cases where multiple update entries may have matching
source and targets. You would use this parameter to ″skip″ over entries in the
search, and continue on searching for a matching update entry that is after
searchStart in the list. On successful return, searchStart will be set to the
position in the list where the update entry was found. This should be set to
CWBUP_SEARCH_FROM_BEGINNING if you want to search all update
entries.
cwbUP_EntryHandle * entryHandle - input/output
Pointer to a cwbUP_EntryHandle where the handle will be returned. This
handle must be used in subsequent calls to the update entry APIs.
Usage: The handle that is returned from this call will be used for accessing the
update entry with other Update APIs. When you use this call, and have completed
your processing of the update entry, you must call cwbUP_FreeEntryHandle. This
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
The entry handle that is to be freed.
Usage: After this call you can no longer access the update entry. To access the
update entry or another update entry, you would need to get a new entry handle.
Syntax:
Parameters:
None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * dllPath - input/output
Pointer to a buffer that will receive the fully qualified name of the DLL that
will be called when individual stages of the update occur.
unsigned long bufferLength - input
Length of the dllPath buffer. Space should be included for the null termination
character. If the buffer is not large enough to hold the entire DLL name, an
error will be returned and the actualLength parameter will be set to the
number of bytes the dllPath buffer needs to be.
unsigned long * actualLength - input/output
Pointer to a length variable that will be set to the size of the buffer needed to
contain the fully qualified DLL name.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entryDescription - input/output
Pointer to a buffer that will receive the description of the update entry.
unsigned long bufferLength - input
Length of the buffer. An extra byte should be included for the null termination
character. If the buffer is not large enough to hold the entire description, an
error will be returned and the actualLength parameter will be set to the
number of bytes the entryDescription buffer needs to be to contain the data.
unsigned long * actualLength - input/output
Pointer to a length variable that will be set to the size of the buffer needed to
contain the description.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
unsigned long * entryAttributes - input/output
Pointer to area to receive the attribute values. (See defines section for values)
Usage: The value that is contained in entryAttributes after this call is made may
be a combination of the attribute flags that are listed near the top of this file.
Syntax:
Parameters:
unsigned long entryPosition - input
Index into the update entry list of the entry for which you want to retrieve a
handle. (Pass in 1 if you wish to retrieve the first update entry)
cwbUP_EntryHandle * entryHandle - input/output
Pointer to a cwbUP_EntryHandle where the handle will be returned. This
handle must be used in subsequent calls to the update entry APIs.
Usage: The handle that is returned from this call will be used for accessing the
update entry with other Update APIs. When you use this call, and have completed
your processing of the update entry, you must call cwbUP_FreeEntryHandle. This
call will ″unlock″ the entry, and free resources that are associated with it. You must
call cwbUP_FreeEntryHandle once for each time that you call an API that returns
an entry handle.
Syntax:
Parameters:
char * lockHolder - input/output
Pointer to a buffer that will receive the name of the application that is
currently locking the update entries.
unsigned long bufferLength - input
Length of the buffer. An extra byte should be included for the null termination
character. If the buffer is not large enough to hold the entire name, an error
will be returned and the actualLength parameter will be set to the number of
bytes the lockHolder buffer needs to be to contain the data.
unsigned long * actualLength - input/output
Pointer to a length variable that will be set to the size of the buffer needed to
contain the application name.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entrySource - input/output
Pointer to a buffer that will receive the source path of the update entry.
unsigned long bufferLength - input
Length of the buffer. An extra byte should be included for the null termination
character. If the buffer is not large enough to hold the entire source path, an
error will be returned and the actualLength parameter will be set to the
number of bytes the entrySource buffer needs to be to contain the data.
unsigned long * actualLength - input/output
Pointer to a length variable that will be set to the size of the buffer needed to
contain the source path.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entryTarget - input/output
Pointer to a buffer that will receive the target path of the update entry.
unsigned long bufferLength - input
Length of the buffer. An extra byte should be included for the null termination
character. If the buffer is not large enough to hold the entire target path, an
error will be returned and the actualLength parameter will be set to the
number of bytes the entryTarget buffer needs to be to contain the data.
unsigned long * actualLength - input/output
Pointer to a length variable that will be set to the size of the buffer needed to
contain the target path.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entryPackage - input
Pointer to a null-terminated string that contains the package file name that is
to be removed from the package file list.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or
cwbUP_FindEntry.
char * dllPath - input
Pointer to a null-terminated string that contains the fully qualified name of the
DLL that will be called when individual stages of the update occur.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entryDescription - input
Pointer to a null-terminated string that contains the full description to be
associated with the update entry.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
unsigned long entryAttributes - input
Combination of the attribute values. (See defines section for values)
rc = cwbUP_SetEntryAttributes(entryHandle, CWBUP_FILEDRIVEN |
CWBUP_ONEPASS );
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entrySource - input
Pointer to a null-terminated string that contains the full source path for the
update entry.
Usage: None
Syntax:
Parameters:
cwbUP_EntryHandle entryHandle - input
Handle that was returned by a previous call to
cwbUP_CreateUpdateEntryHandle, cwbUP_GetUpdateEntryHandle, or to
cwbUP_FindEntry.
char * entryTarget - input
Pointer to a null-terminated string that contains the full target path for the
update entry.
Usage: None
Express Toolkit:
The Client Access Express Toolkit provides Emulator interfaces
documentation, access to header files, and links to sample applications. To
access this information, open the Express Toolkit and select Emulation —>
C/C++ APIs.
Note: Applications that use the previous versions ldape.lib and ldape.dll
will not run on Client Access Express. Copy ldap.dll to ldape.dll,
and ldap.lib to ldape.lib.
Express Toolkit:
The Client Access Express Toolkit provides LDAP documentation, access to
the ldap.h header file, and links to sample programs. To access this
information, open the Express Toolkit and select Directory —> C/C++
APIs.
IBM Lightweight Directory Access Protocol (LDAP) topics:
v “IBM LDAP client incompatibility”
v “LDAP version support”
v “LDAP APIs overview” on page 617
v LDAP utilities APIs listing
v LDAP APIs listing
v “Distinguished names format” on page 696
v “LDAP Data Interchange Format (LDIF)” on page 697
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
Additional LDAP information resources:
v Directory Services (LDAP) topic in the AS/400 Information Center
The copy of LDAP.DLL that is installed in the Windows system directory is for
customer applications that use the LDAP APIs. Client Access Express does not use
this copy of the DLL. Another copy is installed in a Client Access directory.
If you do not use LDAP APIs, or if you experience problems when Client Access
installs LDAP.DLL in the Windows system directory, IBM recommends that you
rename or delete the LDAP.DLL that is located in the system directory.
Note: To avoid this conflict, a future release of Client Access no longer will include
the LDAP APIs. Operations Navigator plug-ins that use LDAP.DLL will load
the DLL that is installed in the Client Access\ldap directory.
With this toolkit, an application that uses the ldap_open API defaults to the LDAP
V2 protocol. In this way, existing LDAP applications will continue to work, and
can interoperate with both LDAP V2 servers and LDAP V3 servers.
An application that uses the ldap_init API defaults to the LDAP V3 protocol (with
optional bind). An LDAP V3 application will not necessarily interoperate with an
LDAP server that supports only LDAP V2 protocols.
Note that an application can use the ldap_set_option API to change its LDAP
protocol version. Do this after using ldap_open or ldap_init but before issuing a
bind or other operation that results in contacting the server.
The type of information that is managed in the directory depends on the nature of
the application. It is common practice to use directories to provide public access to
information about people, including:
v Telephone numbers
v E-mail addresses
v Fax numbers
v Mailing addresses
LDAP APIs provide for both synchronous and asynchronous access to a directory.
Asynchronous access makes it easy for your application to do other work while
waiting for the results of potentially lengthy directory operations to return.
Complete sample programs are provided that perform the following operations:
v “ldapsearch” on page 633 (searches the directory)
v “ldapmodify” on page 626 (changes information in the directory)
ldapadd
ldapadd is the LDAP add-entry tool.
ldapadd topics:
v “ldapadd synopsis”
v “ldapadd description”
v “ldapadd options” on page 620
v “ldapadd input format” on page 621
v “Alternative ldapadd input format” on page 621
v “Examples: Using ldapadd” on page 621
v “ldapadd notes” on page 622
v “ldapadd SSL notes” on page 622
v “ldapadd diagnostics” on page 623
Related topics:
v “ldapmodify” on page 626
v “ldapdelete” on page 623
v “ldapmodrdn” on page 630
v “ldapsearch” on page 633
v “IBM Lightweight Directory Access Protocol (LDAP) APIs” on page 615
v “ldap_add” on page 643
v “ldap_delete” on page 651
v “ldap_modify” on page 676
v “ldap_rename” on page 681
v “ldap_ssl” on page 689
v “LDAP Data Interchange Format (LDIF)” on page 697
ldapadd synopsis: ldapadd [-b] [-c] [-r] [-n] [-v] [-F] [-R] [-d debuglevel] [-D
binddn] [-w passwd] [-h ldaphost] [-p ldapport] [-f file] [-Z] [-K keyfile] [-P
keyfilepw] [-N certificatename]
ldapadd options:
-b Assume that any values that start with a slash (/) are binary values, and that
the actual value is in a file whose path is specified in the place where values
normally appear.
-c Continuous operation mode. Errors are reported, but ldapmodify will continue
with modifications. The default is to exit after reporting an error.
-r Replace existing values by default.
-n Show what would be done, but do not actually modify entries. Useful for
debugging in conjunction with -v.
-v Use verbose mode, with many diagnostics written to standard output.
-R Specifies that referrals are not to be automatically followed.
-d debuglevel
Set the LDAP debugging level to debuglevel.
-D binddn
Use binddn to bind to the LDAP directory. binddn should be a
string-represented destinguished name (see “Distinguished names format” on
page 696).
-w passwd
Use passwd as the password for simple authentication.
-h ldaphost
Specify an alternate host on which the LDAP server is running.
-p ldapport
Specify an alternate TCP port where the LDAP server is listening. The default
LDAP port is 389. If not specified and Z is specified, the default LDAP SSL
port 636 is used.
-f file
Read the entry modification information from an ldif file instead of from
standard input. If an ldif file is not specified, you must use standard input to
specify the update records in ldif format.
-Z Use a secure SSL connection to communicate with the LDAP server. The Z
option is not supported by non-SSL versions of this tool.
-K keyfile
Specify the name of the SSL key ring file. If the key ring file is not in the
current directory, specify the fully-qualified key ring filename. If a key ring
filename is not specified, this utility will look for the presence of the
SSL_KEYRING environment variable with an associated filename. Otherwise,
no key ring file will be used for server authentication and default trusted
certification authority roots will be used. The key ring file typically contains
one or more certificates of certification authorities (CAs) that are trusted by the
client. These types of X.509 certificates are also known as trusted roots. See
“ldapadd SSL notes” on page 622 and ldap_ssl_start for more information
about SSL and certificates. This parameter is ignored if Z is not specified.
-P keyfilepw
Specify the key ring password. This password is required to access the
ldapadd input format: The contents of file, (or by not giving a standard input
with a f flag on the command line), should conform to the “LDAP Data
Interchange Format (LDIF)” on page 697 format.
where attr is the name of the attribute and value is the value.
By default, values are added. If the - r command line flag is given, the default is to
replace existing values with the new one. Note that it is permissible for a given
attribute to appear more than once (for example, to add more than one value for
an attribute). Also note that you can use a trailing ′\\’ to continue values across
lines and preserve newlines in the value itself. (This is useful for changing QUIPU
iattr attributes among others).
attr should be preceded by a - to remove a value. Omit the ′=’ and value to remove
an entire attribute.
Examples: Using ldapadd: Assuming that the file /tmp/entrymods exists and has
the contents:
The command
ldapmodify -b -r -f /tmp/entrymods
Assuming that the file /tmp/newentry exists and has the contents:
dn: cn=Barbara Jensen, o=University of Michigan, c=US
objectClass: person
cn: Barbara Jensen
cn: Babs Jensen
sn: Jensen
title: the world's most famous mythical manager
mail: bjensen@terminator.rs.itd.umich.edu
uid: bjensen
the command
ldapadd -f /tmp/entrymods
will add a new entry for Babs Jensen, using the values from the file
/tmp/newentry.
Assuming that the file /tmp/newentry exists and has the contents:
dn: cn=Barbara Jensen, o=University of Michigan, c=US
changetype: delete
the command
ldapmodify -f /tmp/entrymods
ldapadd notes: If entry information are not supplied from file through the use of
the -f option, the ldapmodify command will wait to read entries from standard
input. To break out of the wait, use Ctrl+C.
ldapadd SSL notes: The SSL-related functions that are described for this utility
are supported for the SSL versions of this utility only. Non-SSL versions, such as
those shipped with the Telstra LDAP/X.500 Directory Server do not include SSL
support.
The contents of a client’s key database file are managed with the ikmgui utility. The
ikmgui utility is used to define the set of trusted certification authorities (CAs) that
the client can trust. You can establish a trust relationship with LDAP servers that
use certificates that are issued by one of the CAs that are marked as trusted.
Accomplish this by doing the following:
1. Obtain certificates from trusted CAs.
2. Store them in the key ring file.
3. Marking them as ″trusted.″
If the LDAP servers that are accessed by the client use server authentication, it is
sufficient to define one or more trusted root certificates in the key ring file. With
server authentication, the client can know that the target LDAP server is issued a
certificate by one of the trusted CAs. In addition, all LDAP transactions that flow
over the SSL connection with the server are encrypted. (This includes the LDAP
credentials that are supplied on the ldap_bind).
For example, if the LDAP server uses a high-assurance Verisign certificate, you
should obtain a CA certificate from Verisign, import it into your key ring file, and
mark it as trusted. If the LDAP server is using a self-signed mkkf server certificate,
the administrator of the LDAP server can supply you with a copy of the server’s
certificate request file. Import the certificate request file into your key ring file and
mark it as trusted.
v Verisign is a registered trademark of Verisign, Inc.
v RSA is a trademark of RSA Data Security, Inc.
v Telstra is a registered trademarks of Telstra, Inc.
v View500 is a registered trademarks of Telstra, Inc.
ldapdelete
ldapdelete is the LDAP delete-entry tool.
ldapdelete topics:
v “ldapdelete synopsis” on page 624
v “ldapdelete description” on page 624
v “ldapdelete options” on page 624
v “Examples: Using ldapdelete” on page 625
v “ldapdelete notes” on page 625
v “ldapdelete SSL notes” on page 625
v “ldapdelete diagnostics” on page 626
Related topics:
v “ldapadd” on page 619
v “ldapmodify” on page 626
v “ldapdelete”
v “ldapmodrdn” on page 630
v “ldapsearch” on page 633
v “IBM Lightweight Directory Access Protocol (LDAP) APIs” on page 615
v “ldap_add” on page 643
v “ldap_delete” on page 651
ldapdelete opens a connection to an LDAP server, binds, and deletes one or more
entries. If one or more dn arguments are provided, entries with those distinguished
names are deleted. Each dn should be a string-represented distinguished name (see
“Distinguished names format” on page 696). By providing no dn arguments, a list
of distinguished names is read from standard input (or from file when using the -f
flag).
ldapdelete options:
-n Show what would be done, but do not actually modify entries. Useful for
debugging in conjunction with -v.
-v Use verbose mode, with many diagnostics written to standard output.
-c Continuous operation mode. Errors are reported, but ldapdelete will continue
with deletions. The default is to exit after reporting an error.
-R Specifies that referrals are not to be automatically followed.
-d debuglevel
Set the LDAP debugging level to debuglevel.
-f file
Read a series of lines from file, performing one LDAP delete for each line. In
this case, the filter given on the command line is treated as a pattern where the
first occurrence of % is replaced with a line from file.
-D binddn
Use binddn to bind to the LDAP directory. binddn should be a
string-represented distinguished name (see “Distinguished names format” on
page 696).
-w passwd
Use passwd as the password for simple authentication.
-h ldaphost
Specify an alternate host on which the LDAP server is running.
-p ldapport
Specify an alternate TCP port where the LDAP server is listening. The default
LDAP port is 389. If not specified and Z is specified, the default LDAP SSL
port 636 is used.
-Z Use a secure SSL connection to communicate with the LDAP server. The Z
option is not supported by non-SSL versions of this tool.
-K keyfile
Specify the name of the SSL key ring file. If the key ring file is not in the
current directory, specify the fully-qualified key ring filename. If a key ring
filename is not specified, this utility will look for the presence of the
SSL_KEYRING environment variable with an associated filename. Otherwise,
no key ring file will be used for server authentication and default trusted
certification authority roots will be used. The key ring file typically contains
one or more certificates of certification authorities (CAs) that are trusted by the
client. These types of X.509 certificates are also known as trusted roots. Also
attempts to delete the entry named with commonName ″Delete Me″ directly below
the University of Michigan organizational entry. It may be necessary to supply a
binddn and passwd for deletion to are allowed (refer to the -D and -w options).
ldapdelete SSL notes: The SSL-related functions that are described for this utility
are supported for the SSL versions of this utility only. Non-SSL versions, such as
those shipped with the Telstra LDAP/X.500 Directory Server do not include SSL
support.
The contents of a client’s key database file is managed with the ikmgui utility. The
ikmgui utility is used to define the set of trusted certification authorities (CAs) that
the client can trust. You can establish a trust relationship with LDAP servers that
use certificates that are issued by one of the CAs that are marked as trusted.
Accomplish this by doing the following.
1. Obtain certificates from trusted CAs.
2. Store them in the key ring file.
3. Mark them as ″trusted.″
If the LDAP servers that are accessed by the client use server authentication, it is
sufficient to define one or more trusted root certificates in the key ring file. With
server authentication, the client can know that the target LDAP server is issued a
For example, if the LDAP server uses a high-assurance Verisign certificate, you
should obtain a CA certificate from Verisign, import it into your key ring file, and
mark it as trusted. If the LDAP server is using a self-signed mkkf server certificate,
the administrator of the LDAP server can supply you with a copy of the server’s
certificate request file. Import the certificate request file into your key ring file and
mark it as trusted.
v Verisign is a registered trademark of Verisign, Inc.
v RSA is a trademark of RSA Data Security, Inc.
v Telstra is a registered trademarks of Telstra, Inc.
v View500 is a registered trademarks of Telstra, Inc.
ldapmodify
ldapmodify is the LDAP change-entry tool.
ldapmodify topics:
v “ldapmodify synopsis”
v “ldapmodify description” on page 627
v “ldapmodify options” on page 627
v “ldapmodify input format” on page 628
v “Alternative ldapmodify input format” on page 628
v “Examples: Using ldapmodify” on page 628
v “ldapmodify notes” on page 630
v “ldapmodify SSL notes” on page 630
v “ldapmodify diagnostics” on page 630
Related topics:
v “ldapadd” on page 619
v “ldapdelete” on page 623
v “ldapmodrdn” on page 630
v “ldapsearch” on page 633
v “IBM Lightweight Directory Access Protocol (LDAP) APIs” on page 615
v “ldap_add” on page 643
v “ldap_delete” on page 651
v “ldap_modify” on page 676
v “ldap_rename” on page 681
v “ldap_ssl” on page 689
v “LDAP Data Interchange Format (LDIF)” on page 697
v “ldap_get_dn” on page 662
ldapmodify synopsis: ldapmodify [-a] [-b] [-c] [-r] [-n] [-v] [-F] [-R] [-d
debuglevel] [-D binddn] [-w passwd] [-h ldaphost] [-p ldapport] [-f file] [-Z] [-K
keyfile] [-P keyfilepw] [-N certificatename]
ldapmodify options:
-a Add new entries. The default for ldapmodify is to modify existing entries. If
invoked as ldapadd, this flag is always set.
-b Assume that any values that start with a ′/’ are binary values and that the
actual value is in a file whose path is specified in the place where values
normally appear.
-c Continuous operation mode. Errors are reported, but ldapmodify will continue
with modifications. The default is to exit after reporting an error.
-r Replace existing values by default.
-n Show what would be done, but do not actually modify entries. Useful for
debugging in conjunction with -v.
-v Use verbose mode, with many diagnostics written to standard output.
-F Force application of all changes regardless of the contents of input lines that
begin with replica: (by default, replica: lines are compared against the LDAP
server host and port in use to decide if a replog record should actually be
applied).
-R Specifies that referrals are not to be automatically followed.
-d debuglevel
Set the LDAP debugging level to debuglevel.
-D binddn
Use binddn to bind to the LDAP directory. binddn should be a
string-represented distinguished name (see “Distinguished names format” on
page 696).
-w passwd
Use passwd as the password for simple authentication.
-h ldaphost
Specify an alternate host on which the LDAP server is running.
-p ldapport
Specify an alternate TCP port where the LDAP server is listening. The default
LDAP port is 389. If not specified and Z is specified, the default LDAP SSL
port 636 is used.
-f file
Read the entry modification information from an ldif file instead of from
standard input. If an ldif file is not specified, you must use standard input to
specify the update records in ldif format.
-Z Use a secure SSL connection to communicate with the LDAP server. The Z
option is not supported by non-SSL versions of this tool.
-K keyfile
Specify the name of the SSL key ring file. If the key ring file is not in the
ldapmodify input format: The contents of file, (or standard input if no f flag is
given on the command line), should conform to the “LDAP Data Interchange
Format (LDIF)” on page 697 format.
where attr is the name of the attribute and value is the value.
By default, values are added. If the - r command line flag is given, the default is to
replace existing values with the new one. Note that it is permissible for a given
attribute to appear more than once (for example, to add more than one value for
an attribute). Also note that you can use a trailing ′\\’ to continue values across
lines and preserve newlines in the value itself. (This is useful for modifying
QUIPU iattr attributes among others).
attr should be preceded by a - to remove a value. Omit the ′=’ and value to remove
an entire attribute.
Examples: Using ldapmodify: Assuming that the file /tmp/entrymods exists and
has the contents:
dn: cn=Modify Me, o=University of Michigan, c=US
changetype: modify
replace: mail
mail: modme@terminator.rs.itd.umich.edu
-
The command
ldapmodify -b -r -f /tmp/entrymods
Assuming that the file /tmp/newentry exists and has the contents:
dn: cn=Barbara Jensen, o=University of Michigan, c=US
objectClass: person
cn: Barbara Jensen
cn: Babs Jensen
sn: Jensen
title: the world's most famous mythical manager
mail: bjensen@terminator.rs.itd.umich.edu
uid: bjensen
the command
ldapadd -f /tmp/entrymods
will add a new entry for Babs Jensen, using the values from the file
/tmp/newentry.
Assuming that the file /tmp/newentry exists and has the contents:
dn: cn=Barbara Jensen, o=University of Michigan, c=US
changetype: delete
the command
ldapmodify -f /tmp/entrymods
ldapmodify SSL notes: The SSL-related functions that are described for this
utility are supported for the SSL versions of this utility only. Non-SSL versions,
such as those shipped with the Telstra LDAP/X.500 Directory Server do not
include SSL support.
The contents of a client’s key database file is managed with the ikmgui utility. The
mkkf utility is used to define the set of trusted certification authorities (CAs) that
the client can trust. You can establish a trust relationship with LDAP servers that
use certificates that are issued by one of the CAs that are marked as trusted.
Accomplish this by doing the following.
1. Obtain certificates from trusted CAs.
2. Store them in the key ring file.
3. Mark them as ″trusted.″
If the LDAP servers that are accessed by the client use server authentication, it is
sufficient to define one or more trusted root certificates in the key ring file. With
server authentication, the client can know that the target LDAP server is issued a
certificate by one of the trusted CAs. In addition, all LDAP transactions that flow
over the SSL connection with the server are encrypted. (This includes the LDAP
credentials that are supplied on the ldap_bind.
For example, if the LDAP server uses a high-assurance Verisign certificate, you
should obtain a CA certificate from Verisign, import it into your key ring file, and
mark it as trusted. If the LDAP server is using a self-signed mkkf server certificate,
the administrator of the LDAP server can supply you with a copy of the server’s
certificate request file. Import the certificate request file into your key ring file and
mark it as trusted.
v Verisign is a registered trademark of Verisign, Inc.
v RSA is a trademark of RSA Data Security, Inc.
v Telstra is a registered trademarks of Telstra, Inc.
v View500 is a registered trademarks of Telstra, Inc.
ldapmodrdn
ldapmodrdn is the LDAP change-entry RDN tool.
ldapmodrdn topics:
v “ldapmodrdn synopsis” on page 631
v “ldapmodrdn description” on page 631
v “ldapmodrdn options” on page 631
v “ldapmodrdn input format” on page 632
v “Examples: Using ldapmodrdn” on page 632
v “ldapmodrdn notes” on page 632
v “ldapmodrdn SSL notes” on page 633
v “ldapmodrdn diagnostics” on page 633
Related topics:
ldapmodrdn synopsis: ldapmodrdn [-r] [-n] [-v] [-c] [-R] [-d debuglevel] [-D
binddn] [-w passwd] [-h ldaphost] [-p ldapport] [-f file] [-Z] [-K keyfile] [-P
keyfilepw] [-N certificatename]
ldapmodrdn opens a connection to an LDAP server, binds, and changes the RDN
of entries. The entry information is read from standard input, from file through the
use of the - f option, or from the command-line pair dn and rdn.
See “Distinguished names format” on page 696 for information about relative
distinguished names and distinguished names.
ldapmodrdn options:
-r Remove old RDN values from the entry. Default is to keep old values.
-n Show what would be done, but do not actually modify entries. Useful for
debugging in conjunction with -v.
-v Use verbose mode, with many diagnostics written to standard output.
-c Continuous operation mode. Errors are reported, but ldapmodify will continue
with modifications. The default is to exit after reporting an error.
-R Specifies that referrals are not to be automatically followed.
-d debuglevel
Set the LDAP debugging level to debuglevel.
-D binddn
Use binddn to bind to the LDAP directory. binddn should be a
string-represented distinguished name (see “Distinguished names format” on
page 696).
-w passwd
Use passwd as the password for simple authentication.
-h ldaphost
Specify an alternate host on which the LDAP server is running.
-p ldapport
Specify an alternate TCP port where the LDAP server is listening. The default
LDAP port is 389. If not specified and Z is specified, the default LDAP SSL
port 636 is used.
-f file
Read the entry modification information from an ldif file instead of from
standard input. If an ldif file is not specified, you must use standard input to
specify the update records in ldif format.
Otherwise, the contents of file, (or by not giving a standard input with a - f flag),
should consist of one or more entries.
Distinguished Name (DN)
Relative Distinguished Name (RDN)
One or more blank lines may be used to separate each DN/RDN pair.
Examples: Using ldapmodrdn: Assuming that the file /tmp/entrymods exists and
has the contents:
cn=Modify Me, o=University of Michigan, c=US
cn=The New Me
the command
ldapmodrdn -r -f /tmp/entrymods
will change the RDN of the ″Modify Me″ entry from ″Modify Me″ to ″The New
Me″ and the old cn, ″Modify Me″ will be removed.
ldapmodrdn notes: The ldapmodrdn command will wait to read entries from
standard input under the following conditions.
v When entry information does not are supplied from file through the use of the -f
option.
v When entry information does not are supplied from the command-line pair dn
and rdn.
ldapmodrdn SSL notes: The SSL-related functions that are described for this
utility are supported for the SSL versions of this utility only. Non-SSL versions,
such as those shipped with the Telstra LDAP/X.500 Directory Server do not
include SSL support.
The contents of a client’s key database file is managed with the ikmgui utility. The
ikmgui utility is used to define the set of trusted certification authorities (CAs) that
the client can trust. You can establish a trust relationship with LDAP servers that
use certificates that are issued by one of the CAs that are marked as trusted.
Accomplish this by doing the following.
1. Obtain certificates from trusted CAs.
2. Store them in the key ring file.
3. Mark them as ″trusted.″
If the LDAP servers that are accessed by the client use server authentication, it is
sufficient to define one or more trusted root certificates in the key ring file. With
server authentication, the client can know that the target LDAP server is issued a
certificate by one of the trusted CAs. In addition, all LDAP transactions that flow
over the SSL connection with the server are encrypted. (This includes the LDAP
credentials that are supplied on the ldap_bind.
For example, if the LDAP server uses a high-assurance Verisign certificate, you
should obtain a CA certificate from Verisign, import it into your key ring file, and
mark it as trusted. If the LDAP server is using a self-signed mkkf server certificate,
the administrator of the LDAP server can supply you with a copy of the server’s
certificate request file. Import the certificate request file into your key ring file and
mark it as trusted.
v Verisign is a registered trademark of Verisign, Inc.
v RSA is a trademark of RSA Data Security, Inc.
v Telstra is a registered trademarks of Telstra, Inc.
v View500 is a registered trademarks of Telstra, Inc.
ldapsearch
ldapsearch is the LDAP search tool.
ldapsearch topics:
v “ldapsearch synopsis” on page 634
v “ldapsearch description” on page 634
v “ldapsearch options” on page 634
v “ldapsearch output format” on page 636
v “Examples: Using ldapsearch” on page 636
v “ldapsearch SSL notes” on page 637
v “ldapsearch diagnostics” on page 638
Related topics:
v “ldapadd” on page 619
v “ldapmodify” on page 626
v “ldapmodrdn” on page 630
v “ldap_add” on page 643
ldapsearch synopsis: ldapsearch [-3] [-n] [-v] [-t] [-A] [-B] [-L] [-R] [-d
debuglevel] [-F sep] [-f file] [-D binddn] [-w bindpasswd] [-h ldaphost] [-p
ldapport] [-Z] [-K keyfile] [-P keyfilepw] [-N certificatename] [-b searchbase] [-s
scope ] [-a deref] [-l time limit] [-z size limit] filter [attrs....]
If ldapsearch finds one or more entries, the attributes that are specified by attrs are
retrieved, and the entries and values are printed to standard output. If no attrs are
listed, all attributes are returned.
ldapsearch options:
-3 Specifies that ldapsearch should run as an LDAP V3 application. This consists
of using ldap_init and ldap_simple_bind_s instead of ldap_open
andldap_bind_s.
-n Show what would be done, but do not actually modify entries. Useful for
debugging in conjunction with -v.
-v Use verbose mode, with many diagnostics written to standard output.
-t Write retrieved values to a set of temporary files. This is useful for dealing
with non-ASCII values such as jpegPhoto or audio.
-A Retrieve attributes only (no values). This is useful when you just want to see if
an attribute is present in an entry and are not interested in the specific values.
-B Do not suppress display of non-ASCII values. This is useful when dealing with
values that appear in alternate characters sets such as ISO-8859.1. This option
is implied by -L (see below).
-L Display search results in ldif format. This option also turns on the -B option,
and causes the -F option to be ignored.
-R Specifies that referrals are not to be automatically followed.
-d debuglevel
Set the LDAP debugging level to debuglevel.
-F sep
Use sep as the field separator between attribute names and values. The default
separator is ′=’, unless the -L flag has been specified, in which case this option
is ignored.
-f file
Read a series of lines from file, performing one LDAP search for each line. In
this case, the filter given on the command line is treated as a pattern where the
first occurrence of %s is replaced with a line from file. If file is a single -
character, then the lines are read from standard input.
ldapsearch output format: If one or more entries are found, each entry is written
to standard output in the form:
Distinguished Name (DN)
attributename=value
attributename=value
attributename=value
...
Multiple entries are separated with a single blank line. If the -F option is used to
specify a separator character, it is used instead of the ′=’ character. By using the -t
option, the name of a temporary file is used in place of the actual value. By giving
the -A option, only the ″attributename″ part is written.
The following command performs a subtree search by using the default search
base for entries with user ID of ″mcs″:
ldapsearch -t "uid=mcs" jpegPhoto audio
The jpegPhoto and audio values are retrieved and written to temporary files. The
output might look like this if one entry with one value for each of the requested
attributes are found:
cn=Mark C Smith, ou=Information Technology Division,
ou=Faculty and Staff,
ou=People, o=University of Michigan, c=US
audio=/tmp/ldapsearch-audio-a19924
jpegPhoto=/tmp/ldapsearch-jpegPhoto-a19924
The following command performs a one-level search at the c=US level for all
organizations whose organizationName begins with university:
Search results display in the LDIF format (see ldif for more information on LIDF
format). The organizationName and description attribute values are retrieved and
printed to standard output, resulting in output similar to this:
dn: o=University of Alaska Fairbanks, c=US
o: University of Alaska Fairbanks
description: Preparing Alaska for a brave new tomorrow
description: leaf node only
And so forth...
ldapsearch SSL notes: The SSL-related functions that are described for this utility
are supported for the SSL versions of this utility only. Non-SSL versions, such as
those shipped with the Telstra LDAP/X.500 Directory Server do not include SSL
support.
The contents of a client’s key ring file is managed with the ikmgui utility. The
ikmgui utility is used to define the set of trusted certification authorities (CAs) for
the client to trust.
To establish a trust relationship with LDAP servers:
Follow these steps to establish a trust relationship with LDAP servers that
use certificates which are issued by trusted CAs:
1. Obtain certificates from trusted CAs.
2. Store them in the key ring file.
3. Mark them as ″trusted.″
If the LDAP servers that are accessed by the client use server authentication, it is
sufficient to define one or more trusted root certificates in the key ring file. With
server authentication, the client can know that the target LDAP server is issued a
certificate by one of the trusted CAs. In addition, all LDAP transactions that flow
over the SSL connection with the server are encrypted. (This includes the LDAP
credentials that are supplied on the ldap_bind.
For example, if the LDAP server uses a high-assurance Verisign certificate, you
should obtain a CA certificate from Verisign, import it into your key ring file, and
mark it as trusted. If the LDAP server is using a self-signed mkkf server certificate,
LDAP controls
Certain LDAP Version 3 operations can be extended with the use of controls. The
possibility exists to send controls to a server, or return them to the client with any
LDAP message. This type of control is called server control.
The LDAP API also supports a client-side extension mechanism usage which
defines client controls. The client-side controls affect the behavior of the LDAP
client library, and never are sent to the server. Note that no client-side controls
definition exists for this client library.
Example: Using LDAPControl:
IBM uses a common data structure to represent both server-side and
client-side controls:
typedef struct ldapcontrol {
char *ldctl_oid;
struct berval ldctl_value;
char ldctl_iscritical;
} LDAPControl, *PLDAPControl;
LDAPControl fields definitions:
The LDAPControl fields have the following definitions:
ldctl_oid
Specifies the control type, represented as a string.
ldctl_value
Specifies the data that is associated with the control. Note that the
control may not include data.
ldctl_iscritical
Specifies whether the control is critical. If the field is non-zero, the
operation carries out only if recognized and supported by the
server (or the client for client-side controls).
Syntax:
#include <ldap.h>
int ldap_abandon(
LDAP *ld,
int msgid)
int ldap_abandon_ext(
LDAP *ld,
int msgid,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
msgid
The message ID of an outstanding LDAP operation, as returned by a call to an
asynchronous LDAP operation such as ldap_search and ldap_modify, and so
forth.
serverctrls
Specifies a list of LDAP server controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about server controls.
clientctrls
Specifies a list of LDAP client controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about client controls.
Return Codes:
ldap_abandon
This error returns 0 if the operation is successful, -1 otherwise, setting
ld_errno appropriately. ldap_abandon_ext returns LDAP_SUCCESS if
successful, and returns an LDAP error code if unsuccessful. See
“ldap_error” on page 653 for details.
Both APIs check to see if the server previously returned the result of the operation.
If it has, it deletes it from the queue of pending messages. If not, it sends an LDAP
abandon operation to the LDAP server.
The caller can expect that the result of an abandoned operation will not return
from a future call to ldap_result.
Syntax:
#include <ldap.h>
int ldap_add(
LDAP *ld,
char *dn,
LDAPMod *attrs[])
int ldap_add_s(
LDAP *ld,
char *dn,
LDAPMod *attrs[])
int ldap_add_ext(
LDAP *ld,
char *dn,
LDAPMod *attrs[]
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp)
int ldap_add_ext_s(
LDAP *ld,
char *dn,
LDAPMod *attrs[]
LDAPControl **serverctrls,
LDAPControl **clientctrls)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn The DN of an entry to add.
attrs
The entry’s attributes, specified using the LAPMod structure, as defined for
ldap_modify. Fill in the mod_type and mod_vals fields, if not already done. The
mod_op field remains ignored unless the use of ORed with the constant
LDAP_MOD_BVALUES. In this case, the mod_op field is used to select the
mod_bvalues case of the mod_vals union.
serverctrls
Specifies a list of LDAP server controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about server controls.
clientctrls
Specifies a list of LDAP client controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about client controls.
msgidp
This result parameter is set to the message ID of the request if the
ldap_add_ext call succeeds.
Note that all entries except those that are specified by the last component in the
given DN must already exist.
The ldap_add_ext API initiates an asynchronous add operation and returns the
constant LDAP_SUCCESS if the request was successfully sent, or another LDAP
error code if not. If successful, ldap_add_ext places the message ID of the request
in *msgidp. A subsequent call to ldap_result can be used to obtain the result of the
operation. Once the operation has completed, ldap_result returns a result that
contains the status of the operation (in the form of an error code). The error code
indicates if the operation completed successfully. The ldap_parse_result API is
used to check the error code in the result.
Similarly, the ldap_add API initiates an asynchronous add operation and returns
the message ID of the operation initiated. A subsequent call to ldap_result, can be
used to obtain the result of the add. In case of error, ldap_add will return -1. This
sets the session error parameters in the LDAP structure appropriately, use
ldap_get_errno to obtain it.
Syntax:
#include <ldap.h>
int ldap_sasl_bind(
LDAP *ld,
char *dn,
char *mechanism,
struct berval *cred,
LDAPControl **servctrls,
LDAPControl **clientctrls,
int *msgidp)
int ldap_sasl_bind_s(
LDAP *ld,
char *dn,
char *mechanism,
struct berval *cred,
LDAPControl **servctrls,
LDAPControl **clientctrls,
struct berval **servercredp)
int ldap_simple_bind(
LDAP *ld,
char *dn,
char *passwd)
int ldap_simple_bind_s(
LDAP *ld,
char *dn,
char *passwd)
int ldap_unbind(
LDAP *ld)
int ldap_unbind_s(
LDAP *ld)
void ldap_set_rebind_proc(
LDAP *ld;
LDAPRebindProc rebindproc)
int ldap_bind(
LDAP *ld,
char *dn,
char *cred,
int method)
int ldap_bind_s(
LDAP *ld,
char *dn,
char *cred,
int method)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn Specifies the Distinguish Name of an entry to bind as.
When communicating with an LDAP server that supports the LDAP V3 protocol, a
bind is optional. The LDAP V3 server interprets the absence of a bind as a request
for unauthenticated access. A bind is required by LDAP servers that support only
the LDAP V2 protocol.
All bind routines take ld as their first parameter, as returned from ldap_init,
ldap_ssl_init, or ldap_open.
SIMPLE AUTHENTICATION
The simplest form of the bind call is ldap_simple_bind_s. It takes the DN to bind
as, as well as the user’s password (supplied in passwd). It returns an LDAP error
indication (see “ldap_error” on page 653). The ldap_simple_bind call is
asynchronous, taking the same parameters but only initiating the bind operation
and returning the message ID of the request it sent. A subsequent call to
ldap_result obtains the result of the operation.
GENERAL AUTHENTICATION
Use them when the authentication method to use needs to become selected at
runtime. They both take an extra method parameter that selects which
authentication method to use. Set method to LDAP_AUTH_SIMPLE when using
this toolkit to select simple authentication. ldap_bind and ldap_simple_bind
return the message ID of the initiated request. ldap_bind_s and
ldap_simple_bind_s return an LDAP error indication, or LDAP_SUCCESS on
successful completion.
SASL AUTHENTICATION
The primary reason for using the SASL bind facility is to use the client
authentication mechanism that is provided by SSL to strongly authenticate the
directory server. Do this by using the client’s X.509 certificate. For example, the
client application can use the following logic:
v ldap_ssl_client_init (initialize the SSL library).
A server that supports this mechanism (such as V4R4 or later AS/400 Directory
Server) can then access the directory by using the strongly authenticated client
identity (as extracted from the client’s X.509 certificate).
UNBINDING
The ldap_unbind call is used to unbind from the directory, end the current
association, and free the resources contained in the ld structure. Once called, any
open connection to the LDAP server closes, and the ld structure is not valid. The
ldap_unbind_s and ldap_unbind; are both synchronous. Use either.
The ldap_set_rebind_proc call is used to set the entry-point of a routine that will
be called to obtain bind credentials. These credentials are for use when contacting
a new server during the following of an LDAP referral. Note that this function is
only available when LDAP_OPT_REFERRALS is set (this is the default). Never
calling ldap_set_rebind_proc, or calling it with a NULL rebindproc parameter,
generates an unauthenticated simple LDAP bind when chasing referrals.
The LDAP library first will call the rebindproc to obtain the referral bind
credentials, and the freeit parameter will be zero. Set the whop, credp, and methodp
parameters as appropriate. If the rebindproc returns LDAP_SUCCESS, referral
processing continues. The rebindproc is called a second time with freeit non-zero.
This will give your application a chance to free any memory that was allocated in
the previous call.
If the first call to the rebindproc returns anything but LDAP_SUCCESS, then
referral processing stops. Additionally, that error code returns for the original
LDAP operation.
Syntax:
#include <ldap.h>
int ldap_compare(
LDAP *ld,
char *dn,
char *attr,
char *value)
int ldap_compare_s(
LDAP *ld,
char *dn,
char *attr,
char *value)
int ldap_compare_ext(
LDAP *ld,
char *dn,
char *attr,
struct berval *bvalue,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp)
int ldap_compare_ext_s(
LDAP *ld,
char *dn,
char *attr,
struct berval *bvalue,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn Specifies the DN of an entry on which to perform the compare.
attr
Specifies the attribute type to use in the comparison.
bvalue
Specifies the attribute value to compare against the value in the entry. Use this
parameter in the ldap_compare_ext and ldap_compare_ext_s routines. They
serve as a pointer to a struct berval, making it possible to compare binary
values. See “ldap_get_values” on page 663 for more information.
value
Specifies the string attribute value to compare against the value in the entry.
Use this parameter in the ldap_compare and ldap_compare_s routines, because
they are suitable only for string attributes.Use ldap_compare_ext or
ldap_compare_ext_s if you need to compare binary values.
serverctrls
Specifies a list of LDAP server controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about server controls.
Usage: The various LDAP compare routines are used to perform LDAP compare
operations. They take the following parameters:
v dn (the DN of the entry on which to perform the compare).
v attr (the attribute type to compare to those that are found in the entry).
v value (the value to compare to those that are found in the entry).
Syntax:
#include <ldap.h>
int ldap_delete_s(
LDAP *ld,
char *dn
int ldap_delete(
LDAP *ld,
char *dn)
int ldap_delete_ext_s(
LDAP *ld,
char *dn,
LDAPMod *attrs,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp)
int ldap_delete_ext(
LDAP *ld,
char *dn,
LDAPMod *attrs,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn This parameter specifies the DN of the entry to delete.
serverctrls
Specifies a list of LDAP server controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about server controls.
clientctrls
Specifies a list of LDAP client controls. This parameter may be set to NULL.
See “LDAP controls” on page 638 for more information about client controls.
msgidp
This result parameter is set to the message ID of the request if the
ldap_add_ext call succeeds.
Return Codes: ldap_delete_s returns an LDAP error code that can be interpreted
by calling one of the ldap_error routines. ldap_delete returns -1 if initiating the
request fails. It returns the non-negative message ID of the request if successful.
Usage: Note that the entry to delete must be a leaf entry (that is, it must have no
children). LDAP does not support the deletion of entire subtrees in a single
operation.
Syntax:
#include <ldap.h>
int ldap_get_errno(
LDAP *ld)
void ldap_perror(
LDAP *ld,
char *s)
int ldap_result2error(
LDAP *ld,
LDAPMessage *res,
int freeit)
char *ldap_err2string(
int error)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
s Specifies the message prefix, which is added to the beginning of the string
form of the error code that is held stored under the LDAP structure. The string
form of the error is the same string that would be returned by a call to
ldap_err2string.
res
Specifies the result, as produced by ldap_result or ldap_search_s, to be
converted to the error code with which it is associated.
freeit
Specifies whether the result, res, becomes freed as a result of calling
ldap_result2error. If non-zero, the result res will be feed by the call. If zero, res
will not be freed by the call.
Return Codes: The possible values for an LDAP error code are:
#define LDAP_SUCCESS 0x00
#define LDAP_OPERATIONS_ERROR 0x01
#define LDAP_PROTOCOL_ERROR 0x02
#define LDAP_TIMELIMIT_EXCEEDED 0x03
#define LDAP_SIZELIMIT_EXCEEDED 0x04
#define LDAP_COMPARE_FALSE 0x05
#define LDAP_COMPARE_TRUE 0x06
#define LDAP_STRONG_AUTH_NOT_SUPPORTED 0x07
#define LDAP_STRONG_AUTH_REQUIRED 0x08
#define LDAP_PARTIAL_RESULTS 0x09
Usage: These routines provide interpretation of the various error codes that are
returned by the LDAP protocol and LDAP library routines.
The ldap_get_errno API obtains information about the most recent error that
occurred for an LDAP operation. Call this function for any LDAP API that does
not return an error.
Syntax:
#include <ldap.h>
int ldap_count_attributes(
LDAP *ld,
LDAPMessage *entry)
char *ldap_first_attribute(
LDAP *ld,
LDAPMessage *entry,
BerElement **berptr)
char *ldap_next_attribute(
LDAP *ld,
LDAPMessage *entry,
BerElement *berptr)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
entry
The attribute information as returned by ldap_first_entry or ldap_next_entry.
berptr
This is an output parameter that is returned from ldap_first_attribute, which
returns a pointer to a BerElement that is allocated to keep track of current
position. It is an input parameter and an output parameter for subsequent calls
to ldap_next_attribute. This is where it specifies a pointer to a BerElement that
was allocated by the previous call to ldap_first_attribute or
ldap_next_attribute. The BerElement structure is opaque to the application.
If the ldap_next_attribute call results in an error, NULL is returned, the error code
is set, and the memory to which berptr points also must be freed by calling
ldap_ber_free.
The attribute names that are returned by ldap_first_attribute are suitable for
inclusion in a call to ldap_get_values.
ldap_next_attribute returns a string that contains the name of the next type in the
entry. Free this string by using ldap_memfree when its use completes.
The attribute names that are returned by ldap_next_attribute are suitable for
inclusion in a call to ldap_get_values to retrieve the attribute’s values.
Note: APIs with the ″_np″ suffix are preliminary implementations, and are not
documented in the Internet Draft, C LDAP Application Program Interface.
Syntax:
#include <ldap.h>
LDAPMessage *ldap_first_entry(
LDAP *ld,
LDAPMessage *result)
LDAPMessage *ldap_next_entry(
LDAP *ld,
LDAPMessage *entry)
int ldap_count_entries(
LDAP *ld,
LDAPMessage *result)
int ldap_get_entry_controls_np(
LDAP *ld,
LDAPMessage *entry
LDAPControl ***serverctrlsp)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
entry
Specifies a pointer to an entry that is returned on a previous call to
ldap_first_entry, ldap_next_entry, ldap_first_reference, or
ldap_next_reference.
result
Specifies the result that is returned by a call to ldap_result or one of the
synchronous search routines (ldap_search_s, ldap_search_st, or
ldap_search_ext_s).
serverctrlsp
Specifies a pointer to a result parameter that is filled in with an allocated array
of controls copied out of the LDAPMessage message. Free the control array by
calling ldap_controls_free.
PROCESSING ENTRIES
The ldap_first_entry and ldap_next_entry APIs are used to step through and
retrieve the list of entries from a search result chain. When an LDAP operation
completes and the result is obtained as described, a list of LDAPMessage
structures is returned. This is referred to as the search result chain. A pointer to
the first of these structures is returned by ldap_result and ldap_search_s.
The ldap_first_entry routine is used to retrieve the first entry in a chain of search
results. It takes the result as returned by a API call, (from those that are listed
below), and returns a pointer to the first entry in the result.
v ldap_result.
v ldap_search_s.
v ldap_search_st.
v ldap_search_ext_s.
COUNTING ENTRIES
The ldap_count_entries API returns the number of entries that are contained in a
chain of entries. It also counts the number of entries that remain in a chain. This is
true provided the API was called with a message, entry, or continuation reference
returned by ldap_first_message, ldap_next_message, ldap_first_entry,
ldap_next_entry, ldap_first_reference, or ldap_next_reference, respectively.
Note: APIs with the ″_np″ suffix are preliminary implementations, and are not
documented in the Internet Draft, C LDAP Application Program Interface.
Syntax:
#include <ldap.h>
LDAPMessage *ldap_first_reference(
LDAP *ld,
LDAPMessage *result)
LDAPMessage *ldap_next_reference(
LDAP *ld,
LDAPMessage *entry)
int ldap_count_references(
LDAP *ld,
LDAPMessage *result)
int ldap_parse_reference_np(
LDAP *ld,
LDAPMessage *ref
char ***referralsp,
LDAPControl ***serverctrlsp,
int freeit )
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
entry
Specifies a pointer to an entry that are returned on a previous call to
ldap_first_entry, ldap_next_entry, ldap_first_reference, or
ldap_next_reference.
result
Specifies the result that is returned by a call to ldap_result or one of the
synchronous search routines (ldap_search_s, ldap_search_st, or
ldap_search_ext_s).
referralsp
Specifies a pointer to a result parameter that is filled in with the contents of
the referrals field from the LDAPMessage message, indicating zero or more
alternate LDAP servers where the request should be retried. The referrals array
should be freed by calling ldap_value_free. NULL may be supplied for this
parameter to ignore the referrals field.
serverctrlsp
Specifies a pointer to a reslt parameter that is filled in with an allocated array
of controls copied out of the LDAPMessage message. The control array should
be freed by calling ldap_controls_freed.
freeit
Specifies a boolean value that determines if the LDAP result chain (as specified
by ref) is to be freed. Any non-zero value will result in the LDAP result chain
being freed after the requested information is extracted. Alternatively, the
ldap_msgfree API can be used to free the LDAP result chain at a later time.
Usage: These routines parse results that are received from ldap_result or the
synchronous LDAP search operation routines ldap_search_s, ldap_search_st, and
ldap_search_ext_s.
COUNTING REFERENCES
Syntax:
#include <ldap.h>
char *ldap_get_dn(
LDAP *ld,
LDAPMessage *entry)
char **ldap_explode_dn(
char *dn,
int notypes)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn Specifies the DN to be exploded (as returned fromldap_get_dn).
entry
The entry whose dn is retrieved, as returned by ldap_first_entry or
ldap_next_entry.
notypes
Specifies if type information is to return with each RDN. Any returned
non-zero information strips the type information. Any returned zero
information keeps the type information. For example, notypes=1 results in
″cn=Fido″ that returns as ″Fido″.
Note: These routines malloc memory that the caller must free.
Syntax:
#include <ldap.h>
char **ldap_get_values(
LDAP *ld,
LDAPMessage *entry,
char *attr)
int ldap_count_values(
char **vals)
int ldap_count_values_len(
struct berval **bvals)
void ldap_value_free(
char **vals)
void ldap_value_free_len(
struct berval **bvals)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
attr
Specifies the attribute whose values are desired.
entry
Specifies an LDAP entry as returned by ldap_first_entry or ldap_next_entry.
vals
Specifies a pointer to a NULL-terminated array of attribute values, as returned
by ldap_get_values.
bvals
Specifies a pointer to a NULL-terminated array of pointers to berval structures,
as returned by ldap_get_values_len.
Usage: Use these routines to retrieve and manipulate attribute values from an
LDAP entry as returned by ldap_first_entry or ldap_next_entry. The
ldap_get_values API takes the entry and the attribute attr whose values are desired
and returns a NULL-terminated array of pointers to NULL-terminated character
If the attribute values are binary in nature, and therefore not suitable to be
returned as an array of char *s, use the ldap_get_values_len routine instead. It
takes the same parameters as ldap_get_values, but returns a NULL-terminated
array of pointers to berval structures. These structures each contain the length of
and a pointer to a value.
Syntax:
#include <ldap.h>
LDAP *ldap_init(
char *host,
int port)
LDAP *ldap_open(
char *host,
int port)
int ldap_set_option(
LDAP *ld,
int optionToSet,
void *optionValue)
int ldap_get_option(
LDAP *ld,
int optionToGet,
void *optionValue)
int ldap_version(
LDAPVersion *version)
Parameters:
host
Specifies the name of the host on which the LDAP server is running. The host
parameter may contain a blank-separated list of possible connection hosts.
Additionally, each host may optionally be of the form host:port. If present, the
:port overrides the port parameter to supplied on ldap_init, ldap_ssl_init, or
ldap_open. If the host parameter is null, the LDAP server is assumed to be
running on the local host.
port
Specifies the port number to which to connect. Specify LDAP_PORT if you
desire the default IANA-assigned port of 389. To use the default SSL port 636
for SSL connections, use LDAPS_PORT.
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
optionToSet
Identifies the option value that is to be set on the ldap_set_option call. See
USAGE below for the list of supported options.
optionToGet
Identifies the option value that is to be queried on the ldap_get_option call.
See USAGE below for the list of supported options.
optionValue
This parameter specifies one of the following addresses.
v The address of the value to set by using ldap_set_option.
v The address of the storage in which to return the queried value by
ldap_get_option.
Usage: ldap_init initializes a session with an LDAP server. The server is not
actually contacted until an operation is performed that requires it. This allows the
setting of various options that are after initialization, but before actually contacting
the host. It allocates an LDAP structure, which is used to identify the connection
and maintain per-connection information.
Although deprecated, IBM still supports the use of ldap_open. The ldap_open API
allocates an LDAP structure and opens a connection to the LDAP server. IBM
recommends using ldap_init instead of ldap_open.
The ldap_init and ldap_open APIs return a pointer to an LDAP structure, which
should be passed to subsequent calls to ldap_set_option, ldap_simple_bind,
ldap_search, and so forth.
Note: You should not make any assumptions about the order or location of
elements in the opaque LDAP structure.
The ldap_version API returns the toolkit version (multiplied by 100). It also sets
information in the LDAPVersion structure.
Set or get the following session settings by using the ldap_set_option and
ldap_get_option API:
LDAP_OPT_SIZELIMIT
Get or Set maximum number of entries that return on a search operation
LDAP_OPT_TIMELIMIT
Get or Set maximum number of seconds to wait for search results
LDAP_OPT_REFHOPLIMIT
Get or Set maximum number of referrals in a sequence that the client can
follow
LDAP_OPT_DEREF
Get or Set rules for following aliases at the server
LDAP_OPT_REFERRALS
Get or Set whether the client should follow referrals
LDAP_OPT_DEBUG
Get or Set debug options
LDAP_OPT_SSL_CIPHER
Get or Set SSL ciphers to use
LDAP_OPT_SSL_TIMEOUT
Get or Set SSL timeout for refreshing session keys
LDAP_OPT_REBIND_FN
Get or Set address of application’s setrebindproc procedure
LDAP_OPT_PROTOCOL_VERSION
Get or Set LDAP protocol version to use (V2 or V3)
LDAP_OPT_SERVER_CONTROLS
Get or Set default server controls
LDAP_OPT_CLIENT_CONTROLS
Get or Set default client library controls
LDAP_OPT_HOST_NAME
Get current host name (cannot be set)
LDAP_OPT_ERROR_NUMBER
Get error number (cannot be set)
LDAP_OPT_ERROR_STRING
Get error string (cannot be set)
See for important information if any of the following listed conditions exist on
your system.
v Your LDAP application is based on the LDAP V2 APIs (that is, you are using
ldap_open).
v Your application uses ldap_init and ldap_set_option to transition from LDAP
V3 to LDAP V2.
LDAP_OPT_SIZELIMIT
sizevalue=50;
ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &sizevalue);
ldap_get_option( ld, LDAP_OPT_SIZELIMIT, &sizevalue );
LDAP_OPT_TIMELIMIT
This API specifies the number of seconds to wait for search results.
Note: The actual time limit for operations also is bounded by the maximum time
that the server is configured to allow. The actual time limit is the lesser of
the value specified with this option and the value configured in the LDAP
server. The default is unlimited (specified with a value of zero).
Examples:
timevalue=50;
ldap_set_option( ld, LDAP_OPT_TIMELIMIT, &timevalue);
ldap_get_option( ld, LDAP_OPT_TIMELIMIT, &timevalue );
LDAP_OPT_REFHOPLIMIT
This option specifies the maximum number of hops that the client library will take
when chasing referrals. The default is 5.
Examples:
hoplimit=7;
ldap_set_option( ld, LDAP_OPT_REFHOPLIMIT, &hoplimit);
ldap_get_option( ld, LDAP_OPT_REFHOPLIMIT, &hoplimit);
LDAP_OPT_DEREF
This option specifies alternative rules for following aliases at the server.
Supported values:
LDAP_DEREF_NEVER 0
LDAP_DEREF_SEARCHING 1
LDAP_DEREF_FINDING 2
LDAP_DEREF_ALWAYS 3
LDAP_OPT_REFERRALS
This option specifies whether the LDAP library will automatically follow referrals
that are returned by LDAP servers. Supported values are:
LDAP_OPT_DEBUG
Specifies a bit-map that indicates the level of debug trace for the LDAP library.
Supported values:
/* Debug levels */
LDAP_DEBUG_OFF 0x000
LDAP_DEBUG_TRACE 0x001
LDAP_DEBUG_PACKETS 0x002
LDAP_DEBUG_ARGS 0x004
LDAP_DEBUG_CONNS 0x008
LDAP_DEBUG_BER 0x010
LDAP_DEBUG_FILTER 0x020
LDAP_DEBUG_CONFIG 0x040
LDAP_DEBUG_ACL 0x080
LDAP_DEBUG_STATS 0x100
LDAP_DEBUG_STATS2 0x200
LDAP_DEBUG_SHELL 0x400
LDAP_DEBUG_PARSE 0x800
LDAP_DEBUG_ANY 0xffff
Examples:
int value;
int debugvalue= LDAP_DEBUG_TRACE | LDAP_DEBUG_PACKETS;
ldap_set_option( ld, LDAP_OPT_DEBUG, &debugvalue);
ldap_get_option( ld, LDAP_OPT_DEBUG, &value );
LDAP_OPT_SSL_CIPHER
This option specifies a set of one or more ciphers to use when negotiating the
cipher algorithm with the LDAP server. The first cipher in the list that is common
with the list of ciphers that are supported by the server is chosen. For the export
version of the SSL library, the value used is ″0306″. For the domestic version of the
SSL library, the default value is ″05040A090306″. Note that the cipher string that is
supported by the export version of the SSL library is fixed, and cannot be
modified.
Supported ciphers:
LDAP_SSL_RC4_MD5_EX "03"
LDAP_SSL_RC2_MD5_EX "06"
LDAP_SSL_RC4_SHA_US "05" (Non-export only)
LDAP_SSL_RC4_MD5_US "04" (Non-export only)
LDAP_SSL_DES_SHA_US "09" (Non-export only)
LDAP_SSL_3DES_SHA_US "0A" (Non-export only)
LDAP_OPT_SSL_TIMEOUT
This option specifies the SSL inactivity timer in seconds. After the specified
seconds, in which no SSL activity has occurred, the SSL connection refreshes with
new session keys. A smaller value may marginally increase security, but will have
a small impact on performance. The default SSL timeout value is 43200 seconds (12
hours).
Examples:
value = 100;
ldap_set_option( ld, LDAP_OPT_SSL_TIMEOUT, &value );
ldap_get_option( ld, LDAP_OPT_SSL_TIMEOUT, &value)
LDAP_OPT_REBIND_FN
This option specifies the address of a routine that is called by the LDAP library
when the need arises to authenticate a connection with another LDAP server. This
can occur, for example, when the LDAP library is chasing a referral. If a routine is
not defined, referrals always will be chased using the anonymous identity. A
default routine is not defined..
Examples:
LDAP_OPT_PROTOCOL_VERSION
This option specifies the LDAP protocol for the LDAP client library to use when
connecting to an LDAP server. This option also is used to determine which LDAP
protocol to use for the connection. In general, an application that uses ldap_init to
create the LDAP connection is assumed to be using LDAP V3 to communicate with
the LDAP server. An application that uses the deprecated ldap_open API is
assumed to be using LDAP V2 to communicate with the LDAP server. In either
case, use the LDAP_OPT_PROTOCOL_VERSION option with ldap_set_option to
change the default. Reset the LDAP protocol version prior to issuing the bind (or
any operation that causes an implicit bind).
Examples:
version2 = LDAP_VERSION2;
version3 = LDAP_VERSION3;
/* Example for Version 3 application setting version to version 2 */
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version2);
/* Example of Version 2 application setting version to version 3 */
ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version3);
ldap_get_option( ld, LDAP_OPT_PROTOCOL_VERSION, &value);
LDAP_OPT_SERVER_CONTROLS
LDAP_OPT_CLIENT_CONTROLS
Specifies a default list of client controls to be processed by the client library with
each request. Since client controls are not defined for this version of the library, the
ldap_set_option API can be used to define a set of default, non-critical client
controls. If one ore more client controls in the set is critical, the entire list is
rejected with a return code of LDAP_UNAVAILABLE_CRITICAL_EXTENSION.
LDAP_OPT_HOST_NAME
This is a read-only option that returns a pointer to the hostname for the original
connection (as specified on the ldap_init or ldap_ssl_init).
Example:
char *hostname;
ldap_get_option( ld, LDAP_OPT_HOST_NAME, &hostname);
LDAP_OPT_ERROR_NUMBER
This is a read-only option that returns the error code that is associated with the
most recent LDAP error that occurred for the specified LDAP connection.
Example:
int error;
ldap_get_option( ld, LDAP_OPT_ERROR_NUMBER, &error);
LDAP_OPT_ERROR_STRING
This is a read-only option that returns the text message that is associated with the
most recent LDAP error that occurred for the specified LDAP connection.
Example:
char *error_string;
ldap_get_option( ld, LDAP_OPT_ERROR_STRING, &error_string);
LDAP_OPT_EXTERROR
This is a read-only option that returns the extended error code. For example, if an
SSL error occurred when attempting to call aldap_search_s API, you can obtain the
actual SSL error by using LDAP_OPT_EXTERROR.
Example:
int error;
ldap_get_option( ld, LDAP_OPT_ERROR_EXTERROR, &error);
Returns errors reported by the SSL library.
int protocolVersion;
if ( protocolVersion == LDAP_VERSION2 ) {
ldap_set_option( ld, LDAP_OPT_SIZELIMIT, (void *)sizeLimit );
} else { /* the protocol version is LDAP_VERSION3 */
ldap_set_option( ld, LDAP_OPT_SIZELIMIT, $sizeLimit );
}
MULTITHREADED APPLICATIONS
The LDAP client libraries generally are thread safe. While a multithreaded
application safely can use the LDAP library on multiple threads within the
application, be aware of the following considerations:
1. Use the LDAP connection (the ld) on the thread that is created. This avoids the
possibility of possible conflicts if multiple threads concurrently are processing
the results of an operation submitted on a different thread.
2. Design an application to submit requests on one or more threads, with the
results returned on different threads. This avoids the possibility of two threads
attempting to process the results associated with a single LDAP connection.
3. The ldap_get_errno API obtains information with respect to the most recent
error that occurred for the specified LDAP connection. It does not return the
most recent LDAP error that occurred on the thread on which it is issued.
4. A key consideration is that only a single thread should be performing
operations on a particular LDAP connection at a particular instance.
Syntax:
#include <ldap.h>
void ldap_memfree(
char *mem)
void ldap_ber_free(
BerElement *berptr)
void ldap_control_free(
LDAPControl *ctrl)
void ldap_controls_free(
LDAPControl **ctrls)
void ldap_msg_free(
LDAPMessage *msg)
Parameters:
mem
Specifies the address of storage that was allocated by the LDAP library.
berptr
Specifies the address of the BerElement returned from ldap_first_attribute and
ldap_next_attribute.
ctrl
Specifies the address of an LDAPControl structure.
ctrls
Specifies the address of an LDAPControl list, represented as a NULL-stopped
array of pointers to LDAPControl structures.
Usage: ldap_memfree is used to free storage that has been allocated by the LDAP
library (libldap). Use this routine as directed when using ldap_error,
ldap_get_option, and ldap_first_attribute.
For those LDAP APIs that allocate an LDAPControl structure, use the
ldap_control_free API.
For those LDAP APIs that allocate a list of LDAPControl structures, use the
ldap_controls_free API.
The ldap_msgfree routine is used to free the memory allocated for an LDAP
message by ldap_result, ldap_search_s, ldap_search_ext_s, or ldap_search_st. It
takes a pointer to the result to be freed, and returns the type of the message it
freed.
The ldap_ber_free routine is used to free the BerElement pointed to by berptr. The
LDAP library automatically frees the BerElement when ldap_next_attribute returns
NULL. The application is responsible for freeing the BerElement if for any reason it
does not invoke the ldap_next_attribute until it returns NULL.
Syntax:
#include <ldap.h>
LDAPMessage *ldap_first_message(
LDAP *ld,
LDAPMessage *result)
LDAPMessage *ldap_next_message(
LDAP *ld,
LDAPMessage *msg)
int ldap_count_messages(
LDAP *ld,
LDAPMessage *result)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
result
Specifies the result that is returned by a call to ldap_result or one of the
synchronous search routines (ldap_search_s, ldap_search_st, or
ldap_search_ext_s).
msg
Specifies the message that is returned by a previous call to ldap_first_message
or ldap_next_message.
Usage: Use these routines to step through the list of messages in a result chain, as
returned by ldap_result.
Use the ldap_count_messages API to count the number of messages returned. Use
the ldap_msgtype API to distinguish between the different message types.
Syntax:
#include <ldap.h>
int ldap_modify(
LDAP *ld,
char *dn,
LDAPMod *mods[])
int ldap_modify_ext(
LDAP *ld,
char *dn,
LDAPMod *mods[],
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp)
int ldap_modify_s(
LDAP *ld,
char *dn,;
LDAPMod *mods[])
int ldap_modify_ext_s(
LDAP *ld,
char *dn,
LDAPMod *mods[],
LDAPControl **serverctrls,
LDAPControl **clientctrls)
void ldap_mods_free(
LDAPMod **mods,
int freemods)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn Specifies the DN of an entry to change.
mods
Specifies a NULL-terminated array of modifications to make to the entry. Each
element of the mods array is a pointer to an LDAPMod structure (see USAGE
below).
freemods
Specifies whether the mods pointer frees in addition to the NULL-terminated
array of mod structures.
Return Codes: ldap_modify_s and ldap_modify_ext_s will return the LDAP error
code that result from the modification operation.
Use the mod_op field to specify the type of modification to perform. The field
should be one of the following:
v LDAP_MOD_ADD (0x00)
v LDAP_MOD_DELETE (0x01)
v LDAP_MOD_REPLACE (0x02)
This field also indicates the type of values that are included in the mod_vals union.
For binary data, you also must logically OR the operation type with
LDAP_MOD_BVALUES (0x80). This indicates that the values are specified in a
NULL-terminated array of struct_berval structures.
The mod_type field specifies the type of attribute to add, change, or delete.
For LDAP_MOD_ADD modifications, the given values are added to the entry,
creating the attribute if necessary.
For LDAP_MOD_DELETE modifications, the given values are deleted from the
entry, and remove the attribute if no values remain. To delete the entire attribute,
set the mod_values field to NULL.
All modifications are performed in the order in which they are listed.
ldap_modify_s returns the LDAP error code resulting from the change operation.
This error code can be interpreted by ldap_perror and ldap_err2string.
The ldap_modify operation works the same way as ldap_modify_s, except for the
following conditions.
v It is asynchronous.
v It returns the message ID of the request it initiates.
v It returns a -1 on error.
Obtain the result of the operation by calling ldap_result.
Syntax:
#include <ldap.h>
int ldap_parse_result(
LDAP *ld;
LDAPMessage *res,
int *errcodep,
char **matcheddnp,
char **errmsgp,
char ***referralsp,
LDAPControl ***servctrlsp,
int freeit)
int ldap_parse_sasl_bind_result(
LDAP *ld;
LDAPMessage *res,
struct berval **servercredp,
int freeit)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
res
Specifies the result of an LDAP operation as returned by ldap_result or one of
the synchronous LDAP API operation calls.
errcodep
Specifies a pointer to the result parameter that the LDAP error code field fills
in from the LDAPResult message. The LDAP server produces the LDAPResult
message, and indicates the outcome of the operation. Specify NULL for
errcodep to ignore the LDAPResult message.
matcheddnp
Specifies a pointer to a result parameter. When LDAP_NO_SUCH_OBJECT
returns as the LDAP error code, this result parameter fills in with a
Distinguished Name that indicates how much of the name in the request the
server recognized. Specify NULL for matcheddnp to ignore the matched DN.
Call ldap_memfree to free the matched DN string.
errmsgp
Specifies a pointer to a result parameter that is filled in with the contents of
the error message from the LDAPMessage message. Call ldap_memfree to free
the error message string.
referralsp
This parameter specifies a pointer to a result parameter that is filled in with
the contents of the referrals field from the LDAPMessage message. This
message indicates zero or more alternate LDAP servers where the request
retries. Call ldap_value_free to free the referrals array. Supply a NULL for this
parameter to ignore the referrals field.
serverctrlsp
Specifies a pointer to a result parameter that is filled in with an allocated array
of controls that are copied out of the LDAPMessage message. Call
ldap_controls_free to free the control array.
Return Codes: The parse routines return an LDAP error code if they encounter an
error by parsing the result.
See “ldap_error” on page 653 for a list of the LDAP error codes.
The ldap_err2string API is used to convert the numeric LDAP error code.
(Provided it was returned by one of the ldap_parse_*_result APIs, or one of the
synchronous APIs, into a NULL-terminated character string that describes the
error.) The string returns as static data and must not be freed by the application.
Syntax:
#include <ldap.h>
int ldap_rename(
LDAP *ld,
char *dn,
char *newrdn,
char *newparent,
int deleteoldrdn,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
int *msgidp)
int ldap_rename_s(
LDAP *ld,
char *dn,
char *newrdn,
char *newparent,
int deleteoldrdn,
LDAPControl **serverctrls,
LDAPControl **clientctrls)
int ldap_modrdn(
LDAP *ld,
char *dn,
char *newrdn,
int deleteoldrdn)
int ldap_modrdn_s(
LDAP *ld,
char *dn,
char *newrdn,
int deleteoldrdn)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
dn Specifies the DN of an entry whose DN is to change. When specified with the
deprecated ladp_modrdn API and deprecated ldap_modrdn_s API, dn
specifies the DN of the entry whose RDN is to change.
newrdn
Specifies the new RDN that is given to the entry.
newparent
Specifies the new parent, or superior entry. If this parameter is NULL, only the
RDN of the entry changes. Specify the root DN by passing a zero length string,
″″. The newparent parameter always should be NULL when using version 2 of
the LDAP protocol; otherwise the server’s behavior is undefined.
deleteoldrdn
Specifies a boolean value. When set to 1, the old RDN value deletes from the
entry. When set to 0, the old RDN value remains as a non-distinguished value.
With regard to the ldap_rename and ldap_rename_s APIs, this parameter only
has meaning if newrdn is different from the old RDN.
Return Codes: The synchronous version of this routine returns an LDAP error
code, either LDAP_SUCCESS or an error code if there was an error. The
asynchronous version returns -1 in case of trouble. If the asynchronous API is
successful, use ldap_result to obtain the results of the operation. See “ldap_error”
on page 653 for more details.
Usage: In LDAP V2, the ldap_modrdn and ldap_modrdn_s APIs were used to
change the name of an LDAP entry. They could only be used to change the least
significant component of a name (the RDN or relative distinguished name). LDAP
V3 provides the Change DN protocol operation that allows more general name
change access. The ldap_rename and ldap_rename_s routines are used to change
the name of an entry, and the use of the ldap_modrdn and routines is deprecated.
The synchronous ldap_rename_s API returns the result of the operation. Either the
constant LDAP_SUCCESS if the operation was successful, or another LDAP error
code if it was not.
The ldap_rename and ldap_rename_s APIs both support LDAP V3 server controls
and client controls.
Syntax:
#include <ldap.h>
int ldap_result(
LDAP *ld,
int msgid,
int all,
struct timeval *timeout,
LDAPMessage **result)
int ldap_msgtype(
LDAPMessage *msg)
int ldap_msgid(
LDAPMessage *msg)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
msgid
Specifies the message ID of the operation whose results are to be returned. Set
the parameter to LDAP_RES_ANY if you require any result.
all This parameter only has meaning for search results. For search results, use all
to specify how many search result messages return in a single call to
ldap_result. Specify LDAP_MSG_ONE to retrieve one search result message at
a time. Specify LDAP_MSG_ALL to request receival of all results of a search
before returning all results in a single chain. Specify LDAP_MSG_RECEIVED
to indicate that all results retrieved so far should return in the result chain.
timeout
Specifies how long in seconds to wait for results (as identified by the supplied
msgid) to return from ldap_result. A NULL value causes ldap_result to wait
until results for the operation identified by msgid are available. To poll, the
timeout parameter should be non-NULL, pointing to a zero-valued timeval
structure.
msg
Specifies a pointer to a result, as returned from ldap_result, ldap_search_s,
ldap_search_st, or ldap_search_ext_s.
result
Contains the result of the asynchronous operation that is identified by msgid.
Pass this result to the LDAP through parsing routines such as ldap_first_entry.
Usage: The ldap_result routine is used to wait for and return the result of an
operation previously initiated by one of the LDAP asynchronous operation
routines. (For example, ldap_search, ldap_modify, and so forth.) These routines
return a msgid that uniquely identifies the request. Use the msgid to request the
result of a specific operation from ldap_result.
The ldap_msgtype API returns the type of LDAP message, based on the LDAP
message that is passed as input (by using the msg parameter).
The ldap_msgid API returns the message ID associated with the LDAP message
that is passed as input (by using the msg parameter).
Note: This routine allocates memory for results that it receives. Free the memory
by calling ldap_msgfree.
Syntax:
#include <sys/time.h> /* for struct timeval definition */
#include <ldap.h>
int ldap_search(
LDAP *ld,
char *base,
int scope,
char *filter,
char *attrs[],
int attrsonly)
int ldap_search_ext(
LDAP *ld,
char *base,
int scope,
char *filter,
char *attrs[],
int attrsonly,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
struct timeval *timeout,
int sizelimit,
int *msgidp)
int ldap_search_s(
LDAP *ld,
char *base,
int scope,
char *filter,
char *attrs[],
int attrsonly,
LDAPMessage **res)
int ldap_search_ext_s(
LDAP *ld,
char *base,
int scope,
char *filter,
char *attrs[],
int attrsonly,
LDAPControl **serverctrls,
LDAPControl **clientctrls,
struct timeval *timeout,
int sizelimit,
LDAPMessage **res)
int ldap_search_st(
LDAP *ld,
char *base,
int scope,
char *filter,
char *attrs[],
int attrsonly,
struct timeval *timeout,
LDAPMessage **res)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
Use the ’x=’ construct to specify approximate matching of the filters. The
representation for <attributetype> and <attributevalue> are as described in The
For example, the filter ″mail=*″ will find any entries that have a mail attribute.
The filter ″mail=*@terminator.rs.itd.umich.edu″ will find any entries that have a
mail attribute that end in the specified string. To put parentheses in a filter,
escape them with a backslash ’\\’ character. See A String Representation of
Once the operation has completed, ldap_result returns a result that contains the
status of the operation (in the form of an error code). The error code indicates if
the operation completed successfully. The ldap_parse_result API is used to check
the error code in the result.
There are three options in the session handle ld which potentially affects the
performance of the search. They are:
LDAP_OPT_TIMELIMIT
A limit on the number of seconds to spend on the search. A
value of zero means no limit. Note that the value from the
session handle is ignored when using the ldap_search_ext()
or ldap_search_ext_s() functions.
LDAP_OPT_DEREF
One of LDAP_DEREF_NEVER (0x00), LDAP_DEREF_SEARCHING
(0x01), LDAP_DEREF_FINDING (0x02), or LDAP_DEREF_ALWAYS
(0x03), specifying how aliases should be handled during the
search. The LDAP_DEREF_SEARCHING value means aliases should
be dereferenced during the search but not when locating the
base object of the search. The LDAP_DEREF_FINDING value
means aliases should be dereferenced when locating the base
object but not during the search.
READING AN ENTRY
LDAP does not support a read operation directly. Instead, this operation is
emulated by a search with base set to the DN of the entry to read, scope set to
LDAP_SCOPE_BASE, and filter set to ″(objectclass=*)″. attrs contains the list of
attributes to return.
LDAP does not support a list operation directly. Instead, this operation is emulated
by a search with base set to the DN of the entry to list, scope set to
LDAP_SCOPE_ONELEVEL, and filter set to ″(objectclass=*)″. attrs contains the list
of attributes to return for each child entry.
If only the distinguished names of child entries is required, the attrs parameter
should specify a NULL-terminated array of one character string, which has the
value ″dn″.
Note: These routines use malloc to allocate storage that is returned by the res
parameter. Use ldap_msgfree to free this storage.
Syntax:
#include <ldap.h>
#include <ldapssl.h>
int ldap_ssl_client_init(
char *keyring,
char *keyring_pw,
int ssl_timeout)
int *pSSLReasonCode)
LDAP *ldap_ssl_init(
char *host,
int port,
char *name)
int ldap_ssl_start(
LDAP *ld,
char *keyring,
char *keyring_pw,
char *name)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
host
Specifies the name of the host on which the LDAP server is running. The host
parameter may contain a blank-separated list of connection hosts. Additionally,
each host may optionally be of the form host:port. If present, the :port overrides
the ldap_ssl_init port parameter to supplied on ldap_init or ldap_open. If the
host parameter is null, the LDAP server is assumed to be running on the local
host.
port
Specifies the port number to which to connect. If you want the default
IANA-assigned SSL port of 636, specify LDAPS_PORT.
keyring
Specifies the key database file (with ″kdb″ extension). The key database file
typically contains one or more certificates of certification authorities (CAs) that
are trusted by the client. These types of X.509 certificates also are known as
trusted roots. Use of a key database file extends to storing the client’s private
keys and associated client certificates. Requirement for a private key and
associated client certificate exists only if the LDAP server configuration
requires client and server authentication. If the LDAP server configuration
provides only server authentication, a private key and a client certificate are
not used.
Although still supported, the use of the ldap_ssl_start API is now deprecated. The
ldap_ssl_client_init and ldap_ssl_init APIs should be used instead. The
ldap_ssl_start API starts a secure connection (using SSL) to an LDAP server.
ldap_ssl_start accepts the ld from a ldap_open and performs an SSL handshake to
a server. ldap_ssl_start must be called after ldap_open and prior to ldap_bind.
Once the secure connection is established for the ld, all subsequent LDAP
messages that flow over the secure connection are encrypted. This includes the
ldap_bind parameters, until ldap_unbind is invoked.
The following scenario depicts the recommended calling sequence where the entire
set of LDAP transactions are ″protected″ by using a secure SSL connection. This
includes the dn and password that flow on the ldap_simple_bind:
rc = ldap_ssl_client_init (keyfile, keyfile_pw, timeout, reasoncode);
ld = ldap_ssl_init(ldaphost, ldapport, label );
rc = ldap_set_option( ld, LDAP_OPT_SSL_CIPHER, &ciphers);
rc = ldap_simple_bind_s(ld, binddn, passwd);
rc = ldap_unbind( ld );
The SSL handshake attempts the following ciphers by default, in the order that is
shown.
(Export Version)
RC4_MD5_EXPORT
RC2_MD5_EXPORT
(Non-export Version)
RC4_SHA_US
RC4_MD5_US
DES_SHA_US
3DES_SHA_US
RC4_MD5_EXPORT
RC2_MD5_EXPORT
ldap_ssl options
Support exists for options that control the nature of the secure connection. Set
these options by using the ldap_set_option API.
To specify the number of seconds for the SSL session-level timer, use:
ldap_set_option(ld,LDAP_OPT_SSL_TIMEOUT, &timeout)
To specify a specific cipher, or set of ciphers, to be used when negotiating with the
server, use ldap_set_option to define a sequence of ciphers. For example, the
following defines a sequence of three ciphers to use when negotiating with the
server. The first cipher that is found to be in common with the server’s list of
ciphers is used.
ldap_set_option( ld, LDAP_OPT_SSL_CIPHER, (void *)
LDAP_SSL_3DES_SHA_US
LDAP_SSL_RC4_MD5_US);
#define LDAP_SSL_RC4_MD5_EX
#define LDAP_SSL_RC2_MD5_EX
(Non-export Version)
#define LDAP_SSL_RC4_SHA_US
#define LDAP_SSL_RC4_MD5_US
#define LDAP_SSL_DES_SHA_US
#define LDAP_SSL_3DES_SHA_US
#define LDAP_SSL_RC4_MD5_EX
#define LDAP_SSL_RC2_MD5_EX
Note: ldapssl.h contains return codes that are specific for ldap_ssl_client_init,
ldap_ssl_init, and ldap_ssl_start.
Syntax:
#include <sys/time.h> /* for struct timeval definition */
#include <ldap.h>
int ldap_is_ldap_url(
char *url)
int ldap_url_parse(
char *url,
LDAPURLDesc **ludpp)
ldap_free_urldesc(
LDAPURLDesc *ludp)
int ldap_url_search(
LDAP *ld,
char *url,
int attrsonly)
int ldap_url_search_s(
LDAP *ld,
char *url,
int attrsonly,
LDAPMessage **res)
int ldap_url_search_st(
LDAP *ld,
char *url,
int attrsonly,
struct timeval *timeout,
LDAPMessage **res)
Parameters:
ld Specifies the LDAP pointer that is returned by a previous call to ldap_init,
ldap_ssl_init, or ldap_open.
url
Specifies a pointer to the URL string.
attrsonly
Specifies attribute information. Set to 1 to request attribute types only. Set to 0
to request both attribute types and attribute values.
timeout
Specifies a timeout value for a synchronous search that is issued by the
ldap_url_search_st routine.
Usage: These routines support the use of LDAP URLs (uniform resource locators).
LDAP URLs look like this:
ldap://[hostport]/dn[?attributes[?scope[?filter]]]
where:
hostport is a host name with an optional ":portnumber"
dn\f is the base DN to be used for an LDAP search operation
attributes is a comma separated list of attributes to be retrieved
scope is one of these three strings: base one sub (default=base)
filter\f is LDAP search filter as used in a call to ldap_search
for example
URL:ldap://ldap.itd.umich.edu/c=US?o,description?one?o=umich
<URL:ldapurl>
for example
<URL:ldap://ldap.itd.umich.edu/c=US?o,description?one?o=umich>
ldap_url_parse breaks down an LDAP URL passed in url into its component
pieces. If successful, zero returns, an LDAP URL description allocates, fills in, and
setsludpp to point to it. If an error occurs, one of these values returns:
LDAP_URL_ERR_NOTLDAP - URL does not begin with "ldap://"
LDAP_URL_ERR_NODN - URL has no DN (required)
LDAP_URL_ERR_BADSCOPE - URL scope string is invalid
LDAP_URL_ERR_MEM - cannot allocate memory space
Note: For search operations, omitting hostport causes the system to use the host
and port for the current connection. Specifying hostport different from host
and port combination that are used for the current connection, directs the
search to hostport instead of the current connection. In this case, use the
underlying referral mechanism to bind to hostport.
If the LDAP URL does not contain a search filter, the filter defaults to
objectClass=*.
Semicolon (″;″) may be used as an alternate separator. The possibility exists to mix
separators, but this usage is discouraged.
The final examples show both methods for the quoting of a comma in an
Organization name:
CN=L. Eagle, O="Sue, Grabbit and Runn", C=GB
A line may be continued by starting the next line with a single space or tab
character, for example,
dn: cn=Barbara J Jensen, o=University of Michi
gan, c=US
Blank lines separate multiple entries within the same LDIF file.
View an example of LDIF:
“Example: LDIF” on page 698
Notice that the jpegPhoto that is encoded in Jennifer Jensen’s entry now uses base
64.
Support for Ultimedia System Facilities APIs resides in the application layer above
the operating system. It uses standard operating system interfaces, including:
v Client Access/400 for communications between the AS/400 system and the
client
v Network drives to store both byte-stream multimedia data and attribute data
v Multimedia extensions that are supplied by Microsoft Windows environments
v Standard graphical user interface-support of the Windows environment
v AS/400 security for the protection of objects that are stored in the Ultimedia
System Facilities Multimedia Repository
Express Toolkit:
The Client Access Express Toolkit provides USF APIs documentation,
access to the USF interface definition (header) files, and links to sample
programs. To access this information, open the Express Toolkit and select
Multimedia —> C/C++ APIs.
Using USF in Windows:
By using AS/400 Objects APIs, you can write workstation applications that are
customized for the user’s environment. For example, you can write an application
to manage spooled files for a single user, or for all users across a network of
AS/400s. This includes holding, releasing, changing attributes of, deleting, sending,
retrieving and answering messages for the spooled files.
Express AS/400 Objects APIs required files:
Express Toolkit:
The Client Access Express Toolkit provides AS/400 Objects documentation,
access to the cwbobj.h header file, and links to sample programs. To access
this information, open the Express Toolkit and select AS/400 Operations
—> C/C++ APIs.
Express AS/400 Objects APIs topics:
v “AS/400 objects attributes”
v Express AS/400 Objects API listing
v “Example: Using Express AS/400 Objects APIs” on page 815
v “Express AS/400 Object APIs return codes” on page 26
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
Align Page
Key CWBOBJ_KEY_ALIGN
ID 0x000B
Type char[11]
Description
Indicates whether a forms alignment message is sent prior to printing this
spooled file. Valid values are *YES, *NO.
Authority
Key CWBOBJ_KEY_AUT
ID 0x000D
Type char[11]
Description
Specifies the authority that is given to users who do not have specific
authority to the output queue. Valid values are *USE, *ALL, *CHANGE,
*EXCLUDE, *LIBCRTAUT.
Authority to Check
Key CWBOBJ_KEY_AUTCHK
ID 0x000E
Type char[11]
Description
Indicates what type of authorities to the output queue allow the user to
control all the files on the output queue. Valid values are *OWNER,
*DTAAUT.
Code Page
Key CWBOBJ_KEY_CODEPAGE
ID 0x0019
Type char[11]
Description
The mapping of graphic characters to code points for this spooled file. If
the graphic character set field contains a special value, this field may
contain a zero (0).
Copies
Key CWBOBJ_KEY_COPIES
ID 0x001C
Type long
Description
The total number of copies to be produced for this spooled file.
Current Page
Key CWBOBJ_KEY_CURPAGE
ID 0x001E
Type long
Description
Current page that is being written by the writer job.
Data Format
Key CWBOBJ_KEY_DATAFORMAT
ID 0x001F
Type char[11]
Description
Data format. Valid values are *RCDDATA, *ALLDATA.
Defer Write
Key CWBOBJ_KEY_DFR_WRITE
ID 0x0023
Type char[11]
Description
Whether print data is held in system buffers before
Destination Option
Key CWBOBJ_KEY_DESTOPTION
ID 0x0098
Type char[129]
Description
Destination option. A text string that allows the user to pass options to the
receiving system.
Destination Type
Key CWBOBJ_KEY_DESTINATION
ID 0x0025
Type char[11]
Description
Destination type. Valid values are *OTHER, *AS400, *PSF2.
Device Class
Key CWBOBJ_KEY_DEVCLASS
ID 0x0026
Type char[11]
Description
The device class.
Device Model
Key CWBOBJ_KEY_DEVMODEL
ID 0x0027
Type char[11]
Description
The model number of the device.
Device Type
Key CWBOBJ_KEY_DEVTYPE
Ending Page
Key CWBOBJ_KEY_ENDPAGE
ID 0x002B
Type long
Description
The page number at which to end printing the spooled file. Valid values
are 0 or the ending page number. The value *END is encoded as 0.
File Separators
Key CWBOBJ_KEY_FILESEP
ID 0x002C
Type long
Description
The number of file separator pages that are placed at the beginning of each
copy of the spooled file. Valid values are -1, or the number of separators.
The value *FILE is encoded as -1.
Fold Records
Key CWBOBJ_KEY_FOLDREC
ID 0x002D
Type char[11]
Font Identifier
Key CWBOBJ_KEY_FONTID
ID 0x002E
Type char[11]
Description
The printer font that is used. Valid special values include *CPI and *DEVD.
Form Feed
Key CWBOBJ_KEY_FORMFEED
ID 0x002F
Type char[11]
Description
The manner in which forms feed to the printer. Valid values are *CONT,
*CUT, *AUTOCUT, *DEVD.
Form Type
Key CWBOBJ_KEY_FORMTYPE
ID 0x0030
Type char[11]
Description
The type of form to be loaded in the printer to print this spooled file.
Hardware Justification
Key CWBOBJ_KEY_JUSTIFY
ID 0x0038
Internet Address
Key CWBOBJ_KEY_INTERNETADDR
ID 0x0094
Type char[16]
Description
The internet address of the receiving system.
Job Name
Key CWBOBJ_KEY_JOBNAME
ID 0x003B
Type char[11]
Description
The name of the job that created the spooled file.
Job Number
Key CWBOBJ_KEY_JOBNUMBER
ID 0x003C
Type char[7]
Description
The number of the job that created the spooled file.
Job Separators
Key CWBOBJ_KEY_JOBSEPRATR
ID 0x003D
Type long
Job User
Key CWBOBJ_KEY_USER
ID 0x003E
Type char[11]
Description
The name of the user that created the spooled file.
Length of Page
Key CWBOBJ_KEY_PAGELEN
ID 0x004E
Type float
Description
The length of a page. Units of measurement are specified in the
measurement method attribute.
Library Name
Key CWBOBJ_KEY_LIBRARY
ID 0x000F
Type char[11]
Description
The name of the library.
Measurement Method
Key CWBOBJ_KEY_MEASMETHOD
ID 0x004F
Type char[11]
Description
The measurement method that is used for the length of page and width of
page attributes. Valid values are *ROWCOL, *UOM.
Message Help
Key CWBOBJ_KEY_MSGHELP
ID 0x0081
Type char(*)
Description
The message help, which is sometimes known as second-level text, can be
returned by a ″retrieve message″ request. The system limits the length to
3000 characters (English version must be 30 % less to allow for translation).
Message ID
Key CWBOBJ_KEY_MESSAGEID
ID 0x0093
Type char[8]
Description
The message ID.
Message Queue
Key CWBOBJ_KEY_MSGQUE
Message Reply
Key CWBOBJ_KEY_MSGREPLY
ID 0x0082
Type char[133]
Description
The message reply. Text string to be provided by the client which answers
a message of type ″inquiry″. In the case of message retrieved, the attribute
value is returned by the server and contains the default reply which the
client can use. The system limits the length to 132 characters. Should be
null-terminated due to variable length.
Message Text
Key CWBOBJ_KEY_MSGTEXT
ID 0x0080
Type char[133]
Description
The message text, that is sometimes known as first-level text, can be
returned by a ″retrieve message″ request. The system limits the length to
132 characters.
Message Type
Key CWBOBJ_KEY_MSGTYPE
ID 0x008E
Type char[3]
Description
The message type, a 2-digit, EBCDIC encoding. Two types of messages
indicate whether one can ″answer″ a ″retrieved″ message: ’04’
Informational messages convey information without asking for a reply
(may require a corrective action instead), ’05’ Inquiry messages convey
information and ask for a reply.
Message Severity
Key CWBOBJ_KEY_MSGSEV
ID 0x009F
Type long
Description
Message severity. Values range from 00 to 99. The higher the value, the
more severe or important the condition.
Number of Files
Key CWBOBJ_KEY_NUMFILES
ID 0x0045
Type long
Description
The number of spooled files that exist on the output queue.
Operator Controlled
Key CWBOBJ_KEY_OPCNTRL
ID 0x0046
Type char[11]
Output Priority
Key CWBOBJ_KEY_OUTPTY
ID 0x0048
Type char[11]
Description
The priority of the spooled file. The priority ranges from 1 (highest) to 9
(lowest). Valid values are 0-9, where 0 represents *JOB.
Pel Density
Key CWBOBJ_KEY_PELDENSITY
ID 0x00B2
Type char[2]
Description
For font resources only, this value is an encoding of the number of pels
(″1″ represents a pel size of 240, ″2″ represents a pel size of 320).
Additional values may become meaningful as the AS/400 system defines
them.
Point Size
Key CWBOBJ_KEY_POINTSIZE
ID 0x0053
Type float
Description
The point size in which this spooled file’s text is printed. The special value
*NONE will be encoded as 0.
Print Fidelity
Key CWBOBJ_KEY_FIDELITY
ID 0x0054
Type char[11]
Description
The kind of error handling that is performed when printing. Valid values
are *ABSOLUTE, *CONTENT.
Print Sequence
Key CWBOBJ_KEY_PRTSEQUENCE
ID 0x0057
Type char[11]
Description
Print sequence. Valid values are *NEXT.
Print Text
Key CWBOBJ_KEY_PRTTEXT
ID 0x0058
Type char[31]
Description
The text that is printed at the bottom of each page of printed output and
on separator pages. Valid special values include *BLANK and *JOB.
Printer
Key CWBOBJ_KEY_PRINTER
ID 0x0059
Type char[11]
Description
The name of the printer device.
Printer Queue
Key CWBOBJ_KEY_RMTPRTQ
ID 0x005D
Type char[129]
Description
The name of the destination printer queue when sending spooled files via
SNDTCPSPLF (LPR).
Record Length
Key CWBOBJ_KEY_RECLENGTH
ID 0x005F
Type long
Description
Record length.
Remote System
Key CWBOBJ_KEY_RMTSYSTEM
ID 0x0060
Type char[256]
Description
Remote system name. Valid special values include *INTNETADR.
Replacement Character
Key CWBOBJ_KEY_RPLCHAR
ID 0x0062
Type char[2]
Description
The character that replaces any unprintable characters.
Resource name
Key CWBOBJ_KEY_RSCNAME
ID 0x00AF
Type char[11]
Description
The name of the external AFP resource.
Restart Printing
Key CWBOBJ_KEY_RESTART
ID 0x0063
Type long
Description
Restart printing. Valid values are -1, -2, -3, or the page number to restart at.
The value *STRPAGE is encoded as -1, the value *ENDPAGE is encoded as
-2, and the value *NEXT is encoded as -3.
Seek Offset
Key CWBOBJ_KEY_SEEKOFF
ID 0x007E
Type long
Seek Origin
Key CWBOBJ_KEY_SEEKORG
ID 0x007F
Type long
Description
Valid values include 1 (beginning or top), 2 (current), and 3 (end or
bottom).
Send Priority
Key CWBOBJ_KEY_SENDPTY
ID 0x0065
Type char[11]
Description
Send priority. Valid values are *NORMAL, *HIGH.
Separator page
Key CWBOBJ_KEY_SEPPAGE
ID 0x00A1
Type char[11]
Description
Allows a user the option of printing a banner page. Valid values are *YES
or *NO.
Source Drawer
Key CWBOBJ_KEY_SRCDRWR
ID 0x0066
Type long
Description
The drawer to be used when the automatic cut sheet feed option is
selected. Valid values are -1, -2, 1-255. The value *E1 is encode as -1, and
the value *FORMDF is encoded as -2.
Spool SCS
Key CWBOBJ_KEY_SPLSCS
ID 0x00AD
Type Long
Description
Determines how SCS data is used during create spool file. Valid values are
-1, 0, 1, or the page number. The value *ENDPAGE is encoded as -1. For
the value 0, printing starts on page 1. For the value 1, the entire file prints.
Starting Page
Key CWBOBJ_KEY_STARTPAGE
ID 0x006C
Type long
Description
The page number at which to start printing the spooled file. Valid values
are -1, 0, 1, or the page number. The value *ENDPAGE is encoded as -1.
For the value 0, printing starts on page 1. For the value 1, the entire file
prints.
Total Pages
Key CWBOBJ_KEY_PAGES
ID 0x006F
Type long
Description
The number of pages that are contained in a spooled file.
Unit of Measure
Key CWBOBJ_KEY_UNITOFMEAS
ID 0x0072
Type char[11]
Description
The unit of measure to use for specifying distances. Valid values are *CM,
*INCH.
User Comment
Key CWBOBJ_KEY_USERCMT
ID 0x0073
Type char[101]
Description
The 100 characters of user-specified comment that describe the spooled file.
User ID
Key CWBOBJ_KEY_TOUSERID
ID 0x0075
Type char[9]
Description
User ID to which the spooled file is sent.
User ID Address
Key CWBOBJ_KEY_TOADDRESS
ID 0x0076
Type char[9]
Description
Address of user to whom the spooled file is sent.
VM/MVS Class
Key CWBOBJ_KEY_VMMVSCLASS
ID 0x0077
Type char[2]
Description
VM/MVS class. Valid values are A-Z and 0-9.
Width of Page
Key CWBOBJ_KEY_PAGEWIDTH
ID 0x0051
Type float
NPS CCSID:
Key CWBOBJ_KEY_NPSCCSID
ID 0x008A
Type long
Description
CCSID that the Network Print Server expects that all strings will be
encoded in.
NPS Object:
Key CWBOBJ_KEY_NPSOBJECT
ID 0x008B
Type long
NPS Level:
Key CWBOBJ_KEY_NPSLEVEL
ID 0x008D
Type char[7]
Description
The version, release, and modification level of the Network Print Server.
This attribute is a character string encoded as VXRYMY (ie. ″V3R1M0″)
where
X is in (0..9)
Y is in (0..9,A..Z)
Syntax:
Parameters:
const char *data - input
pointer to data to be analyzed.
unsigned long bufLen - input
The length of the buffer pointed to by data.
cwbOBJ_SplFDataType *dataType - output
On output this will contain the data type. If the data type can not be
determined, it defaults to CWBOBJ_DT_USERASCII.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: This uses the same routine that is used during the creation of spooled files
that don’t have a data type specified or have a data type of *AUTO specified. The
result defaults to *USERASCII if it can not be determined.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to answer the message for.
const char *msgAnswer - input
Pointer to a ASCIIZ string that contains the answer for the message.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be passes as a parameter to the exit programs.
void *data - input
Pointer to a block of date that will be passed to the exit programs. The format
of this data is exit program specific.
unsigned long dataLen - input
length of data pointed to by pData.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: This is a way for a client program to communicate with its server portion
to do processing of spooled files. All exit programs registered with the QNPSERVR
program on the AS/400 will be called, so it is up to the client program and exit
program to architect the format of the data in *data such that the exit program can
recognize it. See the AS/400 ’Guide to Programming for Print’ for information on
the interface between the QNPSERVR server program and the exit programs.
Syntax:
Parameters:
cwbOBJ_ObjHandle newSplFHandle - input
New spooled file handle. This is the handle passed back on the
cwbOBJ_CreateNewSplF() API.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Once a spooled file is closed, you can no longer write to it.
Syntax:
Parameters:
cwbOBJ_ObjHandle newSplFHandle - input
New spooled file handle. This is the handle passed back on the
cwbOBJ_CreateNewSplF() API.
cwbOBJ_ObjHandle *splFHandle - output
Pointer to an object handle that, upon successful, completion of this call, will
hold the spooled file handle. This handle may be used with other APIs that
take a spooled file handle as input.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
Handle of the list to be closed. This list must be opened.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Closing the list frees the memory used by the list to hold its items. Any
object handles gotten with cwbOBJ_GetObjHandle() API should be released before
closing the list to free resources. These handles are no longer valid.
Syntax:
Parameters:
cwbOBJ_ObjHandle resourceHandle - input
Handle of the resource to be closed.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: If the handle for the resource was obtained via a call to the
cwbOBJ_OpenResourceForSplF() API, then this api will delete the handle for you
(the handle was dynamically allocated for you when you opened the resource and
this call deallocates it).
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be closed.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle of the object to copy.
cwbOBJ_ObjHandle *newObjectHandle - output
Upon successful competition of this call, this handle will contain the new
object handle.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: If you have a handle to an object in a list and wish to maintain a handle
to that object after the list has been close this API allows you to do that.
cwbOBJ_DeleteObjHandle() must be called to release resources for this handle.
Syntax:
Parameters:
cwbOBJ_ParmHandle parmListHandle - input
Handle of the parameter list object to copy.
cwbOBJ_ParmHandle *newParmListHandle - output
Upon successful competition of this call, this handle will contain the new
parameter list object handle.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
const char *systemName - input
Pointer to the system name contained in ASCIIZ string
cwbOBJ_ListType type - input
Type of list to allocate (eg. spooled file list, output queue list, etc).
cwbOBJ_ListHandle *listHandle - output
Pointer to a list handle that will be passed back on output. This handle is
needed for other calls using the list.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Caller must call cwbOBJ_DeleteListHandle when done using this list
handle. Typical calling sequence for retrieving a list of objects would be:
1. cwbOBJ_CreateListHandle()
2. cwbOBJ_SetListFilter() { repeated as needed }
3. cwbOBJ_OpenList()
4. cwbOBJ_GetListSize() to get the size of the list.
5. For n=0 to list size - 1 cwbOBJ_GetObjHandle for list item in position n do
something with the object cwbOBJ_DeleteObjHandle()
6. cwbOBJ_CloseList() - You may go back to step 2 here.
7. cwbOBJ_DeleteListHandle()
Syntax:
Parameters:
const char *systemName - input
Pointer to the system name contained in ASCIIZ string
cwbOBJ_ParmHandle *parmListHandle - input
Optional. A pointer to a valid parameter list object handle that contains
parameters for creating the spooled file. Parameters set in this list override
what is in the printer file and the *outputQueueHandle parameter.
cwbOBJ_ObjHandle *printerFileHandle - input
Optional. A pointer to a valid printer file object handle that references the
printer file to be used when creating this spooled file. The printer file must
exist on the same system that this spooled file is being created on.
cwbOBJ_ObjHandle *outputQueueHandle - input
Optional. A pointer to a valid output queue object handle that references the
output queue that this spooled file should be created on. The output queue
must exist on the same system that this spooled file is being created on. If the
output queue is set in the *parmListHandle parameter (with
CWBOBJ_KEY_OUTQUELIB & CWBOBJ_KEY_OUTQUE) it will override the
output queue specified by this output queue handle.
cwbOBJ_ObjHandle *newSplFHandle - output
A pointer to a object handle that will be filled in upon successful completion of
this call with the newly created spooled file handle. This handle is needed to
write data into and close the new spooled file.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Notes:
1. Code page and graphic character set are dependent on each other. If you
specify one of these, you must specify the other.
2. The special value of *FILE is not allowed when using this attribute to create a
new spooled file.
3. Up to 4 user defined options may be specified.
Syntax:
Parameters:
cwbOBJ_ParmHandle *parmListHandle - output
Handle of the parameter object.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
const char *systemName - input
Pointer to the system name contained in an ASCIIZ string.
const char *resourceName - input
Pointer to the name of the AFP resource.
const char *resourceLibrary - input
Pointer to the name of the AS/400 library that contains the resource.
cwbOBJ_AFPResourceType resourceType - input
Specifies what type of resource this is. Must be one of the following:
v CWBOBJ_AFPRSC_FONT
v CWBOBJ_AFPRSC_FORMDEF
v CWBOBJ_AFPRSC_OVERLAY
v CWBOBJ_AFPRSC_PAGESEG
v CWBOBJ_AFPRSC_PAGEDEF
cwbOBJ_ObjHandle *objectHandle - output
On output this will contain the resource handle.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Use this API to get a handle to a resource if you know the name library
and type of resource. If you don’t know either of these or want to choose from a
Syntax:
Parameters:
const char *systemName - input
Pointer to the system name contained in an ASCIIZ string.
const char *jobName - input
Pointer to the name of the AS/400 job that created the spooled file in an
ASCIIZ string.
const char *jobNumber - input
Pointer to the number of the AS/400 job that created the spooled file in an
ASCIIZ string.
const char *jobNumber - input
Pointer to the user of the AS/400 job that created the spooled file in an ASCIIZ
string.
const char *splFName - input
Pointer to the name of the spooled file in an ASCIIZ string.
const unsigned long splFNumber - input
The number of the spooled file.
cwbOBJ_ObjHandle *objectHandle - output
On output this will contain the spooled file handle.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: This API does no checking of the spooled file on the host. The first time
this handle is used to retrieve data for the spooled file, a host error will be
encountered if the spooled file doesn’t exist.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
List handle that will be deleted.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: If the list associated with this handle is opened, this call will close it. If
there are opened handles to objects in this list, they will no longer be valid. After
this call returns successfully, the list handle is no longer valid.
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle of the object to release.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ParmHandle parmListHandle - input
Handle of the parameter object.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: After this call returns successfully, the parmListHandle is no longer valid.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be deleted.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle resourceHandle - input
Handle of the AFP Resource object. It must be an overlay or a pagesegment
type of resource.
const char *view - input
Optional, may be NULL. If specified, it is a pointer to an ASCIIZ string that
specifies the view to use when invoking the AFP viewer. There are two
predefined views shipped with the viewer: LETTER (8.5″ x 11″) and SFLVIEW
(132 column). Users may also add their own.
const unsigned long flags - input
Any of following bits may be set: CWBOBJ_DSPSPLF_WAIT - instructs this call
to wait until the viewer process has successfully opened the resource before
returning. If this bit is 0, this API will return after it starts the viewer process.
If it is 1, this API will wait for the viewer to get the resource open before
returning. All other bits must be set to 0.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the parameter object.
const char *view - input
Optional, may be NULL. If specified it is a pointer to an ASCIIZ string that
specifies the view to use when invoking the spooled file viewer. The are two
predefined views shipped with the viewer:
1. LETTER (8.5″ x 11″)
2. SFLVIEW (132 column)
Users may also add their own.
const unsigned long flags - input
Any of following bits may be set: CWBOBJ_DSPSPLF_WAIT - instructs this call
to wait until the viewer process has successfully opened the spooled file before
returning. If this bit is 0, this API will return after it starts the viewer process.
If it is 1, this API will wait for the viewer to get the spooled file open before
returning. All other bits must be set to 0.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Use this API to bring up the AFP viewer on the specified spooled file. The
AFP viewer can view AFP data, SCS data and plain ASCII text data. A return code
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle writerHandle - input
Handle of the writer job to be stopped. This handle can be obtained by either
listing writers and getting the writer handle from that list or from starting a
writer and asking for the writer handle to be returned.
cwbOBJ_ParmHandle *parmListHandle - input
Optional. A pointer to a valid parameter list object handle that contains
parameters for ending the writer.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
Handle of the list to get the size of. This list must be opened.
unsigned long *size - output
On output, this will be set to the current size of the list.
cwbOBJ_List_Status *listStatus - output
Optional, may be NULL. This will always be CWBOBJ_LISTSTS_COMPLETED
for lists opened synchronously.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
const char *systemName - input
Pointer to the system name contained in an ASCIIZ string.
cwbOBJ_KeyID key - input
Identifying key of the attribute to retrieve.
void *buffer - output
The buffer that will hold the attribute value. If this call returns successfully.
The value of the key determines what type of data will be put into pBuffer.
The type is also returned to the *keyType parameter, if provided.
unsigned long bufLen - input
The length of the buffer pointed to by pBuffer.
unsigned long *bytesNeeded - output
On output, this will be the number of bytes needed to hold result.
cwbOBJ_DataType *keyType - output
Optional, may be NULL. On output this will contain the type of data used to
represent this attribute and what is stored at *buffer.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The following attributes may be retrieved from the QNPSERVR program:
v CWBOBJ_KEY_NPSCCSID - Server CCSID
v CWBOBJ_KEY_NPSLEVEL - Server code level
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle of the object to get the attribute for.
cwbOBJ_KeyID key - input
Identifying key of the attribute to retrieve. The CWBOBJ_KEY_XXX constants
define the key ids. The type of object pointed to by objectHandle determine
which keys are valid.
void *buffer - output
The buffer that will hold the attribute value, if this call returns successfully.
The value of the key determines what type of data will be put into pBuffer.
The type is also returned to the *keyType parameter, if provided.
unsigned long bufLen - input
The length of the buffer pointed to by pBuffer.
unsigned long *bytesNeeded - output
On output, this will be the number of bytes needed to hold result.
cwbOBJ_DataType *keyType - output
Optional, may be NULL. On output this will contain the type of data used to
represent this attribute and what is stored at *buffer.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The following attributes may be retrieved for these object types:
v CWBOBJ_LIST_SPLF:
CWBOBJ_KEY_AFP - AFP resources used
CWBOBJ_KEY_ALIGN - Align page
CWBOBJ_KEY_BKMGN_ACR - Back margin across
CWBOBJ_KEY_BKMGN_DWN - Back margin down
CWBOBJ_KEY_BKOVRLLIB - Back overlay library name
CWBOBJ_KEY_BKOVRLAY - Back overlay name
CWBOBJ_KEY_BKOVL_ACR - Back overlay offset across
CWBOBJ_KEY_BKOVL_DWN - Back overlay offset down
CWBOBJ_KEY_CPI - Characters per inch
CWBOBJ_KEY_CODEDFNTLIB - Coded font library name
CWBOBJ_KEY_CODEDFNT - Coded font
CWBOBJ_KEY_COPIES - Copies (total)
CWBOBJ_KEY_COPIESLEFT - Copies left to produce
CWBOBJ_KEY_CURPAGE - Current page
CWBOBJ_KEY_DATE - Date file was opened
CWBOBJ_KEY_PAGRTT - Degree of page rotation
CWBOBJ_KEY_ENDPAGE - Ending page
CWBOBJ_KEY_FILESEP - File separators
CWBOBJ_KEY_FOLDREC - Wrap text to next line
CWBOBJ_KEY_FONTID - Font identifier to use (default)
CWBOBJ_KEY_FORMFEED - Form feed
CWBOBJ_KEY_FORMTYPE - Form type
CWBOBJ_KEY_FTMGN_ACR - Front margin across
CWBOBJ_KEY_FTMGN_DWN - Front margin down
CWBOBJ_KEY_FTOVRLLIB - Front overlay library name
CWBOBJ_KEY_FTOVRLAY - Front overlay
CWBOBJ_KEY_FTOVL_ACR - Front overlay offset across
CWBOBJ_KEY_FTOVL_DWN - Front overlay offset down
CWBOBJ_KEY_CHAR_ID - Graphic character set
CWBOBJ_KEY_JUSTIFY - Hardware justification
CWBOBJ_KEY_HOLD - Hold the spool file
CWBOBJ_KEY_JOBNAME - Name of the job that created file
CWBOBJ_KEY_JOBNUMBER - Number of the job that created file
CWBOBJ_KEY_USER - Name of the user that created file
CWBOBJ_KEY_LASTPAGE - Last page that printed
CWBOBJ_KEY_LPI - Lines per inch
CWBOBJ_KEY_MAXRECORDS - Maximum number of records allowed
CWBOBJ_KEY_OUTPTY - Output priority
CWBOBJ_KEY_OUTQUELIB - Output queue library name
CWBOBJ_KEY_OUTQUE - Output queue
CWBOBJ_KEY_OVERFLOW - Overflow line number
CWBOBJ_KEY_PAGELEN - Page length
CWBOBJ_KEY_MEASMETHOD - Measurement method
CWBOBJ_KEY_PAGEWIDTH - Page width
CWBOBJ_KEY_MULTIUP - Logical pages per physical side
CWBOBJ_KEY_POINTSIZE - The default font's point size
CWBOBJ_KEY_FIDELITY - The error handling when printing
CWBOBJ_KEY_DUPLEX - Print on both sides of paper
CWBOBJ_KEY_PRTQUALITY - Print quality
CWBOBJ_KEY_PRTTEXT - Text printed at bottom of each page
CWBOBJ_KEY_PRTDEVTYPE - Printer dev type (data stream type)
CWBOBJ_KEY_PRTRFILELIB - Printer file library
CWBOBJ_KEY_PRTRFILE - Printer file
CWBOBJ_KEY_RECLENGTH - Record length
CWBOBJ_KEY_RPLUNPRT - Replace unprintable characters
CWBOBJ_KEY_RPLCHAR - Character to replace unprintables
CWBOBJ_KEY_RESTART - Where to restart printing at
CWBOBJ_KEY_SAVESPLF - Save file after printing
v CWBOBJ_LIST_PRTD:
CWBOBJ_KEY_AFP - AFP resources used
CWBOBJ_KEY_CODEPAGE - code page
CWBOBJ_KEY_DEVCLASS - device class
CWBOBJ_KEY_DEVMODEL - device model
CWBOBJ_KEY_DEVTYPE - device type
CWBOBJ_KEY_DRWRSEP - drawer to use for separators
CWBOBJ_KEY_FONTID - font identifier
CWBOBJ_KEY_FORMFEED - form feed
CWBOBJ_KEY_CHAR_ID - graphic character set
CWBOBJ_KEY_MFGTYPE - manufacturer's type & model
CWBOBJ_KEY_MSGQUELIB - message queue library
CWBOBJ_KEY_MSGQUE - message queue
CWBOBJ_KEY_POINTSIZE - default font's point size
CWBOBJ_KEY_PRINTER - printer
CWBOBJ_KEY_PRTQUALITY - print quality
CWBOBJ_KEY_DESCRIPTION - text description
CWBOBJ_KEY_SCS2ASCII - transform SCS to ASCII
CWBOBJ_KEY_USRDFNDTA - user defined data
CWBOBJ_KEY_USRDFNOPTS - user defined options
CWBOBJ_KEY_USRDFNOBJLIB- user defined object library
CWBOBJ_KEY_USRDFNOBJ - user defined object
CWBOBJ_KEY_USRDFNOBJTYP- user defined object type
CWBOBJ_KEY_USRTFMPGMLIB- user data transform
program library
CWBOBJ_KEY_USRTFMPGM - user data transform program
CWBOBJ_KEY_USRDRVPGMDTA- user driver program data
CWBOBJ_KEY_USRDRVPGMLIB- user driver program library
CWBOBJ_KEY_USRDRVPGM - user driver program
v CWBOBJ_LIST_PRTF:
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle of the object to get the attribute for.
unsigned long numAttrs - input
number of attributes to retrieve
cwbOBJ_GetObjAttrParms *getAttrParms - input
an array of numAttrs elements that for each attribute to retrieve gives the
attribute key (id), the buffer where to store the value for that attribute and the
size of the buffer
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: See the Usage Notes in cwbOBJ_GetObjAttr to see which attribute are
valid for the various types of objects.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
Handle of the list to get the object handle from. This list must be opened.
unsigned long ulPosition - input
The position within the list of the object to get a handle for. It is 0 based. Valid
values are 0 to the number of objects in the list - 1. You can use
cwbOBJ_GetListSize() to get the size of the list.
cwbOBJ_ObjHandle *objectHandle - output
On return, this will contain the handle of the object.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
void *idBuffer - input
The buffer that holds the id of this object.
unsigned long bufLen - input
The length of the data pointed to by pIDBuffer.
cwbOBJ_ObjType type - input
Type of object this ID is for. This must match the type of object the ID was
taken from.
cwbOBJ_ObjHandle *objectHandle - output
If this call returns successfully, this will be the handle to the object. This handle
should be released with the cwbOBJ_DeleteObjHandle() API when done using
it.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle of the object to get the ID from.
void *idBuffer - output
The buffer that will hold the ID of this object.
unsigned long bufLen - input
The length of the buffer pointed to by pIDBuffer.
unsigned long *bytesNeeded - output
On output, this will be the number of bytes needed to hold the ID.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ParmHandle parmListHandle - input
Handle of the parameter object.
cwbOBJ_KeyID key - input
The id of the parameter to set.
void *buffer - output
The buffer that will hold the attribute value. If this call returns successfully.
The value of the key determines what type of data will be put into pBuffer.
The type is also returned to the *keyType parameter, if provided.
unsigned long bufLen - input
The length of the buffer pointed to by buffer.
unsigned long *bytesNeeded - output
On output, this will be the number of bytes needed to hold result.
cwbOBJ_DataType *keyType - output
Optional, may be NULL. On output this will contain the type of data used to
represent this attribute and what is stored at *buffer.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle newSplFHandle - input
New spooled file handle. This is the handle passed back on the
cwbOBJ_CreateNewSplF() API.
cwbOBJ_ObjHandle *splFHandle - output
Pointer to an object handle that, upon successful completion of this call, will
hold the spooled file handle. This handle may be used with other APIs that
take a spooled file handle as input.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
If you are using automatic data typing for the spooled file (the attribute of
CWBOBJ_KEY_PRTDEVTYPE was set to *AUTO or or wasn’t specified on the
cwbOBJ_CreateNewSplF() API) then creation of the spooled file will be delayed
until sufficient data has been written to the spooled file to determine the type of
the data (*SCS, *AFPDS or *USERASCII). If the new spooled file is in this state
when you call this API, the return code will be CWBOBJ_RC_SPLFNOTOPEN.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file.
cwbOBJ_KeyID key - input
Identifying key of the attribute to retrieve. The CWBOBJ_KEY_XXX constants
define the key ids.
void *buffer - output
The buffer that will hold the attribute value, if this call returns successfully.
The value of the key determines what type of data will be put into pBuffer.
The type is also returned to the *keyType parameter, if provided.
unsigned long bufLen - input
The length of the buffer pointed to by pBuffer.
unsigned long *bytesNeeded - output
On output, this will be the number of bytes needed to hold result.
cwbOBJ_DataType *keyType - output
Optional, may be NULL. On output this will contain the type of data used to
represent this attribute and what is stored at *buffer.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Message formatting characters will appear in the message text and should be used
as follows:
&N Force the text to a new line indented to column 2. If the text is longer than
1 line, the next lines should be indented to column 4 until the end of text
or another format control character is found.
&P Force the text to a new line indented to column 6. If the text is longer than
1 line, the next lines should be indented to column 4 until the end of text
or another format control character is found.
&B Force the text to a new line indented to column 4. If the text is longer than
1 line, the next lines should be indented to column 6 until the end of text
or another format control character is found.
Syntax:
Parameters:
cwbOBJ_ObjHandle queueHandle - input
Handle of the output queue to be held.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be held.
cwbOBJ_ParmHandle *parmListHandle - input
Optional. A pointer to a valid parameter list object handle that contains
parameters for holding the spooled file.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The following parameter key may be set in the parmListHandle object:
v CWBOBJ_KEY_HOLDTYPE
- what type of hold to do. May be ″*IMMED″ or ″*PAGEEND″. ″*IMMED″ is
the default.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Use this function to test for the presence of the viewer on the workstation.
If the viewer is installed this function will return CWB_OK. If the viewer is not
available, the function will return CWB_NO_VIEWER and the errorHandle
parameter (if provided) will contain an appropriate error message. Using this
function, applications can check for viewer support without calling the
cwbOBJ_DisplaySplF() API.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be moved.
cwbOBJ_ObjHandle *targetSplFHandle - input
Optional. The handle of another spooled file on the same system, that specifies
the spooled file to move this spooled file after. If this is specified,
*outputQueueHandle is not used.
cwbOBJ_ObjHandle *outputQueueHandle - input
Optional. The handle of an output queue on the same system that specifies
which output queue to move the spooled file to. The spooled file will be
moved to the first position on this queue. This parameter is ignored if
targetSplFHandle is specified.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
Handle of the list to open.
cwbOBJ_List_OpenType openHandle - input
Manner in which to open the list. Must be set to
CWBOBJ_LIST_OPEN_SYNCH
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle resourceHandle - input
Handle of the AFP resource file to be opened for reading.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file that is already opened for reading and that the
resource will be opened against. The same conversation (and same instance of
the the network print server program on the AS/400) will be used for reading
the resource and spooled file.
const char *resourceName - input
Pointer to the name of the AFP Resource in an ASCIIZ string.
const char *resourceLibrary - input
Optional, may be NULL. Pointer to the AS/400 library of the AFP Resource in
an ASCIIZ string. If no library is specified, the library list of the spooled file is
used to search for the resource.
unsigned long resourceType - input
An unsigned long integer with one of the following bits on:
CWBOBJ_AFPRSC_FONT
CWBOBJ_AFPRSC_FORMDEF
CWBOBJ_AFPRSC_OVERLAY
CWBOBJ_AFPRSC_PAGESEG
CWBOBJ_AFPRSC_PAGEDEF
Specifies what type of resource to open.
const char *reserved -
Reserved, must be NULL.
cwbOBJ_OBJHandle *resourceHandle - output
Pointer to an OBJHandle that on successful return will contain the dynamically
allocated resource handle that can be used to read, seek and eventually close
the resource.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: This call, if successful, will generate a temporary resource handle and
return it in the resourceHandle parameter. This handle will be deleted
automatically when the caller calls the cwbOBJ_CloseResource() API with it.
The resource should be closed with the cwbOBJ_CloseResource()) API when done
reading from it.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be opened for reading.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The spooled file should be closed with the cwbOBJ_CloseSplF() API when
done reading from it.
Syntax:
Parameters:
cwbOBJ_ObjHandle queueHandle - input
Handle of the output queue to be purged.
cwbOBJ_ParmHandle * parmListHandle - input
Optional. A pointer to a valid parameter list object handle that contains
parameters for purging the output queue.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle resourceHandle - input
Handle of the AFP resource object to be read from.
char *buffer - input
Pointer to buffer to hold the bytes read from the resource.
unsigned long bytesToRead - input
Maximum number of bytes to read. The number read may be less than this.
unsigned long *bytesRead - output
Number of bytes actually read.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The cwbOBJ_OpenResource() API must be called with this resource handle
before this API is called OR the handle must be retrieved with a call to the
cwbOBJ_OpenResourceForSplF() API. If the end of file is reached when reading,
the return code will be CWBOBJ_RC_ENDOFFILE and bytesRead will contain the
actual number of bytes read.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be read from.
char *buffer - input
Pointer to buffer to hold the bytes read from the spooled file.
unsigned long bytesToRead - input
Maximum number of bytes to read. The number read may be less than this.
unsigned long *bytesRead - output
Number of bytes actually read.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The cwbOBJ_OpenSplF() API must be called with this spooled fil handle
before this API is called. If the end of file is reached when reading, the return code
will be CWBOBJ_SPLF_ENDOFFILE and bytesRead will contain the actual number
of bytes read.
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle of the object to be refreshed.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle queueHandle - input
Handle of the output queue to be released.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be released.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
List handle to reset.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Use this call to reset the list handle’s list of attributes to retrieve after
calling cwbOBJ_SetListAttrsToRetrieve().
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
Handle of the list to have its filter reset.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The list must be closed and reopened for the change to take affect.
Syntax:
Parameters:
cwbOBJ_ObjHandle resourceHandle - input
Handle of the AFP resource file to be seeked.
cwbOBJ_SeekOrigin seekOrigin - input
Where to seek from. Valid values are:
CWBOBJ_SEEK_BEGINNING - seek from the beginning of file
CWBOBJ_SEEK_CURRENT - seek from the current read position
CWBOBJ_SEEK_ENDING - seek from the end of the file
signed long seekOffset - input
Offset (negative or positive) from the seek origin in bytes to move the current
read pointer to.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The cwbOBJ_OpenResource() API must be called with this resource handle
before this API is called OR the handle must be retrieved with a call to the
cwbOBJ_OpenResourceForSplF() API.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be closed.
cwbOBJ_SeekOrigin seekOrigin - input
Where to seek from. Valid values are:
v CWBOBJ_SEEK_BEGINNING - seek from the beginning of file
v CWBOBJ_SEEK_CURRENT - seek from the current read position
v CWBOBJ_SEEK_ENDING - seek from the end of the file
signed long seekOffset - input
Offset (negative or positive) from the seek origin in bytes to move the current
read pointer to.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The cwbOBJ_OpenSplF() API must be called with this spooled file handle
before this API is called.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be sent.
cwbOBJ_ParmHandle parmListHandle - input
Required. A handle of a parameter list object that contains the parameters for
sending the spooled file.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to be sent.
cwbOBJ_ParmHandle parmListHandle - input
Required. A handle of a parameter list object that contains the parameters for
sending the spooled file.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
const char *systemName - input
Pointer to the system name contained in ASCIIZ string.
unsigned int connections - input
The number to of connections to keep open.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The default number of connections left open per system is 0. The
connections are made per process, so this API only affects connections under the
process it is called under. Setting the number of connections to be left open does
not open any new connections.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
List handle to apply the list of attribute keys to.
unsigned long numKeys - input
The number of keys pointed to by the ’keys’ parameter. May be 0, which
means that no attributes are needed for objects in the list.
const cwbOBJ_KeyID *keys - input
An array of numKeys keys that are the IDs of the attributes to be retrieved for
each object in the list when the list is opened.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
List handle that this filter will be applied to.
cwbOBJ_KeyID key - input
The id of the filtering field to be set.
const void *value - input
The value this field should be set to.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: The value of key will determine the type that is pointed to value. The
length of value is determined by its type. The following filters may be set against
these list types Spooled File Lists:
v CWBOBJ_LIST_SPLF:
CWBOBJ_KEY_USER
Specifies which user’s spooled files are to be listed. May be a specific user
ID or one of these special values: *ALL - all users. *CURRENT - list
spooled files for the current user only. *CURRENT is the default.
CWBOBJ_KEY_OUTQUELIB
Specifies which libraries to search for output queues in. May be a specific
name or one of these special values: ″″ - if the OUTQUEUE key word is
*ALL, this combination will search all output queue on the system.
*CURLIB - the current library *LIBL - the library list *LIBL is the default if
the OUTQUE filter is not *ALL. ″″ is the default if the OUTQU filter is set
to *ALL.
CWBOBJ_KEY_OUTQUE
Specifies which output queues to list. May be a specific name, a
generic name or *ALL. *ALL is the default.
Library Lists:
v CWBOBJ_LIST_LIB:
CWBOBJ_KEY_LIBRARY
Specifies which libraries to list. May be a specific name, a generic name or
any of these special values:
*ALL - all libraries
*CURLIB - the current library
*LIBL - the library list
*USRLIBL - the user portion o the library list.
*USRLIBL is the default.
v CWBOBJ_LIST_RSC:
Resources can be lists in a spooled file (lists all of the external AFP resources
used by this spooled file) or in a library or set of libraries. To list resources
for a spooled file, use the cwbOBJ_SetListFilterWithSplF API along with the
SetListFilter API for the RSCTYPE and RSCNAME attributes.
CWBOBJ_KEY_RSCLIB
Specifies which libraries to search for resources in. This filter is
ignored if the list is filter by spooled file (i.e. SetListFilterWithSplF).
May be a specific name, a generic name or any of these special values:
*ALL - all libraries
*ALLUSR - All user-defined libraries, plus libraries containing user
data and having names starting with Q.
*CURLIB - the current library
*LIBL - the library list
*USRLIBL - the user portion o the library list.
*LIBL is the default.
CWBOBJ_KEY_RSCNAME
Specifies which resources to list by name. May be a specific name, a
generic name or *ALL.
*ALL is the default.
CWBOBJ_KEY_RESCTYPE
Specifies which type of resources to list. May be any combination of
the following bits logically OR’d together:
CWBOBJ_AFPRSC_FONT
CWBOBJ_AFPRSC_FORMDEF
CWBOBJ_AFPRSC_OVERLAY
Syntax:
Parameters:
cwbOBJ_ListHandle listHandle - input
List handle that this filter will be applied to.
cwbOBJ_ObjHandle splFHandle - input
Handle of the spooled file to filter on.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Filtering by spooled file is used when listing AFP resources so the list type
must be CWBOBJ_LIST_RSC. If you filter resources based on a spooled file you
cannot also filter based on a library or libraries. The resource library filter will be
ignored if both are specified. Resetting a list filter will also reset the spooled file
filter to nothing.
Syntax:
Parameters:
cwbOBJ_ObjHandle objectHandle - input
Handle to the object that is to be changed.
cwbOBJ_ParmHandle parmListHandle - input
Handle to the parameter object which contains the attributes that are to be
modified for the object.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Syntax:
Parameters:
cwbOBJ_ParmHandle parmListHandle - input
Handle of the parameter object.
cwbOBJ_KeyID key - input
The id of the parameter to set.
void *value - input
The value to set the parameter to. The type that value points to is determined
by the value of key.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
Syntax:
Parameters:
cwbOBJ_ObjHandle *printerHandle - input
Required. A pointer to a valid printer object handle that identifies which
printer this writer is to be started to.
cwbOBJ_ObjHandle *outputQueueHandle - input
Optional. A pointer to a valid output queue object handle that identifies which
output queue this writer is to be started from. If the parmListHandle is also
specified and contains the CWBOBJ_KEY_OUTQUE parameter key, this
parameter is ignored.
cwbOBJ_ParmHandle *parmListHandle - input
Optional. A pointer to a valid parameter list object handle that contains
parameters for starting the writer.
cwbOBJ_ObjHandle *writerHandle - output
Optional. A pointer to a writer object handle that will be filled in upon
successful return from this API. If this parameter is specified, the caller must
call cwbOBJ_DeleteObjHandle() to release resources allocated for this writer
handle.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: Calling this API causes the writer job to be submitted to run. The writer
job may fail to start even though this API returns successfully (the job may be
Syntax:
Parameters:
cwbOBJ_ObjHandle newSplFHandle - input
New spooled file handle. This is the handle passed back on the
cwbOBJ_CreateNewSplF() API.
const char *data - input
Pointer to the data buffer that will be written into the spooled file.
unsigned long ulDataLen - input
Length of the data to be written.
cwbSV_ErrHandle errorHandle - output
Optional, may be 0. Any returned messages will be written to this object. It is
created with the cwbSV_CreateErrHandle() API. The messages may be
retrieved through the cwbSV_GetErrText() API. If the parameter is set to zero,
no messages will be retrievable.
Usage: None
#ifdef UNICODE
#define _UNICODE
#endif
#include <windows.h>
#include <stdio.h>
#include "CWBOBJ.H"
main(int argc, char *argv[ ], char *envp[ ])
{
cwbOBJ_ListHandle listHandle;
cwbOBJ_ObjHandle splFHandle;
unsigned int ulRC;
unsigned long ulListSize, ulObjPosition, ulBytesNeeded;
cwbOBJ_KeyID keysWanted[] = { CWBOBJ_KEY_SPOOLFILE,
CWBOBJ_KEY_USER };
unsigned long ulNumKeysWanted = sizeof(keysWanted)/sizeof(*keysWanted);
char szSplFName[11];
char szUser[11];
ulRC = cwbOBJ_CreateListHandle(_TEXT("ANYAS400"),
CWBOBJ_LIST_SPLF,
&listHandle,
0);
if (ulRC == CWB_OK)
{
cwbOBJ_SetListFilter(listHandle, CWBOBJ_KEY_USER,
_TEXT("*CURRENT"), 0);
/****************************************/
/* call cwbOBJ_GetObjAttr() to get info */
/* about this spooled file. May also */
/* call spooled file specific APIs */
/* with this handle, such as */
/* cwbOBJ_HoldSplF(). */
/****************************************/
ulRC = cwbOBJ_GetObjAttr(splFHandle,
CWBOBJ_KEY_SPOOLFILE,
(void *)szSplFName,
sizeof(szSplFName),
&ulBytesNeeded,
NULL,
0);
if (ulRC == CWB_OK)
{
ulRC = cwbOBJ_GetObjAttr(splFHandle,
CWBOBJ_KEY_USER,
(void *)szUser,
sizeof(szUser),
&ulBytesNeeded,
NULL,
0);
if (ulRC == CWB_OK)
{
printf("%3u: %11s %s\n",
ulObjPosition, szSplFName, szUser);
} else {
/* ERROR on GetObjAttr! */
}
} else {
/* ERROR on GetObjAttr! */
}
/* free this object handle */
cwbOBJ_DeleteObjHandle(splFHandle, 0);
} else {
/* ERROR on GetObjHandle! */
}
ulObjPosition++;
}
} else {
/* ERROR on GetListSize! */
}
cwbOBJ_CloseList(listHandle, 0);
} else {
/* ERROR on OpenList! */
cwbOBJ_DeleteListHandle(listHandle, 0);
}
Express Toolkit:
The Client Access Express Toolkit provides Remote Command and
Distributed Program Call documentation, access to the cwbrc.h header file,
and links to sample programs. To access this information, open the Express
Toolkit and select either Remote Command or Distributed Program Call
—> C/C++ APIs.
Express Remote Command/Distributed Program Call APIs topics:
v “Typical use of Express Remote Command/Distributed Program Call
APIs” on page 818
v Express Remote Command/Distributed Program Call APIs listing
v “Example: Using Remote Express Command/Distributed Program Call
APIs” on page 839
v “Express Remote Command/Distributed Program Call APIs return
codes” on page 27
Related topics:
v “AS/400 system name formats for APIs” on page 10
v “OEM, ANSI, and Unicode considerations” on page 10
Note: The Command Request object previously was known as the ″system
object″ in Client Access.
Program object
This represents the AS/400 program. Parameters can be added, and the
program can be sent to the system to run the program.
There is not a separate object for commands. The command string is sent directly
to the command request.
Syntax:
unsigned int CWB_ENTRY cwbRC_AddParm(
cwbRC_PgmHandle program,
unsigned short type,
unsigned long length,
const unsigned char *parameter);
Parameters:
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
unsigned short type - input
The type of parameter this is. Use one of the defined parameter types:
CWBRC_INPUT, CWBRC_OUTPUT, CWBRC_INOUT. If you want to
automatically convert between local CCSID and host CCSID, add the
appropriate convert flag to this field with a bitwise, or use one of the defined
parameter types:
CWBRC_TEXT_CONVERT
CWBRC_TEXT_CONVERT_INPUT
CWBRC_TEXT_CONVERT_OUTPUT
The last two types are intended for use with CWBRC_INOUT when conversion
is only needed in one direction.
unsigned long length - input
The length of the parameter. If this is an CWBRC_OUTPUT parameter, the
length should be the length of the buffer where the returned parameter will be
written.
const unsigned char * parameter - input
Pointer to a buffer that will contain: the value if the type is CWBRC_INPUT or
CWBRC_INOUT, or the place where the returned parameter is to be written if
the type is CWBRC_OUTPUT or CWBRC_INOUT.
will use the buffer as is to send to the host, and will convert the output (eg to
ASCII) before putting the result into the buffer.
Syntax:
Parameters:
cwbRC_SysHandle system - input
Handle that was returned by a previous call to the cwbRC_StartSysEx function.
It identifies the AS/400 system.
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object. object.
cwbSV_ErrHandle msgHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrTextIndexed API. If the parameter is set to zero, no messages
will be retrieved.
Usage: None
Syntax:
Parameters:
const char *programName - input
Pointer to an ASCIIZ string that contains the name of the program that you
want to call.
const char *libraryName - input
Pointer to an ASCIIZ string that contains the name of the library where the
program resides.
cwbRC_PgmHandle * program - output
Pointer to a cwbRC_PgmHandle where the handle of the program will be
returned.
Usage: You should create a separate program object for each program you want
to call on the AS/400. You can use the functions described in this file to change the
values of the parameters being sent to the program, but cannot change the number
of parameters being sent.
Syntax:
Parameters:
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
Usage: None.
Syntax:
Parameters:
cwbRC_SysHandle system - input
Handle that was returned by a previous call to the cwbRC_StartSysEx function.
It identifies the AS/400 system.
unsigned long * clientCCSID - output
Pointer to an unsigned long where the client CCSID will be written.
Syntax:
Parameters:
cwbRC_SysHandle system - input
Handle that was returned by a previous call to the cwbRC_StartSysEx function.
It identifies the AS/400 system.
unsigned long * hostCCSID - output
Pointer to an unsigned long where the host CCSID will be written.
Syntax:
Parameters:
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
char * libraryName - output
Pointer to a ten character buffer where the name of the library will be written.
Usage: None
Syntax:
Parameters:
cwbRC_PgmHandle handle - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
unsigned short index - input
The number of the specific parameter in this program that should be retrieved.
This index is zero-based.
unsigned short * type - output
Pointer to the type of parameter this is. The value will be one of the defined
parameter types:
CWBRC_INPUT
CWBRC_OUTPUT
CWBRC_INOUT
unsigned long * length - input
Pointer to the length of the parameter.
unsigned char * * parameter - output
Pointer to a buffer that will contain the address of the actual parameter.
Usage: None
Syntax:
Parameters:
cwbRC_PgmHandle handle - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
unsigned short * count - output
Pointer to an unsigned short where the parameter count will be written.
Usage: None
Syntax:
Parameters:
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
char * programName - output
Pointer to a ten character buffer where the name of the program will be
written.
Usage: None
Syntax:
Parameters:
cwbRC_SysHandle system - input
Handle that was returned by a previous call to the cwbRC_StartSysEx function.
It identifies the AS/400 system.
const char *commandString - input
Pointer to a string that contains the command to be issued on the AS/400
system. This is an ASCIIZ string.
cwbSV_ErrHandle msgHandle - output
Any messages returned from the AS/400 will be written to this object. It is
created with the cwbSV_CreateErrHandle API. The messages may be retrieved
through the cwbSV_GetErrTextIndexed API. If the parameter is set to zero, no
messages will be retrieved.
Usage: None
Syntax:
Parameters:
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
const char *libraryName - input
Pointer to an ASCIIZ string that contains the name of the library where the
program resides.
Usage: Use this function to change the name of the name of the library that
contains the program you want to call. This function should not be used to call a
different program with different parameters.
Syntax:
Parameters:
cwbRC_PgmHandle handle - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
unsigned short index - input
The number of the specific parameter in this program that should be changed.
This index is zero-based.
unsigned short type - input
The type of parameter this is. Use one of the defined parameter types:
CWBRC_INPUT
CWBRC_OUTPUT
CWBRC_INOUT
If you want to automatically convert between local CCSID and host CCSID,
add the appropriate convert flag to this field with a bitwise-OR. Use one of the
defined parameter types:
CWBRC_TEXT_CONVERT
CWBRC_TEXT_CONVERT_INPUT
CWBRC_TEXT_CONVERT_OUTPUT
The latter two are intended for use with CWBRC_INOUT when conversion is
only needed in one direction.
unsigned long length - input
The length of the parameter. If this is an CWBRC_OUT parameter, the length
should be the length of the buffer where the returned parameter will be
written.
const unsigned char * parameter - input
Pointer to a buffer that will contain the value if the type is CWBRC_INPUT or
CWBRC_INOUT, or the place where the return parameter is to be written if
the type is CWBRC_OUTPUT or CWBRC_INOUT.
will use the buffer as is to send to the host, and will convert the output (for
example, to ASCII) before putting the result into the buffer.
Syntax:
Parameters:
cwbRC_PgmHandle program - input
Handle that was returned by a previous call to the cwbRC_CreatePgm API. It
identifies the program object.
const char *programName - input
Pointer to an ASCIIZ string that contains the name of the program that you
want to call.
Usage: Use this function to change the name of the program that you want to
call. This function should not be used to change the program object to call a
different program with different parameters.
Syntax:
Parameters:
const cwbCO_SysHandle systemObj - input
Handle to an existing system object of the system on which you want
programs and commands to be run.
cwbRC_SysHandle *request - output
Pointer to a cwbRC_SysHandle where the handle of the command request will
be returned.
Syntax:
Parameters:
cwbRC_SysHandle system - input
Handle that was returned by a previous call to the cwbRC_StartSysEx function.
It identifies the AS/400 system.
Usage: None
void main()
{
cwbCO_SysHandle system;
cwbRC_SysHandle request;
cwbRC_PgmHandle program;
Express Toolkit:
The Client Access Express Toolkit provides Serviceability documentation,
access to the cwbsv.h header file, and links to sample programs. To access
this information, open the Express Toolkit and select Error Handling —>
C/C++ APIs.
Express Serviceability APIs topics:
v “History log and trace files”
v “Error handles” on page 843
v “Typical use of Serviceability APIs” on page 843
v Express Serviceability APIs listing
v “Example: Using Express Serviceability APIs” on page 910
v “Express Serviceability APIs return codes” on page 28
The following Express Serviceability APIs are listed alphabetically, and are grouped
according to function:
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile()
function.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: None
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile()
function.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: None
Syntax:
Parameters:
cwbSV_ErrHandle *errorHandle - input/output
Pointer to a cwbSV_ErrHandle where the handle will be returned.
Usage: None
Syntax:
Parameters:
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this message entry. Parameter is optional, if null, no productID is set.
NOTE: A maximum of CWBSV_MAX_PRODUCT_ID characters will be logged
for the product ID. Larger strings will be truncated.
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this message entry. Parameter is optional, if null, no componentID is
set. NOTE: A maximum of CWBSV_MAX_COMP_ID characters will be logged
for the component ID. Larger strings will be truncated.
cwbSV_MessageTextHandle * messageTextHandle - input/output
Pointer to a cwbSV_MessageTextHandle where the handle will be returned.
This handle should be used in subsequent calls to the message text functions.
Syntax:
Parameters:
cwbSV_ServiceRecHandle * serviceRecHandle - input/output
Pointer to a cwbSV_ServiceRecordHandle where the handle will be returned.
This handle should be used in subsequent calls to the service record functions.
Usage: This handle can be used in your program to read records from an open
service file and extract information from the record.
Syntax:
Parameters:
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this message entry. Parameter is optional, if null, no productID is set.
NOTE: A maximum of CWBSV_MAX_PRODUCT_ID characters will be logged
for the product ID. Larger strings will be truncated.
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this message entry. Parameter is optional, if null, no componentID is
set. NOTE: A maximum of CWBSV_MAX_COMP_ID characters will be logged
for the component ID. Larger strings will be truncated.
cwbSV_TraceAPIHandle * traceAPIHandle - input/output
Pointer to a cwbSV_TraceAPIHandle where the handle will be returned. This
handle should be used in subsequent calls to the trace API functions.
Syntax:
Parameters:
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this message entry. Parameter is optional, if null, no productID is set.
NOTE: A maximum of CWBSV_MAX_PRODUCT_ID characters will be logged
for the product ID. Larger strings will be truncated.
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this message entry. Parameter is optional, if null, no componentID is
set. NOTE: A maximum of CWBSV_MAX_COMP_ID characters will be logged
for the component ID. Larger strings will be truncated.
cwbSV_TraceDataHandle * traceDataHandle - input/output
Pointer to a cwbSV_TraceDataHandle where the handle will be returned. This
handle should be used in subsequent calls to the trace data functions.
Syntax:
Parameters:
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this message entry. Parameter is optional, if null, no productID is set.
NOTE: A maximum of CWBSV_MAX_PRODUCT_ID characters will be logged
for the product ID. Larger strings will be truncated.
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this message entry. Parameter is optional, if null, no componentID is
set. NOTE: A maximum of CWBSV_MAX_COMP_ID characters will be logged
for the component ID. Larger strings will be truncated.
cwbSV_TraceSPIHandle * traceSPIHandle - input/output
Pointer to a cwbSV_TraceSPIHandle where the handle will be returned. This
handle should be used in subsequent calls to the trace SPI functions.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - output
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
function.
Usage: This call should be made when the handle is no longer needed.
Syntax:
Parameters:
cwbSV_MessageTextHandle messageTextHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateMessageTextHandle() function.
Usage: This call should be made when the handle is no longer needed.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
Usage: This call should be made when the handle is no longer needed.
Syntax:
Parameters:
cwbSV_TraceAPIHandle traceAPIHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateTraceAPIHandle() function.
Usage: This call should be made when the handle is no longer needed.
Syntax:
Parameters:
cwbSV_TraceDataHandle traceDataHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateTraceDataHandle() function.
Usage: This call should be made when the handle is no longer needed.
Syntax:
Parameters:
cwbSV_TraceSPIHandle traceSPIHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateTraceSPIHandle() function.
Usage: This call should be made when the handle is no longer needed.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
char * componentID - input/output
Pointer to a buffer that will receive the component ID that is stored in the
record that is identified by the handle.
unsigned long componentIDLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_COMP_ID.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
char * dateStamp - input/output
Pointer to a buffer that will receive the datestamp that is stored in the record
that is identified by the handle.
unsigned long dateStampLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_DATE_VALUE.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
function.
unsigned long * errorClass - output
Pointer to a variable that will receive the error class that is stored in the error
that is identified by the handle.
Usage: None
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
function.
unsigned long errorIndex - input
Index value that indicates which error text to return if multiple errors are
associated with the error handle.
unsigned long * errorClass - output
Pointer to a variable that will receive the error class that is stored in the error
that is identified by the index.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
function.
unsigned long * errorCount - input/output
Pointer to variable that receives the number of messages associated with this
error handle. If zero is returned, no errors are associated with the error handle.
Usage: None
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
API.
char * fileName - input/output
Pointer to a buffer that will receive the message file name stored in the error
identified by the handle. The value returned is an ASCIIZ string.
unsigned long fileNameLength - input
Length of the receive buffer passed in. It should include space for the
terminating null character. If the buffer is too small, the value will be truncated
and CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_MSGFILE_NAME.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Usage: AS/400 messages may be added to the error handle when using the
cwbRC_CallPgm() and cwbRC_RunCmd() API’s. In these cases, you can use this
API to retrieve the message file name for the AS/400 messages contained in the
error handle. If there is no message file name attribute for the message, return code
CWBSV_ATTRIBUTE_NOT_SET will be returned.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
API.
unsigned long index - input
Index value indicating which message file name to return if multiple errors are
associated with the error handle. The valid index range is from 1 to the
number of messages contained in the error handle. The number of messages
can be obtained by calling the cwbSV_GetErrCount() API.
char * fileName - input/output
Pointer to a buffer that will receive the message file name stored in the error
identified by the index. The value returned is an ASCIIZ string.
unsigned long fileNameLength - input
Length of the receive buffer passed in. It should include space for the
terminating null character. If the buffer is too small, the value will be truncated
and CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_MSGFILE_NAME.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
API.
char * libraryName - input/output
Pointer to a buffer that will receive the message file library name stored in the
error identified by the handle. The value returned is an ASCIIZ string.
unsigned long libraryNameLength - input
Length of the receive buffer passed in. It should include space for the
terminating null character. If the buffer is too small, the value will be truncated
and CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_MSGFILE_LIBR.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Usage: AS/400 messages may be added to the error handle when using the
cwbRC_CallPgm() and cwbRC_RunCmd() API’s. In these cases, you can use this
API to retrieve the message file library name for the AS/400 messages contained in
the error handle. If there is no message file library name attribute for the message,
return code CWBSV_ATTRIBUTE_NOT_SET will be returned.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
API.
unsigned long index - input
Index value indicating which message file library name to return if multiple
errors are associated with the error handle. The valid index range is from 1 to
the number of messages contained in the error handle. The number of
messages can be obtained by calling the cwbSV_GetErrCount() API.
char * libraryName - input/output
Pointer to a buffer that will receive the message file library name stored in the
error identified by the index. The value returned is an ASCIIZ string.
unsigned long libraryNameLength - input
Length of the receive buffer passed in. It should include space for the
terminating null character. If the buffer is too small, the value will be truncated
and CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_MSGFILE_LIBR.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
API.
char * substitutionText - input/output
Pointer to a buffer that will receive the substitution text for the message
identified by the handle. NOTE: The data returned is binary, hence it is NOT
returned as an ASCIIZ string. Any character strings contained in the
substitution text are returned as EBCDIC values.
unsigned long substitutionTextLength - input
Length of the receive buffer passed in. If the buffer is too small, the value will
be truncated and CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output data if the receive buffer is too small. It will also be set to
the actual number of bytes of output data returned upon successful
completion.
Usage: AS/400 messages may be added to the error handle when using the
cwbRC_CallPgm() and cwbRC_RunCmd() API’s. In these cases, you can use this
API to retrieve the substitution text for the AS/400 messages contained in the error
handle. If there is no substitution text for the message, return code
CWBSV_ATTRIBUTE_NOT_SET will be returned. Use the returnLength parameter
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
API.
unsigned long index - input
Index value indicating which substitution text to return if multiple errors are
associated with the error handle. The valid index range is from 1 to the
number of messages contained in the error handle. The number of messages
can be obtained by calling the cwbSV_GetErrCount() API.
char * substitutionText - input/output
Pointer to a buffer that will receive the substitution text stored in the error
identified by the index. Note: The data returned is binary, hence it is NOT
returned as an ASCIIZ string. Any character strings contained in the
substitution text are returned as EBCDIC values.
unsigned long substitutionTextLength - input
Length of the receive buffer passed in. If the buffer is too small, the value will
be truncated and CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output data if the receive buffer is too small. It will also be set to
the actual number of bytes of output data returned upon successful
completion.
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
function.
char * errorText - input/output
Pointer to a buffer that will receive the error message text that is stored in the
error that is identified by the handle.
unsigned long errorTextLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Usage: None
Syntax:
Parameters:
cwbSV_ErrHandle errorHandle - input
Handle that was returned by a previous call to the cwbSV_CreateErrHandle()
function.
unsigned long errorIndex - input
Index value that indicates which error text to return if multiple errors are
associated with the error handle.
char * errorText - input/output
Pointer to a buffer that will receive the error message text that is stored in the
error that is identified by the index.
unsigned long errorTextLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile
function.
unsigned long * recordCount - input/output
Pointer to variable that receives the size of the largest record in the file.
Usage: None
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
char * messageText - input/output
Pointer to a buffer that will receive the message text that is stored in the record
that is identified by the handle.
unsigned long messageTextLength - input
Length of the receive buffer passed in. If the buffer is too small, the value will
be truncated, and CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output data if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
char * productID - input/output
Pointer to a buffer that will receive the product ID that is stored in the record
that is identified by the handle.
unsigned long productIDLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_PRODUCT_ID.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile
function.
unsigned long * recordCount - input/output
Pointer to variable that receives the total number of records in the file.
Usage: None
Syntax:
Parameters:
cwbSV_ServiceFileType serviceFileType - input
Value indicating which service file name you want returned. -
CWBSV_HISTORY_LOG - CWBSV_PROBLEM_LOG -
CWBSV_DETAIL_TRACE_FILE - CWBSV_ENTRY_EXIT_TRACE_FILE
char * fileName - input/output
Pointer to a buffer that will receive the service file name associated with the
one that was requested.
unsigned long fileNameLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_FILE_PATH.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
cwbSV_ServiceRecType * serviceType - output
Pointer to a cwbSV_ServiceRecType where the serviceType will be returned. -
CWBSV_MESSAGE_REC - CWBSV_PROBLEM_REC -
CWBSV_DATA_TRACE_REC - CWBSV_API_TRACE_REC -
CWBSV_SPI_TRACE_REC
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
char * timeStamp - input/output
Pointer to a buffer that will receive the timestamp that is stored in the record
that is identified by the handle.
unsigned long timeStampLength - input
Length of the receive buffer passed in. It should include space for the ending
null character. If the buffer is too small, the value will be truncated, and
CWB_BUFFER_OVERFLOW and returnLength will be set. NOTE: The
recommended size is CWBSV_MAX_TIME_VALUE.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output string if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
char * apiData - input/output
Pointer to a buffer that will receive the API trace data that is stored in the
record that is identified by the handle. Note: The data that is returned is
binary. Hence, it is NOT returned as an ASCIIZ string.
unsigned long apiDataLength - input
Length of the receive buffer passed in. If the buffer is too small, the value will
be truncated, and CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output data if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
char * apiID - input/output
Pointer to one-byte field that receives the API event ID.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
cwbSV_EventType * eventType - output
Pointer to a cwbSV_EventType where the eventType will be returned. -
CWBSV_ENTRY_POINT - CWBSV_EXIT_POINT
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
char * traceData - input/output
Pointer to a buffer that will receive the trace data that is stored in the record
that is identified by the handle. Note: The data that is returned is binary.
Hence, it is NOT returned as an ASCIIZ string.
unsigned long traceDataLength - input
Length of the receive buffer passed in. If the buffer is too small, the value will
be truncated, and CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output data if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
char * spiData - input/output
Pointer to a buffer that will receive the SPI trace data that is stored in the
record that is identified by the handle. Note: The data that is returned is
binary. Hence, it is NOT returned as an ASCIIZ string.
unsigned long spiDataLength - input
Length of the receive buffer passed in. If the buffer is too small, the value will
be truncated, and CWB_BUFFER_OVERFLOW and returnLength will be set.
unsigned long * returnLength - input/output
Optional, may be NULL. A return address to store the number of bytes needed
to hold the output data if the receive buffer is too small.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
char * spiID - input/output
Pointer to one-byte field that receives the SPI event ID.
Syntax:
Parameters:
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle() function.
cwbSV_EventType * eventType - output
Pointer to a cwbSV_EventType where the eventType will be returned. -
CWBSV_ENTRY_POINT - CWBSV_EXIT_POINT
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Syntax:
Parameters:
cwbSV_TraceAPIHandle traceAPIHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceAPIHandle().
unsigned char apiID - input
A unique one-character code that will distinguish this API trace point from
others that are logged by your program. Definition of these codes are left up to
the caller of this API. The recommended approach is to use the defined range
(0x00 - 0xFF) for each unique component in your product (that is, start at 0x00
for each component)
char * apiData - input
Points to a buffer that contains additional data (for example, input parameter
values from your caller) that you want to log along with this entry point.
Parameter is optional, it is ignored if the address is NULL or the data length is
zero. This buffer can contain binary data because the length parameter is used
in determining the amount to trace.
unsigned long apiDataLength - input
Specifies the number of bytes in the API data buffer to log for this trace entry.
Syntax:
Parameters:
cwbSV_TraceAPIHandle traceAPIHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceAPIHandle().
unsigned char apiID - input
A unique one-character code that will distinguish this API trace point from
others that are logged by your program. Definition of these codes are left up to
the caller of this API. The recommended approach is to use the defined range
(0x00 - 0xFF) for each unique component in your product (that is, start at 0x00
for each component)
char * apiData - input
Points to a buffer that contains additional data (for example, output parameter
values passed back to your caller) that you want to log along with this exit
point. Parameter is optional, it is ignored if the address is NULL or the data
length is zero. This buffer can contain binary data because the length
parameter is used in determining the amount to trace.
unsigned long apiDataLength - input
Specifies the number of bytes in the API data buffer to log for this trace entry.
Syntax:
Parameters:
cwbSV_MessageTextHandle messageTextHandle - input
Handle that was returned by a previous call to
cwbSV_CreateMessageTextHandle().
char * messageText - input
Points to a buffer that contains the message text you want to log.
unsigned long messageTextLength - input
Specifies the number of bytes in the message text buffer to log for this message
entry.
Usage: None
Syntax:
Parameters:
cwbSV_TraceSPIHandle traceSPIHandle - input
Handle that was returned by a previous call to cwbSV_CreateTraceSPIHandle().
unsigned char spiID - input
A unique one-character code that will distinguish this SPI trace point from
others that are logged by your program. Definition of these codes are left up to
the caller of this API. The recommended approach is to use the defined range
(0x00 - 0xFF) for each unique component in your product (that is, start at 0x00
for each component)
char * spiData - input
Points to a buffer that contains additional data (for example, input parameter
values from your caller) that you want to log along with this entry point.
Parameter is optional, it is ignored if the address is NULL or the data length is
zero. This buffer can contain binary data because the length parameter is used
in determining the amount to trace.
unsigned long spiDataLength - input
Specifies the number of bytes in the SPI data buffer to log for this trace entry.
Syntax:
Parameters:
cwbSV_TraceSPIHandle traceSPIHandle - input
Handle that was returned by a previous call to cwbSV_CreateTraceSPIHandle().
unsigned char spiID - input
A unique one-character code that will distinguish this SPI trace point from
others that are logged by your program. Definition of these codes are left up to
the caller of this API. The recommended approach is to use the defined range
(0x00 - 0xFF) for each unique component in your product (that is, start at 0x00
for each component)
char * spiData - input
Points to a buffer that contains additional data (for example, output parameter
values passed back to your caller) that you want to log along with this exit
point. Parameter is optional, it is ignored if the address is NULL or the data
length is zero. This buffer can contain binary data because the length
parameter is used in determining the amount to trace.
unsigned long spiDataLength - input
Specifies the number of bytes in the SPI data buffer to log for this trace entry.
Syntax:
Parameters:
cwbSV_TraceDataHandle traceDataHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceDataHandle().
char * traceData - input
Points to a buffer that contains the trace data you want to log. The buffer can
contain binary data because the length parameter is used in determining the
amount to trace.
unsigned long traceDataLength - input
Specifies the number of bytes in the trace data buffer to log for this trace entry.
Usage: None
Syntax:
Parameters:
char * serviceFileName - input
Points to a buffer that contains the fully-qualified name (for example,
c:\path\filename.ext) of the service file to open.
cwbSV_ServiceFileHandle * serviceFileHandle - input/output
Pointer to a cwbSV_ServiceFileHandle where the handle will be returned. This
handle should be used in subsequent calls to the service file functions.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: None
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile
function.
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This read would be used as a ″priming-type″ read before issuing a series
of cwbSV_ReadPrevRecord() calls until the end-of-file indicator is returned.
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile
function.
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This read would normally be used once the priming read,
″ReadOldestRecord()″ is performed.
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile
function.
cwbSV_ServiceRecHandle serviceRecHandle - input
Handle that was returned by a previous call to the
cwbSV_CreateServiceRecHandle function.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This read would be used as a ″priming-type″ read before issuing a series
of cwbSV_ReadNextRecord() calls until the end-of-file indicator is returned.
Syntax:
Parameters:
cwbSV_ServiceFileHandle serviceFileHandle - input
Handle that was returned by a previous call to the cwbSV_OpenServiceFile
function. V_ServiceRecHandle serviceRecHandle -input Handle that was
returned by a previous call to the cwbSV_CreateServiceRecHandle function.
cwbSV_ErrHandle errorHandle - output
Any returned messages will be written to this object. It is created with the
cwbSV_CreateErrHandle API. The messages may be retrieved through the
cwbSV_GetErrText API. If the parameter is set to zero, no messages will be
retrieved.
Usage: This read would normally be used once the priming read,
″ReadNewestRecord()″ is performed.
Syntax:
unsigned int CWB_ENTRY cwbSV_SetMessageClass(
cwbSV_MessageTextHandle messageTextHandle,
cwbSV_MessageClass messageClass);
Parameters:
cwbSV_MessageTextHandle messageTextHandle - input
Handle that was returned by a previous call to
cwbSV_CreateMessageTextHandle().
cwbSV_MessageClass messageClass - input
One of the following:
CWBSV_CLASS_INFORMATIONAL
CWBSV_CLASS_WARNING
CWBSV_CLASS_ERROR
Usage: This value should be set before calling the corresponding log function,
″cwbSV_LogMessageText()″.
Syntax:
Parameters:
cwbSV_MessageTextHandle messageTextHandle - input
Handle that was returned by a previous call to
cwbSV_CreateMessageTextHandle().
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this message entry. NOTE: A maximum of CWBSV_MAX_COMP_ID
characters will be logged for the component ID. Larger strings will be
truncated.
Usage: This value should be set before calling the corresponding log function,
″cwbSV_LogMessageData()″. The suggested hierarchy is that you would define a
product ID with one or many components that are defined under it.
Syntax:
Parameters:
cwbSV_MessageTextHandle messageTextHandle - input
Handle that was returned by a previous call to
cwbSV_CreateMessageTextHandle().
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this message entry. NOTE: A maximum of CWBSV_MAX_PRODUCT_ID
characters will be logged for the product ID. Larger strings will be truncated.
Usage: This value should be set before calling the corresponding log function,
″cwbSV_LogMessageData()″. The suggested hierarchy is that you would define a
product ID with one or many components that are defined under it.
Syntax:
Parameters:
cwbSV_TraceAPIHandle traceAPIHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceAPIHandle().
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this trace entry. NOTE: A maximum of CWBSV_MAX_COMP_ID
characters will be logged for the component ID. Larger strings will be
truncated.
Usage: This value should be set before calling the corresponding log functions,
″cwbSV_LogAPIEntry()″ and ″cwbSV_LogAPIExit(). The suggested hierarchy is
that you would define a product ID with one or many components that are
defined under it.
Syntax:
Parameters:
cwbSV_TraceAPIHandle traceAPIHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceAPIHandle().
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this trace entry. NOTE: A maximum of CWBSV_MAX_PRODUCT_ID
characters will be logged for the product ID. Larger strings will be truncated.
Usage: This value should be set before calling the corresponding log functions,
″cwbSV_LogAPIEntry()″ and ″cwbSV_LogAPIExit(). The suggested hierarchy is
that you would define a product ID with one or many components that are
defined under it.
Syntax:
Parameters:
cwbSV_TraceSPIHandle traceSPIHandle - input
Handle that was returned by a previous call to cwbSV_CreateTraceSPIHandle().
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this trace entry. NOTE: A maximum of CWBSV_MAX_COMP_ID
characters will be logged for the component ID. Larger strings will be
truncated.
Usage: This value should be set before calling the corresponding log functions,
″cwbSV_LogAPIEntry()″ and ″cwbSV_LogAPIExit(). The suggested hierarchy is
that you would define a product ID with one or many components that are
defined under it.
Syntax:
Parameters:
cwbSV_TraceSPIHandle traceSPIHandle - input
Handle that was returned by a previous call to cwbSV_CreateTraceSPIHandle().
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this trace entry. NOTE: A maximum of CWBSV_MAX_PRODUCT_ID
characters will be logged for the product ID. Larger strings will be truncated.
Usage: This value should be set before calling the corresponding log functions,
″cwbSV_LogAPIEntry()″ and ″cwbSV_LogAPIExit(). The suggested hierarchy is
that you would define a product ID with one or many components that are
defined under it.
Syntax:
Parameters:
cwbSV_TraceDataHandle traceDataHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceDataHandle().
char * componentID - input
Points to a null-terminated string that contains a component identifier to be
used on this trace entry. NOTE: A maximum of CWBSV_MAX_COMP_ID
characters will be logged for the component ID. Larger strings will be
truncated.
Usage: This value should be set before calling the corresponding log function,
″cwbSV_LogTraceData()″. The suggested hierarchy is that you would define a
product ID with one or many components that are defined under it.
Syntax:
Parameters:
cwbSV_TraceDataHandle traceDataHandle - input
Handle that was returned by a previous call to
cwbSV_CreateTraceDataHandle().
char * productID - input
Points to a null-terminated string that contains a product identifier to be used
on this trace entry. NOTE: A maximum of CWBSV_MAX_PRODUCT_ID
characters will be logged for the product ID. Larger strings will be truncated.
Usage: This value should be set before calling the corresponding log function,
cwbSV_LogTraceData. The suggested hierarchy is that you would define a product
ID with one or many components that are defined under it.
return(rc);
}
/* Open the active message log for READ access and return a handle */
/* to it. */
if ((rc = cwbSV_OpenServiceFile(buffer, &serviceFileHandle, errorHandle))
!= CWB_OK)
return(rc);
/* Read the newest record in the active message log into the */
/* record handle provided. */
if ((rc = cwbSV_ReadNewestRecord(serviceFileHandle, serviceRecHandle,
errorHandle)) != CWB_OK) {
cwbSV_DeleteServiceRecHandle(serviceRecHandle);
cwbSV_CloseServiceFile(serviceFileHandle, 0);
return(rc);
}
return(rc);
}
Express Toolkit:
The Client Access Express Toolkit provides System Object Access
documentation, access to the cwbsoapi.h header file, and links to sample
programs. To access this information, open the Express Toolkit and select
AS/400 Operations —> C/C++ APIs.
Express System Object Access APIs topics:
v “SOA objects” on page 912
v “AS/400 object views” on page 912
SOA objects
Use System Object Access to view and to manipulate the following AS/400 objects:
You can view and manipulate these objects:
v Jobs
v Printers
v Printed output
v Messages
v Spooled files
You only can manipulate these objects:
v Users and groups
v TCP/IP interfaces
v TCP/IP routes
v Ethernet lines
v Token-ring lines
v Hardware resources
v Software resources
v Libraries in QSYS
//******************************************************************
// Start a conversation with AS/400 system SYSNAME. Specify
// application name APPNAME.
//******************************************************************
cwbUN_GetSystemHandle((char *)"SYSNAME", (char *)"APPNAME", &hSystemHandle);
cwbRC_StartSysEx(hSystemHandle, &hSystem);
//*******************************************************************
// Create a list of spooled files. Set desired sort/filter criteria.
//*******************************************************************
// Customize the UI by disabling selected UI functions. Set the list title.
//*******************************************************************
// Do not allow users to change list filter
CWBSO_DisallowListFilter(hList);
// Set the string that will appear in the list title bar
CWBSO_SetListTitle(hList, "Application Title");
//*******************************************************************
// Display the list.
//*******************************************************************
// List window has been closed - save filter criteria in application profile
CWBSO_WriteListProfile(hList, hError);
}
//*******************************************************************
// Processing complete - clean up and exit.
//*******************************************************************
// Clean up handles
CWBSO_DeleteErrorHandle(hError);
CWBSO_DeleteListHandle(hList);
//********************************************************************
// Return from WinMain.
//********************************************************************
return rc;
}
//*******************************************************************
// Start a conversation with AS/400 system SYSNAME. Specify
// application name APPNAME.
//******************************************************************
cwbRC_StartSysEx(hSystemHandle, &hSystem);
//*******************************************************************
// Create a list of spooled files. Set desired filter criteria.
//*******************************************************************
// Create a list of spooled files on system SYSNAME
CWBSO_CreateListHandleEx(hSystemHandle,
CWBSO_LIST_SFL,
&hList);
//*******************************************************************
// Open the list.
//*******************************************************************
if (listSize > 0)
{
// Get the first object in the list
CWBSO_GetObjHandle(hList, 0, &hObject, hError);
//*******************************************************************
// Processing complete - clean up and exit.
//*******************************************************************
// Clean up handles
CWBSO_DeleteErrorHandle(hError);
CWBSO_DeleteListHandle(hList);
//********************************************************************
// Return from WinMain.
//********************************************************************
return rc;
}
A list object for a list of AS/400 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. After storing the desired
output priority value of ″9″ in the parameter object, a loop is entered. Each object
in the list is examined in turn, and if a spooled file is found to have more than 10
pages then its output priority is changed.
//********************************************************************
// Create a list of spooled files. Set desired filter criteria.
//********************************************************************
//*******************************************************************
// Open the list.
//*******************************************************************
//******************************************************************
// 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.
//******************************************************************
totalPages = atoi(szString);
} /* end while */
} /* end if */
//********************************************************************
// Processing complete - clean up and exit.
//********************************************************************
// Clean up handles
CWBSO_DeleteErrorHandle(hError);
CWBSO_DeleteListHandle(hList);
//********************************************************************
// Return from WinMain.
//********************************************************************
return 0;
}
For internal processing errors, error objects automatically log an entry in the
System Object Access log file soa.log, in the Client Access install directory. This
file is English only and is intended for use by IBM personnel for problem analysis.
Related topic:
“Express System Object Access APIs return codes” on page 29
The data is saved by AS/400 system name, and within system name by object
type. To read or write profile data, a system name must be specified on the
CWBSO_CreateListHandle call for the list object.
When the cwbRC_StartSysEx API is called, the application is blocked until the
conversation is established. Therefore, it is good practice to inform the user that a
connection is about to be attempted immediately before the call. On return, the
conversation will have been initiated, and System Object Access list processing will
use this conversation instead of starting a new one.
When cwbRC_StartSysEx is used in this way, the last list to be deleted will not
end the conversation. You must call cwbRC_StopSys explicitly before you exit the
application.
See “SOA attribute special values” on page 962 for related information.
SOA enablers:
System Object Access also includes enablers (APIs), which applications can
use to access data in AS/400 objects or to request graphical lists and
attribute views of the object data. The APIs for manipulating lists of objects
must be called in the correct order. The basic flow is as follows:
CreateErrorHandle -- Creates a handle to an "error" object
to be passed to other APIs
CreateListHandle -- Instantiates a list object on the client
OpenList -- Builds list on AS/400 associated with client
list
(Manipulate the list and its objects using various generic
and subclass APIs)
CloseList -- Closes list and release resource on AS/400
DeleteListHandle -- Destroys list object on the client
After the list is allocated, the “CWBSO_SetListFilter” on page 953 API can
be called to change the filter criteria for the list. CWBSO_SetListFilter is
optional; if it is not called, the list will be built with the default filter
criteria. Similarly, the “CWBSO_SetListSortFields” on page 955 API can be
called to define the attributes on which the list will be sorted. If it is not
called the list will not be sorted.
The “CWBSO_OpenList” on page 949 API must be called to build the list
of objects. This will result in a request to be sent to the AS/400. The list
will be built on the AS/400, and some or all of the objects (records) in the
list will be buffered down to the list on the client. Although all objects in
the list are not necessarily cached on the client, the APIs will behave as if
they are. Once the CWBSO_OpenList API is called successfully, the
following APIs can be called:
“CWBSO_GetObjHandle” on page 947
Retrieves a handle to a specific object in the list. The object handle
can then be used to manipulate the specific object.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error that was returned by a previous call to
CWBSO_CreateErrorHandle. When the value that is returned by this API is
CWBSO_ERROR_OCCURRED, the error handle may be used to retrieve the
error message text or display the error to the user.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. CWBSO_CreateErrorHandle must be called prior to calling this API. The
error handle that is returned by CWBSO_CreateErrorHandle must be passed as
input to this API. The list must currently be open. The list is opened by calling
CWBSO_OpenList. This API will not end the conversation with the AS/400. For
the conversation to be ended the list must be deleted using
CWBSO_DeleteListHandle.
Syntax:
Parameters:
CWBSO_OBJ_HANDLE objectHandle - input
A handle to an object that was returned by a previous call to
CWBSO_GetObjHandle or CWBSO_CopyObjHandle.
CWBSO_OBJ_HANDLE far* lpNewObjectHandle - output
A long pointer to a handle which will be set to a new handle for the same
AS/400 object. This handle may be used with any other API that accepts an
object handle with the exception that some APIs only operate on specific types
of objects.
Syntax:
Parameters:
CWBSO_ERR_HANDLE far* lpErrorHandle - output
A long pointer to a handle which will be set to the handle for an error.
Usage: When the error handle is no longer needed, the calling program is
responsible for doing the following:
v Call CWBSO_DeleteErrorHandle to free up resources that are allocated on the
client.
Syntax:
Parameters:
char far* lpszSystemName - input
The name of the AS/400 system on which the list will be built. The name that
is specified must be a configured AS/400. If the client is not currently
connected to the AS/400, a connection will be established when the list is
opened. If NULL is specified for the system name, the current Client
Access/400 default system will be used.
char far* lpszApplicationName - input
A character string that identifies the application that will be interacting with
the list. The maximum length of this string is 10 characters, excluding the
NULL terminator.
CWBSO_LISTTYPE type - input
The type of list to be built. Specify one of the following:
CWBSO_LIST_JOB
List of jobs.
CWBSO_LIST_SJOB
List of server jobs.
CWBSO_LIST_SJOB
List of server jobs.
CWBSO_LIST_MSG
List of messages.
CWBSO_LIST_PRT
List of printers.
CWBSO_LIST_SFL
List of spooled files.
CWBSO_LIST_IFC
List interfaces.
CWBSO_LIST_ELN
List Ethernet lines.
CWBSO_LIST_TLN
List token-ring lines.
CWBSO_LIST_HWL
List hardware resources.
CWBSO_LIST_SW
List software products.
CWBSO_LIST_RTE
List TCP/IP route.
Usage: When the list is no longer needed, the calling program is responsible for
doing the following:
v Call CWBSO_DeleteListHandle to free up resources that are allocated on the
client.
Syntax:
Parameters:
cwbCO_SysHandle systemObjectHandle - input
A handle to the system object that represents the AS/400 system on which the
list will be built. The handle specified must be for a configured AS/400.
CWBSO_LISTTYPE
The type of list to be built. Specify one of the following:
CWBSO_LIST_JOB
List of jobs.
CWBSO_LIST_SJOB
List of server jobs.
CWBSO_LIST_SJOB
List of server jobs.
CWBSO_LIST_MSG
List of messages.
CWBSO_LIST_PRT
List of printers.
CWBSO_LIST_SFL
List of spooled files.
CWBSO_LIST_IFC
List interfaces.
CWBSO_LIST_ELN
List Ethernet lines.
CWBSO_LIST_TLN
List token-ring lines.
CWBSO_LIST_HWL
List hardware resources.
CWBSO_LIST_SW
List software products.
CWBSO_LIST_RTE
List TCP/IP route.
CWBSO_LIST_PRF
List user profiles.
CWBSO_LIST_SMP
List libraries in QSYS.
CWBSO_LIST_HANDLE far* lpListHandle - output
A long pointer to a handle that will be set to the handle for the newly created
list. This handle may be used with any other API that accepts a list handle.
Usage: When the list is no longer needed, the calling program is responsible for
doing the following:
v Call CWBSO_DeleteListHandle to free up resources that are allocated on the
client.
Syntax:
Parameters:
char far* lpszSystemName - input
The name of the AS/400 system on which the object will be built. The name
that is specified must be a configured AS/400. If the client is not currently
connected to the AS/400, a connection will be established when the list is
opened. If NULL is specified for the system name, the current Client
Access/400 default system will be used.
char far* lpszApplicationName - input
A character string that identifies the application that will be interacting with
the list. The maximum length of this string is 10 characters, excluding the
NULL terminator.
CWBSO_OBJTYPE type - input
The type of object to be built. Specify the following:
v CWBSO_OBJ_TCIPATTR - TCP/IP attributes
Usage: When the list is no longer needed, the calling program is responsible for
doing the following:
v Call CWBSO_DeleteObjHandle to free up resources that are allocated on the
client.
Syntax:
Parameters:
CWBSO_PARMOBJ_HANDLE far* lpParmObjHandle - output
A long pointer to a handle which will be set to the handle for the new
parameter object.
Usage: When the parameter object is no longer needed, the calling program is
responsible for doing the following:
v Call CWBSO_DeleteParmObjHandle to free up resources that are allocated on
the client.
Syntax:
Parameters:
CWBSO_ERR_HANDLE errorHandle - input
An error handle that is returned by a previous call to
CWBSO_CreateErrorHandle.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that is returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API.
Syntax:
Parameters:
CWBSO_OBJ_HANDLE objectHandle - input
A handle to an object that is returned by a previous call to
CWBSO_GetObjHandle or CWBSO_CopyObjHandle.
Syntax:
Parameters:
CWBSO_PARMOBJ_HANDLE parmObjHandle - input
A handle to a parameter object that is returned by a previous call to
CWBSO_CreateParmObjHandle.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that is returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
unsigned short far* lpusActionIDs - input
A long pointer to an array of action identifier values These values identify
which actions the user will not be allowed to perform. The valid values for this
parameter depend on the type of objects in the list. See the appropriate header
files for the valid values:
v cwbsojob.h
v cwbsomsg.h
v cwbsoprt.h
v cwbsosfl.h
unsigned short usCount - input
The number of action identifier values specified.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that is returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API.
Syntax:
Parameters:
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
HINSTANCE hInstance - input
The program instance passed to the calling program’s WinMain procedure.
int nCmdShow - input
The show window parameter passed to the calling program’s WinMain
procedure. Alternatively, any of the constants defined for the Windows API
ShowWindow() may be used.
HWND far* lphWnd - output
A long pointer to a window handle. This will be set to the handle of the
window in which the list is displayed.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message text or display the error to
the user.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. CWBSO_CreateErrorHandle must be called prior to calling this API. The
error handle that is returned by CWBSO_CreateErrorHandle must be passed as
input to this API. It is not necessary to call CWBSO_OpenList or CWBSO_CloseList
when using this API. CWBSO_DisplayList handles both the opening and closing of
This API only applies to the following list types: Jobs, Messages, Printers, Printer
Output, and Spooled Files.
Syntax:
Parameters:
CWBSO_OBJ_HANDLE objectHandle - input
A handle to an object that was returned by a previous call to
CWBSO_GetObjHandle or CWBSO_CopyObjHandle.
HINSTANCE hInstance - input
The program instance passed to the calling program’s WinMain procedure.
int nCmdShow - input
The show window parameter passed to the calling program’s WinMain
procedure. Alternatively, any of the constants defined for the Windows API
ShowWindow() may be used.
HWND far* lphWnd - output
A long pointer to a window handle. This will be set to the handle of the
window in which the object attributes are displayed.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
This API only applies to the following list types: Jobs, Messages, Printers, Printer
Output, and Spooled Files.
Syntax:
Parameters:
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
char far* lpszMsgBuffer - output
A long pointer to the output buffer where the message text will be placed. The
message text that is returned by this API will be translated text. The output
buffer is not changed when the return code is not set to CWBSO_NO_ERROR.
unsigned long ulBufferLength - input
The size, in bytes, of the output buffer argument.
unsigned long far* lpulBytesNeeded - output
A long pointer to an unsigned long that will be set to the number of bytes
needed to place the entire message text in the output buffer. When this value is
less than or equal to the size of output buffer that is specified, the entire
message text is placed in the output buffer. When this value is greater than the
size of output buffer that is specified, the output buffer contains a null string.
The output buffer is not changed beyond the bytes that are needed for the
message text. This value is set to zero when the return code is not set to
CWBSO_NO_ERROR.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
unsigned long far* lpulSize - output
A long pointer to an unsigned long that will be set to the number of entries
currently in the list. If the list status indicates that the list is complete, this
value represents the total number of objects for the list. If the list status
indicates that the list is not completely built, this value represents the number
of objects currently available from the host and a subsequent call to this API
may indicate that more entries are available.
unsigned short far* lpusStatus - output
A long pointer to an unsigned short that will be set to indicate whether the list
is completely built. The value will be set to 0 if the list is not completely built
or it will be set to 1 if the list is completely built.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. CWBSO_CreateErrorHandle must be called prior to calling this API. The
error handle that is returned by CWBSO_CreateErrorHandle must be passed as
input to this API. The list must currently be open. The list is opened by calling
CWBSO_OpenList. If CWBSO_CloseList is called to close a list, CWBSO_OpenList
must be called again before this API can be called.
Syntax:
Parameters:
CWBSO_OBJ_HANDLE objectHandle - input
A handle to an object that was returned by a previous call to
CWBSO_GetObjHandle or CWBSO_CopyObjHandle.
unsigned short usAttributeID - input
The identifier of the attribute to be retrieved. The valid values for this
parameter depend on the type of object. See the appropriate header files for
the valid values:
v cwbsojob.h
v cwbsomsg.h
v cwbsoprt.h
v cwbsosfl.h
char far* lpszBuffer - output
A long pointer to the output buffer where the attribute value will be placed.
The value that is returned by this API is NOT a translated string. For instance,
*END would be returned instead of Ending page for the ending page attribute
of a spooled file. See “SOA attribute special values” on page 962 for
information on special values that may be returned for each type of object. The
output buffer is not changed when the return code is not set to
CWBSO_NO_ERROR.
unsigned long ulBufferLength - input
The size, in bytes, of the output buffer argument.
unsigned long far* lpulBytesNeeded - output
A long pointer to an unsigned long that will be set to the number of bytes
needed to place the entire attribute value in the output buffer. When this value
is less than or equal to the size of output buffer that is specified, the entire
attribute value is placed in the output buffer. When this value is greater than
the size of output buffer that is specified, the output buffer contains a null
string. The output buffer is not changed beyond the bytes that are needed for
the attribute value. This value is set to zero when the return code is not set to
CWBSO_NO_ERROR.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that is returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
unsigned long ulPosition - input
The position of the object within the list for which a handle is needed. NOTE:
The first object in a list is considered position 0.
CWBSO_OBJ_HANDLE far* lpObjectHandle - output
A long pointer to a handle which will be set to the handle for the AS/400
object. This handle may be used with any other API that accepts an object
handle with the exception that some APIs only operate on specific types of
objects.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error that was returned by a previous call to
CWBSO_CreateErrorHandle. When the value that is returned by this API is
CWBSO_ERROR_OCCURRED, the error handle may be used to retrieve the
error message text or display the error to the user.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. CWBSO_CreateErrorHandle must be called prior to calling this API. The
error handle that is returned by CWBSO_CreateErrorHandle must be passed as
input to this API. When the list is no longer needed, the calling program is
responsible for doing the following:
v Call CWBSO_CloseList to close the list and free up resources that are allocated
on the AS/400.
v Call CWBSO_DeleteListHandle to free up resources that are allocated on the
client.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object that was created by a previous call to
CWBSO_CreateErrorHandle. When the value that is returned by this API is
CWBSO_ERROR_OCCURRED, the error handle may be used to retrieve the
error message text or display the error to the user.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. CWBSO_SetListProfile must be called prior to calling this API. This API
has no effect on a list that has been opened. In order for the filter criteria in the
profile to take effect, the list must be opened after calling this API.
Syntax:
Parameters:
CWBSO_OBJ_HANDLE objectHandle - input
A handle to an object that was returned by a previous call to
CWBSO_GetObjHandle or CWBSO_CopyObjHandle.
HWND hWnd - input
Handle of window to receive the focus after the refresh is complete. This
parameter may be NULL. If this API is being called from an application
window procedure, then the current window handle should be supplied.
Otherwise, focus will shift to the most recently opened System Object Access
window if one is open.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Syntax:
Parameters:
CWBSO_PARMOBJ_HANDLE parmObjHandle - input
A handle to a parameter object that was returned by a previous call to
CWBSO_CreateParmObjHandle.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
unsigned short usFilterID - input
The filter identifier specifies which portion of the filter to set. The valid values
for this parameter depend on the type of objects in the list. See the appropriate
header files for the valid values:
v cwbsojob.h
v cwbsomsg.h
v cwbsoprt.h
v cwbsosfl.h
char far* lpszValue - input
The value for the filter attribute. If multiple items are specified, they must be
separated by commas. Filter value items that specify AS/400 object names
must be in uppercase. Qualified object names must be in the form of
library/object. Qualified job names must be in the form of
job-number/user/job-name. Filter value items specifying special values
(beginning with asterisk) must be specified in upper case. See “SOA attribute
special values” on page 962 for information on the special values that may be
supplied for each type of object.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. This API has no effect on a list that has been opened. In order for the
filter criteria to take effect, the list must be opened after calling this API. Caution
should be used when requesting complex filters as list performance may be
adversely affected.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or to CWBSO_CreateListHandleEx.
char far* lpszKey - input
A long pointer to a string that will be used as the key in the Windows Registry
for the list. This name could be the name of the application.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
unsigned short far* lpusSortIDs - input
A long pointer to an array of sort column identifiers. The sort IDs specified
will replace the current sort criteria for the list. The valid values for this
parameter depend on the type of objects in the list. See the appropriate header
files for the valid values:
v cwbsojob.h
v cwbsosfl.h
Note: If multiple sort IDs are specified, the order in which they appear in the
array defines the order in which sorting will take place.
unsigned short usCount - input
The number of sort column identifiers specified.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. This API has no effect on a list that has been opened. In order for the sort
criteria to take effect, the list must be opened after calling this API. Caution should
be used when requesting complex sorts as list performance may be adversely
affected.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
char far* lpszTitle - input
A long pointer to a string to be used for the list title. The length of the string
must be less than or equal to 79.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API.
Syntax:
Parameters:
CWBSO_OBJ_HANDLE objectHandle - input
A handle to an object that was returned by a previous call to
CWBSO_GetObjHandle or CWBSO_CopyObjHandle.
CWBSO_PARMOBJ_HANDLE parmObjHandle - input
A handle to a parameter object that was returned by a previous call to
CWBSO_CreateParmObjHandle. The parameter object contains the attributes
that are to be changed for the object.
unsigned short far* lpusErrorIndex - output
If an error occurred, this value will be set to the index of the parameter item
that caused the error. The first parameter item is 1. This value will be set to 0 if
none of the parameter items were in error.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Syntax:
Parameters:
CWBSO_PARMOBJ_HANDLE parmObjHandle - input
A handle to a parameter object that was returned by a previous call to
CWBSO_CreateParmObjHandle.
unsigned short usAttributeID - input
The attribute ID for the parameter to be set. The valid values for this
parameter depend on the type of object. See the appropriate header files for
the valid values:
v cwbsojob.h
v cwbsomsg.h
v cwbsoprt.h
v cwbsosfl.h
char far* lpszValue - input
A long pointer to an attribute value. Note that only ASCIIZ strings are
accepted. Binary values must be converted to strings by using the appropriate
library function. See “SOA attribute special values” on page 962 for information
on the special values that may be supplied for each type of object.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
unsigned long ulPosition - input
The position of the desired object within the list. NOTE: The first object in a
list is considered position 0.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object. If an error occurs that there is error text for, this
handle may be used to retreive the error message and message help.
Usage: CWBSO_CreateListHandle must be called prior to calling this API. The list
handle that is returned by CWBSO_CreateListHandle must be passed as input to
this API. CWBSO_CreateErrorHandle must be called prior to calling this API. The
error handle that is returned by CWBSO_CreateErrorHandle must be passed as
input to this API.
Syntax:
Parameters:
CWBSO_LIST_HANDLE listHandle - input
A handle to a list that was returned by a previous call to
CWBSO_CreateListHandle or CWBSO_CreateListHandleEx.
CWBSO_ERR_HANDLE errorHandle - input
A handle to an error object that was created by a previous call to
CWBSO_CreateErrorHandle. When the value that is returned by this API is
CWBSO_ERROR_OCCURRED, the error handle may be used to retrieve the
error message text or display the error to the user.
Job attributes: System Object Access uses the List Job (QUSLJOB) and Retrieve
Job Information (QUSRJOBI) AS/400 APIs to retrieve attributes for jobs. The
possible special values are the same as those that are documented in the OS/400
APIs: Work Management APIs topic in the AS/400 Information Center. The
following special value mappings are not documented explicitly:
CWBSO_JOB_CpuTimeUsed
If the field is not large enough to hold the actual result, QUSRJOBI returns
-1. System Object Access returns “++++”.
CWBSO_JOB_MaxCpuTimeUsed,
CWBSO_JOB_MaxTemporaryStorage,
CWBSO_JOB_DefaultWaitTime
If the value is *NOMAX, QUSRJOBI returns -1. System Object Access returns
“*NOMAX”.
Message attributes: System Object Access uses the List Nonprogram Messages
(QMHLSTM) OS/400 API to retrieve attributes for messages. The possible special
values are the same as those that are documented in the OS/400 APIs: Message
Handling APIs topic in the AS/400 Information Center.
CWBSO_SetListFilter accepts the special values that are supported by the List
Nonprogram Messages (QMHLSTM) API for Severity Criteria. In addition, a
10-character user name may be supplied, by specifying the
CWBSO_MSGF_UserName filter ID. “*CURRENT” may be used to obtain a list of
messages for the current user.
CWBSO_PRT_AdvancedFunctionPrinting. Whether the printer device supports Advanced Function Printing (AFP).
*NO The printer device does not support Advanced Function Printing.
*YES The printer device supports Advanced Function Printing.
CWBSO_PRT_AllowDirectPrinting. Whether the printer writer allows the printer to be allocated to a job that prints
directly to a printer.
*NO Direct printing is not allowed
*YES Direct printing is allowed.
CWBSO_PRT_BetweenCopiesStatus. Whether the writer is between copies of a multiple copy spooled file. The
possible values are Y (yes) or N (no).
CWBSO_PRT_BetweenFilesStatus. Whether the writer is between spooled files. The possible values are Y (yes) or
N (no).
CWBSO_PRT_ChangesTakeEffect. The time at which the pending changes to the writer take effect. Possible values
are:
*NORDYF
When all the current eligible files are printed.
*FILEEND
When the current spooled file is done printing.
blank No pending changes to the writer.
CWBSO_PRT_CopiesLeftToProduce. The number of copies that are left to be printed. This field is set to 0 when no
file is printing.
CWBSO_PRT_CurrentPage. The page number in the spooled file that the writer is currently processing. The page
number shown may be lower or higher than the actual page number being printed because of buffering done by the
system. This field is set to 0 when no spooled file is printing.
CWBSO_PRT_DeviceStatus. The status of the printer device. Possible values are the same as the device status that
is returned by the Retrieve Configuration Status (QDCRCFGS) API.
CWBSO_PRT_EndPendingStatus. Whether an End Writer (ENDWTR) command has been issued for this writer.
Possible values are:
N No ENDWTR command was issued.
I *IMMED: The writer ends as soon as its output buffers are empty.
C *CNTRLD: The writer ends after the current copy of the spooled file has been printed.
P *PAGEEND: The writer ends at the end of the page.
CWBSO_PRT_FileName. The name of the spooled file that the writer is currently processing. This field is blank
when no file is printing.
CWBSO_PRT_FileNumber. The number of the spooled file that the writer is currently processing. This field is set to
0 when no spooled file is printing.
CWBSO_PRT_FormsAlignment. The time at which the forms alignment message will be sent. Possible values are:
*WTR The writer determines when the message is sent.
*FILE Control of the page alignment is specified by each file.
CWBSO_PRT_FormType. The type of form that is being used to print the spooled file. Possible values are:
*ALL The writer is started with the option to print all spooled files of any form type.
*FORMS
The writer is started with the option to print all the spooled files with the same form type before using a
different form type.
*STD The writer is started with the option to print all the spooled files with a form type of *STD.
form type name
The writer is started with the option to print all the spooled files with the form type you specified.
CWBSO_PRT_FormTypeNotification. Message option for sending a message to the message queue when this form
is finished. Possible values are:
*MSG A message is sent to the message queue.
*NOMSG
No message is sent to the message queue.
*INFOMSG
An informational message is sent to the message queue.
*INQMSG
An inquiry message is sent to the message queue.
CWBSO_PRT_HeldStatus. Whether the writer is held. The possible values are Y (yes) or N (no).
CWBSO_PRT_HoldPendingStatus. Whether a Hold Writer (HLDWTR) command has been issued for this writer.
Possible values are:
N No HLDWTR command was issued.
I *IMMED: The writer is held as soon as its output buffers are empty.
C *CNTRLD: The writer is held after the current copy of the file has been printed.
P *PAGEEND: The writer is held at the end of the page.
CWBSO_PRT_JobNumber. The number of the job that created the spooled file which the writer currently is
processing. This field is blank when no spooled file is printing.
CWBSO_PRT_MessageKey. The key to the message that the writer is waiting for a reply. This field will be blank
when the writer is not waiting for a reply to an inquiry message.
CWBSO_PRT_MessageQueueLibrary. The name of the library that contains the message queue.
CWBSO_PRT_MessageQueueName. The name of the message queue that this writer uses for operational messages.
CWBSO_PRT_MessageWaitingStatus. Whether the writer is waiting for a reply to an inquiry message. The possible
values are Y (yes) or N (no).
CWBSO_PRT_NextFormType. The name of the next form type to be printed. Possible values are:
*ALL The writer is changed with the option to print all spooled files of any form type.
*FORMS
The writer is changed with the option to print all the spooled files with the same form type before using a
different form type.
*STD The writer is changed with the option to print all the spooled files with a form type of *STD.
form type name
The writer is changed with the option to print all the spooled files with the form type name you specified.
blank No change has been made to this writer.
CWBSO_PRT_NextFormTypeNotification. The message option for sending a message to the message queue when
the next form type is finished. Possible values are:
*MSG A message is sent to the message queue.
*NOMSG
No message is sent to the message queue.
*INFOMSG
An informational message is sent to the message queue.
*INQMSG
An inquiry message is sent to the message queue.
blank No change is pending.
CWBSO_PRT_NextOutputQueueLibrary. The name of the library that contains the next output queue. This field is
blank if no changes have been made to the writer.
CWBSO_PRT_NextOutputQueueName. The name of the next output queue to be processed. This field is blank if
no changes have been made to the writer.
CWBSO_PRT_NextSeparatorDrawer. This value indicates the drawer from which to take the separator pages if
there is a change to the writer. Possible values are:
*FILE Separator pages print from the same drawer that the spooled file prints from. If you specify a drawer
different from the spooled file that contains colored or different type paper, the page separator is more
identifiable.
*DEVD
Separator pages print from the separator drawer that is specified in the printer device description.
empty string
No pending change to the writer.
1 The first drawer.
2 The second drawer.
CWBSO_PRT_NextSeparators. The next number of separator pages to be printed when the change to the writer
takes place. Possible values are:
*FILE The number of separator pages is specified by each file.
empty string
No pending change to the writer.
number of separators
The number of separator pages to be printed.
CWBSO_PRT_OnJobQueueStatus. Whether the writer is on a job queue and, therefore, is not currently running.
The possible values are Y (yes) or N (no).
CWBSO_PRT_OutputQueueLibrary. The name of the library that contains the output queue from which spooled
files are selected for printing.
CWBSO_PRT_OutputQueueName. The name of the output queue from which spooled files are being selected for
printing.
CWBSO_PRT_OutputQueueStatus. The status of the output queue from which spooled files are being selected for
printing. Possible values are:
H The output queue is held.
R The output queue is released.
CWBSO_PRT_PrinterDeviceType. The type of the printer that is being used to print the spooled file. Valid values
are:
*SCS SNA (Systems Network Architecture) character stream
*IPDS Intelligent Printer Data Stream
CWBSO_PRT_SeparatorDrawer. Identifies the drawer from which the job and file separator pages are to be taken.
Possible values are:
*FILE The separator page prints from the same drawer that the file is printed from. If you specify a drawer
different from the file that contains colored or different type paper, the page separator is more identifiable.
*DEVD
The separator pages will print from the separator drawer that is specified in the printer device description.
1 The first drawer.
2 The second drawer.
3 The third drawer.
CWBSO_PRT_Status. The overall status of the logical printer. This field is derived from the printer device status
(from the Retrieve Configuration Status QDCRCFGS API), the output queue status (from the List Printer and Writer
Status, SPLSTPRT, XPF macro) and writer status (from the Retrieve Writer Information, QSPRWTRI, API). Possible
values are:
1 Unavailable
2 Powered off or not yet available
3 Stopped
CWBSO_PRT_TotalPages. The total number of pages in the spooled file. Possible values are:
number
The number of pages in the spooled file.
0 No spooled file is printing.
CWBSO_PRT_User. The name of the user who created the spooled file that the writer is currently processing. This
field is blank when no file is printing.
CWBSO_PRT_UserSpecifiedData. The user-specified data that describe the file that the writer is currently
processing. This field is blank when no file is printing.
CWBSO_PRT_WaitingForDataStatus. Whether the writer has written all the data that is currently in the spooled
file and is waiting for more data. Possible values are:
N The writer is not waiting for more data.
Y The writer has written all the data currently in the spooled file and is waiting for more data. This condition
occurs when the writer is producing an open spooled file with SCHEDULE(*IMMED) that is specified.
CWBSO_PRT_WaitingForDeviceStatus. Whether the writer is waiting to get the device from a job that is printing
directly to the printer.
N The writer is not waiting for the device.
Y The writer is waiting for the device
CWBSO_PRT_WriterStarted. Indication of whether a writer is started for this printer. Possible values are:
0 No writer is started
1 Writer is started
CWBSO_PRT_WriterStatus. The status of the writer for this printer. Possible values are:
X’01’ Started
X’02’ Ended
CWBSO_PRT_WritingStatus. Whether the printer writer is in writing status. The possible values are:
Y The writer is in writing status.
N The writer is not in writing status.
S The writer is writing the file separators.
System Object Access accepts a comma-separated list of printer names. Up to 100 printer names may be
specified. A special value of “*ALL” may be supplied to request a list of all printers on the AS/400.
Printer output attributes: System Object Access uses the List Spooled Files
(QUSLSPL) and Retrieve Spooled File Attributes (QUSRSPLA) AS/400 APIs to
retrieve attributes for printer output. The possible special values are the same as
those that are documented in the OS/400 APIs: Spooled File APIs topic in the
AS/400 Information Center. The following special value mappings are not
explicitly documented:
CWBSO_SFL_StartingPage
If the ending page value is to be used, QUSRSPLA returns -1. System
Object Access returns “*ENDPAGE”.
CWBSO_SFL_EndingPage
If the last page is to be the ending page, QUSRSPLA returns 0 or
2147483647. System Object Access returns “*END”.
CWBSO_SFL_MaximumRecords
If there is no maximum, QUSRSPLA returns 0. System Object Access
returns “*NOMAX”.
CWBSO_SFL_PageRotation
If no rotation is done, QUSRSPLA returns 0. System Object Access returns
“*NONE”.
An undocumented API is used to retrieve the printer device name or names for a
spooled file. The attribute and its possible values are described below.
CWBSO_SFL_DeviceNames. The name of the printer device that will print the file. If the printer output is assigned
to more than one printer device, this field contains all of the printer names in the group of printers. Possible values
are:
printer name
The name of the printer to which the printer output is assigned.
list of printer names
The names of the printers in the group to which the printer output is assigned. Commas will separate the
printer names.
empty string
The printer output is not assigned to a printer or group of printers.
CWBSO_SetListFilter accepts all special values that are supported by the List Spooled Files (QUSLSPL)
API.
TCP/IP interfaces attributes: System Object Access uses the AS/400 API TCP/IP
interface (QTOCIFCU) to retrieve attributes for TCP/IP interfaces. The possible
special values are:
CWBSO_TIF_TCPIPNetworkName
Ethernet lines attributes: See the OS/400 APIs: Configuration APIs topic in the
AS/400 Information Center.
Token-ring lines attributes: See the OS/400 APIs: Configuration APIs topic in the
AS/400 Information Center.
Hardware resources attributes: See the OS/400 APIs: Hardware Resource APIs
topic in the AS/400 Information Center.
Software products attributes: See the OS/400 APIs: Software Product APIs topic
in the AS/400 Information Center.
TCP/IP routes attributes: System Object Access uses the AS/400 API TCP/IP
route (QTOCRTEU) to retrieve attributes for TCP/IP routes. The possible special
values are:
CWBSO_RTE_TCPIPNetworkName
CWBSO_RTE_InternetAddress
CWBSO_RTE_BinaryInternetAddress
*RTVxxxLST only - The list of routes returned immediately will follow the
I/O Variable header. The interface structure will repeat for each route
returned.
CWBSO_RTE_SubnetMask
CWBSO_RTE_BinarySubnetMask
*RTVxxxLST only - The list of routes returned immediately will follow the
I/O Variable header. The interface structure will repeat for each route
returned.
CWBSO_RTE_NextHopAddress
CWBSO_RTE_BinaryNextHop
*RTVxxxLST only - The list of routes returned immediately will follow the
I/O Variable header. The interface structure will repeat for each route
returned.
Users and groups attributes: The possible users and groups special values are
valid:
CWBSO_USR_ProfileName
CWBSO_USR_ProfileOrGroupIndicator
CWBSO_USR_GroupHasMembers
CWBSO_USR_TextDescription
CWBSO_USR_PreviousSignonDate
CWBSO_USR_PreviousSignonTime
CWBSO_USR_SignonAttemptsNotValid
CWBSO_USR_Status
CWBSO_USR_PasswordChangeDate
CWBSO_USR_NoPasswordIndicator
CWBSO_USR_PasswordExpirationInterval
CWBSO_USR_DatePasswordExpires
CWBSO_USR_DaysUntilPasswordExpires
CWBSO_USR_SetPasswordToExpire
CWBSO_USR_DisplaySignonInformation
CWBSO_USR_UserClassName
CWBSO_USR_AllObjectAccess
CWBSO_USR_SecurityAdministration
Note: In release/version V4R4 and later, the following attributes are meaningful
only when Lotus Notes is installed on the AS/400:
CWBSO_USR_NotesServerName
CWBSO_USR_NotesCertifierID
CWBSO_USR_MailType
CWBSO_USR_NotesMailFileName
CWBSO_USR_CreateMailFiles
CWBSO_USR_NotesForwardingAddress
CWBSO_USR_SecurityType
CWBSO_USR_LicenseType
CWBSO_USR_MinimumNotesPasswordLength
CWBSO_USR_UpdateExistingNotesUser
CWBSO_USR_NotesMailServer
CWBSO_USR_LocationWhereUserIDIsStored
CWBSO_USR_ReplaceExistingNotesID
CWBSO_USR_NotesComment
Libraries in QSYS attributes: See the OS/400 APIs: Object APIs topic in the
AS/400 Information Center.
The topics that are listed below describe how to add your own C++, Java, or
Visual Basic applications to the Operations Navigator tree, by using the plug-in
feature. Once you have created your new plug-in, you can take advantage of the
support that is provided by the Client Access Selective Setup program to distribute
your plug-in within your organization or to outside users and customers. This
allows your users to consolidate all of their AS/400 administration tasks into a
single application environment.
Developing AS/400 Operations Navigator plug-ins topics:
v “Operations Navigator plug-ins overview”
v “C++ plug-ins” on page 1003
v “Java plug-ins” on page 1112
v “Visual Basic plug-ins” on page 1122
Note: This capability is not yet supported for Java and Visual Basic
plug-ins.
v Add new containers and objects to the hierarchy at predefined locations.
This allows you to add your own containers of specialized objects, with
unique context menus and property sheets. You can define custom
toolbars for your new containers, and implement drag-and-drop
functionality for objects in your containers.
Plug-in illustration:
The following illustration demonstrates how a Java plug-in works:
Use the plug-in support to add a new container to the Operations
Navigator tree. When the user selects the container, the plug-in’s Java code
is called to obtain the container’s contents—in this case, a list of messages
on the user’s default message queue.
AS/400 Operations Navigator dialog — messages in the message queue
What happens when the user wants to perform an action on one of your
objects? The illustration below shows what happens when the user
right-mouses on a message object to display its context menu.
When the user selects the menu item, the Navigator calls another
ActionsManager method to perform the action. Your ActionsManager
implementation calls your existing Java application, which then can display
a confirmation dialog or some other more sophisticated user interface
panel that allows the user to perform a specialized task.
The Operations Navigator user interface is designed to let users work with
lists of AS/400 resources and to perform actions on them. The architecture
of the plug-in feature reflects this user interface design, both by defining
interfaces for working with lists of objects in a hierarchy, and for defining
actions on those objects. A third interface, DropTargetManager, is defined
to handle drag-and-drop operations. For more information, see Operations
Navigator Java interfaces.
Plug-in requirements
Operations Navigator plug-in requirements differ according to the programming
language that you use:
C++ plug-ins:
Plug-ins that are developed by using Microsoft’s Visual C++ programming
language must be written to run on Version 4.2 or later.
Java plug-ins:
Java plug-ins run on the IBM Runtime Environment for Windows, Java
Technology Edition, Version 1.1.8, and on Sun’s Java Foundation (Swing)
Classes Release 1.1.1.
Visual Basic plug-ins:
Visual Basic plug-ins run on Version 5.0 of the Visual Basic runtime
environment.
For each of the plug-in samples, there is a registry (.reg) file. See the README.txt
files in the folder and in the plug-in samples folders for detailed information.
When you double-click on the registry file, the sample plug-in registry information
is entered into Operations Navigator. When you start Operations Navigator, it
detects the new registry entry, and prompts you to scan the system. The sample
plug-in calls the AS/400, and a new Message Queue Sample function folder
appears in the tree view in the left-hand panel. When you select this function, a list
of message queues appears in the list view in the right-hand panel of the
The sample plug-ins illustrate how to add a new folder to the Navigator hierarchy,
and how to implement context menu items, property pages, and drop actions on
items that are defined by the plug-in. The sample folder also will accept drops of
files from file systems. This illustrates the handling of drops by the plug-in of
existing Operations Navigator objects.
Note: The capability to add new property pages to existing objects in the
Operations Navigator hierarchy isn’t yet supported for Java or for Visual
Basic plug-ins.
3. Select the Rescan button to scan the system and update the listing of
plug-ins that are supported by the AS/400.
This procedure is known as the server entry point. The OS/400 release that is
installed on the selected AS/400 is supplied to this procedure, along with a list of
all installed software products. The plug-in can perform additional checks on the
AS/400 and on the client for dependencies that affect its ability to support the
selected system. The plug-in returns an indication of whether its function should
be activated on the specified AS/400.
Note: Only C++ plug-ins support the server entry point function. Java and Visual
Basic plug-ins are not called with a server entry point.
The scan is performed once for each AS/400 in the Client Access configuration. See
“Displaying installed plug-ins with the Operations Navigator Plug-ins tab” on
page 981 for more information about the scan operation.
The Operations Navigator sample plug-ins provide an example that illustrates how
to implement a server entry point. See “Plug-ins samples in the Express Toolkit” on
page 980 for instructions on how to access the sample plug-ins.
The file contains registry keys that identify the location of the ActiveX server DLL
that is associated with the plug-in. There also are keys that specify information that
is used by Navigator to determine the following:
v The type of function that is supplied by the plug-in
v Where in the object hierarchy the function should be activated
An Auto Refresh registry key automatically creates for your plug-in a property
sheet that supports the auto-refresh function.
Where to find information on creating a new registry file:
v “Customizing C++ plug-ins” on page 1035
v “Customizing Java plug-ins” on page 1119
v “Customizing Visual Basic plug-ins” on page 1128
These topics explain how to create a new registry file for your plug-in by
using the files that the samples provide. The topics also explain how to
tailor the registry entries so that Windows registry correctly identifies the
function your plug-in provides.
Registry keys and their associated fields and values:
v “Programmatic identifier (ProgID)” on page 984
v “Globally unique identifiers (GUIDs)” on page 984
v “Primary registry key” on page 984
v “New folder registry key” on page 986
v “Secure Sockets Layer (SSL) registry entry” on page 987
v “Shell plug-ins” on page 988
For Operations Navigator components written in Java and in Visual Basic, you
do not create a unique GUID. All Java plug-ins use the standard GUID that
identifies the built in ActiveX server DLL that directly calls out to all registered
Java components.
Primary registry key: The primary registry key defines a set of fields that specify
global information for the plug-in. This information is required. Note that the
subkey name must match the ProgID for your plug-in.
v “Example: Primary registry key”
v “Primary registry key fields”
;--------------------------------------------------------------------
; Define the primary registry key for the plugin
; NOTE: NLS and ServerEntryPoint DLL names must not contain qualified directory paths
Primary registry key fields: The following are descriptions of each field in the
primary registry key:
Type If the plug-in adds new folders to the Operations Navigator
hierarchy, the value of this field should be PLUGIN. Otherwise, it
should be EXT.
NLS Identifies the name of the resource DLL that contains the
locale-dependent resources for the plug-in. In the development
version of the registry file, this may be a fully-qualified pathname.
NameID A double word containing the resource identifier of the text string
in the resource DLL which will be used to identify the plug-in in
the Operations Navigator user interface.
New folder registry key: A separate registry key must be defined for the root of
each subtree of objects that a plug-in chooses to add to the object hierarchy. This
key contains information specific to the root folder of the subtree.
It is important that the registry key name should be a meaningful folder name, and
must be at least four characters in length.
New folder registry key topics:
v “New folder registry key fields”
v “Example: New folder registry key” on page 987
New folder registry key fields: Following are descriptions of each of the fields in the
new folder registry key:
Parent A three-character ID that identifies the parent of the folder to be
added. One of the following IDs may be specified:
Attributes A 4-byte binary field that contains the attributes for the folder, with
the indicator bytes in reverse order. See the folder attribute flags
defined for the IShellFolder::GetAttributesOf method in the
Microsoft include file SHLOBJ.H.
CLSID The CLSID of the IA4HierarchyFolder implementation that should
be called by the Operations Navigator to obtain the contents of the
folder.
For Java plug-ins, the CLSID always should be:
1827A856-9C20-11d1-96C3-00062912C9B2.
For Visual Basic plug-ins, the CLSID should always be:
040606B1-1C19-11d2-AA12-08005AD17735}.
JavaClass The fully-qualified Java class name of the ListManager
Example: New folder registry key: The following is an example of the new folder
registry key:
;--------------------------------------------------------------------
; Register a new folder
Secure Sockets Layer (SSL) registry entry: Operations Navigator users can
request a secure connection to an AS/400 by selecting the Use Secure Sockets
If all of a plug-in’s communications with the AS/400 are managed by using the
Client Access system handle (enter cwbCO_SysHandle), or by using the class
com.ibm.as400.access.AS400 in the case of a Java plug-in, then it should indicate
that it supports secure connections to the AS/400. For C++ plug-ins, the
cwbCO_SysHandle is obtained by calling the cwbUN_GetSystemHandle API.
When the user requests a secure connection, the Navigator automatically will
enable SSL. In the case of Java plug-ins, the AS/400 object obtained by calling the
getSystemObject method on the class com.ibm.as400.opnav.ObjectName actually
will be an instance of com.ibm.as400.access.SecureAS400. See Operations
Navigator javadoc documentation for more information.
Note: If you are running Java over SSL, and creating your own CA certificate,
Client Access GA service pack is required.
If a plug-in’s communications with the AS/400 are performed by using the Sockets
API or some other low-level communications service, then it is the responsibility of
the plug-in to support SSL if it has been requested. If the plug-in doesn’t provide
this support, it should indicate that it doesn’t support SSL as described below.
When this is done, the plug-in’s function will be disabled if the user has requested
a secure connection.
Example: Adding a registry key to enable SSL
The key is SSL under [HKEY_CLASSES_ROOT\IBM.AS400.Network\3RD PARTY
EXTENSIONS\IBM.Sample\SSL] "Support Level"=dword:00000001 where IBM.Sample is the plu
Shell plug-ins: The final section of the registry file contains entries that specify
which objects in the Navigator hierarchy are affected by the implementation of the
plug-in.
The registry keys map a particular node or set of nodes in the hierarchy to the
type of function supplied by the plug-in, and to the CLSID of the implementation
class which implements the function.
Notice the subkeys \Sample\*\. A pair of object type identifiers is always expected
at this level in the subkey hierarchy. The first identifier in the pair specifies the
root folder for a Navigator component. For plug-ins that add new folders, this
identifier should always match the registry key name for a root folder specified the
previous section. For plug-ins which add behaviors to existing object types, this
subkey should generally be the object type of the first-level folder under an
AS/400 container object. These type strings are defined under
HKEY_CLASSES_ROOT\IBM.AS400.Network\TYPES in the registry.
The second identifier in the pair identifies the specific object type that the plug-in
wants to affect. If * is specified, the plug-in will be called the for the folder type
identified in the parent subkey, plus all folders and objects which appear in the
Remember that any number of shell plug-ins may register their intent to add
function to a given object type in the Navigator hierarchy. The plug-in should
never assume that it is the only server component which is providing function for
a given object type. This applies not only to existing object types, but also to any
new objects that a plug-in may choose to define. If your plug-in is widely used,
there is nothing to prevent another vendor from extending object types that are
defined by your plug-in.
The code file based on the sample file EXTINTFC.CPP contains the code that will
be called for context menus, property pages, and drop actions. The sample code
contains checks for the object types that the sample defines. You must edit this file
and either remove these tests or change them to check for the object types for
which you wish to provide new function.
When performing checks for existing object types, you should use the 3-character
type identifiers that are defined under the key
HKEY_CLASSES_ROOT\IBM.AS400.Network\TYPES in the registry. When
performing checks for new object types that are defined by your plug-in, use a
registry key. Use the registry key that identifies the folder that you specified as
your junction point, or whatever type you will return to the Navigator when
serving data for a folder that is defined by your plug-in.
Property pages for a property sheet handler: The Microsoft Foundation Class Library
classes cannot be used to construct property pages for a property sheet handler.
However, IBM provides CExtPropertyPage, which may be used in place of the
MFC class CPropertyPage. Property pages implemented by Operations Navigator
plug-ins should subclass CExtPropertyPage. The class declaration may be found in
the header file PROPEXT.H, and the implementation is contained in the file
PROPEXT.CPP. Both files are provided as part of the sample plug-in.
If a plug-in requires that a property sheet is associated with one of its own object
types, the SFGAO_HASPROPSHEET flag must be returned as part of the attributes
of the object. When this flag is on, the Navigator automatically will add Properties
to the context menu for the object. Also, when this flag is on, Navigator will call
any registered property sheet handlers to add pages to the property sheet when
the context menu item is selected.
In certain cases a plug-in may desire to implement a Properties context menu item
that is defined for one of its own object types as a standard Windows dialog
instead of a property sheet. A flag is defined for this situation that may be
returned to the Navigator on calls to IContextMenu::QueryContextMenu. If the flag
is returned, no automatic processing for Properties is performed, and it is up to the
plug-in to add the context menu item and implement the associated dialog. This
flag is documented in “Description of QueryContextMenu flags” on page 1027.
If a plug-in intends to add property pages to one of the property sheets for an
AS/400 user, the key that specifies the CLSID of the property sheet handler must
specify a PropSheet field that identifies the property sheet to which the specified
handler will add pages. An example follows.
To add pages to a property sheet for an AS/400 user, the plug-in must implement
the IA4PropSheetNotify interface (see “IA4PropSheetNotify interface specifications
listing” on page 1023).
Restriction:
The following restriction currently applies to property sheets for AS/400
user objects:
Multiple property sheet handlers for the various property sheets that
are associated with an AS/400 user cannot be implemented on the same
implementation class. Each property sheet requires a separate CLSID.
The file must be named SETUP.INI, and it must reside in the primary
<VENDOR>.<COMPONENT> directory for the plug-in on the AS/400.
The format of the file conforms to that of a standard Windows configuration (.INI)
file. The file is divided into three parts:
v Plug-in information
v Service
Listed below are file sections that are used while servicing a plug-in when the
FixLevel value is incremented. Note that MRI and Help files cannot be serviced.
[Service Base Files]
Files that are copied to \PLUGINS\<VENDOR>.<COMPONENT>
under the Client Access install directory.
[Service Shared Files]
Files that are copied to the Client Access Shared directory.
[Service System Files]
Files that are copied to the \WINDOWS\SYSTEM or
\WINNT\SYSTEM32 directory.
[Service Core Files]
Files that are copied to the \WINDOWS\SYSTEM or
\WINNT\SYSTEM32 directory. These files are use counted in the
registry, are never removed, and are typically redistributable files.
[Service Registry Files]
The Windows registry file that is associated with the plug-in.
In all cases, only the file name and plug-in should be specified. Do not specify
directory path names.
The Client Access Toolkit provides a sample setup file for three different sample
plug-ins: C++, Java, and Visual Basic.
a network. For information on system policies, see the Microsoft Web site . The
Microsoft Windows 95 Resource Kit manual is another source of information on
system policies.
Client Access Express allows plug-ins to provide a policy template file that
administrators can use to restrict specific users or specific workstations from
installing the plug-in. Client Access Express also provides a general policy that
allows administrators to restrict users from installing any plug-in that does not
provide a policy template file. By providing its own policy template file, a plug-in
allows administrators to define install restrictions that are used only for that
plug-in. The C++ sample plug-in contains a policy template that is named
sample.adm to use for this purpose.
Note: Visual Basic and the Java plug-in samples in the Client Access Express
Toolkit do not include a policy template. Use the sample.adm template that is
included in the C++ sample plug-in.
The sample.adm file is a standard windows policy template file. It has support for
preventing a user or a specific machine from installing the sample plug-in. To
build a windows policy template file for your plug-in, do the following:
1. Copy the ’sample.adm’ file to something appropriate for your plug-in (the copy
must retain the ’adm’ extension). This file will become the policy template file
for your plug-in.
2. Refer to the comments in the copied file for details on the changes that are
required to use this template file for your plug-in. There are two required
changes:
v You will need to replace both of the ’vendor.component’ fields in this file
with the correct values for your plug-in.
v Change the string that is labeled ’PluginName’ to contain the name of your
plug-in.
3. If your plug-in has defined its own policies, add these to the copied ’adm’ file.
A policy template file is optional and does not need to be provided by every
plug-in. It should be provided only if either of the following situations exist:
Note: If the plug-in does not provide its own policy template file, admistrators
can restrict users from installing this plug-in only by using the general
Client Access Express policy for restricting the installation of plug-ins that
do not provide a policy template file.
v The plug-in defines additional policies.
Special Considerations for plug-ins that are compatible with Client Access
(V3R2M0):
The preceding steps list the requirements for building a policy template file
that can restrict the plug-in from being installed by Client Access Express.
If your plug-in is designed to run on both Client Access Express and Client
Access (V3R2M0), you will need to provide two separate policy template
files:
v A template file for workstations that are attempting to install your
plug-in by using Client Access Express. This is described above.
v A template file for workstations attempting to install your plug-in by
using Client Access (V3R2M0).
For directions on how to create this template file, see the sample plug-in
that was included in the V3R2M0 Client Access Toolkit.
You must name the file MRISETUP.INI. A version of this file must reside in the
MRI29XX subdirectory on the AS/400 for each national language that the plug-in
supports.
The format of the file conforms to that of a standard Windows configuration (.INI)
file. The file contains a single section, MRI Info. The MRI Info section provides the
Version value for the MRI of the plug-in. The MRI for the plug-in includes all
resource DLLs, as well as Help files (.HLP and .CNT) for a particular language. For
example:
[MRI Info]
Version=0
The Client Access Selective Setup program checks the Version value of the MRI
during an initial install and during an upgrade of the plug-in when incrementing
the Version or release level of the plug-in. The MRI Version value in this file must
match the Version value in the SETUP.INI file of the plug-in during the install or
upgrade. When these values do not match, the MRI files will not be copied to the
client PC. The Client Access Toolkit provides a sample MRI setup file with the
sample plug-in.
The following figure displays the Application Administration dialog while viewing
the Operations Navigator functions. In this example, the function titled AS/400
Operations Navigator is the Product function. Basic Operations and Job
Management are examples of Group functions. Messages, Printer Output, and
Jobs are all examples of Administrable functions.
Once this is done, you will need to modify your plug-in’s registry file with the
information that defines the Application Administration functions and their
hierarchy. You either can add this registry information to your plug-in’s existing
registry file, or add it to a separate registry file that is installed with your plug-in
(The C++ sample plug-in has placed its Application Administration information in
a separate registry file for simplification purposes).
[HKEY_CLASSES_ROOT\IBM.AS400.Network\Application_Administration\Client_Defined_Functions\Plugins\IBM.Sample\QIBM_SAMPLE_SMPFLR]
"SeqNum"=dword:00000001
"Container"=""
"FunctionType"=dword:00000000
"FuncDescID"=dword:000000a5
"FuncNameID"=dword:00000082
This registry file must create a key with the following name:
HKEY_CLASSES_ROOT\IBM.AS400.Network\Application_Administration\Client_Defined_Functions\Plugins\<vendor>.<component>
The following registry values may exist for each of the subkeys that define
Application Administration functions. All of the resources identified below are
retrieved from the DLL that is specified by the AIMRIDLL registry value:
FuncDescID
(Required - DWORD) Resource ID of the string used as a one-sentence
description for the function.
FuncNameID
(Required - DWORD) Resource ID of the string that is used as a name for
the function.
FunctionType
(Optional - DWORD) Identifies the type of Administrable function:
0 = Administrable Function. (Default if 'FunctionType is not specified)
1 = Group Function.
2 = Product Function.
FuncBmpID
(Optional - DWORD) Resource ID of the bitmap used for the function. If
not specified, Application Administration will use a default bitmap.
OpenBmpID
(Optional - DWORD) Ignored for Administrable Functions. Resource ID of
the bitmap used when the function is open. If not provided for Group and
Product functions, the bitmap that is defined by FuncBmpID will be used
for both the open and closed states. This value is ignored if the
FuncBmpID value is not specified.
Container
(Optional - STRING) Function ID of the Group Function that is the parent
or container of the function that is being defined. If Container is not
specified or blank, then the Product Function for the application is
assumed to be the parent of the function. Product functions do not have a
Container value.
SeqNum
(Optional - DWORD) Indicates the default sort order of the function. If not
specified, it is assumed that the sequence number (SeqNum) is the
maximum value. All immediate child functions of a Group or Product
function are sorted by SeqNum value in ascending order before being
displayed in the Application Administration screens. If multiple functions
have the same SeqNum value, then those functions are sorted in ascending
order based on their function name.
Each function must have a unique Function ID. Each Function ID must adhere to
the following rules:
v It must be 1 to 30 characters in length. Valid characters are ’A’ - ’Z’ (uppercase
only), ’0’ - ’9’, ’_’, and ’.’.
All IBM products that define Application Administration functions will use
’QIBM’ as the prefix for their Function IDs.
v Once a specific Function ID is shipped with an application, that Function ID
never should be reused to control access to a different interface, even if future
versions of the application no longer use the interface that originally was
controlled by the Function ID.
The Container registry field for the plug-in’s functions should be set to the
Function ID of the Group function that will contain the plug-in’s function. All of
the function IDs for the Operations Navigator Application Administration
functions are contained within the cwbunpla.h header file that is installed with the
Client Access Express Toolkit. For example:
v If your Application Administration function is to control access to a folder that
will have the AS/400 as its parent (as is done in the C++ sample plug-in), then
the Container field should be omitted or left blank.
v If your Application Administration function is to control access to a folder that
will reside within Management Central’s Central system, then it should set the
Container field to QIBM_XE1_OPNAV_MC, which is the function ID of the
application administration function that controls access to the management
central’s root folder.
v If your Application Administration function is to control access to a folder that
will reside within an Operations Navigator folder, you will need to determine
the function ID that controls access to the parent Operations Navigator folder
(all function IDs for Operations Navigator folders are listed in the
CWBUNPLA.H header). You will need to specify the function ID of the
Operations Navigator folder as the Container field value of your Application
Administration function. For example, if your plug-in has a folder that will
reside within the Operations Navigator Database folder, and access to this folder
will be controlled through Application Administration, then the application
administration function that is defined by your plug-in to control access to its
folder should set its Container value to the function ID of the Database folder
(QIBM_XD1_OPNAV_DATABASE).
If your plug-in provides a new folder, and will use Application Administration to
control access to this folder, then you will need to modify the primary registry key
that defines your new folder. The new folder’s primary registry key will need the
AdminItem value set to the function ID of the Application Administration function
that controls access to the new folder. See the “New folder registry key fields” on
page 986 for more information on folder registry key fields. Once the AdminItem
registry value is set to your new function ID, Operations Navigator will display
your folder only if the current user (AS/400 user) has access to its controlling
Application Administration function.
The following types of changes can be made to an application’s function set across
version boundaries:
v Altering the Function Name or Function Description of a function.
v Adding a new Administrable or Group function.
v Altering a function’s bitmap(s) or its sequence number.
v ″Obsoleting″ a function (This occurs when the newer version of the application
no longer uses an Application Administration function that it shipped in a prior
release).
The following types of changes can be made to an application’s function set across
version boundaries only if the newer version contains more functions in its
Application Administration function set than the prior version contained:
v Altering the Group function of a function (altering a function’s container).
If the new version of an application does not contain more functions in its
Application Administration function set, then the Application Administration
support in Operations Navigator will not be able to determine that the newer
version’s set of functions are an Upgrade to a previous version.
The following types of changes require an application to use a completely new set
of Application Administration functions in the newer version of the application:
v Altering the type of a function (Changing a Group function to an Administrable
function, or conversely).
v Deleting a function defined in a previous release.
Note: If the newer version of the application stops by using the deleted
function, but still contains it in its set of Application Administration
functions, then this type of change is considered ″obsoleting″ a function,
and does not require the newer version of the application to use a new set
of functions.
v Altering a function’s Function ID.
This new set of Application Administration functions has no restriction on the type
of changes that can be made across version boundaries of the application (all
function IDs must be unique and can’t be reused from functions defined in prior
versions of the application). Providing a completely new set of functions should be
C++ plug-ins
To develop an Operations Navigator C++ plug-in, you must create an ActiveX
server DLL, which contains the plug-in’s implementation. You must provide
certain predefined information about the plug-in in the form of a Windows
registry file. This information is written to the user’s registry when the plug-in is
installed. The registry information allows Operations Navigator to identify the new
plug-in, and to call its implementation in response to appropriate user actions.
AS/400 Operations Navigator APIs required files:
Express Toolkit:
The Client Access Express Toolkit provides access to AS/400 Operations
Navigator header files, and links to sample programs. To access this
information, open the Express Toolkit and select AS/400 Operations —>
Operations Navigator —> C/C++.
C++ plug-ins overview topics:
v “Product architecture for Operations Navigator C++ plug-ins”
v “Operations Navigator structure and flow of control for C++ plug-ins”
Developing C++ plug-ins topics:
v “Developing Operations Navigator C++ plug-ins” on page 1030
v “Installing Operations Navigator C++ plug-ins” on page 1042
v “Identifying C++ plug-ins to Operations Navigator” on page 1042
v Operations Navigator API listing
v “Return codes unique to Operations Navigator APIs” on page 1111
Related topics:
v “AS/400 system name formats for APIs” on page 10
For more information on COM, consult the Visual C++ online documentation or
Plug-ins work by responding to method calls from Operations Navigator that are
generated in response to user actions. For example, when a user right-clicks on an
object in the Navigator hierarchy, the Navigator constructs a context menu for the
object, and displays the menu on the screen. The Navigator obtains the menu items
by calling each plug-in that has registered its intention to supply context menu
items for the selected object type.
The functions that are implemented by a plug-in logically are grouped into
″interfaces.″ An interface is a set of logically related methods on a class that
Operations Navigator can call to perform a specific function. The Component
Object Model supports the definition of interfaces in C++ through the declaration
of an abstract class that defines a set of pure virtual functions. Classes that call the
interface are known as implementation classes. Implementation classes subclass the
abstract class definition and provide C++ code for each of the functions defined on
the interface.
For more information on the IContextMenu interface, see the Visual C++ online
help documentation.
To add property pages to the property sheet for an object in the Navigator
hierarchy, your plug-in implements the IPropSheetExt interface. The single method
of interest on this interface is AddPages. The Navigator calls AddPages when
construction of the property sheet for an object is in progress. The method creates
the property page or pages it intends to add by using standard Windows APIs. It
then adds the pages by calling a function that was passed to it as a parameter.
The sample plug-in provides an illustration of how to use the IDropTarget and
IPersistFile interfaces. The sample implements the drag and drop of Operations
Navigator file and sample objects to the sample folder. For more information on
these interfaces, see the Visual C++ online help documentation.
The ″Users and Groups″ component of the Operations Navigator is a unique case
where property pages are concerned. Selecting Properties for an AS/400 user
displays a dialog that has a group of several buttons at the bottom. Selecting each
For a plug-in to add new folders to the Operations Navigator hierarchy, it must
use the IA4HierarchyFolder interface. The purpose of this interface is to supply
the data used to populate the contents of a new folder that your plug-in added to
the Navigator hierarchy. It also defines methods for specifying list view columns
and their headings, and for defining a custom toolbar that is associated with a
folder. IA4HierarchyFolder is an IBM interface.
The header file CWBA4HYF.H contains declarations of the interface prototype and
associated data structures and return codes.
The Operations Navigator uses item identifiers that adhere to the following given
structure that must be returned by IA4HierarchyFolder::ItemAt.
<cb><item name>\x01<item type>\x02<item index>
where
<cb> is the size in bytes of the item identifier, including the count field itself
<item name> is the translated name of the object, suitable for displaying to the
user
<item type> is a unique language-independent string that identifies the object
type. It must be at least four characters in length.
<item index> is the zero-based index that identifies the position of the object
within the list of parent folder objects.
Syntax:
Comments: The Operations Navigator calls this function the first time a user
selects or expands a folder. It is called again, after a call to Close, when the user
has requested a refresh of the folder contents.
The function may be called at other times whenever a pointer to the folder
interface needs to be reestablished. An example would be when the user selects a
folder a second time, after having selected another folder. The function should
simply return TRUE if the associated processing has already been performed.
For extremely large lists, you may choose to return from Activate before the list is
completely constructed, after having first created a worker thread to continue
building the list. If this is the case, make sure that your implementation of
GetListSize returns the correct indication of whether the list is completely
constructed.
Syntax:
Parameters:
hwnd
Handle of the view window which will display the list (may be either a tree or
list control). A component should use this handle to determine if a list of
objects for this view is already cached on the client.
pidl
Pointer to an ITEMIDLIST (item identifier list) structure that uniquely
identifies the folder to be enumerated.
riid
Identifier of the interface to return. This parameter points to the
IID_IA4HierarchyFolder interface identifier.
ppvOut
Address that receives the interface pointer. If an error occurs, a NULL pointer
should be returned at this address.
The function should initialize implementation class member variables from the
parameters supplied.
Syntax:
Comments: This function is called when the user has requested a refresh of the
contents of an Operations Navigator folder. The function should destroy cached
folder objects and set any state variables required to force a rebuild of the cache on
the next call to Activate.
The function may be called multiple times in succession. It should simply return
TRUE if the associated processing has already been performed.
Purpose: Called to display an error message to the end user whenever Activate
returns an error. This is a required member function.
Syntax:
Comments: None
Syntax:
Parameters:
pidl
Pointer to an ITEMIDLIST (item identifier list) structure that uniquely
identifies the object whose attributes are to be retrieved.
ulfInOut
The returned object attributes. On input, this parameter will be set to indicate
which object attributes to retrieve.
Comments: Refer to the Windows include file shlobj.h for constants that define the
bit flags.
Syntax:
Parameters:
pidl
Pointer to an ITEMIDLIST (item identifier list) structure that uniquely
identifies the object whose column data is to be obtained.
lParam
The value that was previously associated with the column for which data is
requested by the component (see GetColumnInfo).
lpszColumnData
Address of the buffer that will receive the null-terminated data string.
cchMax
Size of the buffer that will receive the null-terminated data string.
Purpose: Returns a data structure that describes the columns needed to display the
contents of a particular folder in a details view. This is an optional member
function.
Syntax:
Parameters:
ppvInfo
Each column item structure supplies the translated string for the column
heading, the default width of the column, and an integer value that uniquely
identifies the data field that supplies data for the column. Refer to
CWBA4HYF.H.
Comments: The Operations Navigator calls this function after the call to Open has
returned, to create the column headings for a details view.
If this function is not implemented, the Navigator will insert two columns: Name
and Description. GetColumnDataItem must be capable of returning data for these
two fields, which are identified with integer values of 0 and 1, respectively.
Use the Windows IMalloc interface to allocate memory for the returned structures.
The Navigator will be responsible for deleting this memory.
Purpose: Returns the index into the component resource DLL that may be used to
load the icon for the hierarchy folder. This is a required member function.
Syntax:
Parameters:
pidl
Pointer to an ITEMIDLIST (item identifier list) structure that uniquely
identifies the object whose icon index is to be retrieved.
uFlags
This parameter may be zero, or it may contain the value GIL_OPENICON,
indicating that the icon which should be supplied is an open folder.
GIL_OPENICON is defined in the Windows include file SHLOBJ.H.
piIndex
Pointer to an integer that receives the icon index.
Purpose: Returns the total count of objects contained in a particular folder in the
Operations Navigator hierarchy. This is a required member function.
Syntax:
Parameters:
pCount
Pointer to a long integer that will receive the count of items in the list.
For extremely large lists, you may choose to return from Activate before the entire
list has been cached on the client. If this is the case, you should return
A4HYF_OK_LISTNOTCOMPLETE from GetItemCount. From that point on,
GetItemCount will be called by the Operations Navigator every 10 seconds until
A4HYF_OK_LISTCOMPLETE or A4HYF_E_LISTDATAERROR is returned.
Purpose: Returns a structure that describes the custom tool bar that is associated
with the specified folder in the Operations Navigator hierarchy. This is a required
member function.
Syntax:
Parameters:
pidl
Pointer to an ITEMIDLIST (item identifier list) structure that uniquely
identifies the object for which tool bar information is to be retrieved.
ppvInfo
The returned data structure. An instance of A4hyfToolBarInfo should be
returned in this pointer. This structure supplies the count of toolbar buttons for
the object, the address of an array of TBBUTTON structures containing the
attributes for each button, and the instance handle of the plug-in. Refer to
CWBA4HYF.H.
Comments: This function is called each time a user selects a folder or object that
belongs to an Operations Navigator plug-in.
Use the Windows IMalloc interface to allocate memory for the returned structure.
The Navigator will be responsible for deleting this memory.
If this member function is not implemented, the default Operations Navigator tool
bar will be used. This toolbar contains Copy, Paste, Delete, Properties, buttons for
the four list views, and Refresh. The Operations Navigator calls the
implementation of IContextMenu::GetCommandString (with the GCS_VALIDATE
flag set) that is in your product to discover which of the toolbar buttons should be
enabled for your objects.
Syntax:
Parameters:
lpszObjectName
The fully-qualified object name for which a list object will be returned.
ppvObj
The returned pointer to an implementation-defined object. The calling routine
should cast this pointer to an appropriate object type.
Comments: Calls to this function occur whenever your plug-in code calls
cwbUN_GetListObjectFromName or cwbUN_GetListObjectFromPidl to obtain a
″proxy″ object that was instantiated by the Activate method. The plug-in uses this
proxy object to access data on the AS/400, or to perform actions on the AS/400.
Because IA4HierarchyFolder implementation maintains the cache of proxy objects,
the calling program should not attempt to delete the object.
Purpose: Returns as SHITEMID (item identifier) structure for the folder object at
the specified position in the list of folder contents. This is a required member
function.
Syntax:
Parameters:
ulIndex
The zero-based index of the item for which an item identifier is requested.
ppidl
Address of the pointer that will receive the requested item identifier.
Purpose: Call to this function occur when the user closes the Operations Navigator
window to provide the plug-in with an opportunity to save persistent data. This is
an optional member function.
Syntax:
Comments: None
Purpose: Destroys any cached folder objects and rebuilds the cache using new data
obtained from the AS/400. This is a required member function.
Syntax:
The interface implementation is compiled and linked into the ActiveX server DLL
for the plug-in. The Navigator learns of the existence of the new DLL by means of
entries in the Windows registry. These entries specify the location of the DLL on
the user’s personal computer. The Navigator then loads the DLL at the appropriate
time, calling methods on the IA4PropSheetNotify interface as needed.
Syntax:
Parameters:
wUserState
The current state of the AS/400 user. Supplies one of three mutually exclusive
values:
IUS_NEWUSER
Creating a user based on attributes that are supplied by the Operations
Navigator user.
IUS_NEWUSERBASEDON
Creating a user based on the attributes of an existing AS/400 user.
IUS_USEREXISTS
The user already exists on the AS/400.
Comments: None
Purpose: Called to inform the implementation that data that belongs to the user
should now be saved.
Syntax:
Parameters:
pszNewUserName
Supplies the name of the new AS/400 user if creating the user for the first
time, for example, if InformUserState specifies a value other than
IUS_USEREXISTS.
Comments: None
Syntax:
Parameters:
pszErrMsg
Address of the buffer that will receive the null-terminated error message.
cchMax
Size of the buffer that will receive the null-terminated error message.
Comments: None
Items on the File pulldown are arranged slightly differently. If you add
Properties to the menu, you should avoid inserting a separator as is
normally done before this item. Also, edit actions such as Copy or
Paste should not be added to the File menu, because they appear on
the Edit pulldown instead. (The Operations Navigator calls your shell
plug-in at the appropriate time to obtain the items for the Edit menu,
and does not set UNITY_CMF_FILEMENU).
Unique property dialogs
In certain cases, a plug-in may desire to implement a Properties context
menu item that is defined for one of its own object types as a standard
Windows dialog instead of a property sheet. A flag that is defined for this
situation may be returned to the Navigator on calls to
IContextMenu::QueryContextMenu when the UNITY_CMF_STANDARD
flag is set. This flag, A4HYF_INFO_PROPERTIESADDED, should be OR’d
with the HRESULT value that is returned by QueryContextMenu.
Description of server entry point: A server entry point allows the plug-in to help
determine whether the function supplied by the plug-in should be activated for a
particular AS/400 that appears in the Operations Navigator hierarchy. The
Navigator calls the server entry point whenever a ″scan″ function is performed.
Normally the scan is performed the first time a user selects an AS/400 after the
client workstation has one or more plug-ins installed or upgraded. The user also
can start a manual rescan from the Plug-ins tab on the Property sheet for an
AS/400.
Note: Only C++ plug-ins support the server entry point function. Java and Visual
Basic plug-ins will not be called with a Server entry point.
Syntax:
Parameters:
lpszAS400Name
The name of the AS/400 for which the function is to be surfaced.
lpszVRM
The Version/Release/Modification level of the specified AS/400, expressed as a
string of the form vvrrmm. For example, OS/400 Version 4 Release 2 would be
″040200.″
lpszInstalledProducts
A large string that contains the product IDs of every product installed on the
specified AS/400. The character ″/x01″ precedes each product ID in the string.
Return Codes: The function should return TRUE if the plug-in will surface its
function for this AS/400, and FALSE if the plug-in will not display the function.
Comments: Activation of this function occurs only when the ServerEntryPoint field
in the primary registry key for the plug-in contains the name of the DLL in which
the function resides. During development, a fully-qualified pathname may be
specified. When the plug-in is in production, only the name of the DLL should be
specified in the registry. The DLL will be loaded from the
<VENDOR>.<COMPONENT> subdirectory of the CLIENT ACCESS/PLUGINS.
IA4CheckIfSupported is called on a data thread, not the main UI thread. No user
interface tasks should be attempted.
The plug-in receives this information as a list of fully qualified object names. For
C++ plug-ins, a call to IShellExtInit::Initialize passes this list to the plug-in.
Microsoft defined the IShellExtInit interface for the purpose of initializing the
implementation class for shell plug-ins. A call to its only method, Initialize, occurs
before the creation of an instance of IContextMenu or IPropSheetExt. For more
information about the format of Operations Navigator object names, see
“IA4HierarchyFolder interface specifications listing” on page 1007. For Java and
Visual Basic plug-ins, an ObjectName class is defined that provides information
about the selected objects.
Plug-ins that add folders to the object hierarchy must return items in the folder to
Operations Navigator in the form of ″item identifiers.″ For more information about
item identifiers in C++, see “IA4HierarchyFolder interface specifications listing” on
page 1007. For Java and Visual Basic plug-ins, an ItemIdentifier class is defined
and is used by the plug-in to return the requested information.
Detail: If the new directory is not c:\MyProject, you will need to change the
registry file. See “Registering the ActiveX server DLL for C/C++
plug-ins” on page 1032 for more information.
2. Copy all of the sample files into this directory. You can download the samples
from the Client Access Express Toolkit - Operations Navigator Plug-ins Web
page.
3. In the Developer Studio, open the File menu and select Open Workspace.
4. In the Open Project Workspace dialog, switch to the MyProject directory and in
Files of Type: select Makefiles (*.mak).
5. Select sampext.mak and click Open.
6. Open the Tools menu and select Options...
7. In the Directories tab, make sure that the Client Access Include directory
appears at the top of your Include files search path.
8. In Show directories for:, select Library files. Make sure that the Client Access
Lib directory appears at the top of your Library files search path.
9. Click OK to save the changes, then close and reopen Developer Studio. This is
the only known way to force Developer Studio to save the search path changes
to your hard disk.
What to do next:
Build the ActiveX server DLL
Building the ActiveX server DLL for C/C++ plug-ins: To build the ActiveX
server DLL, complete the following steps.
1. In the Developer Studio, open the Build menu and select Set Default
Configuration...
2. In the Default Project Configuration dialog, select samptext Win32 Debug
Configuration.
3. Open the Build menu and select Rebuild All to compile and link the DLL.
Building the resource library for C/C++ plug-ins: The resource DLL that contains
the translatable text strings and other locale-dependent resources for the plug-in is
included with the sample. This means that you do not have to create this DLL on
your own. Even if your plug-in supports only one language, your plug-in code
must load its text strings and locale-specific resources from this resource library.
Registering the ActiveX server DLL for C/C++ plug-ins: The SAMPDBG.REG file
in the MyProject directory contains registry keys that communicate the location of
the sample plug-in on your workstation to the Operations Navigator. If you
specified a directory other than c:\MyProject in “Preparing to build an ActiveX
server DLL for C/C++ plug-ins” on page 1031, complete the following steps.
1. Open the SAMPDBG.REG file in the Developer Studio (or use your chosen text
editor).
2. Replace all occurrences of ″c:\\MyProject\\″ with ″x:\\<dir>\\,″ where x is
the drive letter where your directory resides and <dir> is the name of the
directory.
3. Save the file.
4. In Windows Explorer, double-click the SAMPDBG.REG file. This will write the
entries in the registry file to the Windows registry on your machine.
Detail: In Windows NT, you must login with administrative privileges on your
workstation to write to the Windows registry.
What to do next:
Run Operations Navigator in the debugger
To create the new Developer Studio workspace, complete the following steps.
1. Create a new ActiveX server DLL
2. Add files to the project workspace
3. Create a new resource DLL
4. Create help files
Adding files to the project workspace: The source files from the sample plug-in
can be used as a base for the code in your new server DLL. Make sure that the
names of the copied files conform to the naming convention for files in your new
project.
You will copy certain source files and header files from the sample, based on the
type of function that you plan on providing in your new plug-in. To add files to
your workspace, complete the following steps.
1. Open the Insert menu and select Files Into Project...
2. Make a new copy of the files EXTINTFC.CPP and EXTINTFC.H and add them
to your new project workspace.
3. Edit the copy of EXTINTFC files. Replace all occurrences of the class name
CSampleExtInterfaces with a class name that incorporates the <component>
string you defined for your plug-in.
4. If your plug-in will add new folders to the Operations Navigator hierarchy,
make a new copy of the files SAMPDATA.CPP, SAMPLIB.CPP, SAMPLIB.H,
TBARINFO.CPP and TBARINFO.H. Add these files to your new project
workspace.
5. Edit the SAMPDATA files. Replace all occurrence of the class name
CSampleData with a class name that incorporates the name of one of your new
folders.
Detail: If your plug-in will not implement a custom toolbar, change the code in
the GetToolbarInfo method to return E_NOTIMPL.
6. If your plug-in will add property pages to a property sheet for a folder or
object, make a new copy of the files PAGEADV.CPP and PAGEGEN.CPP. Then,
add these files to your new project workspace.
7. Make a copy of the file PROPEXT.CPP and add it to your new project
workspace.
8. If your plug-in adds additional context menu items to the context menu for a
folder or object, make a new copy of the file DLGDLT.CPP and DLGDLT.H.
Then, add these files to your new workspace.
9. Open the File menu and select SaveAll to save the changes to the Developer
Studio project file.
Now you’re ready to create a new resource DLL.
Creating a new resource DLL: Associated with the server DLL for an Operations
Navigator plug-in is a resource DLL that contains translatable text strings and
locale-dependent resources for the plug-in. To create this DLL, complete the
following steps.
1. Follow the instructions in the Visual C++ online help for creating a new
resource DLL.
2. Edit the primary source file for your ActiveX server DLL. Change the name of
the resource DLL specified in the InitInstance method to match the name of
your new resource DLL.
Detail: This will temporarily carry forward the resources that are defined in
the resource DLL for the sample plug-in into your new resource DLL.
This ensures that the sample code that you are using as a base for your
plug-in will still work properly.
Finally, create the help files that will be associated with your new C++ plug-in.
Creating help files for C++ plug-ins: Help files that are associated with your
plug-in are built and tested using the support that is provided by Visual C++. No
special considerations apply, except to ensure that the name of your help file is
correctly specified in the InitInstance method for your ActiveX server DLL.
What to do next:
Customize the C++ plug-in
For more information specific to working with registry files in this context, see
“Registry files for Operations Navigator plug-ins” on page 983.
Creating a new registry file with a new ProgID for your C++ plug-in: The
registry file contains important information about your plug-in, including the
programmatic identifier (ProgID). For more information about registry files, see
“Registry files for Operations Navigator plug-ins” on page 983. For more
information about ProgID, “Programmatic identifier (ProgID)” on page 984.
To create a new registry file for your plug-in, complete the following steps.
1. Copy the SAMPRLS.REG, one of the sample registry files that is included with
the sample.
Detail: You need to copy and edit both registry files that are included in the
sample, SAMPDBG.REG and SAMPRLS.REG. Use SAMPDBG.REG as
you develop your plug-in. Use. SAMPRLS.REG for the retail version of
your plug-in.
2. Rename the SAMPRLS.REG file. Use the naming convention that you have
defined for your new plug-in.
3. Begin editing the registry file with your preferred utility. Change all instances
of ″IBM.Sample″ with your new <vendor>.<component> string (ProgID).
Generating a new GUID: For your Operations Navigator C++ plug-in to work
properly, you must replace specific CLSIDs in your new registry file with GUIDs
that you generate. See “Globally unique identifiers (GUIDs)” on page 984 for more
information about GUIDs, CLSIDs, and the registry file.
Registering a data server implementation: If your C++ plug-in adds a new folder
to the Operations Navigator hierarchy, edit the first section of the registry file. If
your plug-in does not add any new folders to the Operations Navigator hierarchy,
delete this section and proceed to the next task. You will see code similar to that in
the following example:
--------------------------------------------------------------------
; This section will register an IA4HierarchyFolder implementation for
; each new folder added to the Operations Navigator hierarchy. This
; section is not needed if your plug-in does not add any folders.
[HKEY_CLASSES_ROOT\CLSID\{D09970E1-9073-11d0-82BD-08005AA74F5C}]
@="AS/400 Data Server - Sample Data"
[HKEY_CLASSES_ROOT\CLSID\{D09970E1-9073-11d0-82BD-08005AA74F5C}\InprocServer32]
@="%CLIENTACCESS%\Plugins\IBM.Sample\sampext.dll"
"ThreadingModel"="Apartment"
1. Change the name of the DLL to match the name of the DLL that is generated
by your new project workspace.
2. Generate and copy a new GUID (see “Generating a new GUID”).
3. Replace both occurrences of the CLSID in this section of the registry with the
new GUID string you just generated.
Detail: If your plug-in will add more than one new folder to the hierarchy, you
must duplicate this section of the registry file for each additional folder.
Follow steps 1-3 for each separate section. Make sure to generate a
separate GUID for each folder.
4. Search for the string ″IMPLEMENT_OLECREATE″ in the file that you created
that was based on SAMPDATA.CPP (see “Adding files to the project
workspace” on page 1034). You will see code similar to that in the following
example:
/////////////////////////////////////////////////////////////////////////////
// Declare the CLSID for this data server subclass
// {D09970E1-9073-11d0-82BD-08005AA74F5C}
IMPLEMENT_OLECREATE(CSampleData, _T("AS/400 Data Server - Sample Data"),
0xd09970e1, 0x9073, 0x11d0, 0x82, 0xbd, 0x8, 0x0, 0x5a, 0xa7, 0x4f, 0x5c);
5. Paste the new GUID over the existing CLSID in the comment line, then change
the CLSID in the IMPLEMENT_OLECREATE macro call to match the hex
values in your new GUID. Replace the word ″Sample″ with the name of your
new folder.
Detail: The header file (.H) contains the class declaration for the new
implementation class. The implementation file (.CPP) contains the code
that obtains the data for the new folder.
7. Replace all occurrences of the class name ″CSampleData″ in the two source files
with a class name that is meaningful in the context of your plug-in.
8. To add the new implementation files to the project workspace, open the Insert
menu and select Files Into Project....
Detail: Because you are duplicating SAMPDATA.CPP in this way, all your new
folders will initially contain library objects.
What to do next:
Register the shell plug-in implementation
Registering the shell plug-in implementation: The next two sections of the
registry file that register the shell plug-in implementation must always be present.
To edit these sections, complete the following steps. You will see code similar to
that in the following example:
;--------------------------------------------------------------------
; This section will register the shell plug-in implementation class.
; A shell plug-in adds context menu items and/or property pages
; for new or existing objects in the hierarchy.
[HKEY_CLASSES_ROOT\CLSID\{3D7907A1-9080-11d0-82BD-08005AA74F5C}]
@="AS/400 Shell plug-ins - Sample"
[HKEY_CLASSES_ROOT\CLSID\{3D7907A1-9080-11d0-82BD-08005AA74F5C}\InprocServer32]
@="%CLIENTACCESS%\Plugins\IBM.Sample\sampext.dll"
"ThreadingModel"="Apartment"
;--------------------------------------------------------------------
; Approve shell plug-in (required under Windows NT)
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell plug-ins\Approved]
"{3D7907A1-9080-11d0-82BD-08005AA74F5C}"="AS/400 Shell plug-ins - Sample"
1. Change the DLL name to match the name of the DLL that was generated by
your new project workspace.
2. Generate and copy a new GUID (see “Generating a new GUID” on page 1036).
3. Replace all occurrences of the CLSID in the entries that are shown in the
example above with the new GUID you just generated.
4. Search for the string ″IMPLEMENT_OLECREATE″ in the file that you created
that was based on EXTINTFC.CPP (see “Adding files to the project workspace”
on page 1034). You will see code similar to that in the following example:
/////////////////////////////////////////////////////////////////////////////
// Declare the CLSID for the implementation class
// {3D7907A1-9080-11d0-82BD-08005AA74F5C}
IMPLEMENT_OLECREATE(CSampleExtInterfaces, _T("AS/400 Shell plug-ins - Sample"),
0x3d7907a1, 0x9080, 0x11d0, 0x82, 0xbd, 0x8, 0x0, 0x5a, 0xa7, 0x4f, 0x5c);
5. Paste the new GUID over the existing CLSID in the comment line, then change
the CLSID in the IMPLEMENT_OLECREATE macro call to match the hex
values in your new GUID.
What to do next:
Specify C++ plug-in information
Registering shell plug-ins for objects: The final section of the registry specifies
which objects in the Navigator hierarchy are affected by implementation of the
plug-in. To edit this section of the registry, complete the steps that follow. You will
see code that is similar to the following example:
;--------------------------------------------------------------------
; Register a context menu handler for the new folder and its objects
;--------------------------------------------------------------------
; Register a property sheet handler for the new folder and its objects
;--------------------------------------------------------------------
; Register the Auto Refresh property sheet handler for the new folder and its objects
; (this will allow your folder to take advantage of the Operations Navigator
; Auto Refresh function)
;------------------------------------------------------------------------------
; Register drag and drop context menu handlers
;------------------------------------------------------------------------------
; Register Drop Handler to accept drops of objects
;------------------------------------------------------------------------------
; Register that this plug-in supports Secure Socket Layer (SSL) Connection
; Note: "Support Level"=dword:00000001 says the plugin supports SSL
; Note: "Support Level"=dword:00000000 says the plugin does not support SSL
if (strObject == SMPTYPE_SAMPLELIBRARY)
{
(perform some action)
}
Details:
a. You should see the folders, context menu items, property pages, and drop
actions from the sample, depending on how much function from the sample
you decided to retain.
What to do next:
Construct property pages for a property sheet handler
Testing the C++ new plug-in: After finishing the previous tasks, you have
created project workspaces for your new ActiveX server DLL and an associated
resource DLL. You have also created a registry file that you can use to try out the
new plug-in.
To build the server DLL and resource DLL, complete the following steps.
1. In Developer Studio, open the Build menu and select Rebuild All fore each
DLL.
Detail: If a project does not rebuild cleanly, press F4 to display errors, then
make appropriate changes to the code. You may have to remove
INCLUDE statements for header files that you are not using.
2. In Windows Explorer, double-click your new registry file (the development
version) to register your new plug-in.
3. Run Operations Navigator.
4. If you do not see evidence of your new plug-in, check the Client Access
History Log for error messages. The online help for the messages will explain
how to correct any problems.
In general, the code that is packaged in a plug-in DLL is able to use any of the
services normally available to a Windows DLL. It may call any of the Windows
APIs. It may subclass the MFC library to implement any panels and dialogs
associated with the plug-in (subject to the restriction for property pages noted
above). It may call any of the Client Access APIs, including the special service APIs
that are implemented for use by Operations Navigator plug-ins. The comments in
the sample code provide additional information for use when you are developing
plug-ins.
You may wish to create functions and procedures that reside in one or more
additional code DLLs. These DLLs may be designated for installation on the client
workstation in any of several locations (refer the next section). Your plug-in DLL
may then call these functions as needed.
When creating additional code DLLs, you may experience difficulty the first time
you attempt to link to a new DLL from your plug-in DLL. When your new DLL is
not in the current directory or in a directory in the Windows search path, your
plug-in DLL will not be loaded, and the function of your plug-in will not appear
in the Navigator. This also occurs if your plug-in is attempting to link to an entry
point in the new DLL that is obsolete, or whose parameters have changed. In these
situations the History Log will contain an error message that includes a return
code from the LoadLibrary API in the form of an HRESULT. The online help lists
the common codes and their meaning, but the codes are not always reliable,
particularly on Windows NT. Therefore, before attempting to link to a new DLL,
make sure that the DLL is in the correct directory. Also make sure that you have
recompiled and relinked your plug-in DLL to minimize the likelihood of problems.
Note that ActiveX server DLLs are not automatically unloaded from memory when
the Operations Navigator window is closed. Instead, they are unloaded by the
operating system on a time-initiated basis. This creates a problem if you want to
rebuild your server DLL right away - the link step will fail because the previous
version of the DLL will be locked. To avoid this problem, you need to either restart
your workstation, or shut down the Windows shell.
If your plug-in implements a custom toolbar, then you must create a toolbar
resource in your resource DLL, and update the code file that you created based on
the sample file TBARINFO.CPP to correctly specify the toolbar buttons in the array
of Windows TBBUTTON structures.
Note: By default, the History Log is not active. To ensure that error messages are
written to this file, History logging must be started. See the Express User’s
Guide, which is shipped with Client Access Express, for information on
starting the History Log.
The entries in the History Log consist of messages with and without message IDs.
Messages with message IDs have online help available. Messages without message
IDs do not have online help available.
Displaying recovery information for error messages with IDs:
To display the cause and recovery information associated with a message
that has a message ID, double-click on it. View any message that has a
message ID by selecting the Message topic in the online Express User’s
Guide.
Client Access Express also has associated messages that are logged on the AS/400
system. These messages begin with PWS or IWS.
To display messages that are logged on the AS/400 system:
Type the appropriate command (displayed below) at the AS/400
command-line prompt, where xxxx is the number of the message:
DSPMSGD RANGE(IWSxxxx) MSGF(QIWS/QIWSMSG)
If the plug-in supports Windows policies, include the .adm policy template file for
the plug-in in the MRI29xx directory.
After the users have installed your new plug-in, you may choose either to upgrade
it at a later date, or to ship code problem fixes. When the code is upgraded on the
AS/400, the Client Access Check Version program will detect that this process has
occurred, and automatically download the updates to the users’ PCs. Client Access
also provides uninstall support, which allows users to completely remove the
plug-in from their PCs.
Users can display the plug-ins that are installed on their PCs by selecting the
Plug-ins tab on the Operations Navigator Properties for a particular AS/400.
cwbUN_GetParentFolderNameFromName
cwbUN_GetParentFolderPathFromName
cwbUN_GetParentFolderPidl
cwbUN_GetSystemNameFromName
cwbUN_GetSystemNameFromPidl
cwbUN_GetTypeFromItemId
cwbUN_GetTypeFromName
cwbUN_GetTypeFromPidl
Refresh the Operations Navigator window: cwbUN_RefreshAll
Following the completion of an operation on
cwbUN_RefreshList
behalf of the user, these APIs enable
execution of a request by the plug-in to cwbUN_RefreshListItems
refresh the tree and list views or to place a cwbUN_UpdateStatusBar
message in the Navigator status bar.
ODBC connections: These APIs allow the cwbUN_GetODBCConnection
plug-in developer to reuse and end the
cwbUN_EndODBCConnections
handle for an ODBC connection that already
has been obtained by the Database
component of the Operations Navigator.
Access Operations Navigator icons: These cwbUN_GetIconIndex
APIs allow the plug-in developer to access
cwbUN_GetSharedImageList
the icon image lists for objects that appear in
the Navigator object hierarchy.
Application Administration: These APIs cwbUN_GetAdminValue
allow the plug-in developer to
cwbUN_GetAdminValueEx
programmatically determine whether a user
is denied or allowed use of an cwbUN_GetAdminCacheState
Administrable function. An Administrable cwbUN_GetAdminCacheStateEx
function is any function whose use can be
controlled through the Application
Administration subcomponent of Operations
Navigator.
Install: This API allows the plug-in cwbUN_IsSubcomponentInstalled
developer to determine if an Operations
Navigator subcomponent is installed.
The connection is established through the Client Access LDAP client (LDAP.LIB
and LDAP.DLL), and only can be used with that client.
This API will attempt to establish bind using LDAP version 3, and then LDAP
version 2. Use the ldap_get_option LDAP client API to determine what version the
bind used if you need to use LDAP version 3 client APIs with the connection.
Syntax:
int cwbUN_BindToLdapServerA
( LPCSTR server,
int port,
int sslPort,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
int cwbUN_BindToLdapServerW
( LPCWSTR server,
int port,
int sslPort,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
Parameters:
LPCSTR system - input
NULL-terminated AS/400 system name or dotted IP address.
int port - input
The port to be used for standard connections. Specify 0 to force an SSL
connection.
int sslPort - input
The port to be used for SSL connections. Specify 0 if SSL connections are not
supported by the server.
cwbUN_LdapBindOption options - input
Specifies options controlling the display of error messages and the ″Connect to
Directory Server″ dialog. Possible values are:
CWBUN_LDAP_BINDOPT_NO_DLG
Do not show the ″Connect To Directory Server″ dialog and do not
display any error messages.
Usage: None
The connection is established through the Client Access LDAP client (LDAP.LIB
and LDAP.DLL), and only can be used with that client.
This API will attempt to establish bind using LDAP version 3, and then LDAP
version 2. Use the ldap_get_option LDAP client API to determine what version the
bind used if you need to use LDAP version 3 client APIs with the connection.
Syntax:
int cwbUN_BindToLdapServerOnAs400A
( LPCSTR system,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
int cwbUN_BindToLdapServerOnAs400W
( LPCWSTR system,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
Parameters:
LPCSTR system - input
NULL terminated AS/400 system name.
cwbUN_LdapBindOption options - input
Specifies options controlling the display of error messages and the ″Connect to
Directory Server″ dialog. Possible values are:
CWBUN_LDAP_BINDOPT_NO_DLG
Do not show the ″Connect To Directory Server″ dialog and do not
display any error messages.
CWBUN_LDAP_BINDOPT_DLG_ON_ERR
Show the ″Connect To Directory Server″ dialog and error messages.
The user has the opportunity to change bind information if an error
occurs.
CWBUN_LDAP_BINDOPT_SHOW_DLG
Show the ″Connect to Directory Server″ dialog before attempting to
connect to the server. The user has the opportunity to change bind
information before connecting to the server.
int version - input
Specifies the LDAP API version to use for binding to the server. Possible
values are:
Usage: None
Syntax:
Parameters:
const char * szAS400Name - input
The AS/400 name whose validity is to be checked.
const char * szSystemName - input
The name of the AS/400 system on which to perform the check.
USHORT usTypeId - input
A numeric value that indicates how the input string should be interpreted: as a
long object name, a short object name, a communications name, or a string
(type constants are defined above).
Usage: None
Syntax:
Parameters:
const char * szObjectPath - input
The AS/400 object path for which authority is to be checked.
const char * szObjectType - input
The AS/400 object type for the object for which authority is to be checked, for
example *DTAQ.
const char * szAuthorityType - input
The AS/400 object authority to be checked. Possible values are:
EXCLUDE
CHANGE
USE
AUTLMGT
OBJALTER
OBJOPR
OBJMGT
OBJEXIST
OBJREF
READ
ADD
UPD
DLT
EXECUTE
If more than one authority is to be checked, the authorities should be
concatenated (for example, *OBJMGT*OBJEXIST). Up to eleven authority types
may be specified on a single call. The function will return CWB_OK only if the
user has all of the specified authorities to the object.
const char * szSystemName - input
The name of the AS/400 system on which to perform the check.
Syntax:
Parameters:
const char * szSpecialAuthority - input
The AS/400 special authority to be checked. Possible values are:
*ALLOBJ
*AUDIT
*IOSYSCFG
*JOBCTL
*SAVSYS
*SECADM
*SERVICE
*SPLCTL
const char * szSystemName - input
The name of the AS/400 system on which to perform the check.
Usage: None
Syntax:
Parameters:
LPCITEMIDLIST pidl - input
Pointer to the ITEMIDLIST (item identifier list) structure that is to be
converted.
char * szObjectName - output
Address of the buffer that will receive the null-terminated object name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated object name.
Usage: None
Syntax:
CWBAPI unsigned int WINAPI cwbUN_EndODBCConnections(
);
Parameters: None
Also ensure that the destructor for the folder of your application extension invokes
the EndODBCConnections if any code in your extension uses
GetODBCConnection.
Syntax:
int cwbUN_FreeLdapBindInfo
( cwbUN_ldapBindInfoHandle handle
);
Parameters:
cwbUN_ldapBindInfoHandle handle - input
The handle for which resources should be freed.
Syntax:
int cwbUN_FreeLdapPublishing
( cwbUN_ldapPubHandle handle
);
Parameters:
cwbUN_ldapPubHandle handle - input
The handle for which resources should be freed.
Syntax:
int cwbUN_FreeLocalLdapServer
( cwbUN_ldapSvrHandle handle
);
Parameters:
cwbUN_ldapSvrHandle handle - input
The handle for which resources should be freed.
Syntax:
Parameters:
const char * szSystemName
The name of the AS/400 system on which to perform the check.
cwbUN_State& adminState
Indicates if the next invocation of the cwbUN_GetAdminValue API will be
long running or if it will use its internal cache to return without accessing the
host AS/400.
Syntax:
Parameters:
cwbCO_SysHandle* pSysHandle - input
A pointer to a system object handle. The system name must be specified in the
system object prior to calling this API.
cwbUN_State& adminState
Indicates if the next invocation of the cwbUN_GetAdminValue API will be
long running or if it will use its internal cache to return without accessing the
host AS/400.
Syntax:
Parameters:
const char * szSystemName
The name of the AS/400 system on which to perform the check.
char* adminFunction
A pointer to an ASCII string that contains the name of the Administrable
function. The string must be null terminated and has a maximum length of 30
bytes + 1 byte for the NULL terminator. See cwbunpla.h for a list of supported
input values.
cwbUN_Usage & usageValue
This value is only valid if the return code of CWB_OK is returned. One of two
values will be returned:
v cwbUN_granted — User is allowed use of the function.
v cwbUN_denied — user is denied use of the function.
Usage: This API determines if the current Operations Navigator user for the
specified AS/400 is allowed to use the specified function. If no user is currently
signed on to the specified AS/400, the API will sign the user on, possibly
displaying a user ID and password prompt.
This API can only be used to check Administrable functions that are in the AS/400
Operations Navigator or the Client Applications function category.
Syntax:
Parameters:
cwbCO_SysHandle* pSysHandle
A pointer to a system object handle. The system name must be specified in the
system object prior to calling this API. The cwbUN_GetAdminValueEx API’s
behavior is based on whether the system object has obtained a signon to the
AS/400:
Not Signed On->
cwbUN_GetAdminValueEx will signon to the AS/400. The latest
Application Administration settings for the user will be downloaded
from the AS/400 if they are not already cached on the client PC.
Signed On->
If the system object was signed on to the AS/400 specifying that the
AS/400 userID and password should be validated (Validate Mode),
then the cwbUN_GetAdminValueEx API will be using a snapshot of
AS/400’s Application Administration settings that were accurate at the
time the signon was completed. If the signon was done without
validating the userID and password, then it is possible that
cwbUN_GetAdminValueEx will use a copy of the AS/400’s Application
Administration settings that may be as much as 24 hours old.
char* adminFunction
A pointer to an ASCII string that contains the name of the Administrable
function. The string must be null terminated and has a maximum length of 30
bytes + 1 byte for the NULL terminator. See CWBUNPLA.H for a list of
supported input values.
Usage: This API determines if the current AS/400 user (as defined by the input
system object) is allowed to use the specified function. If no user is currently
signed on to the specified AS/400, the API will sign the user on, possibly
displaying a user ID and password prompt.
This API can only be used to check Administrable functions that are in the AS/400
Operations Navigator or the Client Applications function category.
Syntax:
Parameters:
const char * szItemId - input
The Unity item identifier from which the item name will be extracted.
char * szItemName - output
Address of the buffer that will receive the null-terminated item name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated item name.
Usage: None
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the item name will be extracted.
char * szItemName - output
Address of the buffer that will receive the null-terminated item name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated item name.
Usage: None
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the pathname will be derived.
char * szPathName - output
Address of the buffer that will receive the null-terminated pathname.
UINT cchMax - input
Size of the buffer that will receive the null-terminated pathname.
Usage: None
Syntax:
Parameters:
LPCITEMIDLIST pidl - input
Pointer to the ITEMIDLIST (item identifier list) structure that is used to
identify the icon to be referenced.
UINT uFlags - input
Specification of the type of icon index to retrieve (defined above). The
following flag types are allowed:
GII_ICON
GII_SMALLICON
GII_OPENICON
int * piIndex - output
Address of the integer that will receive the icon index.
Usage: None
Syntax:
Parameters:
const char * szItemId - input
The Unity item identifier from which the item index will be extracted.
ULONG* piIndex - output
Address of an unsigned long integer that will receive the item index.
Usage: None
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the item index will be extracted.
ULONG* piIndex - output
Address of an unsigned long integer that will receive the item index.
Usage: None
Syntax:
Parameters:
LPCITEMIDLIST pidl - input
Pointer to an ITEMIDLIST (item identifier list) structure from which the item
index will be extracted.
ULONG* piIndex - output
Address of an unsigned long integer that will receive the item index.
Usage: None
Syntax:
int cwbUN_GetLdapPublishCount
( cwbUN_ldapPubHandle handle,
int *count
);
Parameters:
cwbUN_ldapPubHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLdapPublishing().
int * count - output
The number of publish records configured on the AS/400.
Usage: None
Syntax:
int cwbUN_GetLdapPublishParentDnW
( cwbUN_ldapPubHandle handle,
int index,
LPWSTR parentDn,
int *length
);
int cwbUN_GetLdapPublishParentDnA
( cwbUN_ldapPubHandle handle,
int index,
LPSTR parentDn,
int *length
);
Parameters:
cwbUN_ldapPubHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLdapPublishing().
int index - input
Zero-based index of the publish record. This value must be less than the count
returned by cwbUN_GetLdapPublishCount().
LPSTR parentDn - output
Pointer to the buffer that will contain the name of the parentDn.
int * length - input/output
Pointer to the length of the parentDn buffer. If the buffer is too small to hold
the string, including space for the terminating NULL, the size of the buffer
needed will be filled into this parameter.
Syntax:
int cwbUN_GetLdapPublishPort
( cwbUN_ldapPubHandle handle,
int index,
int *port,
cwbUN_LdapCnnSecurity *connectionSecurity
);
Parameters:
cwbUN_ldapPubHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLdapPublishing().
int index - input
Zero-based index of the publish record. This value must be less than the count
returned by cwbUN_GetLdapPublishCount().
int * port - output
The port number used to connect to the server.
cwbUN_LdapCnnSecurity * connectionSecurity - output
The type of connection used to connect to the server. This indicates the type of
connection that can be established over the associated port. Possible values
include:
CWBUN_LDAPCNN_NORMAL
A normal connection is used.
CWBUN_LDAPCNN_SSL
An SSL connection is used.
Usage: None
Syntax:
int cwbUN_GetLdapPublishServerW
( cwbUN_ldapPubHandle handle,
int index,
LPWSTR server,
int *length
);
int cwbUN_GetLdapPublishServerA
( cwbUN_ldapPubHandle handle,
int index,
LPSTR server,
int *length
);
Parameters:
cwbUN_ldapPubHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLdapPublishing().
int index - input
Zero-based index of the publish record. This value must be less than the count
returned by cwbUN_GetLdapPublishCount().
LPSTR server - output
Pointer to the buffer that will contain the name of the server.
int * length - input/output
Pointer to the length of the server buffer. If the buffer is too small to hold the
string, including space for the terminating NULL, the size of the buffer needed
will be filled into this parameter.
Usage: None
Syntax:
int cwbUN_GetLdapPublishType
( cwbUN_ldapPubHandle handle,
int index,
cwbUN_LdapPubCategories *information
);
Parameters:
cwbUN_ldapPubHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLdapPublishing().
int index - input
Zero-based index of the publish record. This value must be less than the count
returned by cwbUN_GetLdapPublishCount().
cwbUN_LdapPubCategories * information - output
The type of information for which this publish record is. Possible values
include:
CWBUN_LDAP_PUBLISH_USERS
User information
CWBUN_LDAP_PUBLISH_COMPUTERS
AS/400 systems
CWBUN_LDAP_PUBLISH_NETWORK_INVENTORY
NetFinity
CWBUN_LDAP_PUBLISH_PRINTERS
AS/400 printers
Usage: None
Syntax:
int cwbUN_GetLdapServerBindDnA
( cwbUN_ldapBindInfoHandle handle,
LPSTR bindDn,
int *length
);
int cwbUN_GetLdapServerBindDnW
( cwbUN_ldapBindInfoHandle handle,
LPWSTR bindDn,
int *length
);
Parameters:
cwbUN_ldapBindInfoHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLdapBindInfo().
LPSTR bindDn - output
Pointer to the buffer that will contain the distinguished name used by
Operations Navigator to bind to the server.
int * length - input/output
Pointer to the length of the bindDn buffer. If the buffer is too small to hold the
string, including space for the terminating NULL, the size of the buffer needed
will be filled into this parameter.
Usage: None
Syntax:
int cwbUN_GetLdapSvrPort
( cwbUN_ldapSvrHandle handle,
int *port,
int *sslPort
);
Parameters:
cwbUN_ldapSvrHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLocalLdapServer().
int * port - output
The port number used for LDAP connections.
int * sslPort - output
The port number used for SSL connections.
Usage: None
Syntax:
int cwbUN_GetLdapSvrSuffixCount
( cwbUN_ldapSvrHandle handle,
int *count
);
Parameters:
cwbUN_ldapSvrHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLocalLdapServer().
int * count - output
The number of suffixes present on the server.
Usage: None
Syntax:
int cwbUN_GetLdapSuffixNameA
( cwbUN_ldapSvrHandle handle,
int index,
LPSTR suffix,
int *length
);
int cwbUN_GetLdapSuffixNameW
( cwbUN_ldapSvrHandle handle,
int index,
LPWSTR suffix,
int *length
);
Parameters:
cwbUN_ldapSuffixHandle handle - input
A handle previously obtained by a call to cwbUN_OpenLocalLdapServer().
int index - input
Zero-based index of the suffix. This value must be less than the count returned
by cwbUN_GetLdapSvrSuffixCount().
LPSTR suffix - output
Pointer to the buffer that will contain the distinguished name of the suffix.
int * length - input/output
Pointer to the length of the suffix buffer. If the buffer is too small to hold the
string, including space for the terminating NULL, the size of the buffer needed
will be filled into this parameter.
Usage: None
Syntax:
Parameters:
const char * szFileName - input
The Unity object name from which the object pointer will be found and
returned.
LPVOID pListObject - output
Address of a pointer to the request Unity object.
Usage: None
Syntax:
Parameters:
const char * szSystemName - input
The name of the AS/400 system on which to retrieve an ODBC connection.
HDBC *phDBC - output
Address to return the ODBC connection handle.
Usage: None
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the parent folder name will be extracted.
char * szParentFolderPath - output
Address of the buffer that will receive the null-terminated parent folder name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated parent folder name.
Usage: None
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the parent folder object name will be
extracted.
char * szParentFolderPath - output
Address of the buffer that will receive the null-terminated parent folder object
name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated parent folder object
name.
Usage: None
Syntax:
Parameters:
LPCITEMIDLIST pidl - input
Pointer to an ITEMIDLIST (item identifier list) structure from which the parent
folder item identifier list will be extracted.
LPITEMIDLIST* ppidl - output
Address of an item identifier list pointer that will receive the parent folder
item identifier list.
Usage: None
Syntax:
Parameters:
const char * pszProgID - input
The programmatic identifier which uniquely identifies an Operations
Navigator plug-in. It should be of the form <vendor><component>.
char * pszLibraryPath - output
Address of the buffer that will receive the fully-qualified pathname of the NLS
directory.
UINT cchMax - input
Size of the buffer that will receive the fully-qualified pathname of the NLS
directory.
Usage: None
Syntax:
Parameters:
UINT uFlags - input
Specification of the type of image list to retrieve (defined above) The following
flag types are allowed:
GSIL_ICON
GSIL_SMALLICON
HIMAGELIST* phImageList -
Address of the variable that will receive the image list handle.
Usage: None
If the application name is set to NULL, the returned system handle will be unique.
If the application name is set, the same system handle that matches the application
name will be returned.
If an application requires to share an AS/400 job, then all callers of this function
should pass in the same application name.
Syntax:
Parameters:
char * szSystemName - input
Pointer to an ASCIIZ string that contains the name of the system for which
you want a system handle to be created.
char * szAppName - input
Pointer to an ASCIIZ string of no more than 12 characters. This uniquely
identifies the application that will share a single system handle.
cwbCO_SysHandle * systemHandle - output
Pointer to the handle of the system for this system name.
Usage: This function must be used by all third-party applications that want to
support SSL using the Client Access APIs. For example, all Client Access
communications APIs require a system handle to support SSL.
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the system name will be extracted.
char * szSystemName - output
Address of the buffer that will receive the null-terminated system name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated system name.
Usage: None
Syntax:
Parameters:
LPCITEMIDLIST pidl - input
Pointer to an ITEMIDLIST (item identifier list) structure from which the system
name will be extracted.
char * szSystemName - output
Address of the buffer that will receive the null-terminated system name.
UINT cchMax - input
Size of the buffer that will receive the null-terminated system name.
Usage: None
Syntax:
Parameters:
const char * szSystemValueId - input
A numeric value that identifies the AS/400 system value to be retrieved.
Definitions for the system value constants are in the header file
’CWBA4SVL.H’
char * szSystemValue - output
Address of the buffer that will receive the null-terminated system value string.
UINT cchMax - input
Size of the buffer that will receive the null-terminated value string.
Usage: The value that is returned by this API is not a National Language Support
(NLS) string and is not translated. For example, ’*NONE’ will be returned instead
of ’None.’
Syntax:
Parameters:
const char * szItemId - input
The Unity item identifier from which the item type will be extracted.
char * szType - output
Address of the buffer that will receive the null-terminated item type.
UINT cchMax - input
Size of the buffer that will receive the null-terminated item type.
Usage: None
Syntax:
Parameters:
const char * szObjectName - input
The Unity object name from which the item index will be extracted.
char * szType - output
Address of the buffer that will receive the null-terminated item type.
UINT cchMax - input
Size of the buffer that will receive the null-terminated item type.
Usage: None
Syntax:
Parameters:
LPCITEMIDLIST pidl - input
Pointer to an ITEMIDLIST (item identifier list) structure from which the item
index will be extracted.
char * szType - output
Address of the buffer that will receive the null-terminated item type.
UINT cchMax - input
Size of the buffer that will receive the null-terminated item type.
Usage: None
Syntax:
Parameters:
USHORT usAttributeId - input
A numeric value which identifies the user attribute value to be retrieved.
Definitions for the user attribute constants are in the header file
’CWBA4USR.H.’
const char * szSystemName - input
The name of the AS/400 system from which to retrieve the user attribute.
char * szValue - output
Address of the buffer that will receive the null-terminated attribute value
string.
UINT cchMax - input
Size of the buffer that will receive the null-terminated value string.
Usage: The value that is returned by this API is not an NLS string and is not
translated. For example, ’*NONE’ will be returned instead of ’None.’
Syntax:
Parameters:
const char * szSystemName - input
The name of the AS/400 system which will be checked to determine if a
TCP/IP connection is being used.
Usage: None
Syntax:
Parameters:
UNIT uOption
Specifies the Operations Navigator subcomponent to check. See the API’s
prolog in cwbun.h for a list of supported values.
Usage: None.
The connection is established through the Client Access LDAP client (LDAP.LIB
and LDAP.DLL), and only can be used with that client.
This API will attempt to establish bind using LDAP version 3, and then LDAP
version 2. Use the ldap_get_option LDAP client API to determine what version the
bind used if you need to use LDAP version 3 client APIs with the connection.
Syntax:
int cwbUN_NullBindToLdapServerA
( LPCSTR server,
int port,
int sslPort,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
int cwbUN_NullBindToLdapServerW
( LPCWSTR server,
int port,
int sslPort,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
Parameters:
LPCSTR server - input
NULL terminated name of directory server or dotted IP address.
int port - input
The port to be used for standard connections. Specify 0 to force an SSL
connection.
int sslPort - input
The port to be used for SSL connections. Specify 0 if SSL connections are not
supported by the server.
cwbUN_LdapBindOption options - input
Specifies options controlling the display of error messages and the ″Connect to
Directory Server″ dialog. Possible values are:
CWBUN_LDAP_BINDOPT_NO_DLG
Do not show the ″Connect To Directory Server″ dialog and do not
display any error messages.
CWBUN_LDAP_BINDOPT_DLG_ON_ERR
Show the ″Connect To Directory Server″ dialog and error messages.
The user has the opportunity to change bind information if an error
occurs.
Usage: None
The connection is established through the Client Access LDAP client (LDAP.LIB
and LDAP.DLL), and only can be used with that client.
This API will attempt to establish bind using LDAP version 3, and then LDAP
version 2. Use the ldap_get_option LDAP client API to determine what version the
bind used if you need to use LDAP version 3 client APIs with the connection.
Syntax:
int cwbUN_NullBindToLdapServerOnAs400A
( LPCSTR system,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
int cwbUN_NullBindToLdapServerOnAs400W
( LPCWSTR system,
cwbUN_LdapBindOption options,
int version,
HWND hwnd,
void **LPldap
);
Parameters:
LPCSTR system - input
NULL terminated AS/400 system name.
int port - input
The port to be used for standard connections. Specify 0 to force an SSL
connection.
int sslPort - input
The port to be used for SSL connections. Specify 0 if SSL connections are not
supported by the server.
cwbUN_LdapBindOption options - input
Specifies options controlling the display of error messages and the ″Connect to
Directory Server″ dialog. Possible values are:
CWBUN_LDAP_BINDOPT_NO_DLG
Do not show the ″Connect To Directory Server″ dialog and do not
display any error messages.
CWBUN_LDAP_BINDOPT_DLG_ON_ERR
Show the ″Connect To Directory Server″ dialog and error messages.
The user has the opportunity to change bind information if an error
occurs.
CWBUN_LDAP_BINDOPT_SHOW_DLG
Show the ″Connect to Directory Server″ dialog before attempting to
connect to the server. The user has the opportunity to change bind
information before connecting to the server.
Usage: None
Syntax:
int cwbUN_OpenLdapBindInfoW
( LPCWSTR server,
cwbUN_ldapBindInfoHandle *pHandle
);
int cwbUN_OpenLdapBindInfoA
( LPCSTR server,
cwbUN_ldapBindInfoHandle *pHandle
);
Parameters:
LPCSTR server - input
Pointer to LDAP server name or IP address.
cwbUN_ldapBindInfoHandle *pHandle - output
On return, contains a handle that can be used with the following APIs:
v cwbUN_FreeLdapBindInfo
v cwbUN_GetLdapServerBindDn
Usage: None
Syntax:
int cwbUN_OpenLdapPublishingW
( LPCWSTR system,
cwbUN_ldapPubHandle *pHandle
);
int cwbUN_OpenLdapPublishingA
( LPCSTR system,
cwbUN_ldapPubHandle *pHandle
);
Parameters:
LPCSTR system - input
Pointer to AS/400 system name.
cwbUN_ldapSvrHandle *pHandle - output
On return, contains a handle that can be used with the following APIs:
cwbUN_FreeLdapPublishing
cwbUN_GetLdapPublishCount
cwbUN_GetLdapPublishType
cwbUN_GetLdapPublishParentDn
cwbUN_GetLdapPublishServer
cwbUN_GetLdapPublishPort
Usage: None
Syntax:
int cwbUN_OpenLocalLdapServerW
( LPCWSTR system,
cwbUN_ldapSvrHandle *pHandle
);
int cwbUN_OpenLocalLdapServerA
( LPCSTR system,
cwbUN_ldapSvrHandle *pHandle
);
Parameters:
LPCSTR system - input
Pointer to AS/400 system name.
cwbUN_ldapSvrHandle *pHandle - output
On return, contains a handle that can be used with the following APIs:
v cwbUN_FreeLocalLdapServer
v cwbUN_GetLdapSvrPort
v cwbUN_GetLdapSvrSuffixCount
v cwbUN_GetLdapSuffixName
Usage: None
Syntax:
Parameters:
const char * pszStatusText - input
A null-terminated string to be placed in the status bar window on completion.
This parameter may be NULL.
Usage: Use this function to refresh the entire contents of the Operations Navigator
after performing an action that is requested by the user.
Syntax:
Parameters:
const char * pszStatusText - input
A null-terminated string to be placed in the status bar window on completion.
This parameter may be NULL.
Usage: Use this function to refresh the contents of the list window after
performing an action that is requested by the user.
Syntax:
Parameters:
const char * pszStatusText - input
A null-terminated string to be placed in the status bar window on completion.
This parameter may be NULL.
Usage: Use this function to refresh the selected items in the list window after
performing an action that was requested by the user.
If the caller of this function has the last reference to the handle, the handle
resources actually will be destroyed.
Syntax:
Parameters:
cwbCO_SysHandle * systemHandle - input
Pointer to the handle of the system that was obtained on a
cwbUN_GetSystemHandle call.
Usage: When the caller of this function no longer needs the system handle for
communications, the handle can be released.
Syntax:
Parameters:
const char * pszStatusText - input
A null-terminated string to be placed in the status bar window on completion.
Usage: Use this function to inform the user that an action that was requested by
clicking the OK button on a dialog has completed successfully.
6050 CWBUN_NAME_TOO_LONG
Name is too long.
6051 CWBUN_NAME_NULLSTRING
String in empty - no chars at all.
6054 CWBUN_NAME_INVALIDCHAR
Invalid character.
6101 CWBUN_LDAP_NOT_AVAIL
LDAP is not installed or configured.
6102 CWBUN_LDAP_BIND_FAILED
LDAP bind failed.
The following return codes are for check AS/400 name APIs.
1001 CWBUN_NULLSTRING
String is empty.
1004 CWBUN_INVALIDCHAR
Invalid character.
1005 CWBUN_STRINGTOOLONG
String is too long.
1006 CWBUN_MISSINGENDQUOTE
End quote for quoted string missing.
1007 CWBUN_INVALIDQUOTECHAR
Character invalid for quoted string.
1008 CWBUN_ONLYBLANKS
String contains only blanks.
1009 CWBUN_STRINGTOOSHORT
String is less than the defined minimum.
1011 CWBUN_TOOLONGFORIBM
String is OK, but too long for IBM commands.
1012 CWBUN_INVALIDFIRSTCHAR
First character is invalid.
1999 CWBUN_GENERALFAILURE
Unspecified error.
Java plug-ins
To create Operations Navigator plug-ins in Java, you must create one or more Java
classes that implement certain predefined interfaces. The class files and any
associated strings and graphics resources are then packaged into one or more Java
Archive (JAR) files for distribution to Operations Navigator users. When
Operations Navigator detects that one or more Java plug-ins are installed, the IBM
Win32 Java virtual machine is loaded into the Navigator’s process space. Running
Java code in Operations Navigator is similar to running Java code in a Web
browser; the plug-in may be thought of as an Operations Navigator applet. For
V4R5, Java plug-ins must be written to run on version 1.1.8 of the Java virtual
machine, using version 1.1.1 of the Swing classes.
Note: If you are running Java over SSL, and creating your own CA certificate,
Client Access GA service pack is required.
SSL versions: AS/400 Toolbox for Java does not contain the algorithms needed to
encrypt and decrypt data. These algorithms are shipped with AS/400 licensed
programs 5769-CE1, 5769-CE2, and 5769-CE3. You need to order one of the
5769-CEx product versions of SSL depending on the country in which you live.
Contact your IBM representative for more information, or to order:
v AS/400 Client Encryption (40-bit), 5769-CE1, is used in France.
v AS/400 Client Encryption (56-bit), 5769-CE2, is used in countries other than the
US, Canada or France.
Note: 5769-CE2 client encryption is only 40-bit within AS/400 Toolbox for Java.
v AS/400 Client Encryption (128-bit), 5769-CE3, is used only in the United States
and Canada.
SSL considerations for AS/400 Operations Navigator Java plug-ins: Before you
use SSL with an AS/400 Operations Navigator Java plug-in, you should take into
consideration the following:
v You must understand your legal responsibilities. IBM AS/400 Client Encryption
products provide SSL Version 3.0 encryption support using non-exportable
128-bit (designated US and Canada use only) and exportable 40-bit encryption
algorithms for international use.
v In customer configurations where client encryption products might be
downloaded across national boundaries, the customer is responsible to assure
that the non-exportable client encryption products are not made available
outside the US and Canada. Both the non-exportable and exportable Client
Encryption products can be used in combination to allow the appropriate Client
Encryption product to be downloaded based on different URLs.
v You must install a Cryptographic Access Provider licensed program (5769-AC1,
5769-AC2, or 5769-AC3). The 5769-CE products provide encryption capabilities
on the client side. You also need encryption on the AS/400 side, which is
provided by the 5769-AC products. Contact your IBM representative for more
information.
v If you are creating your own CA certificate, Client Access GA service pack is
required.
Using SSL: To use SSL, the AS/400 Java Toolbox and the Secure Sockets Layer
(SSL) components must be selected during installation of AS/400 Client Access
Express for Windows.
If you are using certificates issued by a trusted authority, you need to perform the
following steps:
1. Install the certificate authority certificate on the AS/400.
2. Apply the certificate to your host servers.
Afterward, the certificate keyring is set up for you, the connection is secure, and
SSL is working for you. When you choose to use a trusted certificate authority,
there are no further steps required on the client.
AS/400 Toolbox for Java supports certificates that are issued by the following
trusted authorities:
v VeriSign, Inc
v Integrion Financial Network
v IBM World Registry
v Thawte Consulting
v RSA Data Security, Inc.
If you choose not to use a certificate from a trusted authority, you can build your
own certificate. Benefits of building your own certificate include:
v You do not have to pay for it.
v You have more control over it.
v You are putting together a local intranet of systems.
Note: Client Access GA service pack is required to build your own CA certificate.
When you choose to create your own SSL certificates, there are several steps
required to set them up for use with Java plug-ins:
1. Create a file called makekey.bat. This file simplifies the creation and
installation of the AS/400 SSL keys that are needed to run by using secure
sockets:
@echo off
if %1.==. goto error
REM Make sure that the next two lines point at the AS/400 Client Access Express for Windows Classes directory:
C:
cd "\Program Files\IBM\Client Access\Classes"
set port=9476
if not %2.==. set port=%2
mkdir com
mkdir com\ibm
mkdir com\ibm\as400
mkdir com\ibm\as400\access
echo Password is: toolbox
..\jre\bin\jre -nojit -classpath
..\jre\lib\rt.jar;..\jt400\lib\jt400.jar;..\jt400\lib\SSLTools.zip;..\jt400\lib\sslightu.zip;
..\jt400\lib\sslightx.zip; com.ibm.sslight.nlstools.keyrng com.ibm.as400.access.KeyRing connect %1:%port%
goto end
:error
echo usage: makekey system [port]
:end
2. Run this program, and provide the name of the AS/400 system to which you
will connect by using SSL. If your system administrator has set up SSL on a
port other than 9476, provide that port number as the second parameter.
The certificate that you need to copy from the AS/400 system to the client is
the Certificate Authority (CA) certificate, NOT a site certificate.
Note: If you will be using certificates provided by a trusted authority and SSL
certificates that you build yourself, it will be necessary to extract the
com.ibm.as400.access.KeyRing.class file from jt400.jar file and place it in
the c:\Program Files\IBM\Client
Access\Classes\com\ibm\as400\access subdirectory before you run the
makekey program.
makekey systemname portnumber
The password required by the makekey program is: toolbox.
makekey systemname
Password is: toolbox
Password for com.ibm.as400.access.KeyRing.class: toolbox
Connecting to systemname: 9,476
CA Certificate - Number 1
------------------------------------------------------------------------------
3. Remember that you will need to run makekey for every AS/400 system that
you will run by using SSL. After a connection to the AS/400 system has been
configured by using AS/400 Operations Navigator, it is necessary to specify
SSL as the connection method:
a. Right-click on the AS/400 system name in AS/400 Operations Navigator,
and select Properties.
b. Select the Connections tab.
c. In the Security box, select Use Secure Sockets Layer (SSL). (insert AS/400
properties dialog, viewed by right-clicking on a configured AS/400 system)
d. Press OK to continue.
e. Restart AS/400 Operations Navigator to enable the SSL connection to the
AS/400 system.
For Java plug-ins, Operations Navigator provides a built-in ActiveX server that
manages the communication between the Navigator and the plug-in’s Java classes.
The server component uses the Java Native Interface (JNI) API to create the
plug-in’s objects and to call their methods. Thus, Java programmers who are
developing Operations Navigator plug-ins do not need to be concerned with the
details of ActiveX server implementation.
When a user is interacting with Operations Navigator Java plug-ins, calls will be
generated to the different registered Java interface classes for the implementation
of the specific request.
Plug-ins work by responding to method calls from Operations Navigator that are
generated in response to user actions. For example, when a user right-clicks on an
object in the Navigator hierarchy, the Navigator constructs a context menu for the
object, and displays the menu on the screen. The Navigator obtains the menu items
by calling each plug-in that has registered its intent to supply context menu items
for the selected object type.
The functions that are implemented by a plug-in logically are grouped into
″interfaces.″ An interface is a set of logically related methods on a class that
Operations Navigator can call to perform a specific function. For Java plug-ins, the
following three Java interfaces are defined:
v ListManager
v ActionsManager
The plug-in receives this information as a list of fully-qualified object names. For
Java plug-ins, an ObjectName class is defined that provides information about the
selected objects.
Plug-ins that add folders to the object hierarchy must return items in the folder to
Operations Navigator in the form of ″item identifiers.″ For Java plug-ins, an
ItemIdentifier class is defined that is used by the plug-in to return the requested
information.
Access Express Toolkit - Operations Navigator Plug-ins Web page . The sample
includes detailed set-up instructions and documentation.
What to do next:
Customize your new Java plug-in.
Note: You can copy sections of the Operations Navigator sample Java plug-in to
use as a base for your new plug-in.
What to do next:
Diagnose any Java plug-ins errors.
Note: By default, the History Log is not active. To ensure that error messages are
written to this file, History logging must be started. See the Express User’s
Guide, which is shipped with Client Access Express, for information on
starting the History Log.
Client Access Express also has associated messages that are logged on the AS/400
system. These messages begin with PWS or IWS.
To display messages that are logged on the AS/400 system:
Type the appropriate command (displayed below) at the AS/400
command-line prompt, where xxxx is the number of the message:
DSPMSGD RANGE(IWSxxxx) MSGF(QIWS/QIWSMSG)
If the plug-in supports Windows policies, include the .adm policy template file for
the plug-in in the MRI29xx directory.
After the users have installed your new plug-in, you may choose either to upgrade
it at a later date, or to ship code problem fixes. When the code is upgraded on the
AS/400, the Client Access Check Version program detects that this process has
occurred, and automatically downloads the updates to the users’ PCs. Client
Access also provides uninstall support, which allows users to completely remove
the plug-in from their PCs.
Users can display the plug-ins that are installed on their PCs by selecting the
Plug-ins tab on the Operations Navigator Properties for a particular AS/400.
Plug-ins work by responding to method calls from Operations Navigator that are
generated in response to user actions. For example, when a user right-clicks on an
object in the Navigator hierarchy, Navigator constructs a context menu for the
object and displays the menu on the screen. Navigator obtains the menu items by
calling each plug-in that has registered its intent to supply context menu items for
the selected object type.
The functions that are implemented by a plug-in are logically grouped into
interfaces. An interface is a set of logically related methods on a class that
Operations Navigator can call to perform a specific function. For Visual Basic
plug-ins, three interfaces are defined:
v ListManager
v ActionsManager
v DropTargetManager
The Client Access Express Toolkit contains a link to the Visual Basic interface
definition help file. See “Accessing the Visual Basic interface definition help file”
for instructions.
Accessing the Visual Basic interface definition help file: The Client Access
Express Toolkit contains a link to the Visual Basic interface definition help file. To
access this file, do the following:
1. Make sure that the Client Access Express Toolkit is installed on your PC. If it is
not, see “Installing the Express Toolkit” on page 10 for instructions.
2. Launch the Express Toolkit. See “Launching the Express Toolkit” on page 10 for
instructions.
3. Select the AS/400 Operations topic.
4. Select the Operations Navigator Plug-ins topic.
5. Select Visual Basic.
6. Under the Interface definition topic, select cwbunvbi.hlp to open the interface
description help file.
For detailed descriptions of this class and its methods, see the online help
provided with the Operations Navigator Visual Basic Plug-in Support DLL
(cwbunvbi.dll and cwbunvbi.hlp).
For detailed descriptions of this class and its methods, see the online help
provided with the Operations Navigator Visual Basic Plug-in Support DLL
(cwbunvbi.dll and cwbunvbi.hlp files).
For detailed descriptions of this class and its methods, see the online help
provided with the Operations Navigator Visual Basic Plug-in Support DLL
(cwbunvbi.dll and cwbunvbi.hlp).
The plug-in receives this information as a list of fully-qualified object names. For
Visual Basic plug-ins, an ObjectName class is defined that provides information
about the selected objects.
Plug-ins that add folders to the object hierarchy must return items in the folder to
Operations Navigator in the form of ″item identifiers.″ For Visual Basic plug-ins,
an ItemIdentifier class is defined that is used by the plug-in to return the requested
information.
See “Operations Navigator Visual Basic interfaces” on page 1123 for more
information.
Detail: A Visual Basic plug-in also can use the C++ APIs in the cwbun.h header
file to achieve similar results.
For detailed descriptions of this class and its methods, see the online help that is
provided with the Operations Navigator Visual Basic Plug-in Support DLL
(cwbunvbi.dll and cwbunvbi.hlp).
Plug-ins .
Details:
1. Visual Basic plug-ins must be created using Microsoft Visual Basic 5.0.
2. All Visual Basic plug-ins require a small Windows resource DLL that contains
certain information about your plug-in. This allows Operations Navigator to
represent your function in the Navigator object hierarchy without having to
load your plug-in’s implementation. The sample’s resource DLL was created by
using Microsoft’s Visual C++ version 4.2, but any C compiler that supports
compiling and linking Windows resources may be used.
3. For third-party Visual Basic plug-ins to be available to Operations Navigator
users, they must have Version 4 Release 4 Modification Level 0 or later of
Client Access Express for Windows installed on their personal computers.
4. The Client Access Express Toolkit contains the binaries and help files that are
needed to build a Visual Basic plug-in. The Toolkit component is not included
in a typical install. See “Installing the Express Toolkit” on page 10 and
“Launching the Express Toolkit” on page 10 for more information.
How to develop a Visual Basic plug-in:
To develop an Operations Navigator Visual Basic plug-in, complete the
following tasks:
1. Build, register and run the Visual Basic sample plug-in
2. Customize your new Visual Basic plug-in.
3. Diagnose any Visual Basic plug-ins errors.
4. Prepare the Visual Basic plug-in for final delivery and installation.
Detail: If the new directory is not C:\VBSample, you will need to change the
registry file. See for “Registering the ActiveX server DLL for Visual
Basic plug-ins” on page 1127 more information.
2. Download the Visual Basic sample from the Client Access Express Toolkit -
Operations Navigator Plug-ins Web page. , and copy all of the sample files
into this directory.
3. In Visual Basic, open the File menu and select Open Project.
4. In the Open Project dialog, switch to the VBSample directory.
5. Select vbsample.vbp and click Open.
6. Open the Project menu and select References.
7. In the References dialog, select IBM AS/400 Client Access Express ActiveX
Object Library. Also select Operations Navigator Visual Basic Plug-in
Support.
Detail: The IBM AS/400 Client Access Express ActiveX Object Library contains
ActiveX automation objects that the sample application requires to
make remote command calls to the AS/400. The Operations Navigator
Visual Basic Plug-in Support contains classes and interfaces required to
create a Visual Basic Plug-in.
Building the ActiveX server DLL for Visual Basic plug-ins: To build the ActiveX
server DLL, complete the following steps.
1. In Visual Basic, open the File menu and select Make....
Detail: If the DLL does not compile and link cleanly, locate and fix the errors.
Then open the File menu and select Make... to restart the build.
Next, build the resource library.
Building the resource library for Visual Basic plug-ins: The resource DLL that
contains the translatable text strings and other locale-dependent resources for the
plug-in is included with the sample. This means that you do not have to create this
DLL on your own. Even if your plug-in supports only one language, your plug-in
code must load its text strings and locale-specific resources from this resource
library.
Detail: If the sample directory is not C:\VBSample, you will need to change
the registry file. See “Registering the ActiveX server DLL for Visual
Basic plug-ins” on page 1127 for more information.
2. In Microsoft Developer Studio, open the File menu, select Open Workspace...
and select the VBSample\win32 directory.
Detail: You can change the icons for the Visual Basic Sample plug-in in
Operations Navigator by using this project. There are two icons that
can be changed:
IDI_LIBRARY
Visual Basic Sample plug-in library icon.
IDI_SAMPLEFOLDER
Visual Basic Sample plug-in folder in open and closed state.
Registering the ActiveX server DLL for Visual Basic plug-ins: The
VBSMPDBG.REG file in the VBSample directory contains registry keys that
communicate the location of the sample plug-in on your PC to the Operations
Navigator. If you specified a directory other than c:\VBSample in “Preparing to
build an ActiveX server DLL for Visual Basic plug-ins” on page 1126, complete the
following steps.
1. Open the VBSMPDBG.REG file in a text editor.
2. Replace all occurrences of ″c:\\VBSample\\″ with ″x:\\<dir>\\,″ where x is
the drive where your directory resides and <dir> is the name of the directory.
3. Save the files.
4. In Windows Explorer, double-click the VBSMPDBG.REG file. This will write the
entries in the registry file to the Windows registry on your machine.
Detail: In Windows NT, you must login with administrative privileges on your
PC to write to the Windows registry.
Finally, Observe your sample Visual Basic plug-in.
Observing the sample Visual Basic plug-in: To run Operations Navigator and
observe the sample plug-in in action, complete the following steps:
1. Make sure that Operations Navigator is installed on your PC. If it is not, install
Operations Navigator by selecting Start --> Programs --> IBM AS400 Client
Access --> Selective Setup. Follow the prompts until the Component selection
dialog is displayed, and select Operations Navigator. Follow the prompts
through completion.
2. In Windows, select Start --> Programs --> IBM AS400 Client Access Express
--> AS400 Operations Navigator (or if you have the Operations Navigator icon
on your desktop, simply double-click on it).
3. Because you have just registered a new Navigator plug-in, an AS/400
Operations Navigator Scan dialog is displayed. Click on Scan Now.
To customize your new Visual Basic plug-in, complete the following tasks:
1. Create a new registry file with a new ProgID for your Visual Basic plug-in
2. Register the Visual Basic plug-in implementation
3. Register the Visual Basic data server implementation
4. Register new Visual Basic folder information
5. Register Visual Basic plug-in objects
6. Construct Visual Basic property pages for a property sheet handler
7. Test the new Visual Basic plug-in
For more information that is specific to working with registry files in this context,
see “Registry files for Operations Navigator plug-ins” on page 983.
Creating a new registry file with a new ProgID for your Visual Basic plug-in:
The registry file contains important information about your plug-in, including the
programmatic identifier (ProgID). For more information about registry files, see
“Registry files for Operations Navigator plug-ins” on page 983. For more
information about ProgID, see “Programmatic identifier (ProgID)” on page 984.
To create a new registry file for your Visual Basic plug-in, complete the following
steps.
1. Copy the VBSMPRLS.REG, one of the sample registry files that is included with
the sample.
Detail: You need to copy and edit both of the registry files that are included in
the sample: VBSMPDBG.REG and VBSMPRLS.REG. Use
VBSMPDBG.REG as you develop your plug-in. Use VBSMPRLS.REG
for the retail version of your plug-in.
2. Rename the VBSMPRLS.REG file. Use the naming convention that you have
defined for your new plug-in.
3. Begin editing the registry file with your preferred utility. Change all instances
of ″IBM.VBSample″ with your new ←vendor→.←component→ string (ProgID).
What to do next:
Register the Visual Basic plug-in implementation.
Registering new Visual Basic folder information: This section of the registry is
necessary when your plug-in adds a new folder to the Operations Navigator
hierarchy. If your plug-in does not add a new folder to the Operations Navigator
hierarchy, delete the section entirely, and register Visual Basic plug-in objects.
Example: Registering Visual Basic plug-in objects: The final section of the
registry specifies which objects in the Navigator hierarchy are affected by
implementation of the Visual Basic plug-in. To edit this section of the registry,
complete the following steps. The CLSID key for all Visual Basic plug-ins must use
the value: 040606B2-1C19-11d2-AA12-08005AD17735
Note: Property sheet handlers including the Auto Refresh property sheet handler
are not supported for Visual Basic plug-ins.
You will see code similar to that in the following example:
;--------------------------------------------------------------------
; Register a context menu handler for the new folder and its objects
[HKEY_CLASSES_ROOT\IBM.AS400.Network\3RD PARTY EXTENSIONS\IBM.VBSample\shellex\SampleVBFolder\*\
ContextMenuHandlers\{040606B2-1C19-11d2-AA12-08005AD17735}]
"VBClass"="vbsample.SampleActionsManager"
"VBInterface"="{0FC5EC7A-8E00-11D2-AA9A-08005AD17735}"
;------------------------------------------------------------------------------
; Register drag and drop context menu handlers
[HKEY_CLASSES_ROOT\IBM.AS400.Network\3RD PARTY EXTENSIONS\IBM.VBSample\shellex\SampleVBFolder\*\
DragDropHandlers\{040606B2-1C19-11d2-AA12-08005AD17735}]
"VBClass"="vbsample.SampleActionsManager"
"VBInterface"="{0FC5EC7A-8E00-11D2-AA9A-08005AD17735}"
;------------------------------------------------------------------------------
; Register Drop Handler to accept drops of objects
Details:
v On many of the ActionsManager, ListManager and DropTargetManager
class methods, you will be passed in items or objects. To determine
which folder object is being referenced, use the object type string that is
defined in the Windows registry.
v Property sheets still can be added to your plug-in by using a context
menu item. You cannot use a registry key for a property sheet that is
the mechanism that is used for a C++ plug-in.
In the Visual Basic Sample plug-in, a property page is supported for Libraries in
the Operations Navigator List. This is done with the following steps:
1. In listman.cls, the Library object type specifies a properties page in the
getAttributes method:
' Returns the attributes of an object in the list.
Public Function ListManager_getAttributes(ByVal item As Object) As Long
Dim uItem As ItemIdentifier
Dim nAttributes As ObjectTypeConstants
ListManager_getAttributes = nAttributes
End Function
2. In actnman.cls, the queryActions method specifies that properties should be
shown on the Library object context menu.
Public Function ActionsManager_queryActions(ByVal flags As Long) As Variant
.
.
' Properties
Set actions(0) = New ActionDescriptor
With actions(0)
.Create
.setID IDPROPERTIES
.SetText m_uLoader.getString(IDS_ACTIONTEXT_PROPERTIES)
.setHelpText m_uLoader.getString(IDS_ACTIONHELP_PROPERTIES)
.setVerb "PROPERTIES"
.setEnabled True
.setDefault True
End With
' Pass the Display Name of the selected object into a hidden field on the form
frmProperties.lblLibName = m_ObjectNames(0).getDisplayName
.
End Sub
Note: The code to create and display the property sheet can be seen in
propsht.frm
What to do next:
Test the new Visual Basic plug-in.
Testing the new Visual Basic plug-in: After finishing the previous tasks, you
have copied all of your Visual Basic source parts to a development directory, and
created a project workspaces for your new C++ resource DLL. You have also
created a registry file that you can use to try out the new Visual Basic plug-in.
Note: The Visual Basic sample plug-in assumes the resource DLL source files will
be copied to the c:\vbsample\win32 directory.
1. In Microsoft Developer Studio, open the Build menu and select Rebuild All for
the resource MRI DLL (vbsmpmri.mak).
Note: If a project does not rebuild cleanly, press F4 to display errors, then
make appropriate changes to the code. You may have to remove
INCLUDE statements for header files that you are not using.
2. In Windows Explorer, double-click your new registry file (the development
version) to register your new plug-in (vbsmpdbg.reg).
Note: If you choose to use a different build directory than C:\VBSAMPLE, you
must change the path in the registry file before you apply the registry in
Windows Explorer.
Detail: You should see the folders, context menu items, and property pages from
the sample, depending on how much function from the sample you
decided to retain.
What to do next:
Diagnose Visual Basic plug-ins errors.
Note: By default, the History Log is not active. To ensure that error messages are
written to this file, History logging must be started. See the Express User’s
Guide, which is shipped with Client Access Express, for information on
starting the History Log.
The entries in the History Log consist of messages with and without message IDs.
Messages with message IDs have online help available. Messages without message
IDs do not have online help available.
Displaying recovery information for error messages with IDs:
To display the cause and recovery information associated with a message
that has a message ID, double-click on it. View any message that has a
message ID by selecting the Message topic in the online Express User’s
Guide.
Client Access Express also has associated messages that are logged on the AS/400
system. These messages begin with PWS or IWS.
To display messages that are logged on the AS/400 system:
Type the appropriate command (displayed below) at the AS/400
command-line prompt, where xxxx is the number of the message:
DSPMSGD RANGE(IWSxxxx) MSGF(QIWS/QIWSMSG)
For your Visual Basic plug-in files to be available for installation on client PCs,
they must reside in the following AS/400 directory:
/QIBM/USERDATA/OpNavPlugin
Use this directory for Visual Basic plug-ins. Use Client Access Express to
Install plug-ins in this directory. Client Access is unable to install them.
For Operations Navigator Visual Basic plug-ins, the subdirectory should contain:
v The registry file for the plug-in.
v The Express setup file for the plug-in.
v The ActiveX server DLL for the plug-in, and any associated code DLLs.
If the Visual Basic plug-in supports Windows policies, include the .adm policy
template file for the plug-in in the MRI29xx directory.
Modifying your project for binary compatibility: When you are satisfied with
the function that you have developed to extend the AS/400 Operations Navigator,
it is time to ensure that you have new globally unique identifiers (GUIDs) for your
Visual Basic classes, and to set the binary compatibility in your Visual Basic
project. Follow these steps create new GUIDs for your classes, and to set binary
compatibility:
1. Open the Project menu and select Properties.
2. Select the Component tab.
3. Select the No Compatibility radio button.
4. Select OK to close the Properties dialog.
5. Open the File menu and select Make to build the project and create new
GUIDs for your classes.
6. Open the Project menu and select Properties.
7. Select the Component tab.
8. Select the Binary Compatibility radio button.
Detail: The process documented above creates new GUIDs for your project’s
classes, and then ensures that subsequent builds retain your newly created
GUIDs.
Modifying the Release registry file: Visual Basic creates globally unique
identifiers (GUIDs) for your project and classes at compile time, and writes them to
the registry automatically. Since customers will not be compiling your projects, you
must include in the release registry file the registry entries (with your newly
created GUIDs) for your project and classes. VBSMPRLS.REG contains an example
of a release registry file.
After the users have installed your new plug-in, you may choose either to upgrade
it at a later date, or to ship code problem fixes. When the code is upgraded on the
AS/400, the Client Access Check Version program will detect that this process has
occurred, and automatically download the updates to the users’ PCs. Client Access
also provides uninstall support, which allows users to completely remove the
plug-in from their PCs.
Users can display the plug-ins that are installed on their PCs by selecting the
Plug-ins tab on the Operations Navigator Properties for a particular AS/400.
Note: AS/400 Toolbox for Java interface behaviors such as security and
tracing may differ from those of other Express interfaces.
Client Access Express provides the following methods for accessing AS/400
resources by using ActiveX automation:
Automation objects:
These objects provide support for:
v Accessing AS/400 data queues
v Calling AS/400 system application programming interfaces and user
programs
v Managing AS/400 connections and validating security
v Running CL commands on the AS/400
v Performing data-type and code-page conversions
v Interfacing with host emulation sessions
“Express OLE DB Provider” on page 136:
Call the Express OLE DB Provider, by using Microsoft’s ActiveX Data
Objects (ADO), to access the following AS/400 resources:
v The AS/400 database, through record-level access
v The AS/400 database, through SQL
v SQL stored procedures
v Data queues
v Programs
v CL commands
Custom controls:
ActiveX custom controls are provided for:
v AS/400 data queues
v AS/400 CL commands
v AS/400 system names for previously connected systems
v Operations Navigator
Express Toolkit:
For detailed information on ActiveX support for Client Access Express, see
the ActiveX topic in the Express Toolkit component of Client Access
Express. It includes complete documentation of ADO and ActiveX
automation objects, and links to ActiveX information resources.
How to access the ActiveX topic:
1. Ensure that the Express Toolkit is installed (see “Installing the
Express Toolkit” on page 10).
2. Launch the Express Toolkit (see “Launching the Express
Toolkit” on page 10).
3. Select the Overview topic.
4. Select Programming Technologies.
5. Select ActiveX.
Printed in U.S.A.