The LIKEDS keyword is used to define a data structure, data structure subfield, prototyped return value, or prototyped parameter like another data structure. The subfields of the new item will be identical to the subfields of the parent data structure specified as the parameter to the LIKEDS keyword.
A data structure defined using LIKEDS is automatically qualified even if the parent data structure is not qualified. The subfields must be referred to using the qualified notation DSNAME.SUBFIELDNAME. If the parent data structure has any unnamed subfields, the child data structure will have the same unnamed subfields.
LIKEDS can be coded for subfields of a qualified data structure.
When LIKEDS is coded on a data structure subfield definition, the subfield
data structure is automatically defined as QUALIFIED. Subfields in a LIKEDS
subfield data structure are referenced in fully qualified form:
"ds.subf.subfa". Subfields defined with LIKEDS are themselves data structures, and
can be used wherever a data structure is required.
The values of the ALIGN and ALTSEQ keywords are inherited by the new data structure. The values of the OCCURS, DIM, NOOPT, NULLIND, and INZ keywords are not inherited. To initialize the subfields in the same way as the parent data structure, specify INZ(*LIKEDS).
However, the values of the DIM, NOOPT, and NULLIND keywords specified for the subfields of the parent data structure are inherited by the subfields of the new data structure.
Specifying LIKEDS with a qualified data structure name
- Data structure employees is defined as a subfield of qualified data structure employee_info.
- The check_employee procedure is called, passing an element of the employee_info.employees data structure array.
- The employee parameter of the check_employee procedure is with the LIKEDS keyword with the qualified data structure employee_info.employees.
- The subfields of the employee parameter are the same as the subfields of the qualified data structure subfield employee_info.employees.
DCL-DS employee_info QUALIFIED; num_employees INT(10); DCL-DS employees DIM(20); // 1 name VARCHAR(25); salary PACKED(7:2); END-DS; END-DS; ... ok = check_employee (employee_info.employees(i)); // 2 ... DCL-PROC check_employee; DCL-PI *N IND; employee LIKEDS(employee_info.employees); // 3 END-PI; if (employee.salary < MIN_SALARY); // 4 ... endif; END-PROC;