Rules for the TEMPLATE keyword for Definition specifications:
When the TEMPLATE keyword is specified for a definition, the template
name and the subfields of the template name can be used only in the following
ways
As a parameter for the LIKE keyword
As a parameter for the LIKEDS keyword, if the template is a data structure
As a parameter for the %SIZE builtin function
As a parameter for the %ELEM builtin function
As a parameter for the %LEN builtin function in Definition specifications
(for example, as a named constant or initialization value)
As a parameter for the %DECPOS builtin function in Definition specifications
(for example, as a named constant or initialization value)
The INZ keyword is allowed for template data structures. This allows you
to set an initialization value to be used with LIKEDS definitions of the template,
through the INZ(*LIKEDS) keyword.
Figure 1. : Examples of TEMPLATE definitions
* Define a template for the type of a NAME
D standardName S 100A VARYING TEMPLATE
* Define a template for the type of an EMPLOYEE
D employee_type DS QUALIFIED TEMPLATE INZ
D name LIKE(standardName)
D INZ('** UNKNOWN **')
D idNum 10I 0 INZ(0)
D type 1A INZ('R')
D years 5I 0 INZ(-1)
* Define a variable like the employee type, initialized
* with the default value of the employee type
D employee DS LIKEDS(employee_type)
D INZ(*LIKEDS)
* Define prototypes using the template definitions
*
* The "id" parameter is defined like a subfield of a
* template data structure.
D getName PR LIKE(standardName)
D idNum
D findEmp PR N
D emp LIKEDS(employee_type)
D id LIKE(employee_type.idNum)
D CONST