Using QSPGETSP / QSPPUTSP APIs instead of CPYSPLF command

Posted on 2006-05-23
Last Modified: 2012-05-11

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)                           +

Question by:Inayat081501
    LVL 26

    Expert Comment


    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.

    LVL 13

    Expert Comment

    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?


    Author Comment

    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
    LVL 26

    Accepted Solution


    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.


    Author Comment

    No, I am not using CVTSPLPDF from Coolspools. I downloaded an API save file from  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
    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.
    LVL 26

    Expert Comment


    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.


    Author Comment


    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now