Software AG Products 2.4.1 | Reference Guide | Declaration Command | field-expressions | Periodic Group
 
Periodic Group
A periodic group is a repeating group of up to 65000 occurrences. Adabas Pre-Compiler automatically generates definitions of all fields within the periodic group using the full field names as defined in Predict or their language dependent synonyms if @OPTIONS SYNONYM is used.
The number of occurrences is taken from Predict and if it is not specified, Adabas Pre-Compiler declares 99 occurrences, therefore, ensure that the number of occurrences is correctly specified in Predict. You may specify a single occurrence or a range of occurrences within parentheses.
In the case of a single occurrence or the upper limit of a range, the occurrence number must not be greater than the number specified in the occurrences attribute in the Predict field definition. Otherwise, the occurrence number is ignored and a warning message is printed.
If a single occurrence or a range which does not begin from the first occurrence is required, Adabas Pre-Compiler adds an additional suffix to the periodic group name and all its fields. A range that begins with the first occurrence does not require the suffix.
Adabas Pre-Compiler generates the entire periodic group under a dummy group field. The name of that dummy group is the name of the periodic group with a prefix of "G-".
You do not need all the fields within the periodic group. You may request specific fields that are treated as multiple-value fields, with the exception that you may not request the count of such a field, but only the count of the whole periodic group.
If the file type in Predict is of an Adabas file, Adabas Pre-Compiler assumes that the file definition in Predict is the same as the physical file, therefore the format buffer has the periodic group name. If the file type is of a userview file, the file definition in Predict is different to the physical file. Therefore, Adabas Pre-Compiler generates the elementary field names for every occurrence of the periodic group in the format buffer. This action may result in a very large format-buffer. You may reduce the size by specifying the GROUP-STRUCT=’N’ attribute in the Predict definition for the periodic group. In this case, every field in the periodic group has the occurrences and the main periodic group name is generated as a group.
For example:
@ADADCL4, EMPLOYEES, LEAVE-BOOKED.
The record buffer definition is: (GR-STRUCT = ’ ’ )
01 RECORD-BUF4.
02 G-LEAVE-BOOKED4.
03 LEAVE-BOOKED4 OCCURS 10.
04 LEAVE-START4 PIC 9(6).
04 LEAVE-END4 PIC 9(6).
The record buffer definition is: (GR-STRUCT = ’ N ’ )
01 RECORD-BUF4.
02 LEAVE-BOOKED4.
03 LEAVE-START4 PIC 9(6) OCCURES 10.
03 LEAVE-END4 PIC 9(6) OCCURS 10.
The valid formats of using periodic groups are:
PE
PE specifies a range of occurrences of the periodic group. The number of occurrences is taken from Predict as in the previous example.
PE(i)
PE(i) specifies a single occurrence of the periodic group. "i" represents the occurrence number. The field names in the record buffer have an additional suffix of ’-’ and the occurrence number. For example:
@ADADCL41, EMPLOYEES, LEAVE-BOOKED(3).
The record buffer definition is:
01 RECORD-BUF41.
02 LEAVE-BOOKED41-3.
03 LEAVE-START41-3 PIC 9(6).
03 LEAVE-END41-3 PIC 9(6).
PE(var)
PE(var) specifies a single occurrence of the periodic group. The occurrence number is not fixed and is represented by a user variable name. The name should contain a numeric value at execution time. In this case, the occurrence number may be different for every record read or updated. This format may be used especially in update programs that need to add another occurrence to the periodic group and for every record it is a different occurrence.
Put the occurrence number into the user variable. Adabas Pre-Compiler takes care of updating the format buffer with that occurrence number. The periodic group name in the record buffer does not have any additional suffix and the periodic group may appear only once in a declaration. For example:
@ADADCL42, EMPLOYEES, LEAVE-BOOKED(LBINDEX).
The record buffer definition is:
01 RECORD-BUF42.
02 LEAVE-BOOKED42.
03 LEAVE-START42 PIC 9(6).
03 LEAVE-END42 PIC 9(6).
The user variable LBINDEX should contain the occurrence number before the read or update command.
PE(i-j)
PE(i-j) specifies a range of occurrences of the periodic group. If the range does not start from 1, the name in the record buffer contains an extra suffix, a "-" followed by the range. For example:
@ADADCL43, EMPLOYEES, LEAVE-BOOKED(1-3)
LEAVE-BOOKED(7-9).
The record buffer definition is:
01 RECORD-BUF43.
02 G-LEAVE-BOOKED43.
03 LEAVE-BOOKED43 OCCURS 3.
04 LEAVE-START43 PIC 9(6).
04 LEAVE-END43 PIC 9(6).
02 G-LEAVE-BOOKED43-7-9.
03 LEAVE-BOOKED43-7-9 OCCURS 3.
04 LEAVE-START43-7-9 PIC 9(6).
04 LEAVE-END43-7-9 PIC 9(6).
PE(COUNT)
PE(COUNT) specifies the count of the periodic group. This is defined as an additional field of two binary bytes in which the actual number of occurrences existing in a record is stored. The name of the count field is the same as the periodic group field with a prefix of "C-."
You may define that the periodic group field always has COUNT by defining the field type in Predict as PC instead of PE. In this case, Adabas Pre-Compiler automatically generates the count field while generating the periodic group field, and there is no need to specify the PE(COUNT) in the declaration statement. For example:
@ADADCL44, EMPLOYEES, LEAVE-BOOKED(1-3)
LEAVE-BOOKED(COUNT).
The record buffer definition is:
01 RECORD-BUF44.
02 G-LEAVE-BOOKED44.
03 LEAVE-BOOKED44 OCCURS 10.
04 LEAVE-START44 PIC 9(6).
04 LEAVE-END44 PIC 9(6).
02 C-LEAVE-BOOKED44 PIC 9(4) COMP.