Following
sample PeopleCode can be used to schedule any process using PeopleCode (Application
Engine PeopleCode or in any other event). This sample PeopleCode is used to
schedule Crystal report and email the same to the specific user. First it
override the parameter set in the Crystal report process definition than it
schedules the Crystal Report process and wait until that process resulted into
success.
Local ProcessRequest &Rqst;
Local string &Subject, &Text, &EmailId, &Running, &Finish;
Local integer &PrcsInst;
/*use sql exe to update parameter of crystal report process definition*/
TEST_STATE_AET.PARMLIST.Value = "-ORIENTP " | Char(34) | TEST_STATE_AET.OPRID.Value | Char(34) | " " | Char(34) | TEST_STATE_AET.PROCESS_INSTANCE.Value | Char(34);
&Rqst = CreateProcessRequest();
&Rqst.RunControlID = TEST_STATE_AET.RUN_CNTL_ID.Value;
&Rqst.ProcessType = "Crystal";
&Rqst.ProcessName = "TESTCRST";
&Rqst.RunLocation = "PSNT";
&Rqst.OutDestType = "Email";
&Rqst.OutDestFormat = "PDF";
&Rqst.OutDest = TEST_STATE_AET.EMAILID.Value;
&Rqst.EmailSubject = "TEST MAIL";
&Rqst.EmailText = "TEST MAIL";
&Rqst.EmailAttachLog = False;
&Rqst.Schedule();
&PrcsInst = &Rqst.ProcessInstance;
/* wait until PROCESS finish */
/*check process running status check process completed or not*/
&Running = "S";
While &Running = "S"
SQLExec("select 'x' from psprcsrqst where PRCSINSTANCE = :1 and runstatus in ('5','6','7','14')", &PrcsInst, &Finish);
If None(&Finish) Then
&Running = "N"
End-If;
End-While;
thanks!! help me a lot
ReplyDeleteGood Job. However this can be improved with a timer otherwise it will cause performance issue executing the same sql over and over again!.
ReplyDeleteKeep posting!