Data Description Entries (continued) [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
Data Description Entries (continued)
The symbol P indicates an assumed decimal scaling position and is used to
specify the location of an assumed decimal point when the point is not
within the number appearing in the data item.
That is, for each appearance of a P in the PICTURE of a data item, the
data item is assumed to be multiplied by 10, or by one tenth, depending
upon whether the P symbol is on the right, or on the left of the
character string used to define the field.
The P in a character string does not occupy a position in memory and does
not add to the size of the item. However, the P has the effect of the
digit 0 whenever the item is accessed. When the data item is used for
arithmetic operations, the P must be counted as a digit to determine
whether the field exceeds the 18-digit maximum size for a numeric field.
One or more P symbols can only be placed at either the left or the right
end of a character string. Because P represents a decimal position, the
use of the P symbol and the V symbol as the left or rightmost symbol in
the same string is redundant.
Therefore, if the V symbol is used with the P symbol, it is meaningful
only if it appears as the leftmost or rightmost symbol in the character
string.
The following illustrates the use of the P symbol:
* Input data: 241000
* PICTURE clause: 999P(3)
* Data stored as: 241
* Data accessed as: 241000.
Using the following PICTURE clause for the number 00000241
PICTURE P(5)999
results in the data being stored as 241, but being accessed as .00000241.
A repetition factor may be used with the P symbol. Therefore, PPPPP99 is
equivalent to P(5)99.
All numeric literals used in a VALUE clause must have a value that is
within the range of values indicated in the PICTURE clause. For example,
the range of values permitted for an item with the PICTURE PPP999 are
.000000 through .000999.
Alphanumeric Data.
Alphanumeric data is made up of any valid character used on an HP
computer.
To define an alphanumeric data item, you can use the symbols A, 9, or X.
The PICTURE clause for this type of data, however, must contain at least
one X symbol, or a combination of the A and 9 symbols to indicate that it
represents an alphanumeric data item.
The A symbol can be used to represent alphabetic characters or a space,
while the 9 symbol can be used to represent numerals. However, the
entire PICTURE clause is treated as if it consists entirely of X symbols,
where each X symbol can represent any single character used on an HP
computer.
Repetition factors may be used with all these symbols. For example,
77 FINISHER PICTURE A(5)9(8).
is equivalent to:
77 FINISHER PICTURE X(13).
Alphanumeric-Edited Data.
Alphanumeric data is data consisting of any set of characters available
on an HP computer. This type of data can be edited by specifying where
one or more spaces, strokes, or zeros are to appear as part of the
receiving data item.
You can use the A, X, 9, B, 0 (zero), and / symbols to define a data item
to receive an edited alphanumeric data item. The A, X, 9, and B symbols
are explained under the headings "Alphabetic Data," "Numeric Data,"
"Alphanumeric Data," and "Numeric-edited," respectively.
The 0 symbol is used to specify where in the character string the numeral
0 is to be inserted.
The / (stroke) symbol represents where in the character string a stroke
symbol is to be inserted.
All of the symbols used in an alphanumeric-edited PICTURE clause may use
a repetition factor.
The PICTURE character string of an alphanumeric-edited data item is
restricted to certain combinations of the following symbols:
A, X, 9, B, 0, and /
The PICTURE clause must contain at least one A or X, and must contain at
least one B, 0 (zero), or / (stroke).
For example,
Sending data item: 010685
PICTURE of receiving data item: 99/99/99
Receiving data item: 01/06/85
Sending data item: NAMEADDRESSPHONENUMBERZIPCODE
PICTURE of receiving data item: PICTURE
A(4)B(5)A(7)B(5)A(5)BA(6)/A(7)
Receiving data item: NAME_____ADDRESS_____PHONE_NUMBER/ZIPCODE
Numeric-Edited Data.
In standard data format, numeric-edited data consists of a combination of
the numerals zero through 9 and an optional decimal point.
Editing of this type of data in HP COBOL II consists of leading zero
suppression, filling or replacement, placement and alignment of a decimal
point and a currency symbol, insertion of a sign, commas, blanks, or
strokes. This is accomplished through use of the following symbols:
P, V, 9, B, /, r, Z, (,), (.), *, +, -, CR, DB
and the currency symbol as defined in the CURRENCY SIGN clause of the
SPECIAL-NAMES paragraph in the ENVIRONMENT DIVISION. To distinguish this
type of data from unedited numeric data, at least one of the above
symbols (except the 9) must appear in the PICTURE clause.
A maximum of 18 digit positions can be represented in this type of
PICTURE.
The first three of the above symbols are described under the heading,
"Numeric Data", and the second set of three are described under the
heading, "Alphanumeric-Edited Data". The remaining symbols are described
below.
The Z symbol is used for the suppression of leading zeros in the
receiving data item. It can only be used to represent the leftmost
leading numeric character positions.
The comma symbol (,) represents where in the character string of the
receiving data item a comma is to be inserted. It cannot be the
rightmost character in the PICTURE clause unless followed by the period
symbol (.).
The period symbol (.) represents the decimal point for aligning the
sending and receiving data items and also represents a character position
into which a period (decimal point) is to be inserted. It may not be
used if the V symbol is used, and may only appear once in a given PICTURE
clause if the DECIMAL POINT IS COMMA clause is not specified in the
SPECIAL-NAMES paragraph. Also, it may not appear as the rightmost
element in the PICTURE clause unless followed by the decimal point (.).
The P symbol and the decimal point (.) cannot be used in the same
PICTURE character string.
If the DECIMAL POINT clause is specified, the roles of the commas and
period symbols are reversed. Therefore, in such a case, only one comma
symbol may appear in a numeric-edited PICTURE clause, but several periods
may appear. The plus (+), minus (-), CR (for CRedit), and DB (for DeBit)
are used as editing sign control symbols. Only one of these symbols may
appear in any given PICTURE clause, and when used, specify the position
in the receiving data item into which the editing sign control symbol
will be placed.
The asterisk (*) symbol is used for replacing leading zeros. Each
leading zero in the sending data item is replaced in the receiving data
item by an asterisk if there is an asterisk in the PICTURE clause for the
receiving data item whose position corresponds to the position of the
zero in the sending data item.
This symbol may not appear in a PICTURE clause for a data item which has
the BLANK WHEN ZERO clause specified for it.
The appearance of a currency symbol in a PICTURE clause represents the
position into which a currency symbol is to be placed. If you do not
specify an alternative currency symbol through the CURRENCY SIGN clause
of the SPECIAL-NAMES paragraph, the dollar ($) symbol is used.
This symbol must appear as the leftmost symbol in the character string,
except that it may be preceded by a plus (+) or minus (-) symbol.
With the exception of the symbols V, CR, DB, and period (.), all of the
symbols described above may be specified using a repetition factor.
To illustrate edited numeric data:
Sending data item: -1234.59
PICTURE clause of the receiving data item: PICTURE 99,999.99DB
[REV BEG]
Receiving data item: 01,234.59DB[REV END]
Note in the second example that the DECIMAL-POINT IS COMMA clause is
assumed.
Sending data item: 345777.78
PICTURE clause of the receiving data item: PICTURE
+$ZZZ,ZZZ,ZZZ,ZZZ.99
[REV BEG]
Receiving data item: +$ 345.777,78[REV END]
Table 7-2 summarizes the editing picture characters and their
function.
Table 7-2. Editing Picture Characters
-----------------------------------------------------------------------------
| Picture | Symbol | Editing |
| Characters | Definition | Function |
-----------------------------------------------------------------------------
- B - Letter B - Inserts a blank. -
-----------------------------------------------------------------------------
| / | Slash | Inserts a slash |
| | | character. |
-----------------------------------------------------------------------------
- 0 - Zero - Inserts a zero digit. -
-----------------------------------------------------------------------------
- . - Decimal point - Inserts a decimal point. -
-----------------------------------------------------------------------------
- , - Comma - Inserts a comma. -
-----------------------------------------------------------------------------
- + - Plus sign - Inserts + or - sign. -
-----------------------------------------------------------------------------
- - - Minus sign - Inserts - or blank. -
-----------------------------------------------------------------------------
- CR - Credit sign - Inserts CR. -
-----------------------------------------------------------------------------
- DB - Debit sign - Inserts DB. -
-----------------------------------------------------------------------------
- $ - Dollar sign - Inserts currency symbol. -
-----------------------------------------------------------------------------
| Z | Letter Z | Zero suppression by |
| | | blank. |
-----------------------------------------------------------------------------
- * - Asterisk - Zero suppression by *. -
-----------------------------------------------------------------------------
Size of Elementary Data Items.
The size of an elementary data item is defined as being the number of
character positions occupied by the elementary item in standard data
format. This size is determined by counting the number of allowable
symbols used to represent character positions within a PICTURE clause for
that item.
With the exception of the S, V, period (.), CR and DB symbols, all
symbols in the PICTURE clause may use repetition factors. These
repetition factors are represented by an integer enclosed by parentheses
following the symbol to which they pertain, and indicate the number of
consecutive occurrences of the symbol.
Furthermore, if the SEPARATE CHARACTER phrase of the SIGN clause is not
specified, the V symbol and the S symbol do not participate in the count
when you are determining the size of the data item.
DB and CR each represent two character positions.
When you count occurrences of characters in an elementary data item
description, you must only count those symbols that appear without
repetition factors, and add them to the sum of all integers appearing in
repetition factors for that PICTURE clause.
Examples.
The size of the data item represented by the following PICTURE clause is
11 characters.
PICTURE ZZZ,999V99CR
The size of the data item represented by the next PICTURE clause is 17
characters.
PICTURE A(10)B(5)XX
In the next PICTURE clause, assume that the SIGN IS SEPARATE clause is
NOT specified for the data item represented by the PICTURE clause below.
PICTURE S9(5)V99
The size of the item described above is 7 characters.
Editing Rules.
There are two general methods for performing editing in the PICTURE
clause: insertion, and zero suppression and replacement.
Editing takes place only when data is moved into an elementary data item
whose PICTURE clause specifies editing (that is, whose PICTURE clause is
alphabetic, alphanumeric-edited or numeric-edited). Therefore, data
moved into a numeric field is not edited.
You may perform simple insertion editing for an item belonging to the
alphabetic or alphanumeric-edited categories.
Three other types of insertion, as well as suppression and replacement,
may be performed on numeric-edited data: special, fixed, and floating
insertion.
Table 7-3 below summarizes the type of editing permitted for each
category.
Table 7-3. Allowable Types of Editing For Categories of Data Items
-----------------------------------------------------------------------
| | |
| Category | Type of Editing |
| | |
-----------------------------------------------------------------------
| | |
| Alphabetic | Simple insertion B only |
| | |
-----------------------------------------------------------------------
| | |
| Numeric | None |
| | |
-----------------------------------------------------------------------
| | |
| Alphanumeric | None |
| | |
-----------------------------------------------------------------------
| | |
| Alphanumeric-Edited | Simple insertion (0), (,), (B), and (/) |
| | |
-----------------------------------------------------------------------
| | |
| Numeric-Edited | All |
| | |
-----------------------------------------------------------------------
Simple Insertion Editing.
The comma (,), space (B), zero (0), and stroke (/) symbols are used in
simple insertion editing. These insertion characters are counted in the
size of the receiving item and represent the position in the receiving
item into which the character is inserted.
Simple insertion editing is so called because, other than inserting the
particular symbol, no other editing is done and the data sent is
unaffected except for the placement of the simple insertion characters
between, before, or after the other characters received from the sending
data item.
An example of simple insertion editing is shown in the illustration under
the heading, "Alphanumeric-Edited Data", on the preceding pages.
Special Insertion Editing.
The period (.) is used in special insertion editing. In addition to
being an insertion character, it is also used for alignment purposes when
the sending data item is numeric and contains a decimal point. The
result of this form of editing is the appearance of the period in the
same position as it appears in the PICTURE clause for the item.
When data is moved to an item defined with the special insertion
character, COBOL automatically provides truncation and zero fill to both
the left and the right of the decimal point. However, if zero
suppression or floating insertion editing is included in the PICTURE
clause of the receiving data item, zero fill normally produced by special
insertion editing is overridden.
The following illustrates special editing:
Sending data item: 12345.678
PICTURE clause of receiving data item: 9(5).99
Receiving data item: 12345.67
Note that the rightmost digit, 8, was truncated. This was caused by the
alignment of decimal points.
Sending data item: .001
PICTURE clause of receiving data item: 9,999.9999
Receiving data item: 0,000.0010
Finally:
Sending data item: 658456.995
PICTURE clause of receiving data item: 999.99
Receiving data item: 456.99
Fixed Insertion Editing.
Fixed insertion editing uses the currency symbol and the editing sign
control symbols, +, -, CR, and DB.
Only one currency symbol and one editing sign control symbol can be used
in a given PICTURE clause when you wish to use fixed insertion editing.
When the CR or DB symbol is used, each represents two characters, and
must be in the rightmost character positions counted in determining the
size of the receiving item.
When the + or - symbol is used, it must be either the leftmost or
rightmost character in the PICTURE clause for the receiving item, and is
counted in the size of that item.
The currency symbol must be the leftmost character position to be counted
in the size of the item, except that it may be preceded by a + or a -
symbol.
Fixed insertion editing results in the insertion character occupying the
same character position in the receiving item as it does in the character
string used in the PICTURE clause.
The sign control symbols produce different results, depending upon
whether the sending data item is positive or negative. These differing
results are shown in Table 7-4 below.
Table 7-4. Effects of Sign Control Symbols on Receiving Items
----------------------------------------------------------------------------------------------
| Editing Symbol in | Result |
| Character String | |
----------------------------------------------------------------------------------------------
- - Data Item Positive - Data Item Negative -
----------------------------------------------------------------------------------------------
- + - + - - -
----------------------------------------------------------------------------------------------
- - - space - - -
----------------------------------------------------------------------------------------------
- CR - 2 spaces - CR -
----------------------------------------------------------------------------------------------
- DB - 2 spaces - DB -
----------------------------------------------------------------------------------------------
Floating Insertion Editing.
Floating insertion editing uses the currency, +, or - symbol. Each
symbol is mutually exclusive of the others when you wish to perform this
type of editing.
Also, zero suppression and replacement cannot be used in the same
character string of a PICTURE clause using floating insertion editing.
You can represent floating insertion editing in one of two ways. The
first is to represent any or all of the leading numeric positions to the
left of the decimal point with your chosen floating insertion character.
The second way is to represent every numeric character position, on both
sides of the decimal point, with the insertion character.
Floating insertion editing is indicated by an occurrence of the same
symbol used at least twice in the same string. This is the major
distinction between fixed and floating insertion editing.
Between or to the right of this floating insertion string, can be any of
the simple insertion characters. If such is the case, the simple
insertion characters are a part of the floating insertion character
string.
The bounds of the floating insertion string (including the simple
insertion characters, as noted above) are formed by the leftmost and the
rightmost elements of the floating string.
Nonzero numeric data can be stored in the receiving data item starting at
the first character to the right of the leftmost character in the
floating string, and proceeding through the entire floating string.
If the floating insertion characters are only to the left of the decimal
point, insertion takes place in a fashion analogous to the following
algorithm:
1. The leading character of the sending data item is checked to see
if it has a zero value. If it is zero, the floating insertion
character is inserted in the corresponding character position of
the receiving data item and the preceding character of this data
item is replaced with a space.
2. The next character of the sending data item is then checked for a
zero value, and if it is zero, the action described in step 1 is
repeated.
3. The process continues either until no numeral in the sending data
item is nonzero (in which case all the positions corresponding to
the floating insertion string in the receiving data item are
replaced with spaces), or some nonzero numeral is found in the
sending data item and this numeral appears to the left of the
decimal place.
If any simple insertion character appears as part of the floating
insertion string, and no nonzero character is encountered in the sending
data item before the next floating insertion character position is
considered, one simple insertion character is replaced by the floating
insertion character, and the preceding floating insertion character is
replaced by a space.
When a nonzero numeral is encountered in the data item, that numeral and
all following it are replaced in the positions corresponding to their
positions in the floating insertion string.
If the floating insertion characters correspond to every numeric
character position, including those to the right of the decimal point,
the algorithm is the same as above, with one exception.
The exception is when the original data item is zero. In this case, the
result of floating insertion editing is that the data item referenced by
the PICTURE clause contains only spaces.
Note that to avoid truncation, your character string in the PICTURE
clause for the receiving data item must be, minimally, the size of the
number of characters in the sending data item, plus the number of
nonfloating insertion characters being inserted into the receiving data
item, plus one for the first floating insertion character. To illustrate
floating insertion editing, the following example uses a sending data
item that is 00123.45, in standard data format and uses the PICTURE
clause to describe the receiving data item:
PICTURE $$$,$$$.99
Using the algorithm described above, the steps taken appear as follows:
1. First character equal to 0? Yes. Therefore, receiving data item
appears as _$.
2. Second character equal to 0? Yes. Therefore, receiving data item
appears as ___$ (Because the comma preceded the first occurrence
of a nonzero numeral).
3. Third character equal to 0? No. Therefore, receiving data
item[REV BEG] appears as ___$123.45[REV END]
[REV BEG]Result: ___$123.45[REV END]
Note that if the PICTURE clause had been of the form:
PICTURE $$$.99
[REV BEG]
the result would be $23.45 because of truncation of the[REV END] sending
data item to allow for insertion of the floating character, $, in the
receiving data item.
Zero Suppression Editing.
Zero suppression editing allows you to replace leading zeros of the
sending data item with either spaces or asterisks in the receiving data
item.
You can replace one or more leading zeros with spaces by placing a Z in
the corresponding positions of the PICTURE character string used to
represent the receiving data item.
If you wish to replace leading zeros with asterisks (*), use a string of
asterisks rather than Z's in the PICTURE for the receiving data item.
You may use either the Z symbol or the * symbol, but not both, in any one
PICTURE clause.
The algorithm used in zero suppression and replacement is essentially the
same as the algorithm used for floating insertion editing. That is, any
simple insertion symbols may appear between the first and last symbol or
to the right of the last suppression symbol, and are included as part of
the suppression string.
Furthermore, if the suppression symbols appear only to the left of the
decimal point, any leading zero in the sending data item that corresponds
to a suppression symbol is replaced by that suppression symbol.
Suppression terminates with the first occurrence of a nonzero numeral in
the sending data item or with the decimal point, whichever occurs first.
If all numeric character positions are represented by suppression symbols
and the sending data item is zero, the entire receiving data item
consists of spaces (if Z's are used) or asterisks (if asterisks are
used), except for the decimal point.
If all numeric characters are represented in the receiving data item by
suppression or replacement symbols, and the sending data item is not
zero, suppression and replacement take place in the same manner as if the
suppression symbols appeared only to the left of the decimal place.
Note that you may not use floating insertion editing in the same PICTURE
clause in which you are using zero suppression and replacement. The
following illustrates zero suppression and replacement:
Sending data item in standard data format: 004053.67
Picture of receiving data item: PICTURE $ZZZ,ZZZ.ZZ
Result: $__4,053.67
Using the same sending data item, but with the following picture of the
receiving data item:
PICTURE $***,**9.99
results in:
$**4,053.67
Precedence Rules.
Table 7-5 shows the order of precedence when using insertion,
suppression, or replacement symbols in a character string of a PICTURE
clause.
An x at an intersection indicates that the symbol at the top of the
column may precede the symbol at the left of the row. Multiple symbols
in a box (except for A and X) are mutually exclusive. The leters "cs"
indicate the currency symbol.
The +, -, Z, *, cs, and P symbols appear twice in the Non-Floating and
Floating insertion symbols sections of Table 7-5 . The lefthand
column and the upper row of each of these pairs represents the use of the
symbol to the left of the decimal point. The righthand column and lower
row represent the use to the right of the decimal point.
Table 7-5. PICTURE Character Precedence Chart
---------------------------------------------------------------------------------------------------------------
| | |
| | First Symbol |
| | |
| Second | |
| Symbol | |
| | |
---------------------------------------------------------------------------------------------------------------
| | |
| | Non-Floating |
| | Insertion Symbols |
| | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| | | | | | | + | + | CR | |
| | B | 0 | / | , | . | - | - | DB | cs |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| B | x | x | x | x | x | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| 0 | x | x | x | x | x | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| / | x | x | x | x | x | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| , | x | x | x | x | x | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| . | x | x | x | x | | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| + - | | | | | | | | | |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| + - | x | x | x | x | x | | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| CR DB | x | x | x | x | x | | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| cs | | | | | | x | | | |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| Z * | x | x | x | x | | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| Z * | x | x | x | x | x | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| + - | x | x | x | x | | | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| + - | x | x | x | x | x | | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| cs | x | x | x | x | | x | | | |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| cs | x | x | x | x | x | x | | | |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| 9 | x | x | x | x | x | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| A X | x | x | x | | | | | | |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| S | | | | | | | | | |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| V | x | x | x | x | | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| P | x | x | x | x | | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
| | | | | | | | | | |
| P | | | | | | x | | | x |
| | | | | | | | | | |
---------------------------------------------------------------------------------------------------------------
Table 7-6. PICTURE Character Precedence Chart (Continued)
----------------------------------------------------------------------------------------------------------------------
| | |
| | First Symbol |
| | |
| Second | |
| Symbol | |
| | |
----------------------------------------------------------------------------------------------------------------------
| | | |
| | Floating | |
| | Insertion Symbols | Other Symbols |
| | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| | Z | Z | + | + | | | | A | | | | |
| | * | * | - | - | cs | cs | 9 | X | S | V | P | P |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| B | x | x | x | x | x | x | x | x | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| 0 | x | x | x | x | x | x | x | x | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| / | x | x | x | x | x | x | x | x | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| , | x | x | x | x | x | x | x | | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| . | x | | x | | x | | x | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| + - | | | | | | | | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| + - | x | x | | | x | x | x | | | x | x | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| CR DB | x | x | | | x | x | x | | | x | x | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| cs | | | | | | | | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| Z * | x | | | | | | | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| Z * | x | x | | | | | | | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| + - | | | x | | | | | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| + - | | | x | x | | | | | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| cs | | | | | x | | | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| cs | | | | | x | x | | | | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| 9 | x | | x | | x | | x | x | x | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| A X | | | | | | | x | x | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| S | | | | | | | | | | | | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| V | x | | x | | x | | x | | x | | x | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| P | x | | x | | x | | x | | x | | x | |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
| | | | | | | | | | | | | |
| P | | | | | | | | | x | x | | x |
| | | | | | | | | | | | | |
----------------------------------------------------------------------------------------------------------------------
REDEFINES Clause
The REDEFINES clause allows you to define the same storage area in main
memory for different data items whose lengths are not described as
variable in an OCCURS clause.
Syntax.
Parameters.
level-number level number and data name of the data item being
and data-name-1 described; these are not part of the REDEFINES clause.
and FILLER When the REDEFINES clause is used in a data description
entry, it must be immediately preceded by level-number
and data-name-1.
data-name-2 data name used in a different data description entry; it
must have the same level number associated with it as
does data-name-1. The level number must not be 66 or
88, nor can it be 01, if the REDEFINES clause is used in
the FILE SECTION.
Description.
Redefinition of storage area begins at the data-name-1 entry and
continues until a level number less than or equal to that of data-name-1
(or data-name-2 since they are the same) is found.
Because data-name-1 is a redefinition of the storage area for
data-name-2, no entry having a level number numerically lower than the
level number of data-name-2 may occur between the data description
entries of data-name-2 and data-name-1.
Furthermore, the description entry for data-name-2 cannot contain a
REDEFINES or an OCCURS clause, but may be subordinate to an entry that
contains one of these clauses.
If the data description entry for an item to which data-name-2 is
subordinate contains an OCCURS clause, the reference to data-name-2 in
the REDEFINES clause must not be subscripted or indexed.
If the level number of data-name-1 and data-name-2 is other than 01 or
data-name-2 is an external record, the description of data-name-1 must
specify less than or the same number of character positions as specified
for the data item referenced by data-name-2.
Multiple redefinitions of the same character positions are permitted in
COBOL. However, multiple redefinitions of the same character positions
must all use the data name of the entry that was originally used to
define the area. The entries providing the new descriptions must
immediately follow the entries used to define the area currently being
redefined and the new entries must not (except in the case of condition
name entries) contain any VALUE clauses.
Examples.
01 RECORD-IN PICTURE X(80).
01 RECORD-PARTS REDEFINES RECORD-IN.
02 NAME PICTURE X(30).
02 STREET PICTURE X(20).
02 CITY PICTURE X(20).
02 STATE PICTURE X(10).
01 PARTS-TABLE.
02 PART OCCURS 35 TIMES.
03 NAME PIC X(10).
03 QUANTITY PIC 9(04).
03 UNIT-PRICE PIC 9(06).
03 LOCALE PIC X(10).
03 SITE-INFO REDEFINES LOCALE.
04 BUILDING-NO PIC X(03).
04 FLOOR-NO PIC X(02).
04 SECTION-NO PIC X(02).
04 BIN-NO PIC X(03).
The above two uses of the REDEFINES clause are permissible, whereas the
following two are not.
05 VOCABULARY OCCURS 2000 TIMES PIC X(100).
05 WORDLIST REDEFINES VOCABULARY.
20 INITIAL PIC X(20).
20 SECOND PIC X(30).
20 THIRD PIC X(30).
20 FOURTH PIC X(20).
01 RECORD-IN.
02 FIRST-FIELD.
03 SUB-AA PIC X(15).
02 SECOND-FIELD.
03 SUB-BB REDEFINES SUB-AA PIC X(15) VALUE SPACES.
03 SUB-BB1 PIC X(05).
The first unacceptable usage above is because of the use of an OCCURS
clause in the description of VOCABULARY. The second is unacceptable
because of the 02 level entry between SUB-AA and SUB-BB. The new entry
may not contain any value clauses.
MPE/iX 5.0 Documentation