using i5_program_call, returned values inside a function

General discussion on Zend Core for IBM System i
Post Reply
christiand_serti_com
Posts: 31
Joined: Wed Mar 25, 2009 12:57 am

using i5_program_call, returned values inside a function

Post by christiand_serti_com » Wed Mar 25, 2009 1:06 am

I am using the following code:

Code: Select all

[quote]
	function pgm_prep_rtvpartinfo(){
	
		$description = array(
    		array("Name"=>"@ADD", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>"6"),
    		array("Name"=>"@VEN", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>"3"),
    		array("Name"=>"@PRT", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>"21"),
    		array("Name"=>"@PRX", "IO"=>I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"9"),
        	array("Name"=>"@CORE", "IO"=>I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"9"),
        	array("Name"=>"@STS", "IO"=>I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"3")
			);

			$pgm = i5_program_prepare("pmglib/getprice", $description);
			
			if (!$pgm){
				$this->throw_error($pgm); 				
			}
		
			return $pgm;	
		}

	function pgm_call_rtvpartinfo($pgm, $addnum, $partnum, $vendor){
			
			$parameter = array("@ADD"=>$addnum,"@VEN"=>$vendor,"@PRT"=>$partnum);	
			$parmout = array("@PRX"=>"part_price", "@CORE"=>"part_core", "@STS"=>"part_sts");
	
			$ret = i5_program_call($pgm, $parameter, $parmout);
	
			if (!$ret){
				$this->throw_error($ret); 				
			}
			
			var_dump($part_price);
			echo "<br>";
			var_dump($parmout);
			echo "<br>";
			var_dump($parmout[part_price]);	
			echo "<br>";			
			var_dump($parmout['part_price']);	

			return $part_price;
		}
[/quote]
Whatever I try, it does not work when inside a function. If I copy & paste the code outside my class/function, I can output the data properly using the associative name $part_price.

Anyone has any idea how to get the data properly ?

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

Re: using i5_program_call, returned values inside a function

Post by rodflohr » Thu Mar 26, 2009 1:19 am

You do not show the code used to run these functions. Something like this should work:

$pgm = pgm_prep_rtvpartinfo();
$part_price = pgm_call_rtvpartinfo($pgm, $addnum, $partnum, $vendor);

echo $part_price;

christiand_serti_com
Posts: 31
Joined: Wed Mar 25, 2009 12:57 am

Re: using i5_program_call, returned values inside a function

Post by christiand_serti_com » Thu Mar 26, 2009 12:13 pm

well, I know how to use function. That wasn't the problem. It appeared to simply be a commented line .. got this working.

User avatar
shlomov
Zend Global Support
Posts: 139
Joined: Mon Dec 29, 2008 2:38 pm

Re: using i5_program_call, returned values inside a function

Post by shlomov » Mon May 11, 2009 9:30 am

The attached code looks OK!
Shlomo Vanunu
IBM System i

Post Reply