COBOL Manual for TNS and TNS/R Programs

Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs522555-006
4-15
Data Alignment in Receiving Items
Data Alignment in Receiving Items
Not all data storage locations in a COBOL program are the same size. When you direct
a COBOL program to store a value of a given size at a location of a different size, the
process extends or truncates the value according to alignment rules:
Standard data representation and alignment rules are not always appropriate, so these
clauses and directive exist to override them:
Data Alignment in Memory
How a data item is aligned in memory is determined by:
Its USAGE clause
Whether its description includes the SYNCHRONIZED clause
Whether the program is compiled with the PORT directive
The machine on which the program executes
For efficiency, a data item that is described as USAGE BINARY or USAGE
COMPUTATIONAL is aligned on a 2-byte boundary.
Category of Receiving Item Standard Alignment Rule
Numeric If the receiving data item is numeric, data is aligned by
decimal point and zero-filled or truncated on either end of
each value, as required. When you do not specify a
decimal point in the data item’s description, the decimal
point is assumed to be immediately after the rightmost
character position.
Numeric Edited If the receiving item is numeric edited, data is aligned by
decimal point and zero-filled or truncated on either end of
each value, as required, except where editing would
replace leading zeros.
Alphanumeric
Alphanumeric Edited
Alphabetic
National
If the receiving data item is alphanumeric, alphanumeric
edited, alphabetic, or national, data is aligned at the
leftmost character position and space-filled or truncated to
the right of each value, as required.
Clause or Directive Effect
JUSTIFIED clause Right-justifies an alphanumeric data within a receiving data item
(see JUSTIFIED Clause
)
SYNCHRONIZED clause Aligns an elementary data item on the most natural computer
storage boundary (see SYNCHRONIZED Clause
)
PORT directive Aligns BINARY/COMPUTATIONAL data items on byte
boundaries unless the SYNCHRONIZED clause applies to them,
in which case standard alignment rules apply (see PORT and
NOPORT)