Using a Data Structure to subdivide the field in RPG AS400 |
In this example, Data structure is being used to break fields into several subfields as below. Field SUBFLD1 break into subfields SUBFLD2, SUBFLD3 and SUBFLD4.
Coding RPG Data Structure to subdivide the field in Fixed, Free, and Fully Free format
RPG Code in Fixed format for Using a Data Structure to subdivide the field
D DS1 DS D subfld1 1 5 D subfld2 1 2 D subfld3 3 4 D subfld4 5 5 D subfld5 6 8 C EVAL subfld1 = 'ABCDE' C EVAL subfld5 = 'FGH' C subfld1 DSPLY C subfld2 DSPLY C subfld3 DSPLY C subfld4 DSPLY C subfld5 DSPLY C SETON LR
RPG Code in /Free format for Using a Data Structure to subdivide the field
D DS1 DS D subfld1 1 5 D subfld2 1 2 D subfld3 3 4 D subfld4 5 5 D subfld5 6 8 /Free subfld1 = 'ABCDE'; subfld5 = 'FGH'; DSPLY subfld1; DSPLY subfld2; DSPLY subfld3; DSPLY subfld4; DSPLY subfld5; *INLR = *ON; /End-Free
RPG Code in fully Free format for Using a Data Structure to subdivide the field
**FREE DCL-DS DS1; subfld1 char(5) pos(1); subfld2 char(2) pos(1); subfld3 char(2) pos(3); subfld4 char(1) pos(5); subfld5 char(3) pos(6); END-DS; subfld1 = 'ABCDE'; subfld5 = 'FGH'; DSPLY subfld1; DSPLY subfld2; DSPLY subfld3; DSPLY subfld4; DSPLY subfld5; *INLR = *ON;
Output
DSPLY ABCDE DSPLY AB DSPLY CD DSPLY E DSPLY FGH
Related Post
Read also :
- Data Structure and Types of DS 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
- Array Data Structures in RPG AS400
- Defining Data Structure Parameters in a Prototype or Procedure Interface