Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


As400 - reports

Posted on 2013-05-10
Medium Priority
Last Modified: 2016-07-05

In my application currently we are printing the reports in RPGLE using program described printer files concepts. once the reports are generated then we are copying spool file into physical file using CPYSPLF command with control as *FCFC.

now currently I am planning to build the reports into physical file member instead of generate spool file and copy the spool file. my intention is without changing the program logic i.e) instead of write the data into spool file , reroute printer data into physical file.

currently i didn't know how to route the printer data into physical file. the data in physical file should be as cpysplf command *FCFC way.

could you please help on me.
Question by:Vsomepalli
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 35

Expert Comment

by:Gary Patterson
ID: 39167840
If you don't want to change the program, why don't you just do what you are currently doing, adding one step: deleting the spooled file.

Write to the printer file
Copy the spooled file to a database file
Delete the spooled file

The other option is to OVRDBF to a database file.  There are a few restrictions, and if you run into one you can just use the CPYSPLF and Delete technique,.


- Gary Patterson

- Gary Patterson

Author Comment

ID: 39169234
Hi Patterson,

Thanks for help. but here the problem.

I am using OVRDBF command to write data into database file instead of printer file but i am missing the printer control characters ( i.e) *FCFC values in CPYSPLF command ) . I didn't want to change program logic. but using OVRDBF only but I need control characters.

LVL 35

Expert Comment

by:Gary Patterson
ID: 39169500

Unfortunately, I think you are at the mercy of the program that is doing the printing.

Programs can specify forms control information several different ways.  One of those ways is by putting an ANSI forms control character in the first byte of each row.  If that was happening, you'd see those in the first byte of the database file output when you do an OVRDBF.

Most programs don't generate FCFC, however.  So you are probably seeing something else, like SCS control codes.

I don't know of any better option than to override the spooled file to HOLD and use CPYSPLF and then DLTSPLF.

If isn't a great solution from a performance standpoint, but if you can't change the underlying program, I think it is probably tour best alternative.

I'm assuming this is an SCS print file.  IF it isn't you may have some other options.  What is the format of the spooled file you are capturing?

- Gary
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 39177446
Hi Gray,

Thanks for info.  But in my applications we have 100 programs to generate SCS printer files.

In my project, we are running batch process. In this batch process we are generating reports i.e) printer files. once report is generated then we are coping report into spool files into database file using CPYSPLF command.  due to above two steps the batch process running long time. so now I am thinking to remove the CPYSPLF execution i.e) redirecting printer data into disk file using OVRDBF. but once the program done, I am missing the *FCFC character.

Based on above solution if I need to get *FCFC then, I need to change 100 programs to write *FCFC character.

Could you please suggest the best solution.
Is any other way is their to capturing the printer using the RPG Open access then write data into disk file instead of printer file.

LVL 35

Expert Comment

by:Gary Patterson
ID: 39177902
Hi Venkat,

I can' think of a way to do this without changing all your programs.  Here's a suggestion, though:

If your problem is the long runtime, why not run the CPYSPLF processes in a separate job?

In your primary process, instead of issuing the CPYSPLF, create a data queue, and put an entry on the data queue containing the name of each spooled file you want to copy.  Start a second job that processes the data queue, which performs a CPYSPLF for each file it reads from the data queue.

Data queue "sends" and "receives" (QSNDDTAQ/QRCVDTAQ apis) are really fast, and this way your CPYSPLF operations can run in parallel with you main batch job.

If you are running on an old single-CPU system, or if your are running on a multi-CPU system that is CPU bound or I/O bound during your batch process, then this might not produce much overall runtime improvement.  On most systems, though, it will help a lot.

- Gary Patterson

Author Comment

ID: 39178516
Hi Gray,

Thanks for the help.  It will work. Instead of this RPG OA handler will work on printer file handler or not?   My idea is RPG OA handler capture the IO feedback so in case printer file if I capture the record data then I will include the *FCFC character then write data into disk file.
could you please let me know this solution will work or not.

LVL 35

Accepted Solution

Gary Patterson earned 2000 total points
ID: 39179884

SCS spooled files, by default, contain SCS control codes, not ANSI FCFC control codes:


Here is a table that lists the valid ANSI FCFC codes:


If desired, a programmer can choose to use ANSI FCFC codes in a program, but if so, must code explicitly to write the correct control code in the first byte of each row written to the printer file.  

If your programs aren't coded to do that (it is not a common RPG printing technique), then there ARE NO FCFC CODES IN THE SPOOLED FILE DATA - there are only SCS codes.

SCS codes are stored in the spooled output file.  If the file is printed on an SCS printer, then the spooled file data is sent intact.  If the file is printed on a non-SCS printer, the SCS codes are converted on the fly depending on the outq and or printer configuration.

So how do you get FCFC data if the program isn't coded to generate it?

Answer: You have to write a program or use a tool to create it yourself.

The most common way is to use the CPYSPLF command.  CPYSPLF can dynamically converts the SCS control codes it finds to ANSI FCFC codes - if you specify CTLCHAR(*FCFC).

You could certainly write a program to do the same thing yourself - and yes, RPG Open Access might be a nice way to do that.  I looked at the data available for Printer files in Open Access, and the QrnPrtctl_T data structure contains PRTCTL-style printer spacing control information.  

Looks like your HANDLER program will have to read the PRTCTL data structure for each row and convert it to FCFC.  You'll have to code that logic yourself in your RPG OA HANDLER program.

Refer to the Open Access manual for more information:


Of course, that is going to mean modifying every one of your report programs to add the HANDLER directive, but that is a lot better than some of the other options.

- Gary Patterson

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Make the most of your online learning experience.
Simple Linear Regression
Six Sigma Control Plans

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question