Wednesday, July 11, 2018

Using an output queue to send spool files to another partition

create remote outq to another as400

The germ of the idea for this post came from a conversation I was having with two other programmers I work with. The conversation became finding an easy way to transfer spool files from a development IBM i partition to a production partition.

Where I work there are multiple partitions on one PowerSystems server. These partitions are used by various subsidiary companies in different parts of the USA, and three locations in Europe. If a modification is made to a spool file layout, for example: invoice, how do I show a user in Germany or Illinois what this new layout looks like when I am in California? The development partition does not connect to all the printers used, as we do not want test data printing on a "live" printer when testing. In my experience if I copy the spool file to a PDF the user is not convinced. The only way they will be convinced that the change works is for it to print on their printer.

The two programmers I was talking with used the Send Net Spooled File command, SNDNETSPLF.

            Send Network Spooled File (SNDNETSPLF)

 Type choices, press Enter.

 Spooled file . . . . . . . . . . > QINVOICE  
 User ID:
   User ID  . . . . . . . . . . . >         
   Address  . . . . . . . . . . . >         
                + for more values  
 Job name . . . . . . . . . . . . > QPADEV0001
   User . . . . . . . . . . . . . >   SIMON
   Number . . . . . . . . . . . . >   211725
 Spooled file number  . . . . . . > 61
 Job system name  . . . . . . . . > DEVSYS
 Spooled file created:
   Creation date  . . . . . . . . > 07032018
   Creation time  . . . . . . . . > 160438
 Data format  . . . . . . . . . . > *ALLDATA

I admitted I had used that command in the past. Recently I had switched to using remote output queues on the Development partition to my output queue on the various production partitions.

We Googled to look for an example they could use, and were disappointed not to find a good example that described how to do what I had done. That is when I decided to write this post.

There is not a special command for creating a remote output queue. I just use the Create Output Queue command, CRTOUTQ. In this example I am going to create a remote output queue to the output queue SOMEOUTQ on the partition RMTSYS.

At a command line I type: CRTOUTQ and press F4. I fill in the first two parameters with the name I will be calling the remote output queue, and the library I want it in.

                   Create Output Queue (CRTOUTQ)

Type choices, press Enter.

Output queue . . . . . . . . . . > RMTOUTQ   
  Library  . . . . . . . . . . . >   MYLIB     
Maximum spooled file size:
  Number of pages  . . . . . . .   *NONE      
  Starting time  . . . . . . . .         
  Ending time  . . . . . . . . .         
               + for more values  
Order of files on queue  . . . .   *FIFO 

Remote system  . . . . . . . . .   *NONE             

I have seen various company "standards" stating that all output queues must be created in QUSRSYS, QGPL, etc. I always create mine in my own library, MYLIB. It really makes no difference which library I create the output queue in.

When I enter the name of the other partition, RTMSYS, into the "Remote system" parameter and press Enter, a whole set of new parameters appear.

                   Create Output Queue (CRTOUTQ)

Type choices, press Enter.

Output queue . . . . . . . . . . > RMTOUTQ   
  Library  . . . . . . . . . . . >   MYLIB     
Maximum spooled file size:
  Number of pages  . . . . . . .   *NONE      
  Starting time  . . . . . . . .         
  Ending time  . . . . . . . . .         
               + for more values  
Order of files on queue  . . . .   *FIFO 

Remote system  . . . . . . . . .   RMTSYS            
Remote printer queue . . . . . .   SOMELIB/SOMEOUTQ 
Writers to autostart . . . . . .   1    
Queue for writer messages  . . .   QSYSOPR  
  Library  . . . . . . . . . . .     *LIBL    
Connection type  . . . . . . . .   *SNA   
Destination type . . . . . . . .   *OS400   

I have cheated here. The parameters I show above appear on two screens. I have condensed them onto one to make it easier for me to show what needs to be entered.

The default for the "Remote printer queue" is *USER. If I leave this value then the remote output queue will connect to the output queue which is in the PRTDEV parameter of my user profile on the remote partition. The other special value is *SYSTEM, this will configure the remote output queue to connect to the output queue held in the system value QPRTDEV on the remote partition. I want to use my own output queue, SOMELIB/SOMEOUTQ.

I change the "Writers to autostart" parameter to '1', so that the output queue will be started at IPL.

The "Connection type" defaults to *SNA. I want to use SNA as I want this output queue to connect to an output queue on RMTSYS, not a printer, so I can then transfer the spool file to another output queue.

"Destination type" is *OS400.

I can ignore all the other parameters, leaving them with their default values.

When I press Enter the output queue is created.

All I have to do it change the output queue for any spool file to RMTOUTQ and I can see the spool file being sent to the remote partition.

                   Work with Output Queue

Queue: RMTOUTQ     Library: MYLIB       Status: RLS/WTR

Type options, press Enter.
  1=Send   2=Change   3=Hold   4=Delete   5=Display
  8=Attributes        9=Work with printing status

Opt  File        User        User Data   Sts
     QINVOICE    SIMON                   SND

When the file has been transfer to the remote partition its status, on the local partition, will change to SAV.

On the remote partition the spool file shows as ready.

                   Work with Output Queue

Queue: SOMEOUTQ   Library: SOMELIB     Status: RLS/WTR

Type options, press Enter.
  1=Send   2=Change   3=Hold   4=Delete   5=Display
  8=Attributes        9=Work with printing status

Opt  File        User        User Data   Sts
     QINVOICE    SIMON                   RDY

On the remote partition I can change the output from SOMEOUTQ to the user's printer output queue and it will print for them on their printer.

If I need to confirm which printer my remote output queue is attached to I can use the Work With Output Queue Description command, WRKOUTQD.

WRKOUTQD OUTQ(MYLIB/RMTOUTQ)

On the second screen I can see the remote system and output queue.

                 Work with Output Queue Description

Queue:   RMTOUTQ        Library:   MYLIB

Authority to check . . . . . . :   *OWNER
Remote system  . . . . . . . . :   RMTSYS



Remote printer queue . . . . . :   SOMELIB/SOMEOUTQ

If I wanted to know all of the remote output queues on this partition I can use the Db2 for i Output Queue Information view.

SELECT OUTQ,OUTQLIB,NET_TYPE,DEST_TYPE,
       CAST(REMOTE_NAM AS CHAR(25)) AS REMOTE_NAME,
       CAST(REMOTE_PRT AS CHAR(21)) AS REMOTE_OUTQ
  FROM QSYS2.OUTPUT_QUEUE_INFO
 WHERE WRITER_TYP = 'REMOTE'

I will find my output queue listed amongst all the other remote output queues.

OUTPUT_QUEUE_NAME  OUTQLIB     NET_TYPE  DEST_TYPE  REMOTE_NAME
   RMTOUTQ         MYLIB       *SNA      *OS400     RMTSYS


REMOTE_OUTQ
SOMELIB/SOMEOUTQ

 

You can learn more about this from the IBM website:

 

This article was written for IBM i 7.3, and should work for earlier releases too.

1 comment:

  1. to add my 2 cents of information. Remote system can be a AIX partition in which case we can specify URL as well.

    ReplyDelete

To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.