Please enable JavaScript to view this site.

InterFormNG2 Manual

Navigation: Spooled file support > Spooled files in the workflow

Use translation file to link users with an output queue

Scroll Prev Top Next More

In this section we will look at how we can use a translation file to dynamically select the output queue and output queue library and use that to move a spooled file and to use this for the target printer for a merge with a template.

 

This section is related to the section, Use a database to move a spooled file or set output printer.

 

A prerequisite for this is, that we are processing a spooled file in a workflow e.g. via monitoring an output queue or via IBM i command input.

 

First we should consider the structure of the translation file. We created a simple text (UTF-8 encoded) text file with this as the the contents:

 

KSE         = QUSRSYS/OUTQKSE

KSE3        = QUSRSYS/OUTQKSE3

*OTHERWISE* = QUSRSYS/PRT02

 

This file has three entries where the first two contains a user profile and the last is the fallback value, which is setup with the reserved key value, *OTHERWISE*

 

With this setup we have decided, that the user, KSE prefers the output queue OUTQKSE in library, QUSRSYS and the user KSE3 prefers the output queue, OUTQKSE3 in library QUSRSYS.

 

If we refer to a user, that is not listed, then we want to use the default output queue PRT02 in library, QUSRSYS.

 

We here setup this translation file in the library with the name: UserOutputQueues.properties. We only need a single file without any language (remember that underscores are used for separating the standard file name from the locale, so you should avoid underscore for the root file name).

 

Now we can do a lookup in this translation file with the expression below, where we use the built-in function, ng:translation() and we also want to use the predefined variable, interform.input.spooled.user with is one of the predefined variable for spooled files and this contains the user profile of the spooled file, that triggered the workflow.

 

ng:translation('UserOutputQueues','KSE','en')

This function call looks up in the translation file, UserOutputQueues.properties, use 'KSE' as the key, 'en' as a dummy locale and returns the value: QUSRSYS/OUTQKSE.

 

This function call:

ng:translation('UserOutputQueues',$interform.input.spooled.user,'en') is using the user from the input spooled file as the key.

This will returns the value, QUSRSYS/PRT02 if the user is not included in the translation file as the value for the reserved key, *OTHERWISE* is used if the key is not found.

 

The only thing missing is to separate the output queue library and the output queue and that can be done with the Xpath functions, substring-before() and substring-after() like below:

 

The output queue library can be found with this expression, which returns whatever characters, that are found to the left of '/':

substring-before(ng:translation('UserOutputQueues','KSE3','en'),'/')

 

The output queue can be found with this expression, which returns whatever characters, that are found to the right of '/':

substring-after(ng:translation('UserOutputQueues','KSE3','en'),'/')

 

 

Now we can use functions mentioned above in the examples below:

 

Example 1: Move input spooled file to the user output queue.

Example 2: Print to the printer specified by the users output queue.

Example 3: Print to a dynamic output queue specified by the users output queue and library.

 

 

Example 1: Move input spooled file to the user output queue

If we want to move the input spooled file to the output queue found via the translation file setup above, then we can use this setup:

 

NG2UseTranslationMove001

 

 

 

Example 2: Print to the printer specified by the users output queue

If you make sure, that your InterFormNG2 printers are named the same as the target output queues then you can use the translation file above to select the printer in this manner:

 

NG2UseTranslationMove002

 

 

Example 3: Print to a dynamic output queue specified by the users output queue and library

If you have a license key for InterFormNG2 which allows unlimited number of printers, then you can consider the solution below as a way to avoid creating a lot of printers in InterFormNG2, but instead place the merged spooled file on an output queue and let the operating system handle the printing. Here we are using unregistered printers.

 

In order to do this we need to create the required print data stream and then copy that to a spooled file in an output queue of our choice.

 

This is done with a workflow like below:

 

NG2UseTranslationMove003

 

The three workflow components are setup like below:

 

Step1

The Set multiple workflow variables is setup like shown here:

 

NG2UseTranslationMove009

 

In that way the predefined variables, interform.as400.outputQueue and interform.as400.outputQueueLib are used for setting the target 'printer' by referring to the target output queue instead of a registered printer.

 

 

Step2

The second element generates the print data stream, that we want to send to the printer. In this case it is PCL, but it could also be ZPL, Direct protocol or PDF. For PCL output we want the payload to change into PCL and that is done with the workflow component, Create PCL document like below:

 

NG2UseDBMove005

 

We refer to a template and the result of the merge with this template is the PCL output, which can later be sent to the printer.

 

 

Step3

Now it is time to send the new PCL payload to the printer, that was previously selected. That is done with the workflow component, To printer, which has no parameters:

 

NG2UseDBMove006

 

 

If you want to set additional attributes of the merged spooled file, then you can consider to also insert the component, IBM i print attribute options before the payload is sent to the printer.