Spooled File Data to a CL Variable: One of the newer commands to the CoolSpools suite, available in the latest CoolSpools Version 7 fix packs, GETSPLDTA allows you to retrieve content from an IBM i spooled file into a CL program variable. This command is part of the Spool Converter module, which already provides rich spooled file conversion functionality.

To retrieve data from a spooled file to a CL variable with GETSPLDTA you can specify either the position of the required data within the spooled file or a lookup key string to search the spooled file for the data’s location.

If you know the specific location within the report where the data can be found then use *POS parameters to specify the page, line and column number where the data can be found.

If the location of the data within the report is unpredictable then use *KEY parameters to search the spooled file’s content using a key string, specifying which occurrence of matching text is to be used and the offset from the search text’s location to the required data.

We are aware of at least one CoolSpools client planning to use this new command to retrieve a report identifier that is only available within the report content in order to decide which CoolSpools spooled file conversion command to run in order to generate a PDF or Excel document and distribute it as an email attachment to the appropriate recipients.

Version Requirements

This new command is available in CoolSpools V7R1 fix pack 049 and upwards. If you are a CoolSpools V7R1 site then follow the instructions in the CoolSpools maintenance guide to update to the latest fix pack level. If you are using CoolSpools V6R1 or older and would like to use the GETSPLDTA command then there is no charge involved in upgrading to CoolSpools V7R1, so long as your support and maintenance is up to date.

Example CL Program

WRKSYSSTS is one of several IBM i system commands that only allow output to screen or print, making it difficult to reference the output of the command within a CL program. Using CoolSpools command GETSPLDTA it is now a simple task to retrieve data from within the spooled file output of such a command for use within a CL program.

The example program below uses both *POS and *KEY options to get data elements (ASP Used percentage and the *BASE pool size) from the output of command WRKSYSSTS OUTPUT(*PRINT).

0001.00 /******************************************************************************/
0002.00 /* Use CoolSpools command GETSPLDTA to extract and display data contained     */
0003.00 /* within the output of system command WRKSYSSTS OUTPUT(*PRINT)               */
0004.00 /******************************************************************************/
0006.00              PGM
0008.00           /* Declare variables to hold results of GETSPLDTA */
0009.00              DCL        VAR(&ASPUSED) TYPE(*CHAR) LEN(30)
0010.00              DCL        VAR(&BASEPOOL) TYPE(*CHAR) LEN(30)
0012.00           /* Run system command to generate QPDSPSTS spooled file */
0013.00              WRKSYSSTS  OUTPUT(*PRINT)
0015.00           /* Get 8 chars by *POS from page 1, line 5, column 112 */
0017.00                           DATA(&ASPUSED) GETSPLPRM(*POS) +
0018.00                           GETSPLPOS(1 5 112 8)
0020.00           /* Use *KEY to search *ALL pages for the first occurrence of ‘*BASE’*/
0021.00           /* and get the 9 chars starting 77 columns to the left of that text */
0023.00                           DATA(&BASEPOOL) GETSPLPRM(*KEY) +
0024.00                           GETSPLKEY(*ALL ‘*BASE’ 1 -77 9)
0026.00           /* Output the retrieved data as a program message */
0027.00              SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(‘Current +
0028.00                           ASP Used’ *BCAT &ASPUSED *TCAT ‘% and +
0029.00                           *BASE Pool Size is ‘ *BCAT &BASEPOOL) +
0030.00                           MSGTYPE(*INFO)
0032.00              ENDPGM