Using SPOOL facility

Top  Previous  Next

The second method to print data under XCICS is to use SPOOL commands (SPOOLOPEN, SPOOLWRITE, SPOOLCLOSE.).

This transaction, once started, will issue SPOOL commands to write the print file.

The SPOOL commands provide a long list of parameter to identify and describe the attributes of the printout (FORM, FC; DESTINATION, etc.)  and because of it XCICS will include at the beginning of the generated file a list of all the parameters supplied in the SPOOLOPEN command, prefixed by the tag /spoolopen/.

This list starts with /spoolopen/begin-of-properties tag and will end with the tag /spoolopen/end-of-properties.

I.e.

/spoolopen/begin-of-properties
/spoolopen/title=
/spoolopen/class=C
/spoolopen/asa=true
/spoolopen/copies=3
/spoolopen/sep=false
/spoolopen/nosep=false
/spoolopen/forms=ACRT
/spoolopen/fcb=
/spoolopen/linelength=0
/spoolopen/lines=0
/spoolopen/destination=
/spoolopen/recordlength=133
/spoolopen/node=NODE1
/spoolopen/end-of-properties
******************************************************************
* example SPOOL printout                                          *
******************************************************************
Surname: Smith
Name:    Mary
******************************************************************

This file is temporary stored in the path defined in the configuration parameter spool_path.

When transaction completes XCICS will provide to spool the generated file through the command specified in the configuration parameter spool_command.

The spool_command is  a user defined script/executable which takes care of forwarding the file to the printing subsystem or to do whatever the user needs.

XCICS invokes the spool_command providing the following arguments:

1.the absolute path name of the printout file

Writing JCLs

Sometimes SPOOL facility is used on mainframe to write directly to the SYSREADER, in order to dynamically write and start JCLs.

Under XCICS application may do the same: the spool_command will have to be in this case "intelligent" enough to understand (normally from the file prefix name, of from its contents) if a spooled file is a printing or a JCL, and consequently decide if to print it or handle it as a JCL.

A rehosted online application which dinamically writes JCL should be converted in order to write directly UNIX scripts, but sometimes user may decide to do not this activity. Therefore a dynamic conversion is required (see XMVSCONV, the JCL converter).

An example

We suppose to have a spoo_command named tpsh.

The xcics.conf will contain the following lines:

set print_command=$HOME/bin/tpsh
set spool_path=$HOME/tmp

If a transaction invokes SPOOL commands, when completed, XCICS will issue the command:

$HOME/bin/tpsh $HOME/tmp/<REPORT>.<DATE>.<PID>.<ID>

Where <REPORT> is the name specified in the REPORT() parm of SPOOLOPEN (REPORT is the default)

The "tpsh" script could be defined as follow (an example):

#!/bin/ksh
#
# example spooling shell which
# extract the destination from the spool file
# and forwards it to corresponding lp class
# if destination is not defined assumes $PRINTER as default
#
filename=$1
$temporary_file=/tmp/spool.$$
destination=$(grep "^/spoolopen/destination=" $filename | sed 's/.*=//')
if [ -z "$destination" ]
then
   $destination=$PRINTER
fi
grep -v "^/spoolopen/" < $filename > $temporary_file
lp -c -d $destination $temporary_file
rm -f $temporary_file