cozTools - Check Valid Name (CHKNAME)
The cozTools - Check Valid Name (CHKNAME) command validates the data specified on the NAME parameter for a valid NAME, CNAME or SNAME. If the value on the parameter is not the indicated type of name, message ID CPF019D is sent as an *ESCAPE message. You can monitor for this message in your CL programs using the MONMSG command.
||Name to validate
||Required, Positional 1
||Type of name being validated
||*NAME, *SNAME, *CNAME
||Optional, Positional 2
||Maximum name length allowed
||1-256, *NONE, *SYSVAL, *OBJNAME
||Optional, Positional 3
||Values (up to 20 repetitions): *NOSYMB, *NOSYMBOLS, *NOSYMBOL, *NOBLING
||Optional, Positional 4
||CCSID of name
||Optional, Positional 5
Name to validate (NAME)
Specifies the name to be validated. This parameter accepts valid names up to 256 characters in length. If a test for a specific length is desired, specify the limit on the MAXLEN parameter.
This is a required parameter.
- Specify the name to be validated. The name must conform to the type of name specified on the TYPE parameter. If it does not, CPF019D is sent as an *ESCAPE message.
Type of name being validated (TYPE)
Specifies type of name validation to perform.
- Standard IBM i (OS/400) object name testing is performed. The value on the NAME parameter is tested for a standard Name. A standard Name must have, as its first character, the letters (A-Z), or one of the symbols $, # or @. The remaining characters may be any of those from the first character or may be the numbers 0 through 9, an underscore (_), or period (.).
- The value on the NAME parameter is tested for a Simple name. A Simple Name must have, as its first character, the letters (A-Z), or one of the symbols $, # or @. The remaining characters may be any of those from the first character or may be the numbers 0 through 9, or an underscore (_). (periods are not allowed)
- The value on the NAME parameter is tested for a so call Communications Name. A Communications Name must have, as its first character, the letters (A-Z), or one of the symbols $, # or @. The remaining characters may be any of those from the first character or may be the numbers 0 through 9. (periods and underscores are not allowed)
Maximum length of the name (MAXLEN)
Specifies the maximum length allowed for the value specified on the NAME parameter before it is considered invalide. If the name's length exceeds the size specified for this parameter, then it is considered invalid even if it passes the normal validation process.
- No length validation is performed.
- The length of the validation is set to the value specified. If the name specified on the NAME parameter exceeds this value, the validation fails with CPF019D.
- *OBJNAME or *SYSVAL
- The length of the validation is set to the system object name limit of 10.
Special options (OPTION)
Specifies additional validatino options to perform.
- In addition the standard validation performed by the value specified for the TYPE parameter, the name is further tested for the following symbols and will fail if any of these symbols appears in the name:
- Special Symbols
- $ @ # * - + & %
CCSID of name (CCSID)
Specifies the CCSID to use when validating the name.
- The current JOB's CCSID is used to validate the name.
- The name is specified in the CCSID specified for this parameter.
Examples for CHKNAME
Example 1: Simple Command Example
CHKNAME NAME(&OBJNAME) TYPE(*NAME) MAXLEN(10)
MONMSG MSGID(CPF019D) EXEC(DO)
/* Bad name handling goes here */
This example illustrates how to test the contents of a CL variable for a valid object name. The &OBJNAME variable contains the name being tested. The type is *NAME and a maximum name length of 10 is specified.
Error messages for CHKNAME
- Value &1 not valid as system name.
- Value of &1 for length of name field not valid.
- The type &1 is not allowed or valid.
- Severe error while addressing parameter list.
- CCSID &1 not supported by API.
- Format name &1 is not valid.
- Value for reserved field not valid.
- APPTOOLS function &1 failed with &2. See joblog for details.