Examples: initializing data items
The following examples show how you can
initialize many kinds of data items, including alphanumeric, national-edited,
and numeric-edited data items, by using INITIALIZE
statements.
An INITIALIZE
statement is functionally
equivalent to one or more MOVE
statements. The related
tasks about initializing show how you can use an INITIALIZE
statement
on a group item to conveniently initialize all the subordinate data
items that are in a given data category.
Initializing a data item to blanks or zeros:
INITIALIZE identifier-1
identifier-1 PICTURE |
identifier-1 before | identifier-1 after |
---|---|---|
9(5) |
12345 |
00000 |
X(5) |
AB123 |
bbbbb 1 |
N(3) |
004100420031 2 |
002000200020 3 |
99XX9 |
12AB3 |
bbbbb 1 |
XXBX/XX |
ABbC/DE |
bbbb/bb 1 |
**99.9CR |
1234.5CR |
**00.0bb 1 |
A(5) |
ABCDE |
bbbbb 1 |
+99.99E+99 |
+12.34E+02 |
+00.00E+00 |
|
Initializing an alphanumeric data item:
01 ALPHANUMERIC-1 PIC X VALUE "y".
01 ALPHANUMERIC-3 PIC X(1) VALUE "A".
. . .
INITIALIZE ALPHANUMERIC-1
REPLACING ALPHANUMERIC DATA BY ALPHANUMERIC-3
ALPHANUMERIC-3 |
ALPHANUMERIC-1 before |
ALPHANUMERIC-1 after |
---|---|---|
A |
y |
A |
Initializing an alphanumeric right-justified data item:
01 ANJUST PIC X(8) VALUE SPACES JUSTIFIED RIGHT.
01 ALPHABETIC-1 PIC A(4) VALUE "ABCD".
. . .
INITIALIZE ANJUST
REPLACING ALPHANUMERIC DATA BY ALPHABETIC-1
ALPHABETIC-1 |
ANJUST before |
ANJUST after |
---|---|---|
ABCD |
bbbbbbbb 1 |
bbbbABCD 1 |
|
Initializing an alphanumeric-edited data item:
01 ALPHANUM-EDIT-1 PIC XXBX/XXX VALUE "ABbC/DEF".
01 ALPHANUM-EDIT-3 PIC X/BB VALUE "M/bb".
. . .
INITIALIZE ALPHANUM-EDIT-1
REPLACING ALPHANUMERIC-EDITED DATA BY ALPHANUM-EDIT-3
ALPHANUM-EDIT-3 |
ALPHANUM-EDIT-1 before |
ALPHANUM-EDIT-1 after |
---|---|---|
M/bb 1 |
ABbC/DEF 1 |
M/bb/bbb 1 |
|
Initializing a national data item:
01 NATIONAL-1 PIC NN USAGE NATIONAL VALUE N"AB".
01 NATIONAL-3 PIC NN USAGE NATIONAL VALUE N"CD".
. . .
INITIALIZE NATIONAL-1
REPLACING NATIONAL DATA BY NATIONAL-3
INITIALIZE NATIONAL-1 NATIONAL TO VALUE
NATIONAL-3 |
NATIONAL-1 before
first INITIALIZE |
NATIONAL-1 after
first INITIALIZE |
NATIONAL-1 after
second INITIALIZE |
---|---|---|---|
00430044 1 |
00410042 2 |
00430044 1 |
00410042 2 |
|
Initializing a national-edited data item:
01 NATL-EDIT-1 PIC 0NN USAGE NATIONAL VALUE N"123".
01 NATL-3 PIC NNN USAGE NATIONAL VALUE N"456".
. . .
INITIALIZE NATL-EDIT-1
REPLACING NATIONAL-EDITED DATA BY NATL-3
NATL-3 |
NATL-EDIT-1 before |
NATL-EDIT-1 after |
---|---|---|
003400350036 1 |
003100320033 2 |
003000340035 3 |
|
Initializing a numeric (zoned decimal) data item:
01 NUMERIC-1 PIC 9(8) VALUE 98765432.
01 NUM-INT-CMPT-3 PIC 9(7) COMP VALUE 1234567.
. . .
INITIALIZE NUMERIC-1
REPLACING NUMERIC DATA BY NUM-INT-CMPT-3
NUM-INT-CMPT-3 |
NUMERIC-1 before |
NUMERIC-1 after |
---|---|---|
1234567 |
98765432 |
01234567 |
Initializing a numeric (national decimal) data item:
01 NAT-DEC-1 PIC 9(3) USAGE NATIONAL VALUE 987.
01 NUM-INT-BIN-3 PIC 9(2) BINARY VALUE 12.
. . .
INITIALIZE NAT-DEC-1
REPLACING NUMERIC DATA BY NUM-INT-BIN-3
NUM-INT-BIN-3 |
NAT-DEC-1 before |
NAT-DEC-1 after |
---|---|---|
12 |
003900380037 1 |
003000310032 2 |
|
Initializing a numeric-edited (USAGE DISPLAY
)
data item:
01 NUM-EDIT-DISP-1 PIC $ZZ9V VALUE "$127".
01 NUM-DISP-3 PIC 999V VALUE 12.
. . .
INITIALIZE NUM-EDIT-DISP-1
REPLACING NUMERIC-EDITED DATA BY NUM-DISP-3
NUM-DISP-3 |
NUM-EDIT-DISP-1 before |
NUM-EDIT-DISP-1 after |
---|---|---|
012 |
$127 |
$ 12 |
Initializing
a numeric-edited (USAGE NATIONAL
) data item:
01 NUM-EDIT-NATL-1 PIC $ZZ9V NATIONAL VALUE N"$127".
01 NUM-NATL-3 PIC 999V NATIONAL VALUE 12.
. . .
INITIALIZE NUM-EDIT-NATL-1
REPLACING NUMERIC-EDITED DATA BY NUM-NATL-3
NUM-NATL-3 |
NUM-EDIT-NATL-1 before |
NUM-EDIT-NATL-1 after |
---|---|---|
003000310032 1 |
0024003100320037 2 |
0024002000310032 3 |
|