I have a PHP program that calls a RPGLE program that runs a report. The browser times out sometimes.
I set the timeout settings in IE11 and FireFox 29 but still have the problem.
What I would like to do is have a way to submit the job and monitor its progress from a php program
until it completes.
I used WebSmart PHP tool to create the PHP program that contains the function below:
Does anyone have a idea how to do this?
James R. Martin
e-mail: jmartin@jmartinassociates.net
I set the timeout settings in IE11 and FireFox 29 but still have the problem.
What I would like to do is have a way to submit the job and monitor its progress from a php program
until it completes.
I used WebSmart PHP tool to create the PHP program that contains the function below:
PHP Code:
function prtctl()
{
// Make all global variables available here
foreach($GLOBALS as $arraykey=>$arrayvalue)
{
if ($arraykey != "GLOBALS")
{
global $$arraykey;
}
}
// Get the key field values which identify the record
session_start();
$_SESSION['views'] = 1; // store session data
$USERID = $_SESSION['USERID'];
$LIBNAME = $_SESSION['LIBNAME'];
$LOCNAM = $_SESSION['LOCNAM'];
$_SESSION['LOCNAM'] = $LOCNAM;
$Starttime = $_SESSION['Starttime'];;
/* library and program name: */
$lib = $LIBNAME;
$prgmsg="PRTCRRPT - Print Delinquent Accounts for Reporting";
$PSDCODE = "Printed Code: ";
$PSCODE = " ";
/********** Step 1: set up parameter list description ************/
/* Create an array that specifies the name of */
/* the input, the IO being performed, the variable */
/* type, and the variable name. */
$description = array(
array(
"Name"=>"PSCODE",
"IO"=>I5_INOUT,
"Type"=>I5_TYPE_CHAR,
"Length"=>"1"
) ,
array(
"Name"=>"NONOTP",
"IO"=>I5_INOUT,
"Type"=>I5_TYPE_CHAR,
"Length"=>"7"
) ,
array(
"Name"=>"PGDATE",
"IO"=>I5_INOUT,
"Type"=>I5_TYPE_CHAR,
"Length"=>"10"
)
);
$name = $lib . "/" . "PRTCRRPT";
/********** Step 2: prepare the program for calling **************/
$pgm = i5_program_prepare($name, $description);
// Check if any errors occurred.
if (!$pgm)
{
echo "<br>";
print_r(i5_errormsg());
i5_program_close($pgm);
die("i5_program_prepare");
}
/********** Step 3: assign the parameter values to send **********/
/* Create an array with the input names and the */
/* corresponding values. You need to supply the */
/* actual parm values. */
$in_parameters = array(
"PSCODE"=>"$PSCODE" ,
"NONOTP"=>"$NONOTP" ,
"PGDATE"=>"$PGDATE"
);
/********** Step 4: the parameters that will be returned *********/
/* Create an array with the output parameters */
/* returned by the program. */
$out_parameters = array(
"PSCODE"=>"PSCODE" ,
"NONOTP"=>"NONOTP" ,
"PGDATE"=>"$PGDATE"
);
/****** set tim limit for job **********************/
set_time_limit(0);
error_reporting(E_ALL);
ob_implicit_flush(TRUE);
ob_end_flush();
// set_time_limit(180);
/********** Step 5: Call the program. ***************************/
$ret = i5_program_call($pgm, $in_parameters, $out_parameters);
$anonotp = number_format($NONOTP,0);
// Check if any errors occurred.
if (!$ret)
{
$prgmsg = "Call to PRTCRRPT was not successful";
$color="red";
$anonotp = "";
wrtseg(MainSeg);
wrtseg(ClsSeg);
wrtseg(FootSeg);
i5_program_close($pgm);
die("i5_program_call");
}
global $db2conn;
$db2conn = xl_db2_connect($options);
if(!$db2conn)
{
error_log("Failure to connect... Reopening connection");
// close and reopen the connection to try again
db2_close($db2conn);
$db2conn = xl_db2_connect($options);
if(!$db2conn)
{
$db2conn = xl_db2_connect($options);
if (!$db2conn)
{
die('Failed to connect to database!');
}
}
}
$prgmsg = "PRTCRRPT - Print Delinquent Accounts for Reporting - Completed";
$color="teal";
// Close the program handle (unload from memory).
$Endtime = time();
$elapsetime = $Endtime-$Starttime;
$secs = $elapsetime;
$time_elapsed = "Run Time: ";
$elapsed = time_elapsed($secs);
$ret = $elapsed;
wrtseg(MainSeg);
wrtseg(ClsSeg);
wrtseg(FootSeg);
i5_program_close($pgm);
//Release the database resource
db2_close($db2conn);
}
function time_elapsed($secs)
{
$bit = array(
' year ' => $secs / 31556926 % 12,
' week ' => $secs / 604800 % 52,
' day ' => $secs / 86400 % 7,
' hour ' => $secs / 3600 % 24,
' minute ' => $secs / 60 % 60,
' second ' => $secs % 60
);
foreach($bit as $k => $v){
if($v > 1)$ret[] = $v . $k . '(s)';
if($v == 1)$ret[] = $v . $k;
}
array_splice($ret, count($ret)-1, 0);
$ret[] = ' elapsed';
return join(' ', $ret);
}
James R. Martin
e-mail: jmartin@jmartinassociates.net
Comment