HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


To name fields within an area

HLASM Language Reference
SC26-4940-06

Using a duplication factor of zero in a DS instruction also provides a label for an area of storage without reserving the area. Use DS or DC instructions to reserve storage for, and assign labels to, fields within the area. These fields can then be addressed symbolically. (Another way of accomplishing this is described in DSECT instruction.) The whole area is addressable by its label. In addition, the symbolic label has the length attribute value of the whole area. Within the area, each field is addressable by its label.

For example, assume that 80-character records are to be read into an area for processing and that each record has the following format:
Positions 5-10
Payroll Number
Positions 11-30
Employee Name
Positions 31-36
Date
Positions 47-54
Gross Wages
Positions 55-62
Withholding Tax
The following example shows how DS instructions might be used to assign a name to the record area, then define the fields of the area and allocate storage for them. The first statement names the whole area by defining the symbol RDAREA; this statement gives RDAREA a length attribute of 80 bytes, but does not reserve any storage. Similarly, the fifth statement names a 6 byte area by defining the symbol DATE; the three subsequent statements define the fields of DATE and allocate storage for them. The second, ninth, and last statements are used for spacing purposes and, therefore, are not named.
RDAREA   DS         0CL80
         DS         CL4
PAYNO    DS         CL6
NAME     DS         CL20
DATE     DS         0CL6
DAY      DS         CL2
MONTH    DS         CL2
YEAR     DS         CL2
         DS         CL10
GROSS    DS         CL8
FEDTAX   DS         CL8
         DS         CL18
Here are some more examples of DS statements:
ONE      DS         CL80          One 80 byte field, length attribute of 80
TWO      DS         80C           Eighty 1 byte fields, length attribute of 1
THREE    DS         6F            6 fullwords, length attribute of 4
FOUR     DS         D             1 doubleword, length attribute of 8
FIVE     DS         4H            4 halfwords, length attribute of 2
SIX      DS         GL80          One 80 byte field, length attribute of 80
SEVEN    DS         80G           Eighty 2 byte fields, length attribute of 2
To define four 10 byte fields and one 100 byte field, the respective DS statements might be as follows:
FIELD    DS              4CL10
AREA     DS              CL100

Although FIELD might have been specified as one 40 byte field, the preceding definition has the advantage of providing FIELD with a length attribute of 10. This is pertinent when using FIELD as an SS machine instruction operand.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014