Local number &RptId, &count;
Local ProcessRequest ≺
Local string &crystal_server, &orderno, &oprid, &RPT_NAME, &concatenate;
Component any &ProcInst, &Runstatus, &Runid, &Disstatus;
If CRSE_SESSN_SRCH.SESSION_STATUS.Value <> "A" Then
Error (MsgGetText(31000, 1, "Report will be generated only for Active Sessions."))
End-If;
&RPT_NAME = "REVRPT";
&oprid = %OperatorId;
SQLExec("SELECT SERVERNAME FROM PS_PRCSDEFN WHERE PRCSNAME = :1", &RPT_NAME, &crystal_server);
If None(&crystal_server) Then
SQLExec("SELECT A.SERVERNAME, B.ORDERNO FROM PS_SERVERCLASS A, PSSERVERSTAT B WHERE A.PRCSTYPE = 'Crystal' AND B.SERVERNAME = A.SERVERNAME AND B.SERVERSTATUS = '3' ORDER BY B.ORDERNO", &crystal_server, &orderno);
End-If;
&pr = CreateProcessRequest();
&pr.ProcessType = "Crystal";
&pr.ProcessName = &RPT_NAME;
&pr.RunControlID = "RUN007";
If All(&crystal_server) Then
&pr.RunLocation = &crystal_server
Else
&pr.RunLocation = "Server"
End-If;
&pr.Schedule();
If &pr.Status = 0 Then
&ProcInst = &pr.ProcessInstance;
Repeat
SQLExec("SELECT RUNSTATUS,RUNSTATUSDESCR ,DISTSTATUS FROM PS_PMN_PRCSLIST WHERE PRCSNAME=:1 AND PRCSTYPE='Crystal' and OPRID=:2 AND PRCSINSTANCE=:3", &RPT_NAME, &oprid, &ProcInst, &Runid, &Runstatus, &Disstatus);
If (&Runid = "3" And
&Runstatus = "Error") Then
Error MsgGetText(20008, 3, "Report not generated");
Break;
End-If;
Until (&Runid = "9" And
&Disstatus = "5" And
&Runstatus = "Success");
End-If;
If (&Runstatus = "Success") Then
SQLExec("SELECT CONTENTID FROM PS_CDM_FILELIST_VW WHERE CDM_FILE_TYPE='PDF' AND PRCSINSTANCE=:1", &ProcInst, &RptId);
SQLExec("SELECT URL FROM PS_CDM_LIST_VW WHERE PRCSINSTANCE=:1", &ProcInst, &url);
&concatenate = &url | "/" | &RptId | "/" | &RPT_NAME | "_" | &ProcInst | ".PDF";
DIT_REVIEW_WRK.GENERATE_BTN_ESP.Value = &concatenate;
ViewURL(&concatenate, True);
End-If;
Hi
ReplyDeleteThis is intereting code except that it lacks a exit strategy... For exemple, if the process scheduler is down, your code will loop indefinately until the request is processed