Including External Attachments with BI Publisher Reports

This topic describes including external attachments with BI Publisher reports.

PeopleTools enables you to include attachments from external sources with BI Publisher PDF report output.

The source attachments are converted to PDF format and then merged with the main report. The report is then displayed to the end users or delivered to Report Manager.

To convert attachments to PDF output, BI Publisher utilizes Oracle’s Outside In Technology (OIT), a product that enables the transformation and control of more than 600 file formats, including documents from office suites, specialty formats, and legacy files

This feature is available for any BI Publisher report with PDF output. The following template types are supported: RTF templates, PDF templates, and XSL templates.

Note: This feature is not supported on z/OS platform.

You must create a unique directory with a unique file path on a file system that the application server or process scheduler server can access and then stage the file to convert to PDF and merge with a BI Publisher report in the report output directory. The directory path should be unique for the current user and the current process.

Attachments are passed to the system in a string array and are included in the report in the order in which they are positioned in the array.

You can set the fonts that are used to render text in external attachments and other converted attachment properties using the pspdfexport.cfg file.

The pspdfexport.cfg file is located in the <PS_HOME>\appserv directory.

To specify the font to use to render text, locate the #SCCOPT_FONTDIRECTORY section in the file and uncomment the fontdirectory property and specify the location of the fonts to use.

The following example shows the #SCCOPT_FONTDIRECTORY section of the property file:

#SCCOPT_FONTDIRECTORY
#This option specifies the directory on the fonts that are to be used 
#when rendering text
#This is a required option on unix - if not set in Windows, the fallback 
#will be to use the default windows font directory.
#
#fontdirectory C:/WINDOWS/Fonts

See Oracle’s Outside In Technology documentation for information on the properties in the pspdfexport.cfg file.

Passing external attachments to BI Publisher for converting to PDF and merging with the main report must be done prior to calling the BIP ProcessReport method.

To pass external attachments and files to BI Publisher, use the following PeopleCode:

&oRptDefn.setPDFConversionFiles(&inputFiles)

In this PeopleCode, oRptDefn is a report object already instantiated and &inputFiles is a string array representing paths to the external documents to include in the report as PDF files.

&inputFiles Array

For bursted and non-bursted reports provide an array where each array member specifies an absolute path to the single file or an absolute path to the directory that contains files to be converted.

By default, BI Publisher places the main report as the first document in the PDF report output, followed by the external attachments. The external attachments appear in the generated report in the order in which you define them in the array.

In all cases, the name of the merged output file (main report and external attachments) is the name of the BI Publisher report.

There are three variables that you can use in the &inputFiles array:

Field or Control

Description

%REPORTFILE%

Use this variable to specify where the main report is positioned in the output.

This variable can be positioned only as the first or the last member of the &inputFiles array. If this rule is not followed the report file will be used as the first member of the array

If this placeholder is missing from the array it is added as the first array member during the processing.

%ALLFILES%

Use this variable to include all files in the directory. (This variable resolves to *.*)

It processes only files in the specified directory, child directories are ignored. Converted files appear in alphabetical order.

This variable is valid for bursted and non-bursted reports.

%BTV%

This variable denotes a burst value.

This variable is valid only for bursted reports. If used for a non-bursted report, the array member is ignored.

Example: String Array of Fully-Qualified Paths

This example represents a string array of fully-qualified paths to the external documents to merge with the main report. In this example, the documents in the report output will appear in the order of the array members.

&inputFiles.Push("D:\ExternalFiles\sdk\samplefiles\microsoft-word.doc");
&inputFiles.Push("D:\Temp\Rownumber.htm");
&inputFiles.Push("D:\ExternalFiles\sdk\samplefiles\jpeg-bitmap.jpg");
&inputFiles.Push("D:\ExternalFiles\sdk\samplefiles\microsoft-excel.xls");
&inputFiles.Push("%REPORTFILE%");  
/* in this example the main BI Publisher report is presented as the last */
/* document in the PDF output */

Example: String Array of Single Directories

This example represents an array of a single directory. All files contained in the directory will be converted to PDF documents and merged with the main report.

In this example the attachments in the report output will appear in alphabetical order. To achieve a specific order, rename the documents in the folder accordingly.


/* the main BIP report is presented as the first document in */
/* the PDF output */
&inputFiles.Push("%REPORTFILE%"); 
&inputFiles.Push("D:\Temp\ExternalFiles\%ALLFILES%");
/* Placeholder %ALLFILES% tells BI Publisher to use all documents contained */ 
/* in the folder D:\Temp\ExternalFiles */

Example: String Array of Multiple Directories (Bursted Reports)

This example shows an array of multiple directories named in accordance with the bursted value.

&inputFiles.Push("D:\Temp\ExternalFiles\%BTV%\%ALLFILES%"); 

In this case BI Publisher expects that directory D:\Temp\ExternalFiles has a set of sub-directories named as burst values. Each of the directories contains the documents for a specific bursted value.

For each bursted report, the documents in the BI Publisher output will appear in alphabetical order. Note that the main report will appear first in the output report if there is no %REPORTFILE% placeholder in the &inputFiles array.

The following example shows the Microsoft Windows directory structure where a BI Publisher report is bursted by SALES_ID 8501. In the example, the directory for SALES_ID is D:\Temp\ExternalFiles\8501.

This example illustrates a directory structure for a bursted report. All of the documents in the

Directory structure when a report is bursted by SALES_ID

Example: String Array of Multiple Directories and Multiple Static Files (Bursted Reports)

This example shows a string array that contains multiple directories named in accordance with the bursted value as well multiple static files to add to the bursted report.

This example also illustrates having a header page that separates a report from the converted PDF-formated attachments with a common text for each bursted report.

&inputFiles.Push("D:\Temp\ExteralFiles\attachment_header.rtf");
&inputFiles.Push("D:\Temp\ExternalFiles\%BTV%\%ALLFILES%"); 

To attach multiple static files to each bursted instance use the following syntax:

&inputFiles.Push("D:\Temp\ExternalFiles\COMMON_FILES\%ALLFILES%");  
&inputFiles.Push("D:\Temp\ExternalFiles\%BTV%\%ALLFILES%"); 

In the previous example, the directory D:\Temp\ ExternalFiles\COMMON_FILES is a container for commonly used files for each bursted report instance.

Unicode Support for External Document Paths and Filenames

Unicode characters are supported in the external document paths and filenames.

This includes fully-qualified paths as well as directory paths containing files with Unicode characters in their names.

The following example shows Unicode characters in a full-qualified path:

&inputFiles.Push("D:\ExternalFiles\sdk\VEŘEJNÉ\microsoft-中word.doc");

The following example shows a directory path to a filename that contains Unicode characters:

&inputFiles.Push("D:\Temp\ExternalFiles\%ALLFILES%");

where D:\Temp\ExternalFiles contains a file such as русский_язык_test.txt.

Application servers and Process Scheduler servers running on Unix or Linux platforms require the character set portion of the shell locale to be one that supports Unicode, such as UTF-8.

You can set a timeout value for attachment conversion and processing programmatically in PeopleCode or in BI Publisher’s Global Properties page.

Understanding Setting PDF Attachment Conversion Timeout

When you set a timeout for PDF conversion, if the PDF conversion process is not finished within the specified time, the process is terminated, an error displays, and details are logged in the log file.

For bursted BI Publisher reports the conversion timeout value is used for report attachments for each bursted report instance

The PeopleCode runtime method overrides the value defined in the Global Settings and can be used in cases where relatively large files or a large numbers of files are expected. It also makes sense to increase the timeout interval at runtime in cases when a report is running via process scheduler (PRCS) and execution time is not a priority.

Note: Any programmatic setting made takes precedence over the setting on the Global Properties page.

Setting PDF Attachment Conversion Timeout Programmatically

To set the PDF attachment conversion timeout programmatically, use the following PeopleCode:

&oRptDefn.setPDFConversionTimeOut(&oitTimeOut); 

Where oitTimeOut is a timeout value in seconds.

Setting PDF Attachment Conversion Timeout in the Global Properties

You must have the Report Developer role to set the timeout property in the Global Properties.

To set the PDF attachment conversion timeout in the Global Properties:

  1. Select Reporting Tools > BI Publisher > Setup > BIP Global Properties.

    The Global Properties page appears.

  2. From the Property Group drop-down list, select PeopleTools Settings.

  3. For the psxp_pdfconversion_timeout property, enter a value (in seconds) in the Text column. The default value is 20 seconds.

  4. Click the Save button.

This PeopleCode example illustrates code for creating a report with several attachments merged into the report.

import PSXP_RPTDEFNMANAGER:*;

Local PSXP_RPTDEFNMANAGER:ReportDefn &oRptDefn;
Local string &sRptDefn;
Local string &sTemplateId;
Local date &dAsOfDate;
Local Record &rcdQryPrompts;

try
   &sRptDefn = PSXPRPTSRCH_VW.REPORT_DEFN_ID.Value;
   &sTemplateId = PSXPQRYVIEW_WRK.TMPLDEFN_ID.Value;
   &dAsOfDate = PSXPQRYVIEW_WRK.ASOFDATE.Value;      
   
   /* create report defn object */
   &oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn);
   &oRptDefn.Get();
   
  
   /* output format */
   &sOutputFormat = &oRptDefn.GetOutDestFormatString(Value
			(PSXPQRYVIEW_WRK.OUTDESTFORMAT.Value));
   
   /* fill prompt record */
   &rcdQryPrompts = &oRptDefn.GetPSQueryPromptRecord();
   If Not &rcdQryPrompts = Null Then
      If Not Prompt(&oRptDefn.GetDatasource().Name, "", &rcdQryPrompts) 
				Then
         Exit;
      End-If;
      &oRptDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
   End-If;   
  
   /* If we uncomment 2 statements below output file is generated  */
	 /* in specified location. It should be cleaned up later by Apps */
   rem &oRptDefn.OutDestination = "d:\Temp\BIPoutputdir\" | UuidGen();
   rem CreateDirectory(&oRptDefn.OutDestination, %FilePath_Absolute);

	/* Creating an array of docs to convert. In this case actual report*/
  /* came as the last one */
  If (&oRptDefn.ID = "COUNT_TEST" Or  /* Testing specific reports */
         &oRptDefn.ID = "A_QE_UPGRADE") And
         &sOutputFormat = "PDF" Then
      Local array of string &inputFiles;  
      &inputFiles = CreateArrayRept("", 0);
   
      &inputFiles.Push("D:\ExternalFiles\sdk\samplefiles\
					microsoft-word.doc");
      &inputFiles.Push("D:\Temp\Rownumber.htm");
      &inputFiles.Push("D:\ExternalFiles\sdk\samplefiles\
					jpeg-bitmap.jpg");
      &inputFiles.Push("D:\ExternalFiles\sdk\samplefiles\
					microsoft-excel.xls");
      &inputFiles.Push("%REPORTFILE%"); 
      
     /*setting runtime timeout for conversion process */
      Local number &oitTimeOut = 15;
      &oRptDefn.setPDFConversionFiles(&inputFiles);
      &oRptDefn.setPDFConversionTimeOut(&oitTimeOut);
 		End-If;

		&oRptDefn.ProcessReport(&sTemplateId, %Language_User, &dAsOfDate, 
			&sOutputFormat);
   
   CommitWork();   
   /* display the output */
   &oRptDefn.DisplayOutput();
   
		catch Exception &Err
 			If Not &oRptDefn = Null Then
      	&oRptDefn.Close();
   		End-If;
   
   		Error MsgGet(&Err.MessageSetNumber, &Err.MessageNumber, &Err.ToString());
	end try;