Externally Described Data Structure in RPG AS400 |
Introduction to Externally Described Data Structure
An Externally Described Data Structure is identified by the EXT or EXTNAME keyword for a fully free definition or by an E in position 22 of a fixed format definition.
You can also define the Externally described data structure using the LIKEREC keyword.
Create an Externally described physical file
Let's first create a physical file(PF) named RPGLE14PF whose DDS structure is as follows.
A R RCDFMT14 A IDN 2P 0 A NAME 20A A ADDR1 50A A ADDR2 50A
Create the Physical file object using the command CRTPF command or option 14 on the RPGLE14PF source member of type PF.
Coding Externally Described Data Structure in RPG Fixed, Free and Fully Free format
Example1: Using EXTNAME to code Externally Described DS in RPG
In this example, the Externally described data structure DS1 is defined on a file named RPGLE14PF using EXTNAME keyword. After this, All the fields from file RPGLE14PF can be referred to in the data structure DS1.
D ds1 E DS EXTNAME(rpgle14pf:Rcdfmt14) C EVAL IDN = 2 C EVAL Name = 'DUMMY' C EVAL Addr1 = 'Address1' C EVAL Addr2 = 'Address2' C SETON LR C RETURN
D ds1 E DS EXTNAME(rpgle14pf:Rcdfmt14) /Free IDN = 2; Name = 'DUMMY'; Addr1 = 'Address1'; Addr2 = 'Address2'; *inlr = *on; return; /End-Free
**FREE DCL-DS DS1 EXTNAME('RPGLE14PF') ; END-DS; IDN = 2; Name = 'DUMMY'; Addr1 = 'Address1'; Addr2 = 'Address2'; *inlr = *on; return;
Program Output
> EVAL DS1 IDN OF DS1 = 02. NAME OF DS1 = 'DUMMY ' ADDR1 OF DS1 = 'Address1 ' ADDR2 OF DS1 = 'Address2 '
Example2: Using EXTFLD to code Externally Described DS in RPG
In this example, the Externally described data structure DS1 is defined on a file named RPGLE14PF using the EXTNAME keyword, and individual file fields are renamed using the EXTFLD keyword.
Using EXTFLD to code Externally Described DS in RPGRelated Post
- 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
- 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