IBM Support

Mapping a Numeric Return Code from a Client Access API to a Specific Constant

Troubleshooting


Problem

This document discusses the return codes that might be returned by iSeries Access for Windows APIs.

Resolving The Problem

IBM Documentation lists the return codes by name and numeric constant. The return codes are divided into a global list and a IBM i Access for Windows-specific list. Both lists can be found at the following URL: https://www.ibm.com/docs/en/i/7.4?topic=codes-specific-return Or by navigating to IBM Documentation at https://www.ibm.com/docs/en/i/7.4 then, expanding the following options in the content navigation bar on the left side of the page.
  • Connecting to your system
  • IBM i Access
  • IBM i Access Client Solutions: Application Packages
  • Windows Application Package
  • Programming
  • C/C++ APIs
  • C/C++ APIs overview
  • Return codes and error messages
  • Return codes
  • Specific return codes

The IBM i Access Client Solutions - Windows Application Package: Programming manual lists return codes by constant name (CWB_OK or CWB_LICENSE_ERROR for example), not the numeric value of the return code. The manual does not list all possible return codes for each API but lists only the most common return codes. The complete list of IBM i Access Client Solutions Windows API return codes is defined in the CWB header files. To map a numeric return code to a particular constant name, you must use the CWB header files that are contained in the Client Access and iSeries Access for Windows toolkit. The toolkit is installed with IBM i Access Client Solutions Windows Application Package.

After you install the toolkit, locate the header files in the ..\client access\toolkit\include directory. Return codes fall into the following categories:
  • Global return codes corresponding to operating system errors
  • Global return codes unique to Access Client Solutions Windows Application Package
  • Specific return codes for each Access Client Solutions Windows Application Package API set
Global return codes are defined in the file CWB.H.

Return codes that are specific to an API group are defined in the header files for that particular group. The constant is defined as offset relative to a start point for that API family. To map this error to a numeric value, you must determine the offset, then the start point. The start points are defined relative to another constant, which is defined in CWB.H.

The following is an example of how to find the constant for a data queue API return code of 6014:
  1. Locate CWBDQ.H in the toolkit\include directory.
  2. Search for the definition of CWBDQ_START (usually near the top of the file):
    #define CWBDQ_START CWB_LAST + 1
  3. Track down CWB_LAST in the CWB.H file:
    #define CWB_LAST = 5999
  4. Back to CWBDQ.H, search for offset 14:
    #define CWBDQ_INVALID_TIME CWBDQ_START + 14

A list of the most popular return codes follows. The following list was derived from the R312 Client Access header files and might not be complete. The header files contain the most current and accurate information.
 
Client Access Return Codes Corresponding to Operating System Errors

cwbOK 0
cwbInvalidFunction           1
cwbFileNotFound               2
cwbPathNotFound               3
cwbTooManyOpenFiles       4
cwbAccessDenied               5
cwbInvalidHandle             6
cwbNotEnoughMemory       8
cwbInvalidDrive             15
cwbNoMoreFiles             18
cwbDriveNotReady         21
cwbGeneralFailure           31
cwbSharingViolation         32
cwbLockViolation           33
cwbEndOfFile               38
cwbNotSupported             50
cwbBadNetworkPath         53
cwbNetworkBusy             54
cwbDeviceNotExist           55
cwbUnexpectedNetworkError 59
cwbNetworkAccessDenied   65
cwbFileExists               80
cwbAlreadyAssigned       85
cwbInvalidParameter         87
cwbNetworkWriteFault     88
cwbOpenFailed               110
cwbBufferOverflow           111
cwbDiskFull                 112
cwbProtectionViolation   115
cwbInvalidLevel             124
cwbBusyDrive               142
cwbInvalidFSDName       252
cwbInvalidPath             253
Return Codes Unique to Client Access for Windows95/NT
cwbUserCancelledCommand   4000
cwbConfigError           4001
cwbLicenseError           4002
cwbProdOrCompNotSet       4003
cwbSecurityError         4004
cwbGlobalCfgFailed       4005
cwbProdRetrieveFailed     4006
cwbCompRetrieveFailed     4007
cwbCompCfgFailed         4008
cwbCompFixLevelUpdateFail 4009
cwbInvalidAPIHandle       4010
cwbInvalidAPIParameter   4011
cwbHostNotFound           4012
cwbNotCompatible         4013
cwbInvalidPointer         4014
cwbServerProgramNotFound 4015
cwbAPIError               4016
cwbCANotStarted           4017
cwbFileIOError           4018
cwbCommunicationsError   4019
cwbRuntimeConstructorFail 4020
cwbDiagnostic             4021
cwbCommVersionError       4022
cwbNoViewer               4023
cwbModuleNotLoadable     4024
cwbAlreadySetup           4025
cwbCannotStartProcess     4026
Client Access Service Return Codes

cwbsvNoErrorMessages               6003

Client Access Remote Command and Distributed Program Call Return Codes

cwbrcInvalidSystemHandle 6000
cwbrcInvalidProgram     6001
cwbrcSystemName         6002
cwbrcCommandString     6003
cwbrcProgramName       6004
cwbrcLibraryName         6005
cwbrcInvalidType         6006
cwbrcInvalidParmLength   6007
cwbrcInvalidParm         6008
cwbrcTooManyParms       6009
cwbrcIndexRangeError     6010
cwbrcRejectedUserExit   6011
cwbrcUserExitError       6012
cwbrcCommandFailed       6013
cwbrcProgramNotFound     6014
cwbrcProgramError       6015
cwbrcCommandTooLong     6016
cwbrcUnexpectedError     6099

Client Access Data Queues Return Codes

cwbdqInvalidAttributeHandle 6000
cwbdqInvalidDataHandle     6001
cwbdqInvalidQueueHandle     6002
cwbdqInvalidReadHandle     6003
cwbdqInvalidQueueLength     6004
cwbdqInvalidKeyLength     6005
cwbdqInvalidOrder           6006
cwbdqInvalidAuthority       6007
cwbdqInvalidQueueTitle     6008
cwbdqBadQueueName           6009
cwbdqBadLibraryName       6010
cwbdqBadSystemName         6011
cwbdqBadKeyLength           6012
cwbdqBadDataLength         6013
cwbdqInvalidTime           6014
cwbdqInvalidSearch         6015
cwbdqDataTruncated         6016
cwbdqTimedOut               6017
cwbdqRejectedUserExit       6018
cwbdqUserExitError         6019
cwbdqLibraryNotFound       6020
cwbdqQueueNotFound         6021
cwbdqNoAuthority           6022
cwbdqDamagedQueue           6023
cwbdqQueueExists           6024
cwbdqInvalidMessageLength   6025
cwbdqQueueDestroyed         6026
cwbdqNoData                 6027
cwbdqCannotConvert         6028
cwbdqQueueSyntax           6029
cwbdqLibrarySyntax         6030
cwbdqAddressNotSet         6031
cwbdqHostError             6032
cwbdqUnexpectedError       6099
Client Access Database Return Codes

cwbdbCannotContactServer            6001
cwbdbAttributesFailure              6002
cwbdbServerAlreadyStarted                    6003
cwbdbInvalidDRDAPkgSize      6004
cwbdbRequestMemoryAllocationFailure  6005
cwbdbRequestInvalidConversion    6006
cwbdbServerNotActive                6007
cwbdbParameterError                  6008
cwbdbCloneCreationError              6009
cwbdbInvalidDataFormatForConnection  6010
cwbdbDataFormatInUse                6011
cwbdbInvalidDataFormatForData    6012
cwbdbStringArgTooLong                6013
cwbdbInvalidInternalArg              6014
cwbdbInvalidNumericArg              6015
cwbdbInvalidArg                      6016
cwbdbStmtNotSelect                  6017
cwbdbStreamFetchNotComplete      6018
cwbdbStreamFetchNotActive          6019
cwbdbMissingDataProcessor            6020
cwbdbIllegalCloneRequestType      6021
cwbdbUnsolicitedData                6022
cwbdbMissingData                    6023
cwbdbParmInvalidBitstream            6024
cwbdbConsistencyTokenError          6025
cwbdbInvalidFunction                6026
cwbdbFormatInvalidArg                6027
cwbdbInvalidColumnPosition          6028
cwbdbInvalidColumnType              6029
cwbdbRowVectorNotEmpty            6030
cwbdbRowVectorEmpty                  6031
cwbdbMemoryAllocationFailure      6032
cwbdbInvalidConversion              6033
cwbdbDatastreamTooShort              6034
cwbdbSQLWarning                      6035
cwbdbSQLError                        6036
cwbdbSQLParameterWarning          6037
cwbdbSQLParameterError              6038
cwbdbListServerWarning              6039
cwbdbListServerError                6040
cwbdbListParameterWarning            6041
cwbdbListParameterError              6042
cwbdbNDBFileServerWarning          6043
cwbdbNDBFileServerError              6044
cwbdbFileParameterWarning            6045
cwbdbFileParameterError              6046
cwbdbGeneralServerWarning          6047
cwbdbGeneralServerError              6048
cwbdbExitProgramWarning              6049
cwbdbExitProgramError                6050
cwbdbDataBufferTooSmall              6051
cwbdbNlConversionError              6052
cwbdbCommunicationsError            6053
cwbdbInvalidArgAPI                  6054
cwbdbMissingDataHandler              6055
cwbdbRequestDatastreamNotValid  6056
cwbdbServerUnable                    6057
cwbdbLastStreamChunk                6099

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"},{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSRQKY","label":"IBM i Access Client Solutions"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Historical Number

8090507

Document Information

Modified date:
01 July 2021

UID

nas8N1010205