Below is a snippet of code showing how to initiate a process via peoplecode. This specific scenario is using the delivered record FUNCLIB_SF.PRINT_RECEIPT. It is setting up a BI Publisher process.
Note - For emailing a BI Publisher report the Process Instance can not be 0.
Peoplesoft has some delivered app classes to handle BI Publisher reports (ex: how the report is displayed - browser, email, printer, etc) which can be found in PSXP_RPTDEFNMANAGER:ReportDefn
If %Page = Page.CSH_OFF_DEPT Or
%Page = Page.CSH_RCPT_DETAIL Then
&sProcessName = "PSXPQRYRPT";
End-If;
&sRunCntlid = "PRINT_RECEIPT";
&sProcessType = "XML Publisher";
&RQST = CreateProcessRequest();
&RQST.ProcessType = &sProcessType;
&RQST.ProcessName = &sProcessName;
&RQST.RunControlID = &sRunCntlid;
&RQST.RunLocation = "SERVER";
&RQST.OutDestType = "6";
&RQST.OutDestFormat = "2";
&RQST.RunDateTime = %Datetime;
&RQST.TimeZone = %ServerTimeZone;
If &EmailDept = "Y" And
&EmailReceipt Then
&RQST.OutDestType = "5";
&RQST.OutDestFormat = "2";
&RQST.OutDest = &EmailID; /*&EmailID;*/
&RQST.EmailSubject = "BI Publisher Report";
&RQST.EmailText = "BI Publisher Report";
End-If;
&RQST.Schedule();
&iProcessStatus = &RQST.Status;
................
................
If SetBIPublisherProcess(&sBIPubStat) = True Then
rem Exit (0);
.................
.................
Function SetBIPublisherProcess(&sBIPubStat As string) Returns boolean;
Local SSF_CASHIERING:PrintReceipt:ReportingContext &RptContext = create SSF_CASHIERING:PrintReceipt:ReportingContext();
Local SSF_CASHIERING:PrintReceipt:BIPubReport &BIPubReport = create SSF_CASHIERING:PrintReceipt:BIPubReport( False);
Local string &sBindRecordName = "%Table(RUN_CNTL_SF)";
Local string &sPromptRecName = "Record.PSCONQRSRUNPRMX";
Local Record &RecRunCntlSF = CreateRecord(Record.RUN_CNTL_SF);
Local array of array of string &aFldBindNames;
&aFldBindNames = CreateArray(CreateArray("BUSINESS_UNIT", "CASHIER_OFFICE", "RECEIPT_NBR", "OPRID", "RUN_CNTL_ID"));
&aFldBindNames.Push(CreateArray("BUSINESS_UNIT", "CASHIER_OFFICE", "RECEIPT_NBR", "OPRID", "RUN_CNTL_ID"));
rem Update Bind Record(RUN_CNTL_SF);
&RecRunCntlSF.OPRID.Value = %UserId;
&RecRunCntlSF.RUN_CNTL_ID.Value = &sRunCntlid;
&RecRunCntlSF.BUSINESS_UNIT.Value = &sBusinessUnit;
&RecRunCntlSF.CASHIER_OFFICE.Value = &sCashierOffice;
&RecRunCntlSF.RECEIPT_NBR.Value = &iReceiptNbr;
&RecRunCntlSF.Delete();
&RecRunCntlSF.Insert();
Evaluate CSH_OFF_RECEIPT.CO_TRANS_TYPE.Value
When "03"
rem Departmental Receipt;
&sReportDefinition = "SF750R_DRCPT";
&sReportTemplateDef = "SF750R_DRCPT_1";
Break;
When-Other;
Break;
End-Evaluate;
&RptContext.RunControlId = &sRunCntlid;
&RptContext.ProcessInstance = &RQST.ProcessInstance;
&RptContext.PromptRec = &sPromptRecName;
&RptContext.ReportName = &sReportDefinition;
&RptContext.TemplateId = &sReportTemplateDef;
&RptContext.LanguageCd = "";
&RptContext.AsOfDate = %Date;
&RptContext.CQName = "SF750R_BI_CSH_OFF_RCPT_PRINT";
&RptContext.OutDestFormat = 2;
&RptContext.OutDestType = &nOutDestType;
&RptContext.OutDestPrinter = &sOutDestPrinter;
&RptContext.FldBindNames = &aFldBindNames;
&RptContext.BindRecordName = &sBindRecordName;
If &BIPubReport.GenerateReceipt(&RptContext) = True Then
Return True;
Else
Return False;
End-If;
End-Function;
No comments:
Post a Comment