Link to home
Start Free TrialLog in
Avatar of Inayat081501
Inayat081501

asked on

Using QSPGETSP / QSPPUTSP APIs instead of CPYSPLF command

Hi:

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
the QSPGETSP / QSPPUTSP APIs instead?


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)                           +
           CTLCHAR(&CtlChar)
----------------------------------------------------------------------------------

Thanks
Avatar of Member_2_276102
Member_2_276102

Inayat:

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.

Tom
Avatar of Barry Harper
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:
http://www.netshare400.com/cgi-bin/DSPSAMP?file=QRPGLESRC&mbr=SPLFAPI

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?

Barry
Avatar of Inayat081501

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Member_2_276102
Member_2_276102

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tom,
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.

Barry:

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.
Inayat:

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:

  http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/books/sc415713.pdf

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:

  http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzalu/rzaludatastreams.htm

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.

Tom
Tom,

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