Using a Data Structure to group fields in RPG AS400 |
In this example, we will see how the data structure is used to group fields. All the subfields groupd to form single DS field DS1.
Coding RPG Data Structure to group fields in Fixed, Free and Fully Free format
RPG Code in Fixed format for Using a Data Structure to group the fields
D DS1 DS D subfld1 2P 0 D subfld2 2A D subfld3 3S 0 D subfld4 5A C EVAL subfld1 = 20 C EVAL subfld2 = 'AB' C EVAL subfld3 = 200 C EVAL subfld4 = 'HELLO' C subfld1 DSPLY C subfld2 DSPLY C subfld3 DSPLY C subfld4 DSPLY C SETON LR
RPG Code in /Free format for Using a Data Structure to group the fields
D DS1 DS D subfld1 2P 0 D subfld2 2A D subfld3 3S 0 D subfld4 5A /Free subfld1 = 20 ; subfld2 = 'AB'; subfld3 = 200; subfld4 = 'HELLO'; DSPLY subfld1; DSPLY subfld2; DSPLY subfld3; DSPLY subfld4; *INLR = *ON; /End-Free
RPG Code in fully Free format for Using a Data Structure to group the fields
**FREE DCL-DS DS1; subfld1 packed(2:0); subfld2 char(2); subfld3 zoned(3:0); subfld4 char(5); END-DS; subfld1 = 20 ; subfld2 = 'AB'; subfld3 = 200; subfld4 = 'HELLO'; DSPLY subfld1; DSPLY subfld2; DSPLY subfld3; DSPLY subfld4; *INLR = *ON;
Output
DSPLY 20 DSPLY AB DSPLY 200 DSPLY HELLO
Related Post
Read also :
- Data Structure and Types of DS in RPG AS400
- Using a Data Structure to subdivide the field 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
- Array Data Structures in RPG AS400
- Defining Data Structure Parameters in a Prototype or Procedure Interface