customControl and killing rpg program

Post Reply
shelfos
Posts: 15
Joined: Fri Sep 30, 2011 8:38 pm

customControl and killing rpg program

Post by shelfos » Thu Jun 04, 2015 12:55 am

Ideally we write rpg programs that never fail, that never have errors, or when they do they are handled perfectly, but alas (and maybe I can speak only for myself), I am imperfect.

If an rpg program stops processing with an error on the console awaiting a reply the browser does not get a response until an operator answers the message, or finally the request times out.

I saw in one of Alan Seiden's slideshows that you can use the customControl option to kill an rpg program call if it goes longer than the specified time, but I can't seem to get it to work.

If someone has been able to get it to work please advise on what I am doing wrong. (see the brief code below)

Code: Select all


$ToolkitServiceObj = ToolkitService::getInstance('*LOCAL', $user, $password);

$options = array(
	'stateless' 	=> true,
	'customControl' => '*call(15,kill,server)',			
);

$ToolkitServiceObj->setToolkitServiceParams($options);

$param[] = $ToolkitServiceObj->AddParameterPackDec('in', 11, 0, 'NUMB', 'NUMB', $customerNumber);

$param = array();  //this line forces the rpg program to error out because the parms are wrong.  I simply comment it out after testing

try {
     $result = $ToolkitServiceObj->PgmCall("MYPGM", "MYLIB", $param, null, null);
} catch (Exception $e) {
     //handle errors here
{
Thanks

joe6181
Posts: 2
Joined: Tue Jun 30, 2015 9:22 pm

Re: customControl and killing rpg program

Post by joe6181 » Tue Jun 30, 2015 9:26 pm

Hello shelfos -

I was curious if you ever got this running correctly? We are running into some issues that are causing application 'hangs'.

My first thought in looking at the code you posted is that (from what I was able to find in Alan's presentation) the following line of code should be modified:

from:

$options = array(
'stateless' => true,
'customControl' => '*call(15,kill,server)',
);

to:
$options = array(
'stateless' => true,
'customControl' => '*call(15/kill/server)'
);

shelfos
Posts: 15
Joined: Fri Sep 30, 2011 8:38 pm

Re: customControl and killing rpg program

Post by shelfos » Thu Jul 30, 2015 12:59 am

What I decided to do rather than use the "kill" method was to use another option suggested by Alan Seiden which is to change the job before calling the rpg program so that the job automatically gets ended if an error occurs. What actually happens is that when the rpg program errors out and a message breaks, it automatically gets answered with a 'C' for Cancel.

In my opinion it's a better solution than using the 'kill' method. Both methods are mentioned in Alan's slideshow, but I misunderstood the CHGJOB method to be something more "global" - as if to make all jobs get answered accordingly so I didn't even consider it. After looking more carefully at how CHGJOB works I realized it would be on the specific job rather than for all jobs.

Here is a partial code snippet just to give you an idea - it gets run before calling the actual rpg program:

Code: Select all

...

	$ToolkitServiceObj->setOptions(array('stateless' => true));
	
	$toolkitInfo = $ToolkitServiceObj->getDiagnostics();
	$jobNumber = $toolkitInfo['jobinfo']['jobnbr'];
	$userName = $toolkitInfo['jobinfo']['jobuser'];
	$jobName = $toolkitInfo['jobinfo']['jobname'];
	
	$clcommand = "CHGJOB JOB({$jobNumber}/{$userName}/{$jobName}) INQMSGRPY(*DFT)";
	
	$success = $ToolkitServiceObj->CLCommand($clcommand);

...

Post Reply