2012-04-25

HowTo achieve process instance of scheduled process

[source: http://peoplesoft.ittoolbox.com/groups/technical-functional/peopletools-l/peoplecode-to-discover-process-instance-of-scheduled-process-892219]


In 8.44, when you schedule a process, you are returned a ProcessRequest object which has as a property - ProcessInstance. Here is the entry from PeopleBooks:

--- ProcessInstance Description ---
This property is a system-generated identification number. PeopleSoft Process Scheduler assigns a ProcessInstance at runtime to each process or job it successfully schedules.

This property is read-write. 

<* Example starts *> 
&RQST = CreateProcessRequest(); 
&rec = GetRecord();

/* Set all the Required Properties */ 
&RQST.RunControlID =
&RQST.ProcessType = "Application Engine"; 
&RQST.ProcessName =
&RQST.RunDateTime = &rec.STARTDATETIME.Value; 

/* Schedule the Process - get the instance and change the runstatus to HOLD*/ 
&RQST.Schedule(); 
If &RQST.Status = 0 then 
    /* process successfully scheduled, ***get the instance*** */ 
    &ProcInst = &RQST.ProcessInstance; 
    /* change the runstatus to HOLD */
    If All(&rec.CS_DEPEND_NAME.Value) Then 
        &RQST.RunStatus = "4";
        &RQST.UpdateRunStatus(); 
    End-If; 
Else 
    /* do error processing */
End-If; 
<* Example Ends *> 

No comments: