GetSPLF failing to perform the CPYSPLF function

General discussion on Zend Server for IBM System i
greg7308
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

GetSPLF failing to perform the CPYSPLF function

Post by greg7308 » Thu Sep 11, 2014 11:43 pm

Hi,

I am having issues rendering a spoolfile onto a web page. We are on V6R1, with (I think) the latest zend framework.

This works ... in that It correctly prints an array with the desired spoolfiles in it.

Code: Select all

$opts = array("i5_naming"=>DB2_I5_NAMING_ON, "i5_commit"=>DB2_I5_TXN_NO_COMMIT);
$SplfConn = db2_connect($i5_srvr, $user, $pass, $opts);
if (!$SplfConn) die('Could not connect to db: ' . db2_conn_error() . ' ' . db2_conn_errormsg());
try {
	$ToolkitServiceObj = ToolkitService::getInstance($SplfConn, '1');
} 
catch (Exception $e) {              
    echo  $e->getMessage(), "\n";
    exit();
}

$ToolkitServiceObj->setToolkitServiceParams(array('plug'=>"iPLUG1M"));             
$SpoolFiles = new SpooledFiles($ToolkitServiceObj);
try {
    $spool_list = $SpoolFiles->GetSPLList($SplfUserName);  
}
catch (Exception $e) {              
	echo  $e->getMessage(), "\n";
	exit();
}
if( is_array($spool_list) && count($spool_list)> 0) {         
    print_r($spool_list);
}         
But when I try and get the spoolfile that I want from that array it does not perform the CPYSPLF function correctly, I know the job details etc of the spoolfile I want so I look for the exact match.

Code: Select all

//     real values obscured of course ...
$sname = 'MySplfName';
$snmbr = 'splf#';
$jname = 'jobname';
$jnmbr = 'jobnmbr';
$juser = 'jobuser';
$splfsize = sizeof($spool_list);
for ($x=0; $x<$splfsize; $x++) {
	$nextsplf = $spool_list[$x];
  	$s0 = $nextsplf['Number'];
 	$s1 = $nextsplf['Name'];
	 $s2 = $nextsplf['JobNumber'];
	$s3 = $nextsplf['JobName'];
	$s4 = $nextsplf['JobUser'];
	echo "s0=[$s0] s1=[$s1] s2=[$s2] s3=[$s3] s4=[$s4] <br />";
	if( (trim($s0) == trim($snmbr)) && (trim($s1) == trim($sname)) && 
		(trim($s2) == trim($jnmbr)) && (trim($s3) == trim($jname)) && 
		(trim($s4) == trim($juser)) ) {
		echo "found it<br />";
		/*
                This is the command from the iToolkitService.php module, when i do an echo "cmd=[$cmd]"; it shows the CORRECT details in the command
		$cmd = sprintf ("CPYSPLF FILE(%s) TOFILE($this->TmpLib/$this->TMPFName) JOB(%s/%s/%s) SPLNBR(%s)", 
						$SplfName , trim($JobNmbr),  trim($JobUser), trim($JobName), $SplfNbr);		
		*/
		$txt = $SpoolFiles->GetSPLF($s1, $s0, $s2, $s3, $s4, "SPLFTEST");
		print_r($txt);	
	}
}

As noted above when I echo out the $cmd string from the toolkit it correctly shows the CPYSPLF command that I am looking for, and when I copy and paste that onto the command line it works - so I know the format is good.

However - when I check the QGPL/SPLFTEXT file - it is always empty?

And it throws an exception error message ... 
[b]Fatal error: [/b] [color=#BF0000]Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in /usr/local/zendsvr6/var/libraries/PHP_Toolkit_for_IBMI_i/1.5.0/library/ToolkitService.php on line 1624[/color]
I think the error is due to the file being empty (0 rcds)

but WHY is the [b]CPYSPLF [/b]statement from function GetSPLF not working?

Cheers
GC

greg7308
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: GetSPLF failing to perform the CPYSPLF function

Post by greg7308 » Thu Sep 11, 2014 11:52 pm

Update - when i tried the default test code from the zend manual [ http: / / files . zend . com /help/Zend-Server-IBMi/zend-server.htm#spooled_files_methods.htm%3FTocPath%3DAPI%2520Reference%2520Guide|PHP%2520%2520XMLSERVICE%2520Toolkit|iToolkit%2520Service%2520Class|_____1 ] it worked ,so it is working to some extent.

greg7308
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: GetSPLF failing to perform the CPYSPLF function

Post by greg7308 » Mon Sep 15, 2014 12:33 am

*BUMP*

Anyone got any ideas on this or should I open a bug report with Zend?

Cheers
GC

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: GetSPLF failing to perform the CPYSPLF function

Post by scottgcampbell » Mon Sep 15, 2014 3:30 pm

Is it possible that is it a permissions issue? Possibly the user that is connecting (db2_connect) does not have permission to the spoolfiles?

If it is not that then can you debug the script and check what the value returned from the ClCommandWithCpf in GetSPLF (iToolkitService.php) is (try to get into CLCommand in ToolkitService.php) and see what $outputXml is.

You can also turn on debugging and check what the log has in it.

Scott

aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: GetSPLF failing to perform the CPYSPLF function

Post by aseiden » Tue Sep 16, 2014 10:42 pm

Yes, please submit a support ticket with Zend. They can lead you through the steps to see what's happening. This forum post doesn't have enough info to diagnose it. If a bug is affecting you, Zend can register and track it officially.

Scott's suggestion of creating a debug log is also good, to narrow down the issue. You could send that log to Zend to help them understand what's happening.

Alan

User avatar
clarkphp
Zend Global Services
Posts: 34
Joined: Sat Jun 30, 2012 9:59 pm
Location: United States
Contact:

Re: GetSPLF failing to perform the CPYSPLF function

Post by clarkphp » Fri Sep 19, 2014 2:21 pm

Yes - DO send the debug.log file along with support tool output, if you submit a support ticket!

Support tool info:
http://files.zend.com/help/Zend-Server- ... t_tool.htm

Regards,
Clark

greg7308
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: GetSPLF failing to perform the CPYSPLF function

Post by greg7308 » Tue Sep 23, 2014 11:03 pm

Thanks for the replies!

I'll look into a bug report then, was kinda hoping I wasn't the first with this. If anyone has a working script to do the same as this it would be appreciated.

Code: Select all

http : / / files dot zend dot com/help/Zend-Server-IBMi/zend-server.htm#spooled_files_methods.htm%3FTocPath%3DAPI%2520Reference%2520Guide|PHP%2520%2520XMLSERVICE%2520Toolkit|iToolkit%2520Service%2520Class|_____1
Is it of note thast this always fails - it is on the zend examples page in the docco, but I cannot find this file anywhere? Anyone know where 'authorization.php' should be located?

Code: Select all

include_once 'authorization.php'; 
Cheers
GC

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: GetSPLF failing to perform the CPYSPLF function

Post by scottgcampbell » Wed Sep 24, 2014 1:27 pm

Authorization.php just contains the declarations of a few of the variables ($db,$user,$pass). You can download it from
http://www.youngiprofessionals.com/wiki/XMLSERVICE
it is included in the PHP XMLService pear tests (http://174.79.32.155/wiki/uploads/XMLSE ... -1.8.5.zip)

The script that you linked to works for me, in that it does get the list of spool files for a user and retrieve the contents of the first spoolfile after adding a username to GetSPLList and the required values for $db, $user and $pass.

Scott

greg7308
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: GetSPLF failing to perform the CPYSPLF function

Post by greg7308 » Wed Oct 08, 2014 1:18 am

Thanks for the link Scott,

Finally grabbed the authorization.php file. For some reason it never installed when I loaded the xmlservice stuff - odd.

It appears to be authority related then, will follow up on that line ...

Cheers
GC

greg7308
Posts: 23
Joined: Fri Mar 28, 2014 1:28 am

Re: GetSPLF failing to perform the CPYSPLF function

Post by greg7308 » Thu Oct 16, 2014 2:58 am

Thanks for the help everyone. Sorted now. Seems I was initiating a session on the default QTMHHTTP profile which was retained, and later it was not authorised to use a splf.
Doh!

Post Reply