Repository navigation
Data Structures
Daniel Long edited this page Sep 29, 2026
·
2 revisions
DCL-DS employee QUALIFIED;
id INT(10);
name VARCHAR(50);
salary PACKED(9:2);
END-DS;
employee.id = 1;
employee.name = 'Alice';
employee.salary = 75000.00;
DSPLY employee.name;DCL-DS item QUALIFIED DIM(10);
code CHAR(5);
description VARCHAR(50);
price PACKED(7:2);
END-DS;
item(1).code = 'A001';
item(1).description = 'Widget';
item(1).price = 9.99;DCL-DS address QUALIFIED;
street VARCHAR(100);
city VARCHAR(50);
state CHAR(2);
END-DS;
DCL-DS shipping LIKEDS(address);
shipping.city = 'Springfield';As on IBM i, a data structure without INZ starts as blanks, not zeros.
A character subfield is blank, an integer subfield reads as what blank bytes
decode to (INT(10) is 1077952576, INT(5) 16448), and a packed or zoned
subfield holds no decimal data at all: using it before assigning it is a
decimal data error (status 907).
DCL-DS totals QUALIFIED INZ; // every subfield starts at its type's default
count INT(10);
amount PACKED(9:2);
label CHAR(10) INZ('TOTAL'); // a subfield INZ sets that subfield alone
END-DS;
DCL-DS work QUALIFIED; // no INZ: blanks until assigned
qty PACKED(5:0) INZ(1); // ...except this subfield
price PACKED(7:2);
END-DS;LIKEDS copies the layout, not the initialization: DCL-DS a LIKEDS(b)
starts blank, INZ gives it type defaults, and INZ(*LIKEDS) initializes
it as b is. CLEAR sets every subfield to its type's default; RESET
restores the state the data structure was declared with.
- Installation
- Quick Start
- CLI Reference
- Language Basics
- Data Types
- Variables and Constants
- Data Structures
- Arrays
- Varying-Dimension Arrays
- Control Flow
- Procedures
- Procedure Overloading
- Built-In Functions
- Error Handling
- Operation Extenders
- Enumerations
- Program Status Data Structure
- Data Areas
- SND-MSG
- Embedded SQL
- Record-Level Access
- Display Files (WORKSTN)
- Program-Described Files (I-Specs and O-Specs)
- DATA-INTO and DATA-GEN
- XML-INTO
- Fixed-Format Source
- Database Connections
- Multi-Module Programs
- Environment Variables
- Testing
- Complete Example: Employee Report
- IBM i Conformance Results
- IBM i Execution Results