WORKING-STORAGE SECTION

The WORKING-STORAGE SECTION describes data records that are not part of data files but are developed and processed by a program or method. The WORKING-STORAGE SECTION 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.