Midrange News for the IBM i Community


Posted by: WestCoastGuy
How to access spool file number during an RPG pgm
has no ratings.
Published: 16 Nov 2012
Revised: 23 Jan 2013 - 4082 days ago
Last viewed on: 28 Mar 2024 (9050 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

How to access spool file number during an RPG pgm Published by: WestCoastGuy on 16 Nov 2012 view comments(3)

In a particular program, I am creating a new spool printer file when the account number changes, by doing a close of the current printer file and opening a new one.

 

How do I capture the spool file number of the print job, within an RPG program?

 

Thanks in advance,

 

WCG

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: How to access spool file number during an RPG pgm
Posted: 11 years 4 months 11 days 15 hours 51 minutes ago
Edited: Fri, 16 Nov, 2012 at 15:49:58 (4150 days ago)

If you have COZTOOLS installed:

 

 

H BNDDIR('COZTOOLS')
 /include cozTools/qcpysrc,spool


D splfName    S      10A
D splNbr      S      10I 0

 /free
   ... do whatever here
 
       close QPRINT;
      getSPLFID( '*LAST' : '*' : -1 : SPLFNAME : SPLNBR);

 This will return the SPOOL File name and number of the most recently created SPOOL file.

We also created a getLastSPLF( ... )   function too, where it just returns the info of the last SPLF--basically a wrapper for the above call. It returns the SPLNBR to you, and also accepts return parms for the SPLFNAME, Internal JOB ID and SPLNBR.

 

 

Posted by: DaleB
Premium member *
Reading, PA
Comment on: How to access spool file number during an RPG pgm
Posted: 11 years 4 months 9 days 34 minutes ago

It's in the Open Feedback of the PRINTER file, so you'll need an INFDS. It's at position 160, 4-byte binary, so 10I 0. (See ILE RPG Ref, Ch. 5, File and Program Exception/Errors.) Make sure you get the 6 digit spool nbr, not the old 4-digit field.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: How to access spool file number during an RPG pgm
Posted: 11 years 4 months 8 days 22 hours 45 minutes ago
Edited: Fri, 23 Nov, 2012 at 12:57:26 (4143 days ago)

Dale, wow! Forget about that one.

WCG, here's the /COPY from COZTOOLS of the INFDS PRT data structure in the INFDSPRT member:

 

F* exPrtf  O    F  132        PRINTER INFDS(MYINFDS)        
                                                            
D*  myINfds       DS                  LikedS(coz_INFDSPRT_T)
                                                            
D coz_infdsPRT_T  DS                  Qualified             
D  splfName                     10A   overlay(coz_infdsPRT_T:103) 
D  splfLib                      10A   overlay(coz_infdsPRT_T:113) 
D  SPLNUM                        5I 0 overlay(coz_infdsPRT_T:123)     
D  SPLNBR                       10I 0 overlay(coz_infdsPRT_T:160)     
D  lines                         5I 0 overlay(coz_infdsPRT_T:152)     
D  columns                       5I 0 overlay(coz_infdsPRT_T:154)     
D  overflowLine                  5I 0 overlay(coz_infdsPRT_T:188)     

The file spec is a sample of using the INFDS with the PRINTER file. The MYINFDS is commented out but is also an example of how to declare it. Then the data structure itself is listed. Normally, if you had COZTOOLS DE installed, you just do the following:

 

FMyexPrtf  O    F  132        PRINTER INFDS(MYINFDS)        
           
 /include cozTools/qcpysrc,infdsprt
                                                 
D  myInfds        DS                  LikeDS(coz_INFDSPRT_T)
 /free
         mySPLNBR = myinfds.splNbr;

 In the context of the same program where the SPOOL file is declared, you can retrieve the "current" SPLNBR. If you need to get the *LAST SPOOL Nbr regardless of where the SPOOL file was created in this job, you'll need to call the COZTOOLS function mentioned above.