The working-storage section describes data records that are not part of data files but
are developed and processed by a program or method. It also describes data items whose
values are assigned in the source program or method and do not change during execution of
the object program.
The working-storage section must begin with the section header WORKING-STORAGE
SECTION, followed by a separator period.
- Program working-storage
- The working-storage section for programs (and methods) can also describe external
data records, which are shared by programs and methods throughout the run unit. All
clauses that are used in record descriptions in the file section and also the VALUE and
EXTERNAL clauses (which might not be specified in record description entries in the file
section) can be used in record descriptions in the working-storage section.
- Method working-storage
- A single copy of the working-storage for a method is statically allocated on the
first invocation of the method and persists in a last-used state for the duration of the
run unit. The same copy is used whenever the method is invoked regardless of which object
instance the method is invoked upon.
If a VALUE clause is specified on a method
working-storage data item, the data item is initialized to the VALUE clause value on the
first invocation.
If the EXTERNAL clause is specified on a data description entry in a method
working-storage section, a single copy of the storage for that data item is allocated
once for the duration of the run unit. That storage is shared by all programs and methods
in the run unit that contain a definition for the external data item.
- Object working-storage
- The data described in the working-storage section of an object paragraph is object
instance data, usually called instance data. A separate copy of instance data is statically allocated for each
object instance when the object is instantiated. Instance data persists in a last-used
state until the object instance is freed by the Java runtime system.
Instance data can be initialized by VALUE clauses specified in data declarations or by
logic specified in an instance method.
- Factory working-storage
- The data described in the working-storage section of a factory paragraph is factory
data. A single copy of factory data is statically allocated when the factory object for
the class is created. Factory data persists in a last-used state for the duration of the
run unit.
Factory data can be initialized by VALUE clauses specified in data declarations or by
logic specified in a factory method.
The working-storage section contains record description entries and data description
entries for independent data items, called data item description entries.
- record-description-entry
- Data entries in the working-storage section that bear a definite hierarchic
relationship to one another must be grouped into records structured by level number. See Data division--data description entry for more
information.
- data-item-description-entry
- Independent items in the working-storage section that bear no hierarchic relationship
to one another need not be grouped into records provided that they do not need to be
further subdivided. Instead, they are classified and defined as independent elementary
items. Each is defined in a separate data-item description entry that begins with either
the level number 77 or 01. See Data division--data description entry for more
information.