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

3 comments:

  1. Nice article. Works posting to NT log trace without an issue, however running on unix fails even though I append "/".

    Fails with http transfer error

    ReplyDelete
    Replies
    1. Should work in Unix too, verify if PRCSOUTPUTDIR is returning a valid path.

      Delete
  2. Thanks for the reply. Now posting to view/log works. The way you have explained increases the run time by x2 as the processreport is called twice. Understandable.

    To improve, I set the outdestination to view log trace folder and called the processreport once and posted as well. Now it takes same time as posting to report manager however report manager contains both pdf and log files.

    Is there a way to get rid of the log files in the report manager?

    ReplyDelete