i5_program_call hanging

General discussion on Zend Core for IBM System i
Post Reply
avandam
Posts: 9
Joined: Thu Nov 12, 2009 6:04 am

i5_program_call hanging

Post by avandam » Thu Dec 17, 2009 11:52 am

Hello,

I am new to the i5.

We have a RPG program which I'm trying to call. The program accepts two parameters (char 14 and char 1). It returns a data structure. The test data returns a structure with 64 records.

The structure is defined as follows in the RPG program:

Code: Select all

rs_actno        s             14         
rs_pmtdat       s             10         
rs_pmtamt       s             13  2      
rs_pmtsts       s             14         
rs_benact       s             14         
rs_bennam       s             50         
rs_benref       s             20         
rs_refamt       s             13  2      
rs_refsts       s             20         
rs_refdat       s             10         
In my PHP script I have defined the description as follows:

Code: Select all

	$arrDescription = array(
		array(
			'Name' 	 => 'actno',
			'IO' 	 => I5_IN,
			'Type' 	 => I5_TYPE_CHAR,
			'Length' => '14'
		),
		array(
			'Name' 	 => 'period',
			'IO' 	 => I5_IN,
			'Type' 	 => I5_TYPE_CHAR,
			'Length' => '1'
		),
		array(
			'DSName' => 'result',
			'Count'  => '20',
			'DSParm' => array(
				array(
					'Name'	 => 'actno',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 14
				),
				array(
					'Name'	 => 'pmtdat',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 10
				),
				array(
					'Name'	 => 'pmtamt',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_ZONED,
					'Length' => "13.2"
				),
				array(
					'Name'	 => 'pmtsts',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 14
				),
				array(
					'Name'	 => 'benact',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 14
				),
				array(
					'Name'	 => 'bennam',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 50
				),
				array(
					'Name'	 => 'benref',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 20
				),
				array(
					'Name'	 => 'refamt',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_ZONED,
					'Length' => "13.2"
				),
				array(
					'Name'	 => 'refsts',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 20
				),
				array(
					'Name'	 => 'refdat',
					'IO'	 => I5_OUT,
					'Type'	 => I5_TYPE_CHAR,
					'Length' => 10
				)
			)
		)
	);
Prepare and call as follows:

Code: Select all

$resProgram = i5_program_prepare('TSTLIB/TSTTRX01R', $arrDescription);
	if (!$resProgram) {
		throw new Exception('Error #' . i5_errno() . ' preparing program: ' . i5_errormsg());
	} else {
		echo "Successfully prepared program<br>";
	}
	
	$arrParameter = array(
		'CONSNO' => '0000000000000N',
		'PERIOD' => ' '
	);
	
	$arrResult = array(
		'RESULT' => 'RES'
	);
	
	$resResult = i5_program_call($resProgram, $arrParameter, $arrResult);
	if (!$resResult) {
		throw new Exception('Error #' . i5_errno() . ' calling program: ' . i5_errormsg());
	} else {
		echo "Successfully called program<br>";
	}


When executing the above the script runs fine up to i5_program_call. After that it hangs. When looking in the active jobs, the job has a MSGW status.

If I understand correctly this means that the job is waiting for a message and that possibly the RPG program failed.

The RPG program runs fine when calling it directly.

At this time I have two questions:
1. Are there anything strange/wrong in my code above?
2. How do I debug to determine where the failure is?

Thanks in advance,

Albert

avandam
Posts: 9
Joined: Thu Nov 12, 2009 6:04 am

Re: i5_program_call hanging

Post by avandam » Thu Dec 17, 2009 12:30 pm

I found the problem. The required library is not available.

How do I add a library to the profile library list before calling the program.

I've done:

Code: Select all

	$arrOptions = array(
		"i5_lib" => "TSTLIB"
	);
	$resConnection = i5_connect('127.0.0.1', I5_USER, I5_PWD, $arrOptions);
But it doesn't seem to work.

In the mean while we have added the library to the profile jobd. Now I'm getting a different error which I cannot make sense of:
[num] => 1
[cat] => 5
[msg] =>
[desc] => Parameter error

avandam
Posts: 9
Joined: Thu Nov 12, 2009 6:04 am

Re: i5_program_call hanging

Post by avandam » Mon Dec 21, 2009 8:00 am

I have figured out what that error means. It means Easycom internal error.

What does that mean?

When using the Toolkit classes it works but I cannot get the structure result back. After the program call the result parameter contains the word result.

Post Reply