com.ibm.as400.access

Class ErrorCodeParameter

  • All Implemented Interfaces:
    java.io.Serializable


    public class ErrorCodeParameter
    extends ProgramParameter
    implements java.io.Serializable
    Represents an IBM i "error code parameter".

    An API error code parameter is a variable-length structure that is common to most of the system APIs. The error code parameter controls how errors are returned to the application. The error code parameter must be initialized before the application calls the API. Depending on how the error code structure is set, this parameter either returns information associated with an error condition, or causes the Toolbox to return the errors as AS400Message objects. For some APIs, the error code parameter is optional. If you do not code the optional error code parameter, the API returns both diagnostic and escape messages. If you do code the optional error code parameter, the API returns only escape messages or error codes, and never returns diagnostic messages.

    See Also:
    ProgramCall, ServiceProgramCall, AS400Message, Serialized Form
    • Constructor Detail

      • ErrorCodeParameter

        public ErrorCodeParameter()
        Constructs a simple default ErrorCodeParameter object. The error information resulting from the API execution will be returned as AS400Message objects, which can be accessed via ProgramCall.getMessageList() or ServiceProgramCall.getMessageList().
        Note: This is the constructor that is recommended for the vast majority of applications.
        See Also:
        AS400Message
      • ErrorCodeParameter

        public ErrorCodeParameter(boolean returnSubstitutionData,
                          boolean useCCHAR)
        Constructs an ErrorCodeParameter object. The error information resulting from the API execution will be returned as output data in the error code parameter, rather than as AS400Message objects. To retrieve the error information, call getMessageID() and getSubstitutionData().

        Usage note: This constructor creates error code parameters which cause the run() methods of ProgramCall and ServiceProgramCall to return true even if the called program failed. With this constructor, in order to detect program failure the application must examine the error information returned in the ErrorCodeParameter.

        Parameters:
        returnSubstitutionData - Whether the error information returned from the system is to include error message substitution data. The default is false; that is, error message substitution data is not returned.
        useCCHAR - Whether convertible character (CCHAR) support is to be used. The default is false; that is, CCHAR support is not used.
        See Also:
        ProgramCall.run(), ServiceProgramCall.run()
    • Method Detail

      • getMessageID

        public java.lang.String getMessageID()
        Returns the error message ID that was returned in the error code parameter. For example: "CPF7B03". Null is returned if no message ID has been returned from the system.
        Returns:
        The message ID.
      • getSubstitutionData

        public java.lang.String getSubstitutionData()
        Returns the error message substitution data that was returned in the error code parameter. Null is returned if no error information has been returned from the system. To insert the data into the message, call MessageFile.getMessage(String,String).
        Returns:
        The substitution data.