Start of change

GENERATE_PDF scalar function

The GENERATE_PDF scalar function generates a PDF file in the Integrated File System containing the content of a spooled file.

This function requires the following product: 5770TS1 - Option 1 - Transform Services - AFP to PDF Transform

Authorization: This scalar function uses the Copy Spooled File (CPYSPLF) CL command. Any authority requirements for the CL command apply to the use of this function.

Read syntax diagramSkip visual syntax diagram GENERATE_PDF ( JOB_NAME =>  job-name ,SPOOLED_FILE_NAME => spooled-file-name,SPOOLED_FILE_NUMBER => spooled-file-number,PATH_NAME => path-name )
The schema is SYSTOOLS.
A character string containing a qualified job name. Can contain the following special value:
Use the name of the current job.
A character string containing the name of the spooled file.
The number of the spooled file.
A character string containing the name of the path where the result PDF file is to be written.
The result of the function is an integer. If the command is successful, the function returns a value of 1. If the command returns an error, the function returns a value of -1.


This function is provided in the SYSTOOLS schema as an example of how spooled file data can be converted to PDF format by embedding the CPYSPLF CL command in an SQL scalar function. Similar to other Db2 for i provided tools within SYSTOOLS, the SQL source can be extracted and used as a model for building similar helper functions, or to create a customized version within a user-specified schema.


Convert the specified spooled file to PDF format and save it as /usr/listing1.
                             JOB_NAME            => '908049/QUSER/QZDASOINIT', 
                             SPOOLED_FILE_NAME   => 'PGMA',
                             SPOOLED_FILE_NUMBER => 2,
                             PATH_NAME           => '/usr/listing1');
End of change