PeopleCode JobRunStatus

Function JobRunStatus(&ProcessInstance As number) Returns string;
Local string &RunStatus;
Local Record &rec;
Local SQL &sql;
Local boolean &IsCompleted;

&rec = CreateRecord(Record.PMN_PRCSLIST);
/* PMN_PRCSLIST.SEQUENCENO is the process instance number for either a process or a job */
/* PMN_PRCSLIST.PRCSINSTANCE is the proces instance number for a single process */
/* PMN_PRCSLIST.JOBINSTANCE is the proces instance number for a job */
/* When a process is scheduled PMN_PRCSLIST.SEQUENCENO = PMN_PRCSLIST.PRCSINSTANCE */
/* When a job is scheduled PMN_PRCSLIST.SEQUENCENO = PMN_PRCSLIST.JOBINSTANCE */
rem &sql = CreateSQL("%Selectall(:1) Where JOBINSTANCE = :2");
&sql = CreateSQL("%Selectall(:1) Where SEQUENCENO = :2");
&sql.Execute(&rec, &ProcessInstance);
While &sql.Fetch(&rec)
&IsCompleted = False;
&RunStatus = &rec.RUNSTATUS.Value;
Evaluate &RunStatus
When = "1"
When = "2"
When = "3"
When = "8"
When = "9"
When = "10"
When = "14"
&IsCompleted = True;
Break;
End-Evaluate;
If &IsCompleted Then
Break;
End-If;
End-While;
&sql.Close();
Return &RunStatus;
End-Function;

posted on 2016-08-02 15:11  香里七  阅读(191)  评论(0编辑  收藏  举报