Every IBM i system generates spool files in one way or another. From job logs and compile listings to old-school inventory lists and sales reports, spool files can be quite prevalent. Many companies use tools to convert their spool files into PDFs that can be easily emailed or displayed, and Valence is no exception. The Spool File Viewer app included with Valence makes it easy for users to list spool files and download them in PDF form.

spool file

But did you know you can also bring Spool File Viewer functionality directly into your Nitro App Builder-developed apps? This makes it possible to conveniently show specific spool files without users having to leave the app to find and view the documents generated by their actions.

Introduced in Valence build 6.1.20221219.0, the Spool File Viewer is accessed within NAB Designer as a utility widget. This means you bring it into your app by clicking on "Add Widget", then click the "Utility Widgets" button, then select "Spool File Viewer" as depicted here:

Spool File Viewer utility widget

In order for the desired spool file to be shown in your app, you must supply the viewer widget with pertinent spool file attributes using app variables. The values required are:

  • The name of the spool file
  • The spool file number*
  • The name of the job that created the spool file
  • The user of the job that created the spool file
  • The job number that created the spool file

Spool File Viewer app variables

In cases where you'd like the spool file to occupy the full screen within your app, you may find it easiest to place the Spool File Viewer widget in its own section, then show that section once the required app variables have been populated.

The app variables feeding the spool file viewer may come from the front-end, such as a clicked row in a grid widget, or from a back-end RPG program that has been called through a front-end action, like a button click. The latter scenario is most applicable for calls to programs that create spool files which you'd like to display in-line to the user. In such cases, your back-end RPG program should set the app variables with the pertinent values once the spool file has been created. This is done using the SetAppVar() NAB helper program procedure, as depicted in EXNABBTN.

Once you have the spool file attributes linked to your widget, all you need to do is display it (i.e., using a "Hide/Show Widget" action in Behaviors) and the spool file will be rendered within whatever space you've defined for the widget...

Acme packing list

By default, the spool file viewer will show the spool file as inline text using a uniform size font, as depicted above. If you'd prefer to see the spool file as a PDF (available when running in Desktop only), click on the widget's Settings and click the "View as PDF" checkbox.

Show spool file as PDF

To see the Spool File Viewer widget being put to use in a live demo, be sure to catch the upcoming Developer Diaries episode on February 9. Click here to set a calendar reminder.

 

*Note: In the forthcoming Valence maintenance build, expected to be released in mid February 2023, the app variable holding the spool file number can be hard-coded to a value of *LAST. This will signal the viewer widget to retrieve the last applicable spool file generated by the specified job having a matching spool file name.

CategoryTip of the Month