XML with Query and send mail

import PSXP_XMLGEN:*;
import PSXP_RPTDEFNMANAGER:*;
import PSXP_REPORTMGR:*;

Local string &sRptDefn;

/* Initialize variables */
Local XmlDoc &xmlDoc;

Local string &sTmpltID = "";
Local string &sLangCd = "";
Local date &AsOfDate = %Date;
Local string &sOutFormat = "";
Local string &PRCSOUTPUTDIR;
Local string &reportPath = GetEnv("PS_SERVDIR") | "\files\";
Local string &sFolder = "";
Local string &sPrcsServerName = "";
&URL_ID = "record://UP_FILE_TMP"; /* Attachment will be stored here temporarily */

&sRptDefn = "SF_OFFICE";


/* get report definition object */
&oRptDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&sRptDefn);
&oRptDefn.Get();

&oRptDefn.ReportFileName = "CASHIERING_" | RECORDS_AET.BUSINESS_DATE;
&sfilename = &oRptDefn.ReportFileName | ".pdf";
&tfilename = &oRptDefn.ReportFileName | ".pdf";

/* fill query runtime prompt record */
&rcdQryPrompts = &oRptDefn.GetPSQueryPromptRecord();
If Not &rcdQryPrompts = Null Then
&rcdQryPrompts.TRANS_DT.value = RECORD_AET.BUSINESS_DATE.Value;
&oRptDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
End-If;

/*generate report*/
&oRptDefn.ProcessReport("SF_OFFICE_1", "ENG", %Date, "PDF");

&filepath = GetEnv("PS_FILEDIR") | "\"; /* P:\PSoft\files\ */

&source_file = &oRptDefn.OutDestination | "\RptInst\" | &sfilename;
&dest_file = &filepath | &tfilename;
&return = PutAttachment(&URL_ID, &sfilename, &source_file);
&return = GetAttachment(&URL_ID, &tfilename, &dest_file);
&return = DeleteAttachment(&URL_ID, &sfilename);

&file = &filepath | &tfilename;


&MAIL_FLAGS = 0;
&MAIL_TO = "email@address.com";
&MAIL_CC = "";
&MAIL_BCC = "";
&MAIL_SUBJECT = "Cashiering Recon " | RECORD_AET.BUSINESS_UNIT;
&MAIL_TEXT = "Please see attached report for recon puposes.";
&MAIL_FILES = &file;
&MAIL_TITLES = "";
&MAIL_SENDER = "peoplesoft@peoplesoft.com";

&ret = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_SENDER);

Comments