In the below example, we are generating reports using PS Query(we can use XML too).
/*General code to print BI Publisher Report*/
import PSXP_RPTDEFNMANAGER:*; /* get report definition object */
&oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn (&sRptDefn);
&oRptDefn.Get();
&oRptDefn.OutDestination = "/" | GetCwd(); /*We can change this path, if needed*/
/* fill query runtime prompt record */
&rcdQryPrompts = &oRptDefn.GetPSQueryPromptRecord();
If Not &rcdQryPrompts = Null Then
&oRptDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
End-If;
&oRptDefn.ProcessInstance = &prcsInstId;
/*generate report*/
&oRptDefn.ProcessReport (&sTmpltID, &sLangCd, &AsOfDate, &sOutFormat);
&URL_ID = "record://RECORD_NAME"; /*Create URL ID before proceeding, use this link for the steps to URL ID */
&oRptDefn.ReportFileName = "Report_Name"; /*We are changing the name of the report just make it possible to locate it*/
&filename = "Report_Name"|"."|&sOutFormat; /*Adding the extension of the file*/
&source_file = &oRptDefn.OutDestination | &filename;
&return = PutAttachment(&URL_ID, &filename, &source_file);
/*publish report */
&oRptDefn.Publish(&sPrcsServerName,"",&sFolder, &prcsInstId); /*&sPrcsServerName and &sFolder can be "" (i.e. blank) and &prcsInstId is process instance of your process*/
/*As now we have the path for the report (i.e. &source_file), we can now use this to add this report as an attachment in our email, as shown below code*/
&dest_file = &source_file;
/*SendMail() can directly access this file if application server and ftp server are at same location. If they are at different location, use GetAttachment() to get file from ftp server to application server and then mention the path of application server*/
&RET =SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC,&MAIL_SUBJECT, &MAIL_TEXT, &dest_file, &filename,&MAIL_FROM,&MAIL_SEP,&CONTTYPE,&REPLYTO, &SENDER);
No comments:
Post a Comment