Friday, 25 November 2016

Reporting through Peoplecode - Report


import PSXP_RPTDEFNMANAGER:*;

Local Record &rcdQryPrompts;
Local string &LanguageCd, &MyTemplate, &MyReportName, &OutFormat;
Local date &AsOfDate;
Local number &count;

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Set XML Publisher report required parameters                            */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&EMPID = IOBM_TRNSPT_REC.EMPLID.Value;
SQLExec("select max(strm) from ps_iobm_tran_setup t", &sstrm);






&LanguageCd = "ENG";
&AsOfDate = %Date;
&OutFormat = "PDF";

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Create a PDF using XML Report Definition MY_XMLP_DEMO                   */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&MyReportName = "IOBM_TRANSP";
&MyTemplate = "IOBM_TRANSP_1";





/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Hard code my State vale - would normally pull from a field on the page */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Declare and Instantiate (construct) your Report Definition Object       */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&MyReportName);

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Get a handle on your Report Definition                                  */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
WinMessage("PROD     MAIN   .. 1..1   " | &EMPID, 0);
&oReportDefn.Get();

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Since there is a prompt to the query used in this report, you need to   */
/* provide the value for the prompt                                        */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
rem WinMessage("PROD     MAIN   .. 1..1 ..1  " | &EMPID, 0);
&rcdQryPrompts = &oReportDefn.GetPSQueryPromptRecord();
If Not &rcdQryPrompts = Null Then
   &oReportDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   /* Provide a value to the State Prompt                                  */
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

   &rcdQryPrompts.EMPLID.Value = &EMPID;

  
End-If;
rem WinMessage("befor commit  " | &EMPID, 0);

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Kick of the report process                                              */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
CommitWork();

&oReportDefn.ProcessReport(&MyTemplate, &LanguageCd, &AsOfDate, &OutFormat);

CommitWork();
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* CommitWork must be called prior to displaying the output since the      */
/* application package performed work and SQL statements. If you do        */
/* not commit the work performed to this point you will receive an         */
/* error like “Think-time PeopleCode event (ViewAttachment), but a SQL     */
/* update has occurred in the commit interval. (2, 148)”                   */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */


/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Display Report to the user                                              */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/*
Local String &reportPath = GetEnv("PS_SERVDIR") | "\files\reports";
Local String &folderName = "General";
Local string &serverName = "PSNT";

psreports
*/
rem &FilePath = GetEnv("PS_SERVDIR");
rem MessageBox(0, "", 31000, 1, "File Path = " | &FilePath, "File Path = " | &FilePath);
rem WinMessage("befor commit  and lst one " | &EMPID, 0);
&oReportDefn.DisplayOutput();


&oReportDefn.PrintOutput("%DESTPRINTER%");



No comments:

Post a Comment