|
David Rittenberg wrote: > ..., > Also if you could please tell if what I am doing in the first place is > right > or wrong because I am executing > > READ filename > > in module M1 main procedure and accessing the file fields in the > procedure P1 of module M2 by calling P1 immediately after the READ. > In RPG, doing a READ copies data from the input buffer to fields in the module. If you declare the file in another module, the fields in that module won't be affected by the READ even if you have an override to share the file. If you want the results of the READ to be available to another module, you have a couple of choices: 1. Pass each field as a parameter on your call to P1 2. Declare an externally-described data structure for your file in module M1, and pass the data structure as a single parameter to P1. (Declaring an externally-described DS causes the READ to copy the data into the DS subfields.) I would use #2: Module M1: Fmyfile if e disk D myfileData e ds extname(myfile) * If you use PREFIX on your F spec, be sure to use * the same PREFIX on your E-DS. c read myfile c callp p1 (myfileData) Module M2: P p1 b export D p1 pi D dataParm like(fileData) D fileData e ds extname(myfile) D based(pFileData) c eval pFileData = %addr(dataParm) ... now you can use the fields in the DS/file P p1 e If you are on V5R1, you can avoid the pointer stuff by using LIKEDS: D fileData e ds extname(myfile) P p1 b export D p1 pi D fileData likeds(fileData) ... now you can use the fields in the DS/file ... by coding fileData.fld1 etc c if fileData.fld1 <> *blanks P p1 e
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.