Array Data Structures in RPG AS400 |
Introduction to Array Data Structure
It is a data structure defined with the keyword DIM. An Array data structure is like a multiple occurrence data structure except that the index has to be specified for Arrays.
The syntax for Array Data Structure Declaration
D DS1 DS QUALIFIED DIM(2) D subfld1 10 D subfld2 5 D subfld3 5
**FREE dcl-ds ds1 qualified dim(2); subfld1 char(10); subfld2 char(5); subfld3 char(5); end-ds ds1;
Coding Array Data Structure in RPG AS400
RPG Code in Fixed format for Array Data Structures in RPG AS400
D DS1 DS QUALIFIED DIM(2) D subfld1 10 D subfld2 5 D subfld3 5 C EVAL DS1(1).subfld1 = 'DS1_1' C EVAL DS1(1).subfld2 = 'DS1_2' C EVAL DS1(1).subfld3 = 'DS1_3' C ds1(1) DSPLY C EVAL DS1(2).subfld1 = 'DS1_4' C EVAL DS1(2).subfld2 = 'DS1_5' C EVAL DS1(2).subfld3 = 'DS1_6' C ds1(2) DSPLY C SETON LR
RPG Code in /Free format for Array Data Structures in RPG AS400
D DS1 DS QUALIFIED DIM(2) D subfld1 10 D subfld2 5 D subfld3 5 /Free DS1(1).subfld1 = 'DS1_1'; DS1(1).subfld2 = 'DS1_2'; DS1(1).subfld3 = 'DS1_3'; dsply ds1(1); DS1(2).subfld1 = 'DS1_4'; DS1(2).subfld2 = 'DS1_5'; DS1(2).subfld3 = 'DS1_6'; dsply ds1(2); *INLR = *ON; /End-Free
RPG Code in fully Free format for Array Data Structures in RPG AS400
**FREE dcl-ds ds1 qualified dim(2); subfld1 char(10); subfld2 char(5); subfld3 char(5); end-ds; DS1(1).subfld1 = 'DS1_1'; DS1(1).subfld2 = 'DS1_2'; DS1(1).subfld3 = 'DS1_3'; dsply ds1(1); DS1(2).subfld1 = 'DS1_4'; DS1(2).subfld2 = 'DS1_5'; DS1(2).subfld3 = 'DS1_6'; dsply ds1(2); *INLR = *ON;
Output
DSPLY DS1_1 DS1_2DS1_3 DSPLY DS1_4 DS1_5DS1_6
Related Post
Read also :
- Data Structure and Types of DS in RPG AS400
- Using a Data Structure to subdivide the field in RPG AS400
- Using a Data Structure to group fields in RPG AS400
- Externally Described Data Structure in RPG AS400
- Using EXTFLD to code Externally Described DS in RPG AS400
- Using PREFIX to rename all fields in an external data structure in RPG AS400
- Define an externally-described data structure using the LIKEREC keyword in RPG AS400
- Difference between LIKEREC and EXTNAME keyword in RPG AS400
- Multiple Occurrence Data Structure in RPG AS400
- Data Area Data Structure in RPG AS400
- *LDA Local data area data structure in RPG AS400
- File information data structures (INFDS) in RPG AS400
- Indicator data structure in RPG AS400
- Program Status Data Structure in RPG AS400
- Using keywords QUALIFIED, LIKEDS, and DIM with data structures
- Defining Data Structure Parameters in a Prototype or Procedure Interface