Hi all,
I've been busy for the last couple of weeks to automate most of our reports with vbscript and everything works fine.
Now,
I'm working on some project and for that I use PHP, but I'm having a problem with some code in PHP. What I did is use the code I had from a vbscript and modified it to how I thought PHP would interpret it correctly, but im getting the following error:
Fatal error: Call to a member function Reports() on a non-object
here is the vbscript:
Dim cmsApplication
Dim cmsServer
Dim cmsConnection
Dim cmsReport
Dim info
Dim rc
Dim myLog
Dim myPass
Dim myServer
Dim reportPath
Dim reportName
Dim reportPrompt11
Dim reportPrompt12
Dim reportPrompt13
Dim reportPrompt21
Dim reportPrompt22
Dim reportPrompt23
Dim exportPath
Dim exportName
'Create Objects
Set cmsApplication = CreateObject("ACSUP.cvsApplication")
Set cmsServer = CreateObject("ACSUPSRV.cvsServer")
Set cmsConnection = CreateObject("ACSCN.cvsConnection")
Set cmsReport = CreateObject("ACSREP.cvsReport")
' Assigns Variables
myLog = "mylogin"
myPass = "mypass"
myServer = "0.0.0.0"
reportPath = "Historical\Designer\"
reportName = "JnJ Interval Skill Range - Final"
reportPrompt11 = "Date(s)"
reportPrompt12 = "Times"
reportPrompt13 = "Skill(s)"
reportPrompt21 = "2009/05/01"
reportPrompt22 = "00:00-23:30"
reportPrompt23 = "257;260;310;256;258;259"
exportPath = "c:\CMS-reports"
exportName = "vbtest.csv"
cmsConnection.bAutoRetry = True
On Error Resume Next
If cmsApplication.CreateServer(myLog, myPass, "", myServer, False, "ENU", cmsServer, cmsConnection) Then
If cmsConnection.Login(myLog, myPass, myServer, "ENU") Then
Else
MsgBox "login error"
End If
Else
MsgBox "connection error"
End If
cmsServer.Reports.ACD = 1
Set info = cmsServer.Reports.Reports(reportPath & reportName)
If info Is Nothing Then
MsgBox "Report not found: " & reportPath & reportName
Else
On Error Resume Next
rc = cmsServer.Reports.CreateReport(info, cmsReport)
If rc Then
rc = cmsReport.SetProperty(reportPrompt11, reportPrompt21)
rc = cmsReport.SetProperty(reportPrompt12, reportPrompt22)
rc = cmsReport.SetProperty(reportPrompt13, reportPrompt23)
rc = cmsReport.ExportData(exportPath & "\" & exportName, 44, 0, True, True, True)
cmsReport.Quit
End If
cmsServer.ActiveTasks.Remove cmsReport.TaskID
cmsApplication.Servers.Remove cmsServer.ServerKey
Set cmsReport = Nothing
End If
Set info = Nothing
cmsConnection.Logout
cmsConnection.Disconnect
cmsServer.Connected = False
Set cmsReport = Nothing
Set cmsServer = Nothing
Set cmsConnection = Nothing
Set cmsApplication = Nothing
I modified it a bit in a rush to be similar with my PHP code, so forgive me if there are small errors, now here is the almost the same for PHP (not fully finished, but enough)
php code:
set_time_limit(60);
$cmsApplication = New COM("ACSUP.cvsApplication")or die("Unable to instantiate CMS Application");;
$cmsServer = New COM("ACSUPSRV.cvsServer")or die("Unable to instantiate CMS Server");;
$cmsConnection = New COM("ACSCN.cvsConnection")or die("Unable to instantiate CMS Connection");;
$cmsReport = New COM("ACSREP.cvsReport")or die("Unable to instantiate CMS Report");;
$myLog = "MyLogin";
$myPass = "MyPass";
$myServer = "0.0.0.0";
$reportPath = 'Historical\Designer';
$reportName = '\JnJ Interval Skill Range - Final';
$reportDateText = "Date(s)";
$reportDatesValue = '2009/05/22';
$reportTimesText = "Times";
$reportTimesValue = "00:00-23:00";
$reportSkillsText = "Skill(s)";
$reportSkillsValue = "275;278;274;276;277;279";
$exportPath = $_SERVER['DOCUMENT_ROOT']."CMS-reports";
$exportName = "test.csv";
$cmsConnection->bAutoRetry = True;
If ($cmsApplication->CreateServer($myLog, $myPass , '', $myServer, False, 'ENU', $cmsServer, $cmsConnection)){
If ($cmsConnection->Login($myLog, $myPass, $myServer, "ENU")){
//Login Success
$cmsServer->Reports->ACD = 1;
$report = $cmsServer->Reports->Reports($reportPath.$reportName);
if(!$report){
echo "Report not found: ".$reportPath.$reportName;
}
else{
$reportObject = $cmsServer->Reports->CreateReport($report, $cmsReport);
if($reportObject){
$reportObject = $cmsReport->SetProperty($reportDateText, $reportDatesValue);
$reportObject = $cmsReport->SetProperty($reportTimesText, $reportTimesValue);
$reportObject = $cmsReport->SetProperty($reportSkillsText, $reportSkillsValue);
$reportObject = $cmsReport->ExportData($exportPath.$exportName, 44, 0, True, True, True);
$cmsReport->Quit;
$cmsConnection->Logout;
$cmsConnection->Disconnect;
$cmsServer->Connected = False;
}
}
}
else{
echo "login failed";
}
}
else{
echo "connection error";
}
echo $_SERVER['DOCUMENT_ROOT'];
now the error comes up for 2 pieces of code:
$report = $cmsServer->Reports->Reports($reportPath.$reportName); //gives Fatal error: Call to a member function Reports() on a non-object
$reportObject = $cmsServer->Reports->CreateReport($report, $cmsReport); //gives Fatal error: Call to a member function CreateReport() on a non-object
those lines can be found in the vbscript seperated by .'s
I'm hoping that someone experienced with PHP and vb can explain why im getting this error and can maybe point me in the right direction.
vba's object browser gives this bit of information:
Property Reports As Object
Member of ACSUPSRV.cvsServer
Thanks in advance!