How to get files to show up in the Process Monitor/Report Repository
A common problem for SQR and application engine developers is how to make files generated in SQR and Application Engine accessible to the end user(s). One common solution is to write them to a shared directory on some server. This can cause a bunch of issues and requires security maintenance outside the PeopleSoft database. This model does not always work.
A better solution is to actually have your files show up in the report repository under the “view/log trace”. It turns out to be very easy.
Application Engine Example
In tools 8.4x and beyond, any files opened using the GetFile will actually be automatically transfered to the Report Repository.
Local File &f; &f = GetFile("summary_log.txt", "w", %FilePath_Relative); &f.WriteLine("Hello World"); &f.close()
The key thing about this code is the %FilePath_Relative parameter. In tools 8.4x, the application engine will open the file in the correct place and some scripts that run after the process completes will transfer the file to the Report Repository.
SQR Example
Here is a procedure that you can put in an SQC. A variable named $weboutputdir will be populated with the director where you want to open the file.
begin-procedure get-web-outdir if $sqr-platform = 'WINDOWS-NT' let $dirSep = '\' else let $dirSep = '/' end-if begin-select CDM.PRCSOUTPUTDIR let $weboutputdir = rtrim(&CDM.PRCSOUTPUTDIR, ' ') || $dirSep FROM PS_CDM_LIST CDM WHERE CDM.PRCSINSTANCE = #prcs_process_instance end-select end-procedure
How does it work
When the process scheduler starts any new process, a temporary directory is actually created for each and every process instance. Any files in that temporary directory will get automatically transfered to the process monitor (aka report repository). You can figure out that directory name at run time by querying the PS_CDM_LIST.PRCSOUTPUTDIR record field and opening your file there. All the files that normally show up in the report repository like pdf and log files are actually stored in this directory so you are already following the flow of what PeopleSoft is already doing.
I have been using this trick for about 8-10 years now and it works flawlessly across every operating system that I have worked on. The one caveat is that I have seen that not all file extensions are transfered. I typically use .txt or .csv and those tend to work well. I have had other file types not transfer across different tools release. For example in the past the .dat file type did not transfer on some tools releases.