IBM Support

How to Write to a Physical File Using an External Data Structure in ILE RPG IV

Troubleshooting


Problem

This document explains how to write to a physical file using an external data structure in ILE RPG IV.

Resolving The Problem

Disclaimer: This is an example only. IBM accepts no responsibility for its correctness.


DDS source for PF TESTFILE.

A          R RECORD                                                    
A            DATA          10A        

ILE RPG IV  source named TEST.
 
**FREE
Dcl-F testfile   Usage(*Output);
Dcl-S fld1            Char(10)        inz('aaaaaaaaaa');
Dcl-Ds test ExtName('TESTFILE') End-Ds;
Eval test = fld1;
Write record;
*INLR = '1';  
CRTBNDRPG   PGM(<yourlib>/TEST) SRCFILE(<yourlib>/QRPGLESRC) SRCMBR(TEST)
CALL <yourlib>/TEST
                                  
It writes aaaaaaaaaa to the file.

                    Display Physical File Member                  
File . . . . . . :   TESTFILE            Library  . . . . :   LIBNAME  
Member . . . . . :   TESTFILE            Record . . . . . :   1        
Control  . . . . .                       Column . . . . . :   1        
Find . . . . . . .                                                      
*...+....1                                                              
aaaaaaaaaa                                                              

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

500817388

Document Information

Modified date:
13 November 2024

UID

nas8N1013433