Poor Mans Report Library
Challenge:
The ISSUE : Due to SOX regulations, my Boss wants me to create an archive for all our monthly reports ran, and an automated procedure to populate it.
- We do not use Report Caster or Report Library.
- And to top it off, he wants it completed by tonight ?
How to create a quick automated report library?
Solution:
By default, WebFOCUS assumes all created files are work files, and thus should be deleted once the process is completed or the user disconnects unless otherwise instructed.
We can however, permanently save these files in a few easy steps. To do this only requires knowing several commands depending on the version of WebFOCUS.
APP HOLD
HOLD
APP MAP
&TOD - &DATE
--------------------------------------------------------------
APP HOLD
APP HOLD {APPLICATION}
APP HOLD will store your report or data in an application you created. Can be used for :
- Archiving
- Output for 3rd party apps and interfaces
- Validation
APPHOLD syntax
APP HOLD {APPLICATION}
- APP HOLD application_name
Defines the directory to hold temporary files. - APP FI filename DISK
Provides platform independent syntax to allocate a file. For OS/390 and z/OS, the file must already exist. - APP HOLDMETA application_name
Designates the application as the location for Master Files and Access Files created with the HOLD command. - APP HOLDDATA application_name
Designates the application as the location for data files created with the HOLD command
Simple Report Sample – If you run this report the output will not be saved. :{
TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END
To Save Your Report, we can add a HOLD after the END. The program will still Display the Report and No second pass at the data is required to hold it. :)
TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END ON TABLE HOLD AS CAR FORMAT PDF
Each time we run the report, a copy will be Held, But where ?
TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END ON TABLE HOLD AS CAR FORMAT PDF
That's where APPHOLD comes in. Add APPHOLD to store our output in an APP Directory. We called ours ARCHIVE for this example. This will happen each time you run the report
APP HOLD ARCHIVE TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY END ON TABLE HOLD AS CAR FORMAT PDF
When the report is run, a file is created in the ARCHIVE directory. What will happen the next time this report is run if we use
ON TABLE HOLD AS CAR FORMAT PDF ?
If we do not add some code to make the name unique, it may overwrite the previous file
When the report is run, a file is created in the ARCHIVE directory.
What will happen the next time this report is run if we use
ON TABLE HOLD AS CAR FORMAT PDF ?
If we do not add some code to make the name unique it may overwrite the previous file
You can Use AMPER variables in your hold statement to make hold file names unique. This code will now append a date to the report name.
APP HOLD ARCHIVE TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END
HOLD AS CARREPORT-&MDY FORMAT PDF
How many files a day will we archive using
HOLD AS CARREPORT-&MDY ?
What would we do if we wanted a copy, each time the report is run ?
If you only run this report once a day or once a month, then this will work. If you want it saved more than once a day, you may want to add a time variable.
If we add &TOD (Time of Day) the file names will be unique based on the current Time of Day.
You could even add USER to the file name if you have defined the variable in your CGIVARS file. This way you could tell who ran it and when.
APP HOLD ARCHIVE TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END
HOLD AS CARREPORT-&MDY-&TOD FORMAT PDF
Now each time the user runs the report, Reports are automatically added to directory with the time and date.
What If I do not want to create hold files in my IBI application directories?
You can save you files outside your IBI apppath by using APPMAP.
-* File CAR.fex -* APP MAP will determine where to store my data. APP MAP ARCH_DIR E :\MONTHLY_ARCHIVE APP HOLD ARCH_DIR TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END HOLD AS CAR -&MDY-&TOD FORMAT PDF
These reports will now be stored in
E :\MONTHLY_ARCHIVE
We can now make this fully dynamic by adding the &IBIF_ex variable to automatically populate the FOCEXEC name.
In the example below we replace the SAVE AS “CAR” with the &IBIF_ex variable. When the pgm runs the &IBIF_ex variable will be replaced with the fex name “CAR”
File CAR.fex
APP MAP ARCH_DIR E :\MONTHLY_ARCHIVE APP HOLD ARCH_DIR TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END HOLD AS &IBIF_ex-&MDY-&TOD FORMAT PDF
Because this is now fully dynamic, we can place this line of code in its own FOCEXEC and use the –INCLUDE FEXNAME to call it from any report that we would like to have archived. For the example below we placed the HOLD code above in a FEX called SAVIT.
TABLE FILE CAR PRINT CAR MODEL SEATS BY COUNTRY ON TABLE SET ONLINE-FMT HTML END
-INCLUDE SAVIT
Just include this and your APP PATH into any report and your ready to go,
Now you have completed the coding needed for your simple report library. This solution is Fun and Easy and I hope you enjoyed it.
If any questions, please contact Peter at peter.ellis@ngc.com.



