Problems with i5_program_call

General discussion on Zend Core for IBM System i
Post Reply
rballesteros
Posts: 3
Joined: Tue Mar 02, 2010 11:36 pm

Problems with i5_program_call

Post by rballesteros » Thu Mar 04, 2010 12:04 am

Hi.
I'm using the next code to call an RPG procedure on a library of my I5OS:
(I have to send a parameter to this procedure (a 8 digits number))

$desc = array (array ("Name" => "pedido", "type" => I5_TYPE_CHAR, "length" => "9" ) );
$prog = i5_program_prepare("LIBRERIA/PROC.RPG", $desc);
$desc2 = array('pedido'=>'00654321');
$res = i5_program_call($prog, $desc2);
if (!$rethdl) die("<br>Program call error. Error number=".i5_errno()." msg=".i5_errormsg());

The connection with the i5 is already done and working.
When I reload my page so i can see the results of this it takes too much time and then shows me an error message:

502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

Does anybody know how can I fix this or what am I doing wrong?
I really need this to work as soon as possible.

Tks.

User avatar
rodflohr
Zend Global Support
Posts: 56
Joined: Mon Dec 29, 2008 5:28 pm

Re: Problems with i5_program_call

Post by rodflohr » Thu Mar 04, 2010 8:05 pm

One potential problem is that you are calling the program using resource handle $res, but in the next line, you are testing for $rethdl. Try changing this:

if (!$rethdl) die("<br>Program call error. Error number=".i5_errno()." msg=".i5_errormsg());

to this:

if (!$res) die("<br>Program call error. Error number=".i5_errno()." msg=".i5_errormsg());

Also, you do not have your output field defined to receive the returned parameter value from the RPG program. Try changing this:

$desc2 = array('pedido'=>'00654321');
$res = i5_program_call($prog, $desc2);

to this:

$desc2 = array('pedido'=>'00654321');
$parmOut = array('pedido' => 'pedido');
$res = i5_program_call($prog, $desc2, $parmOut);

rballesteros
Posts: 3
Joined: Tue Mar 02, 2010 11:36 pm

Re: Problems with i5_program_call

Post by rballesteros » Thu Mar 04, 2010 9:44 pm

Thanks for the help.
I just change the lines you say but I still got the same problem

$desc = array (array ("Name" => "pedido", "type" => I5_TYPE_CHAR, "length" => "9" ) );
$progr = i5_program_prepare("ERPLXU833F/PRPEDDES", $desc);
$desc2 = array('pedido'=>'00654321');
$parmOut = array('pedido' => 'pedido');
$res = i5_program_call($progr, $desc2, $parmOut);
if (!$res) die("<br>Program call error. Error number=".i5_errno()." msg=".i5_errormsg());

Have you work with this before? Has it work? I don't understand where the problem is... I've trayed all kind of ways but still doesn't work.

User avatar
rodflohr
Zend Global Support
Posts: 56
Joined: Mon Dec 29, 2008 5:28 pm

Re: Problems with i5_program_call

Post by rodflohr » Fri Mar 05, 2010 10:07 pm

Please show us your complete script. Also, please check these log files for error messages:

/usr/local/Zend/apache2/logs/error_log

/usr/local/Zend/Core/logs/php_error_log

Please consider opening a Support ticket at http://zend.com/support

rballesteros
Posts: 3
Joined: Tue Mar 02, 2010 11:36 pm

Re: Problems with i5_program_call

Post by rballesteros » Fri Mar 05, 2010 10:11 pm

Hi... I just solved the problem...
The library was not available to the user I was sending.
I change it and it just solve the problem.
Thanks.

Post Reply