Re: 4GL Information
Posted in 1994
In article <361te2$103@ankh.iia.org>, fschwaj@iia.org (Jeffrey fSchwartz) wrote: > ... we need to be able to produce > 'flat files' in specific formats. How can I create text files with 4GL? > I was able to do it using the reporting feature and specifying 'output to > 'stuff.dat' or something like that. My problem is that the data in the > file needs to have a different format from line to line. For example, > there is a header record, followed by a number of transactions. Each > transaction could be as few as one or as many as five lines in the file. > These lines have different formats. Can 4GL do this? How? Using the REPORT feature should be just fine, imagine: FOREACH header_curs INTO l_hd_detail OUTPUT TO REPORT textfile("H", l_hd_detail, 0, 0) FOREACH trans_curs INTO l_trdet1, l_trdet2, l_trdet3 OUTPUT TO REPORT textfile("T", l_trdet1, l_trdet2, l_trdet3) END FOREACH END FOREACH REPORT textfile(l_type, l_det1, l_det2, l_det3) ON EVERY ROW IF l_type = "H" THEN # Header record, so PRINT l_det1 # just output the header details END IF IF l_type = "T" THEN # Transaction record, so PRINT l_det1, l_det2, l_det3 # print out more stuff END IF END REPORT And now that I've finished typing that you should probabley do it far nicer with: FOREACH header_curs INTO l_hd_detail FOREACH trans_curs INTO l_trdet1, l_trdet2, l_trdet3 OUTPUT TO REPORT textfile(l_hd_detail, l_trdet1, l_trdet2, l_trdet3) END FOREACH END FOREACH REPORT textfile(l_hd_detail, l_trdet1, l_trdet2, l_trdet3) BEFORE GROUP OF l_hd_detail PRINT l_hd_detail ON EVERY ROW PRINT l_det1, l_det2, l_det3 # print out more stuff END REPORT (The second solution assumes that your header indicator is unique) Kerry S --------------------------------------------------- Kerry Sainsbury, kerry@kcbbs.gen.nz R&D Dude, Quanta Systems, Auckland, New Zealand ph. +64 9 377-4473 (work). +64 9 276-5546 (home) ---------------------------------------------------- The Informix FAQ lives at kcbbs.gen.nz:/informix/* and mathcs.emory.edu:/pub/informix/faq/*