File Information Data Structure in RPG AS400 |
Introduction to File Information Data Structure
We can specify the file information data structure for each file defined in the RPG program using the INFDS keyword. This data structure will provide you the file exception/error status
File Information data structure has pre-defined subfields which provide status information of the file exceptions/errors.
The minimum length of the INFDS is 80.
INFDS Feedback information
The INFDS contains the following feedback information. However, in this blog, we will discuss only File Feedback information.
File Feedback
length is 80 for File feedback information.
Coding an INFDS with File Feedback Information in RPG Fixed Format
FCLPF1 IF E DISK INFDS(DS1) DDS1 DS D FILE *FILE * File name D OPEN_IND 9 9N * File open D EOF_IND 10 10N * File at eof D STATUS *STATUS * Status code D OPCODE *OPCODE * Last opcode D ROUTINE *ROUTINE * RPG Routine D LIST_NUM 30 37 * Listing line D SPCL_STAT 38 42S 0 * SPECIAL status D RECORD *RECORD * Record name D MSGID 46 52 * Error MSGID D SCREEN *SIZE * Screen size D NLS_IN *INP * NLS Input D NLS_OUT *OUT * NLS Output D NLS_MODE *MODE * NLS Mode
Coding an INFDS with File Feedback Information in RPG Fully Free Format
**FREE DCL-F CLPF1 DISK(*EXT) INFDS(DS1); DCL-DS DS1; FILE *FILE; // File name OPEN_IND IND POS(9); // File open EOF_IND IND POS(10); // File at eof STATUS *STATUS; // Status code OPCODE *OPCODE; // Last opcode ROUTINE *ROUTINE; // RPG Routine LIST_NUM CHAR(8) POS(30); // Listing line SPCL_STAT ZONED(5) POS(38); // SPECIAL status RECORD *RECORD; // Record name MSGID CHAR(7) POS(46); // Error MSGID SCREEN *SIZE; // Screen size NLS_IN *INP; // NLS Input NLS_OUT *OUT; // NLS Output NLS_MODE *MODE; // NLS Mode END-DS;
File CLPF1 has the following structure and records
Field File Type Length Scale ROLLNO CLPF1 DECIMAL 5 NAME CLPF1 CHARACTER 20 AGE CLPF1 DECIMAL 3 CLASS CLPF1 DECIMAL 2
ROLLNO NAME AGE CLASS 1 name1 21 1 2 ddf 2 2
Coding File Information Data Structure (INFDS) in RPGLE
RPG Code in Fixed format for Coding File Information Data Strucure (INFDS) in RPGLE AS400
*_________________________________________________________________________ * The INFDS contains the following feedback information:
* File Feedback (length is 80) <-- This video talks about
* Open Feedback (length is 160)
* Input/Output Feedback (length is 126)
* Device Specific Feedback (length is variable)
* Get Attributes Feedback (length is variable)
*_________________________________________________________________________
FCLPF1 IF E DISK INFDS(DS1) D DS1 DS * File Feedback information (starts in position 1 and ends in position 80)
* file name
* record process
* last operation
* status code (>99 is exception)
* RPG IV routine
D FILE *FILE * File name D OPEN_IND 9 9N * File open D EOF_IND 10 10N * File at eof D STATUS *STATUS * Status code D OPCODE *OPCODE * Last opcode D ROUTINE *ROUTINE * RPG Routine D LIST_NUM 30 37 * Listing line D SPCL_STAT 38 42S 0 * SPECIAL status D RECORD *RECORD * Record name D MSGID 46 52 * Error MSGID D SCREEN *SIZE * Screen size D NLS_IN *INP * NLS Input D NLS_OUT *OUT * NLS Output D NLS_MODE *MODE * NLS Mode? C 1 SETLL CLPF1 C READ CLPF1 C DOW NOT%EOF C READ CLPF1 C ENDDO C SETON LR
RPG Code in /Free format for Coding File Information Data Strucure (INFDS) in RPGLE AS400
FCLPF1 IF E DISK INFDS(DS1) D DS1 DS D FILE *FILE * File name D OPEN_IND 9 9N * File open D EOF_IND 10 10N * File at eof D STATUS *STATUS * Status code D OPCODE *OPCODE * Last opcode D ROUTINE *ROUTINE * RPG Routine D LIST_NUM 30 37 * Listing line D SPCL_STAT 38 42S 0 * SPECIAL status D RECORD *RECORD * Record name D MSGID 46 52 * Error MSGID D SCREEN *SIZE * Screen size D NLS_IN *INP * NLS Input D NLS_OUT *OUT * NLS Output D NLS_MODE *MODE * NLS Mode? /Free setll 1 clpf1; read clpf1; dow not%eof; read clpf1; enddo; *INLR = *ON; /End-Free
RPG Code in fully Free format for Coding File Information Data Strucure (INFDS) in RPGLE AS400
**FREE DCL-F CLPF1 DISK(*EXT) INFDS(DS1); DCL-DS DS1; FILE *FILE; // File name OPEN_IND IND POS(9); // File open EOF_IND IND POS(10); // File at eof STATUS *STATUS; // Status code OPCODE *OPCODE; // Last opcode ROUTINE *ROUTINE; // RPG Routine LIST_NUM CHAR(8) POS(30); // Listing line SPCL_STAT ZONED(5) POS(38); // SPECIAL status RECORD *RECORD; // Record name MSGID CHAR(7) POS(46); // Error MSGID SCREEN *SIZE; // Screen size NLS_IN *INP; // NLS Input NLS_OUT *OUT; // NLS Output NLS_MODE *MODE; // NLS Mode END-DS; setll 1 clpf1; read clpf1; dow not%eof; read clpf1; enddo; *INLR = *ON;
Output: Value in DS1 (INFDS)
> EVAL DS1 FILE OF DS1 = 'CLPF1 ' OPEN_IND OF DS1 = '1' EOF_IND OF DS1 = '0' STATUS OF DS1 = 00000. OPCODE OF DS1 = 'READ F' ROUTINE OF DS1 = '*DETC ' LIST_NUM OF DS1 = '00000039' SPCL_STAT OF DS1 = RCLP6. RECORD OF DS1 = 'RCLPF1 ' MSGID OF DS1 = ' ' SCREEN OF DS1 = 0000. NLS_IN OF DS1 = 00. NLS_OUT OF DS1 = 00.
Using INFDS with INFSR catch file exception in RPGLE
We will do exceptional handling in RPGLE using INFDS and INFSR.
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
- 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