QUALIFIED
QUALIFIED
Qualified data structures
The QUALIFIED keyword specifies that the subfields of a data structure will be accessed by specifying the data structure name followed by a period and the subfield name. The data structure must have a name.
The subfields can have any valid name, even if the name has been used elsewhere in the program. This is illustrated in the following example.
In this example, FILE1 and FILE2 are the names of files. FILE1 and FILE2 are also subfields of qualified data structure FILESTATUS. This is valid, because the subfields FILE1 and FILE2 must be qualified by the data structure name: FILESTATUS.FILE1 and FILESTATUS.FILE2.
Ffile1 if e disk
Ffile2 if e disk
D fileStatus ds qualified
D file1 N
D file2 N
C open(e) file1
C eval fileStatus.file1 = %error
Qualified files
The QUALIFIED keyword specifies that the record formats of a file will be accessed by specifying the file name followed by a period and the record format name.
The record formats can have any valid name, even if the name has been used elsewhere in the program. This is illustrated in the following example.
In this example, FILE1 has a record format MYFMT and FILE2 has a record format called MYFMT. Since the files are qualified, it is not necessary to rename one of the formats for the RPG program.
DCL-F file1 EXTDESC('MYLIB/MYFILE') QUALIFIED;
DCL-F file2 EXTDESC('MYLIB/MYFILE') QUALIFIED;
DCL-DS ds1 LIKEREC(file1.myfmt);
DCL-DS ds2 LIKEREC(file2.myfmt);
read file1 ds1;
update file1.myfmt;
Qualified enumerations
The QUALIFIED keyword specifies that the constants of an enumeration will be accessed by specifying the enumeration name followed by a period and the constant name.
The constants can have any valid name, even if the name has been used elsewhere in the program. This is illustrated in the following example.
In this example, ACTIVE is a standalone field. The name ACTIVE can be used as one of the constants in the enumeration because the enumeration is qualified.
- When the name is not qualified, it refers to the standalone field.
- When the name is qualified, it refers to the constant in the enumeration.
DCL-ENUM account_status QUALIFIED;
new 'N';
active 'A';
closed 'C';
END-ENUM;
DCL-S active IND;
if active; // 1
...
endif;
theAccount.status = account_status.active;