Tuesday, December 13, 2011

XMLP Output Options

Following are the different ways to display a XMLP report, via peoplecode.

/* initialize */
&reportdefn = create PSXP_RTPDEFNMANAGER:ReportDefn(&report);
&template = &reportdefn.GetDefaultTemplateID();

/* this will create the PDF report output under c:\temp\ */
/* useful when generating report via an AE program */
&reportdefn.OutDestination = "c:\temp\";
&reportdefn.ProcessReport(&template,%Language_User,%Date,"PDF");
&reportdefn.Publish("","","",N_RECORD_AET.PROCESS_INSTANCE);

/* without setting &reportdefn.OutDestination as mentioned above the PDF report will be written to the report respository and available via the Report Manager */
&reportdefn.ProcessReport(&template,%Language_User,%Date,"PDF");
&reportdefn.Publish("","","",N_RECORD_AET.PROCESS_INSTANCE);

/* this will open the output in a new browser window. In this case code is executed on the appserver as against process scheduler in the above two scenarios */
&reportdefn.ProcessReport(&template,%Language_User,%Date,"PDF");
CommitWork();
&reportdefn.DisplayOutput();

Based on the above scenarios here is cool trick to show the report under process monitor (view/log trace) instead of the report manager.
SQLExec("SELECT PRCSOUTPUTDIR FROM PSPRCSPARMS WHERE PRCSINSTANCE = :1",N_RECORD_AET.PROCESS_INSTANCE, &dir);
&reportdefn.OutDestination = &dir | "\";
&reportdefn.ProcessReport(&template,%Language_User,%Date,"PDF");
&reportdefn.Publish("","","",N_RECORD_AET.PROCESS_INSTANCE);