Object naming rules

These rules are used to name all IBM® i objects used in control language (CL) commands. The parameter summary table for each CL command shows whether a simple object name, a qualified name, or a generic name can be specified.

Naming a Single Object
In the name of a single object, each part (the simple name and the library qualifier name) can have a maximum of 10 characters.
Naming a User-Created Object
To distinguish a user-created object from an IBM-supplied object, you should not begin user-created object names with Q because the names of all IBM-supplied objects (except commands) begin with Q. Although you can use as many as 10 characters in CL object names, you might need to use fewer characters to be consistent with the naming rules of the particular high-level language that you are also using. Also, the high-level language might not allow underscores in the naming rules. For example, RPG limits file names to eight characters and does not allow underscores.
Naming a Generic Object
In a generic name, a maximum of nine alphanumeric characters can be used, not including the asterisk (*) that must immediately follow the last character.

INV and INV* are valid values where a generic name is accepted. When the name INV is specified, only the object INV is referenced. When the generic name INV* is specified, objects that begin with INV are referred to, such as INV, INVOICE, INVENTORY, and INVENPGM1. When the quoted generic name "INV*" is specified, objects that begin with "INV" are referred to, such as "INV%1" and "INV>."

Object Library Qualifier Limitations
No library qualifier can be specified with the object name if the object being created is a library, user profile, line description, controller description, device description, mode description, class-of-service description, or configuration list. A library name can never be qualified because a library cannot be placed in a library. The other object types (*USRPRF, *LIND, *CTLD, *DEVD, *MODD, *COSD, and *CFGL) appear to be types that exist only in the QSYS library. When only the name of an object of these object types is accepted, a library qualifier cannot be specified with the object name. On the Display Object Description (DSPOBJD) command, where any object name is accepted, QSYS can be specified.
Library List Qualifiers
The predefined value *LIBL (and others, such as *CURLIB) can be used in place of a library name in most commands. *LIBL indicates that the libraries named in the job's library list are used to find the object named in the second part of the qualified name.
Duplicate Object Names
Duplicate names are not allowed for objects of the same type in the same library.

Two objects with the same name cannot be stored in the same library unless their object types are different. Two objects named OBJA can be stored in the library LIBx only if, for example, one of the objects is a program and the other is a file. The following combinations of names and object types could all exist on the system at the same time.

 Name and Object Type Combinations

If more than one library contains an object with the same name (and both libraries are in the same library list) and a library qualifier is not specified with the object name, the first object found by that name is used. Therefore, when you have multiple objects with the same name, you should specify the library name with the object name or ensure that the appropriate library occurs first in the library list. For example, if you are testing and debugging and choose not to qualify the names, ensure that your test library precedes your production library in the library list.

Default libraries

In a qualified object name, the library name is typically optional. If an optional library qualifier is not specified, the default given in the command's description is used (typically either *CURLIB or *LIBL). If the named object is being created, the current library is the default; when the object is created, it is placed either in the current library or in the QGPL (the general purpose library ) if no current library is defined. For objects that already exist, *LIBL is the default for most commands, and the job's library list is used to find the named object. The system searches all of the libraries currently in the library list until it finds the object name specified.