Software AG Products 2.4.1 | Reference Guide | Declaration Command | field-expressions | Multiple Value
 
Multiple Value
Generally, a multiple-value field is specified as a single field name and Adabas Pre-Compiler retrieves its occurrences from Predict. If maximum occurrences are not specified in Predict, Adabas Pre-Compiler declares 191 occurrences. Therefore, Software AG recommends that the number of occurrences be 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 for this field in Predict. Otherwise, the occurrence number is ignored and a warning message is printed.
The valid formats of using multiple values are:
MU
MU represents a range of occurrences of the multiple value. The occurrences are taken from the occurrences attribute for this field in Predict. For example:
@ADADCL31, EMPLOYEES, LANG.
The record buffer definition is:
01 RECORD-BUF31.
02 LANG31 PIC X(3) OCCURS 10.
MU(i)
MU(i) represents a single occurrence of the multiple value . The occurrence number is represented by i. The field name is the record buffer has an additional suffix of "-" followed by the occurrence number. For example:
@ADADCL32, EMPLOYEES, LANG(7).
The record buffer definition is:
01 RECORD-BUF32.
02 LANG32-7 PIC X(3).
MU(var)
MU(var) represents a single occurrence of the multiple value. The occurrence number is not fixed and is represented by a user-variable name that 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 multiple value and for every record where this occurrence is different. The occurrence number is put into the user-variable and Adabas Pre-Compiler updates the format buffer with that occurrence number.
The multiple-value name in the record buffer does not have any additional suffix and the multiple value field may appear only once in a declaration. For example:
@ADADCL33, EMPLOYEES, LANG(LINDEX).
The record buffer definition is:
01 RECORD-BUF33.
02 LANG33 PIC X(3).
The user variable LINDEX must contain the occurrence number before the read or update command.
MU(i-j)
MU(i-j) represents a range of occurrences of the multiple value. If the range does not start from 1, the name in the record buffer contains a "-" followed by the range as an extra suffix. For example:
@ADADCL34,EMPLOYEES,LANG(1-5) LANG(9-10).
The record buffer definition is:
01 RECORD-BUF34.
02 LANG34 PIC X(3) OCCURS 5.
02 LANG34-9-10 PIC X(3) OCCURS 2.
MU(LAST)
MU(LAST) represents the last occurrence of the multiple value. This format is valid only for retrieval commands. Adabas returns the last occurrence in every record. The field name in the record buffer does not have any additional suffixes. This declaration may not be used for update commands. For example:
@ADADCL35, EMPLOYEES, LANG(LAST).
The record buffer definition is:
01 RECORD-BUF35.
02 LANG35 PIC X(3).
MU(i-LAST)
MU(i-LAST) represents the range of occurrences until the last occurrence of the multiple value. This format is valid only as the last item in the field expressions. Adabas Pre-Compiler generates the multiple value with the range ’i’ until 191 occurrences, but Adabas fills it only until the last existing occurrence, therefore, it should be only at the end of the record buffer. This declaration may not be used for update commands. For example:
@ADADCL36, EMPLOYEES, PERSONNEL-ID
LANG(1-LAST).
The record buffer definition is:
01 RECORD-BUF 36.
02 PERSONNEL-ID36 PIC X(8).
02 LANG36 PIC X(3) OCCURS 191.
MU(COUNT)
MU(COUNT) represents the count of the multiple value. This format is defined as an additional two-byte binary field in which the actual number of occurrences existing in a record is stored. The name of the count field is the same as the multiple value field with a "C-" prefix.
You may define that the multiple value field always has a COUNT by defining the field type in Predict as MC instead of MU. In this case, Adabas Pre-Compiler automatically generates the count field while generating the multiple value field. It is not necessary to specify the MU(COUNT) in the declaration statement. For example:
@ADADCL4,EMPLOYEES,LANG LANG(COUNT).
The record buffer definition is:
01 RECORD-BUF4.
02 LANG4 PIC X(3) OCCURS 10.
02 C-LANG4 PIC 9(4) COMP.