Friday, 13 July 2018

Run Report through Peoplecode - using in Between Prompt type

import PSXP_RPTDEFNMANAGER:*;

/*=======================================REPORT PRINTING=============================*/


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

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Set XML Publisher report required parameters                            */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */








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

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Create a PDF using XML Report Definition MY_XMLP_DEMO                   */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
&MyReportName = "BHU_CLASS_AT";
&MyTemplate = "BHU_CLASS_AT_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                                  */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
rem 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                                  */
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
 
 
   rem &FieldName1 = &rcdQryPrompts.GetField(1).Name;
   rem  &FieldName2 = &rcdQryPrompts.GetField(2).Name;
   rem &FieldName3 = &rcdQryPrompts.GetField(3).Name;
   rem &FieldName4 = &rcdQryPrompts.GetField(4).Name;
 
   REM WinMessage(&FieldName1 | "----" | &FieldName2 | "-----" | &FieldName3 | "-----" | &FieldName4);
 
 
 
   &rcdQryPrompts.GetField(1).Value = CLASS_TBL.STRM.Value;
   &rcdQryPrompts.GetField(2).Value = CLASS_TBL.CLASS_NBR.Value;
   &rcdQryPrompts.GetField(3).Value = DERIVED_SR_ATND.ATTEND_FROM_DATE.Value;
   &rcdQryPrompts.GetField(4).Value = DERIVED_SR_ATND.ATTEND_TO_DATE.Value;
   /*

If Not &rcdQryPrompts = Null Then
   &oRptDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
End-If;
*/
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%");
rem BHU_RSLT_INT_DW.BH_BUTTON1.Visible = False;

Tuesday, 17 April 2018

OPRID or OPERATOR ID in Query Runtime




OPRID or OPERATOR ID in Query Runtime




Add the record PSOPRDEFN in your original query and select OPRID.