|
What is a "flat file"? That part still eludes me. In the example you offer though, make the file IP and forget the read loops and setting on LR. But add in an input record type to catch any errant records (I used 99 here). If you are going to program-describe anyway, take advantage of the work already done for you by the compiler. (I also added the L1 indicator because if he has both header and detail, I'd bet he'll need L1 break processing.) FINPFILE IP F 250 DISK IINPFILE NS 01 1 CH I 1 1 RCDTPH L1 I 2 5 HDFLD1 I 6 15 HDFLD2 I NS 02 1 CD I 1 1 RCDTPD L1 I 2 5 DTFLD1 I 6 15 DTFLD2 I NS 99 * C L1 EXSR L1DETSR C IF *in01 = *ON * perform header record procesing C ENDIF * C IF *in02 = *ON * perform detail record procesing C ENDIF * CL1 EXSR L1TOTSR ..etc.. _______________________ Booth Martin boothm@earth.goddard.edu http://www.spy.net/~booth _______________________ watern@cbs.fiserv.com Sent by: owner-rpg400-l@midrange.com 02/03/2000 03:37 AM Please respond to RPG400-L To: RPG400-L@midrange.com cc: Subject: Re: Flat File Help? 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 +--- +--- | 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 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.