Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

5.1.2 Working-Storage Section



The Working-Storage Section describes data records that are not part of
X 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
X 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

X The Working-Storage Section for programs (and methods) can also
X describe external data records, which are shared by programs and
X methods throughout the run-unit. All clauses that are used in record descriptions in the File Section as well as 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.


X Method Working-Storage

X A single copy of the Working-Storage for a method is statically
X allocated and persists in a last-used state for the duration of the
X run-unit. The same single copy is used whenever the method is
X invoked, regardless of which object the method is invoked upon.


X If a VALUE clause is specified on a method Working-Storage data item,
X the data item is initialized to the VALUE clause value on the first
X invocation.


X If the EXTERNAL attribute is specified on a data description entry in
X a method Working-Storage Section, a single copy of the storage for
X that data item is allocated once for the duration of the run-unit.
X That storage is shared by all programs and methods in the run-unit
X containing a definition for the external data item.


X Class Working-Storage

X A separate copy of the Class Working-Storage data items is allocated
X for each object instance and remains until that object is destroyed.


X By default, Class Working-Storage data items are global to all of the
X methods introduced by the class.


X To initialize instance data (Class Working-Storage data items), you
X can write a somInit method override. For an example of how to write
X an override method using somInit, see Figure 3. VALUE clauses are not
X supported for initializing instance data.



X IDENTIFICATION DIVISION. X CLASS-ID. OOClass INHERITS SOMObject. X ENVIRONMENT DIVISION. X CONFIGURATION SECTION. X REPOSITORY. X CLASS SOMObject IS "SOMObject" X CLASS OOClass IS "OOClass". X DATA DIVISION. X Working-Storage Section. X 01 instance-data PIC X(3). X PROCEDURE DIVISION.

X IDENTIFICATION DIVISION. X METHOD-ID. "somInit" OVERRIDE. X PROCEDURE DIVISION. X MOVE "new" TO instance-data. X EXIT METHOD. X END METHOD "somInit".

X IDENTIFICATION DIVISION. X METHOD-ID. "MyMethod". X PROCEDURE DIVISION. X IF instance-data = "new" X CALL "Creating" X MOVE "old" TO instance-data X ELSE X CALL "Existing" X END-IF. X EXIT METHOD. X END METHOD "MyMethod".

X END CLASS OOClass.


X Figure 3. Example of a somInit Method Override


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" in topic 5.3 for description.

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" in topic 5.3 for description.


X Note: The data description entries for a class differ from a program
X and method in that:

  • X You cannot specify the EXTERNAL attribute in a data description
    X entry.
  • X The GLOBAL attribute has no effect.
  • X You can only specify the VALUE clause on condition names.


Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.