Transcription

Invoke BI Publisher Report withPeopleCodePT 8.58Randall GronckiIntroductionBI Publisher is a powerful reporting tool available with PeopleTools versions 8.48 and higher. Thoughmost demonstrations and training focus on Query based BI Publisher reports, the tool’s real power iswhen it is embedded into the application pages where users would naturally expect the reports.The delivered PeopleCode BI Publisher Application packages allow full control of the reports with moreoptions to the designer. The data source structures are protected from end users while the developerhas multiple options to invoke and deliver the reports.For purposes of the demonstration, this paper is using PeopleTools 8.58, which is the latest toolsavailable in the PUM environments at the time of its writing. We are using an XML File as the reportdata source.This paper discusses using PeopleCode and other tools within the Application Designer to create anddeliver BI Publisher reports within the PeopleSoft application. It assumes that the user is familiar withthe fundamentals of creating a BI Publisher Report Definition: Define the data source and provide sample XML data file Create the BI Publisher Report template using the sample XML data file Tying all parts together with security in a BI Publisher Report DefinitionThe paper is divided into three sections: Invoking a BI Publisher report in the user’s current session using a push button on the page Invoking a BI Publisher report from an App Engine on the Report Server as a batch process Demonstrates a few ways to present the report to the user including the Report Repository,popup window and emailing the report.PeopleTools Tech Tips1

BI Publisher PeopleCode Object DocumentationPeopleBooks’ PeopleCode API Reference has extensive documentation on the BI Publisher Classes,Methods and Properties.See the API Reference for your PeopleTools version for details and code examplesPeopleBooks Path: PeopleTools Development Tools PeopleCode API Reference BI Publisher ClassesReport Invocation and Creation – Page in User’s SessionGenerating the ReportOnce the XML File is generated, it’s very simple to create the report and give it to the user. Thedelivered PeopleCode Application Package handles all the BI Publisher Report functions.This example displays the report to the user in a new popup window on their display. Given the reportwindow, the user can print, save or do whatever they like with the result.1) Import the application package and instantiateimport PSXP RPTDEFNMANAGER:*;&oXML PUB create PSXP RPTDEFNMANAGER:ReportDefn("Report Definitionname");&oXML PUB.Get();2) Set the data source&oXML PUB.SetRuntimeDataXMLfile(&XML Filename path);3) Process the reportThis process creates the report object itself. After this step, the developer just has to decidehow to present the report to the user./* Process Report */&oXML PUB.ProcessReport("", "", %Date, "");/* save to clear think time functions */CommitWork();4) Display the output in a new popup window&oXML PUB.DisplayOutput();PeopleTools Tech Tips2

Report Invocation and Creation – App Engine in BatchCreating the App EngineBI Publisher batch objects known as “XML Publisher” are nothing more than Application Engines.These App Engines have all the same capabilities as any other App Engine in the system. They just havea different “Process Type” when registering them in the Process Scheduler.PeopleTools Tech Tips3

As App Engines, they should have a State Record, get run control parameters from the user and executethe reportSince an App Engine is running from the Process Scheduler and not the user’s session, there areadvantages for larger reports or reports using more resources to generate data The App Engine is not limited to the user’s session time out limit Little or no impact to online performance Ability to schedule the reportMost BI Publisher App Engines use mostly dynamic “Boiler Plate” PeopleCode based on a PSQuery datasource to generate the report.To demonstrate that the AE BI Publisher PeopleCode is primarily the same as the Online PeopleCode, weare this process as an XML data source too.1) Import the application package and instantiateimport PSXP RPTDEFNMANAGER:*;&oXML PUB create PSXP RPTDEFNMANAGER:ReportDefn("Report Definitionname");&oXML PUB.Get();2) Set the data source&oXML PUB.SetRuntimeDataXMLfile(&XML Filename path);3) Set the destination information should the user have chosen file output (boiler plate code)/* set file path only for file output type - other types usedefault temporary location */If %OutDestType 2 Then /* file */&oXML PUB.BurstValueAsOutSubDir False;&oXML PUB.OutDestination %FilePath;End-If;4) Set the Process Instance information&oXML PUB.ProcessInstance X TRNLTR AET.PROCESS INSTANCE;5) Process the reportThis process creates the report object itself. After this step, the developer just must decide howto present the report to the user./* Process Report */&oXML PUB.ProcessReport("", "", %Date, "");PeopleTools Tech Tips4

6) Publish the report to the user’s preference (boiler plate code)/* publish */If %OutDestType 6 Then /* Web */&oXML PUB.Publish("", "", "", X TRNLTR AET.PROCESS INSTANCE);ElseIf %OutDestType 3 Then /* Printer */&oXML PUB.PrintOutput(%FilePath);ElseIf %OutDestType 5 Then /* Email */&bResult &oXML PUB.EmailOutput(X TRNLTR AET.PROCESS INSTANCE);End-If;End-If;End-If;PeopleTools Tech Tips5

Generating the report to a file on the serverBI Publisher creates directories and files under the Application Server temp file space during operation.The fully qualified file name can be derived using a quick PeopleCode routine and properties of theXML Publisher object.*Note: In order for the PSXP RPTDEFNMANAGER:ReportDefn.OutDestination class property topopulate, the “psxp usedefaultoutdestination” property on the report definition must be set to “True”In the example below, the resulting report’s fully qualified file name is placed in the “&ReportFilePath”string variable.[.code creating report ]&oXML PUB.ProcessReport("", "", %Date, "");CommitWork();&ReportFileName &oXML PUB.ID "." Lower(&oXML PUB.GetOutDestFormatString(2));&ReportFilePath &oXML PUB.OutDestination &sDirSep "RptInst" &sDirSep &ReportFileName;PeopleTools Tech Tips6

Bi Publisher OutputThe delivered application package contains several options for presenting the report:1) Send to the PeopleSoft Report Repository:&XML PUB Object.Publish(&sServerName, &reportPath, &sFolderName,&processInstanceId);2) Send the report to a printer:&XML PUB Object.PrintOutput(&DestPrinter As string);3) Send the report to a new popup window (shown above)&XML PUB Object.DisplayOutput()4) Mail the reporta. If running from the Process Scheduler (Batch) the EmailOutput() uses data from the RunControl parameters to email the report&XML PUB Object.EmailOutput (ProcessInstanceID)b. If Interactive on a page, the following code sends the resultant BI Publisher report to theemail address or addresses contained the “&MAIL TO” string.[.code creating report ]&oXML PUB.ProcessReport("", "", %Date, "");DoSaveNow();&ReportFileName &oXML PUB.ID "." Lower(&oXML PUB.GetOutDestFormatString(2));&ReportFilePath &oXML PUB.OutDestination &sDirSep "RptInst" &sDirSep &ReportFileName;&MAIL FLAGS 0;&MAIL TO "[email protected]";&MAIL CC "";&MAIL BCC "";&MAIL SUBJECT &Email Subject;&MAIL FILES &ReportFilePath;&MAIL TITLES "xml pub.PDF";&ret SendMail(&MAIL FLAGS, &MAIL TO, &MAIL CC, &MAIL BCC, &MAIL SUBJECT,&MAIL TEXT, &MAIL FILES, &MAIL TITLES, &MAIL SENDER);If Not (&ret 0) ThenMessageBox(0, "", 299, 1, "Return status from mail %1" &ret);End-If;PeopleTools Tech Tips7

Invoke BI Publisher Report with PeopleCode PT 8.58 Randall Groncki Introduction BI Publisher is a powerful reporting tool available with PeopleTools versions 8.48 and higher. Though most demonstrations and training focus on Q