Define an externally-described data structure using the LIKEREC keyword in RPG AS400 |
Using the LIKEREC keyword to define the data structure
LIKEREC keyword is used to define data structure, its subfield, prototype parameter like a record, prototype return value.
LIKEREC has two paramters.
LIKEREC(RecordFormatName:extracttype)
The first parameter accepts the Record format name. The second parameter is optional and can have the following values.
A data structure defined using the LIKEREC keyword is a QUALIFIED data structure. Subfields can also be declared using the LIKEREC keyword which in itself becomes data structure.
Coding an externally-described data structure using the LIKEREC keyword
RPG Code in Fixed format for Externally Described Data Structure using LIKEREC keyword.
FRPGLE14PF IF E DISK D ds1 DS LIKEREC(Rcdfmt14:*ALL) C EVAL ds1.IDN = 2 C ds1.IDN DSPLY C EVAL ds1.Name = 'DUMMY' C ds1.Name DSPLY C EVAL ds1.Addr1 = 'Address1' C ds1.Addr1 DSPLY C EVAL ds1.Addr2 = 'Address2' C ds1.Addr2 DSPLY C SETON LR C RETURN
RPG Code in /Free format for Externally Described Data Structure using LIKEREC keyword.
FRPGLE14PF IF E DISK D ds1 DS LIKEREC(Rcdfmt14:*ALL) /Free ds1.IDN = 2; dsply ds1.IDN; ds1.Name = 'DUMMY'; dsply ds1.Name; ds1.Addr1 = 'Address1'; dsply ds1.Addr1; ds1.Addr2 = 'Address2'; dsply ds1.Addr2; *inlr = *on; return; /End-Free
RPG Code in fully Free format for Externally Described Data Structure using LIKEREC keyword.
**FREE dcl-f RPGLE14PF disk usage(*input); DCL-DS ds1 LIKEREC(Rcdfmt14:*All); ds1.IDN = 2; dsply ds1.IDN; ds1.Name = 'DUMMY'; dsply ds1.Name; ds1.Addr1 = 'Address1'; dsply ds1.Addr1; ds1.Addr2 = 'Address2'; dsply ds1.Addr2; *inlr = *on; return;
Output
DSPLY 2 DSPLY DUMMY DSPLY Address1 DSPLY Address2
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
- 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