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: See Note below.

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. Can contain the following special value:Start of change
The spooled file with the highest number with a name matching spooled-file-name is selected.
End of change
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.

Services provided in SYSTOOLS have authorization requirements that are determined by the interfaces used to implement the service. To understand the authority requirements, extract the SQL for the service and examine the implementation.


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');