Multiple Reports to One File
Posted in 2006
A 4GL user (Informix 7.31) wanted one flat file containing a header, item lines, container lines and a footer, produced by two differently-structured reports; starting both reports TO the same filename overwrote the first. Suggestions were to merge both line types into one report using a line-type flag, or to truncate the file first (RUN "> file") and send each report TO PIPE "cat >> file". The poster adopted the pipe approach (first report TO the file, later ones piped to cat >>), tweaking PAGE LENGTH to avoid gaps, and noted each report must be FINISHed before the next writes, or output comes out unpredictably.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Cloud, Docker & Containers
Hello, I am trying to generate a report to a flat file that consists of two very different sections. Like so: HEADER... Item Info... Item Info... Item Info... Item Info... Container Info... Container Info... Container Info... FOOTER... The Item and Container records are not linked directly in a header/detail sort of fashion, so I don't think "on group of" will help. Also, item and container records contain very different information, so parameters passed into the report need to be different for each section. What I would like to do is have two reports but output them to the same file. Unfortunately, if I do the following, the items are overwritten: START REPORT items TO filename OUTPUT... FINISH REPORT items START REPORT containers TO filename ... I've experimented with "TO PIPE" but am not having much luck. My last resort wil be to create two completely seperate files and cat them together when I am done, but I'd rather build a single file as I go. Suggestions? Kimberly
Replying to my own post - I am using Informix version 7.31
kimmerkc wrote: > Hello, > > I am trying to generate a report to a flat file that consists of two > very different sections. Like so: > > HEADER... > Item Info... > Item Info... > Item Info... > Item Info... > Container Info... > Container Info... > Container Info... > FOOTER... > > The Item and Container records are not linked directly in a > header/detail sort of fashion, so I don't think "on group of" will > help. Also, item and container records contain very different > information, so parameters passed into the report need to be different > for each section. You could add a parameter to your report formatter to indicate whether you're supplying an "item" line or a "container" line. The parameters would be the union of item parameters and container parameters, and the parameters that don't apply would be left null, and your ON EVERY ROW would be something along the lines of "if line_type = 'item' then {do whatever to print an item} else {do whatever to print a container} end if" -Carsten
kimmerkc said: > Hello, > > I am trying to generate a report to a flat file that consists of two > very different sections. Like so: > > HEADER... > Item Info... > Item Info... > Item Info... > Item Info... > Container Info... > Container Info... > Container Info... > FOOTER... > > The Item and Container records are not linked directly in a > header/detail sort of fashion, so I don't think "on group of" will > help. Also, item and container records contain very different > information, so parameters passed into the report need to be different > for each section. > > What I would like to do is have two reports but output them to the same > file. Unfortunately, if I do the following, the items are overwritten: > > START REPORT items TO filename > OUTPUT... > FINISH REPORT items > > START REPORT containers TO filename > ... > > I've experimented with "TO PIPE" but am not having much luck. My last > resort wil be to create two completely seperate files and cat them > together when I am done, but I'd rather build a single file as I go. Before you run the report: RUN "> filename" ... Then: START REPORT items TO PIPE "cat >> filename" ... START REPORT containers TO PIPE "cat >> filename" ... ? -- Bye now, Obnoxio "I don't read newspapers anymore except the local rag which I do weekly to cheer myself trying to see if anyone I hate has been stabbed." -- Horribilis XVI -- This message has been scanned for viruses and dangerous content by OpenProtect(http://www.openprotect.com), and is believed to be clean.
Thanks for the help. I actually found the answer myself while digging for the answer to a completely different question. For those who may have the same question later, here's what I did: START REPORT items TO l_file_name LET l_shell_cmd = "cat >> ", l_file_name START REPORT containers TO PIPE l_shell_cmd FOREACH <item record> OUTPUT TO REPORT items... END FOREACH FOREACH <container record> OUTPUT TO REPORT containers... END FOREACH FINISH REPORT items FINISH REPORT containers I put the header in the "items" report and the footer in the "containers" report. Had to mess with Page Length a little to avoid a gap between the reports, but it's working now. Kimberly
Obnoxio The Clown wrote: > Before you run the report: > > RUN "> filename" > ... > > Then: > START REPORT items TO PIPE "cat >> filename" > ... > > START REPORT containers TO PIPE "cat >> filename" > ... > > ? > Thank you! One further question. I've found this only works if I FINISH the first report before writing output to the second. If I wait to FINISH both at the end I get unpredictable results - especially when I expand this to three separate reports. Closing each before opening the next actually works for me - just wondering if anyone has a suggestion to adress this limit for future needs. Kimberly