In this section: |
How to: |
Reference: |
Stacks are array variables containing rows and columns. When defining a stack and its structure, provide a name for the stack and a name, format, and order for each of the columns in the stack.
Stacks can be defined in two ways:
A procedure that includes an INFER command must specify the name of the corresponding Master File in the MAINTAIN command, and must have access to the Master File.
The syntax of the INFER command is
INFER path_spec INTO stackname [;]
where:
Identifies the path to be defined for the data source. To identify a path, specify its anchor and target segments. If the path contains only one segment, the anchor and target are identical. Simply specify the segment once. For paths with multiple segments, to make the code clearer to readers, you can also specify segments between the anchor and target.
To specify a segment, provide the name of the segment or of a field within the segment.
Is the name of the stack.
Terminates the command. Although the semicolon is optional, you should include it to allow for flexible syntax and better processing. For more information about the benefits of including the semicolon, see Terminating a Command's Syntax.
In the following called procedure, two INFER commands define the EmpClasses and ClassCredits stacks:
MAINTAIN FROM EmpClasses INTO ClassCredits INFER Emp_ID Ed_Hrs Date_Attend Course_Code INTO EmpClasses; INFER Emp_ID Course_Code Grade Credits INTO ClassCredits; . . . END
To define stack columns in a procedure for non-data source fields (fields created with the COMPUTE command), you do not need to provide a value for the column. The syntax is:
COMPUTE stackname.target_variable/format = ;
Note that the equal sign is optional when the COMPUTE is issued solely to establish format.
In the following example, the stack column TempEmp was passed to the called procedure. The COMPUTE is issued in the called procedure to define the variable prior to use:
COMPUTE EmpClasses.TempEmp_ID/A9 ;