× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.






Hi,

In RPG, flat files are processed as "program described files".
On the F-spec you specify the record length for the file.
On the I-specs you specify the structure of the records in the file.
If there is more than one record type in the file (eg
header,detail,trailers), the I-specs can cope with this too.

I would check out the RPG400 User Guide and ILE RPG400 programmers guide
for general discussion on program described files vs the traditional
externally described files.
The RPG400 Reference and ILE RPG400 Reference will give you exact details
required for coding with program described files.

If there is only one record type in the file you could consider building an
externally described file and copying the data to it using cpyf
fmtopt(*nochk). This would allow you to process in the "normal" way.

Otherwise, a typical program processing a program described file would look
something like:-

FINPFILE   IF   F  250        DISK
IINPFILE   AA  01    1 CH
I                                  1    1  RCDTPH
I                                  2    5  HDFLD1
I                                  6   15  HDFLD2
IINPFILE   AB  02    1 CD
I                                  1    1  RCDTPD
I                                  2    5  DTFLD1
I                                  6   15  DTFLD2
 *
C                   EVAL      *IN01 = *OFF
C                   EVAL      *IN02 = *OFF
C                   READ      INPFILE
 *
C                   IF        *in01 = *ON
 * perform header record procesing
C                   ENDIF
 *
C                   IF        *in02 = *ON
 * perform detail record procesing
C                   ENDIF
 *
..etc..

Of course your mainline would code a loop to read through the file until no
more records, but this is the jist of what you need.

I will leave you to find out what the f-spec & i-spec coding actually does
from the reference manuals.


hth


<snip>  ...  Could anyone tell me where I might find some
information or an example of a program that reads a
flat file? Any help would greatly be appreciated.   <endsnip>



+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.