Wednesday, May 5, 2010

Running an SQR from within your PeopleCode program

Running an SQR from within your PeopleCode program

The best and safest way to launch an SQR program is to use the PeopleCode functions CreateProcessRequest() and Schedule().

The CreateProcessRequest function allows you to create a ProcessRequest object.
The CreateProccessRequest function takes 2 arguments. The Process Type and the Process Name.

REM Declare your Variables;
Local ProcessRequest &MYRQST;
Local String &MySQR;
&MySQR = "DDDAUDIT"
REM Create My Process Request Object;
&MYRQST = CreateProcessRequest("SQR Process", &MySQR);

REM Set Properties of My Process Request Object;
&MYRQST.RunControlID = "MYRUNCNTRL_ID"

REM Set Properties of My Process Request Object;
&MYRQST.SetOutputOption("Web", "PDF", "", &MySQR);


The above example creates a ProcessRequest object for the DDDAUDIT SQR named &MYRQST. Also specified Run Control ID and the output options. I can now take this Object and use the Schedule() method agains it to Schedule the SQR. Here is an example.

&MYRQST.Schedule();
If &MYRQST.Status = 0 then
/* Schedule succeeded. */
Else
/* Process (job) not scheduled, do error processing */
End-If;

No comments:

Post a Comment