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.
Keyword |
Description |
Choices |
Notes |
NAME |
Name to validate |
Character value |
Required, Positional 1 |
TYPE |
Type of name being validated |
*NAME, *SNAME, *CNAME |
Optional, Positional 2 |
MAXLEN |
Maximum name length allowed |
1-256, *NONE, *SYSVAL, *OBJNAME |
Optional, Positional 3 |
OPTION |
Special options |
Values (up to 20 repetitions): *NOSYMB, *NOSYMBOLS, *NOSYMBOL, *NOBLING |
Optional, Positional 4 |
CCSID |
CCSID of name |
1-65533, *JOB |
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.
- name
- 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.
- *NAME
- 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 (.).
- *SNAME
- 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)
- *CNAME
- 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.
- *NONE
- No length validation is performed.
- 1-256
- 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.
- *NOSYMB
- 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.
- *JOB
- The current JOB's CCSID is used to validate the name.
- 1-65533
- 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 */
ENDDO
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
*ESCAPE Messages
- CPF019D
- Value &1 not valid as system name.
- CPF019E
- Value of &1 for length of name field not valid.
- CPF019F
- The type &1 is not allowed or valid.
- CPF24B4
- Severe error while addressing parameter list.
- CPF3BDE
- CCSID &1 not supported by API.
- CPF3C21
- Format name &1 is not valid.
- CPF3C39
- Value for reserved field not valid.
- COZ8103
- APPTOOLS function &1 failed with &2. See joblog for details.