[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3317
  • Last Modified:

Using QSPGETSP / QSPPUTSP APIs instead of CPYSPLF command


I am using the CPYSPLF utility to copy a spoolfile to a database file.

Could anyone help me with sample code to replace the following code to use

Here is the CPYSPLF line of code in the program that I want to replace:
/*  Copy spooled file into work file                 */
CPYSPLF    &FromFile                                    +
           QTEMP/&ToFile                                  +
           JOB(&JobNbr/&User/&Job)                  +                              
           SPLNBR(&SplNbr)                               +
           MBROPT(*REPLACE)                           +

  • 3
  • 3
1 Solution

Can you clarify what you need? The APIs _can_ be used to get spooled file data into a file, but CPYSPLF is probably a much better tool for it.

Technically, the APIs won't output to a database file. You will need to process the user space that is filled by QSPGETSP and translate the printer controls to get the data into a file. CPYSPLF does that for you.

That assumes you are interested in database files for output. If all you're doing is storing spooled files in user spaces so you can restore and print them later, and you won't be doing any processing of the spooled file data in the *USRSPC, then it's fairly easy.

An additional note to Tom's comment, you are wise to use  QSPGETSP / QSPPUTSP APIs, instead of the 'unsupported' QSPGETF and QSPPUTF.

Some source to get you started with those APIs:

What do you want to do with the spooled file after you store it? Restore it later for printing? Massage it to create a new version of the spooled file?

Inayat081501Author Commented:
Hi Tom / Barry:

 Thank you both for your response.

 The CPYSPLF statement is part of a CL program that is used to convert a Spool File to a PDF file. The spool file I am trying to convert has
 special formatting like a bar code and perhaps other special characters. When I try to step through the CL code the compiler throws out
 an error when encountering CPYSPLF statement due to the special characters and formatting. However, if the spool file has only text, then
 it works fine.
 I read on the internet that CPYSPLF cannot be used to copy such a spool file to a database file. And I also read on IBM's website warning
 not to use the unsupported QSPGETF and QSPPUTF mentioned by Barry.

 After copying the spoolfile to the database file, the program proceeds to invoke CVTSPLPDF to perform the conversion. Since I can't use
 CPYSPLF I am trying to use  QSPGETSP / QSPPUTSP APIs recommended by IBM.

 I can post the code segment if you want to take a look at. I will take a look at the link suggested by Barry and get back.

 Thanks - Inayat
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  


What version of CVTSPLPDF are you using? If this is the CoolSpools command and it's a current release, it should be able to handle bar codes and AFP, IPDS and other spooled file types.

Inayat081501Author Commented:
No, I am not using CVTSPLPDF from Coolspools. I downloaded an API save file from http://www.malume.de/ibmiseries/downloads.html  that has CVTSPLPDF, CVTSPLSTMF
APIs besides others. Actually, I was trying to use CVTSPLSTMF,but I had problem getting it to work.

I then did a search and found source code for CVTSPLSTMF from another location http://www.iseriesnetwork.com/ArtArchiveImages/figure.cfm?Figure=2000/July/7516-Fig3.htm 
I am now trying to compile this code step by step, so I can have better control and see what is going on.

I would need some help to replace CPYSPLF to use the IBM provided APIs QSPGETSP and QSPPUTSP a
sample of which is shown at the link Barry has posted.


Sorry, I am just beginning to learn AS400 by taking up some sample projects. How do I modify my code
to use the code at the link you posted? I need some help in translating the part of code for CPYSPLF to
use the IBM provided APIs QSPGETSP and QSPPUTSP.

This is not an area to "begin" learning. However, if you're serious, the InfoCenter for V5R3 (and other releases) has a lot about printing, printer devices and printer data streams. An over manual can be found by navigating to Printing-> Printer Device Programming (PDF). The link is:


Oddly, a bunch of the detail has been pulled from an appendix and moved back to the InfoCenter. To get to it, you can search the InfoCenter for [printer data streams]. A link at the top of the search list should be:


That ought to be enough to get you started for some time to come. I went through a bunch of this a while back to convert a spooled file user space to HTML and it is no picnic.

Inayat081501Author Commented:

My apologies for getting back to you this late!

Have you tried the CVTSPLPDF from CoolSpools? Perhaps you may be able to assist me with using this one atleast. I am not ready yet to venture into an area that I still need to build up my knowledge on.

Please let me know.

Thank You


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now