Example: Implementation Example
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;