×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Hello.
I need to get this report data as a buffer and use it for some other
purposes. Is it possible to access PRTF record data while it is being
output to the spool?
I have a few thoughts:
a) RPG supports something called 'SPECIAL' files. The idea is that you
tell your program that it's writing data to a file (using O-specs, etc)
but instead of physically writing the data, it calls a program and
passes the data as parameters.
With (relatively) minor changes to your report program, you could
replace the existing PRINTER file with a SPECIAL file. Then the program
that it calls would get the "record buffer" as a parameter.
b) You could keep the existing program completely unchanged, but issue
an override before you call it. If you do OVRDBF you can re-direct
printer output to go to a database file. For example, if the program
prints to QPRINT, you could do OVRDBF FILE(QPRINT) TOFILE(QTEMP/MYFILE)
and instead of printing, it'd save the data to the database file named
"MYFILE" which you could then read in another program.
c) You could keep the existing program unchanged, and let the data to go
the spool -- perhaps on hold -- then use CPYSPLF to copy the data to a
PF and process it. This is useful when you still want to print the
original report, but want to use the data for another purpose as well.
(However, if you don't want to print the original report, the OVRDBF
option is faster and easier.)
d) You could let the data go to the spool and extract the data via the
QSPOPNSP API and the other APIs that go with it. That way you can get
the spooled data in it's internal format and with it's internal
structures, which gives you a ton more information that CPYSPLF does,
but of course requires much more sophisticated code to understand.
e) Yet another alternative to CPYSPLF is QShell's 'catsplf' utility. It
will dump the contents of a spooled file to stdout, which makes it
possible to use it in conjunction with other QShell tools. This can be
a very easy way to parse certain bits of data out of a spooled file --
depending, of course, on what you need to do with it.
All of these can be good alternatives, depending on your needs.
As an Amazon Associate we earn from qualifying purchases.