Data Structure and Types of DS in RPG AS400 |
Introduction to Data Structure
The data structure allows users to define an area in the storage and the fields of the data structure are called Subfields in that storage area. So basically, In simple terms, the data structure is comprised of different data types.
Declare Data Structure in Fixed Format RPG
You can declare the data structure in Fixed format RPG by specifying DS in position 24 through 25 in D specs (Definition Specifications).
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++Comments++++++++++++
*************** Beginning of data **************************************************************
D DS1 DS
When you press F4 by placing the cursor on this line. You will see below i.e. DS is specified in Declaration Type.
Prompt type . . . D Sequence number . . . 0001.00
Declaration To /
Name E S/U Type From Length
DS1 DS
Internal Decimal
Data Type Positions Keywords
Comment
Declare Data Structure in Fully Free RPG
You can declare the data structure in a fully free RPG by specifying the DCL-DS followed by the data structure name and keywords.
DCL-DS DS1; SUBFIELD1 CHAR(1); END-DS;
Use of Data Structure
Types of Data Structure in RPG AS400
A Data Structure can be either program described or an externally described DS. Ap program described data structure does not use keyword EXT or EXTNAME in fully free definition or a BLANK in position 22 for the fixed-format definition.
- Externally Described Data Structure
- Multiple Occurrence Data Structure
- Data Area Data Structure
- Qualified Data Structure
- File Information Data Structure
- Indicator Data Structure
- Program Status Data Structure