🗂️ What is DATA DIVISION?
-
Defines variables used in the program.
-
Must declare data before use.
-
Optional but important.
-
Divided into sections: FILE, WORKING-STORAGE, LOCAL-STORAGE, LINKAGE
🧩 Important Sections
-
FILE SECTION: File record structures.
-
WORKING-STORAGE: Constants, temp variables (initialized once).
-
LOCAL-STORAGE: Variables initialized every program run.
-
LINKAGE: Parameters passed by calling program.
🔢 Data Items & Levels
-
01: Record or elementary item (start Area A).
-
02–49: Group or elementary item (Area A or B).
-
66: RENAMES clause items.
-
77: Independent data items (start Area A).
-
88: Condition names.
🧱 Group vs Elementary Data Items
Group: Contains smaller items, no PIC clause.
Elementary: No subdivisions, requires PIC clause.
📝 Variable Naming Rules
-
Use alphabets, digits, hyphens.
-
Length 1 to 30 chars.
-
No reserved words or spaces.
-
Cannot start with special characters.
⚠️ FILLER
-
Used for unnamed data fields.
-
Cannot be used in operations.
-
Useful for padding or reserved spaces.
🖼️ PICTURE Clause
-
Defines data type, size, sign, decimals.
-
Numeric (9), Alphabetic (A), Alphanumeric (X).
-
Not for groups or level 88.
💡 VALUE Clause
Initializes variables in WORKING-STORAGE only.
🔄 REDEFINES Clause
-
Shares memory for variables with different formats.
-
Redefining & redefined items must be compatible & adjacent.
-
Not allowed on levels 01, 66, or 88.
🏷️ RENAMES Clause
-
Assigns a new name to sequential data items at the same level.
-
Can not rename level 01 or 77.
-
Can not rename items with OCCURS clause.