Hi All,
We have developed CSP application on CE9, now we are moving to BO XI. For short time we are trying to make CSP app work in BO XI. I found some help on the net and converted csp to asp and made some changes to the code. I was able to browse the folders, reports and parameters.
I am failing on scheduling report. We have schedulreport.csp file is doing schedule report. I dont know what is wrong with the code. I am not good at crystal coding, we had a consultant to develop this app. Please help...
<< CODE
<%
'ScheduleReportWithParameters(IStore, ReportID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams,Session("CustomDBLogon"),Session("DBDriver"), Session("DataBaseName"),Session("ServerName"), Session("UserName"), Session("Password"), ScheduledInstanceID)
Function ScheduleReportWithParameters(ByRef IStore, ReportID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams,CustomDBLogon,DBDriver,DataBaseName,ServerName,UserName,Password, ScheduledInstanceID)
'This function schedules a report.
'
'Precondition:
'IStore - The InfoStore object that will schedule the report.
'ReportID - The ID of the report that is to be scheduled.
'BeginHours + EndHours - The begin and end hour of the day to schedule the report.
'BeginMinutes + EndMinutes - The begin and end minute of the hour to schedule the report.
'Params - An array containing the new parameter values.
'NumParams - The number of parameter values.
'
'Notes:
'The function returns TRUE if successful and FALSE otherwise.
'On Error Resume Next
Dim Result
Dim ReportInterface
Dim ReportObject
Set Result = IStore.Query( "Select SI_NAME, SI_PROCESSINFO.SI_PROMPTS, SI_PROCESSINFO.SI_LOGON_INFO From CI_INFOOBJECTS Where SI_ID="&ReportID)
If Err.Number <> 0 Then
ScheduleReportWithParameters = False
Exit Function
End If
Set ReportObject = Result.Item(1)
'''''''''''''''''CHANGE REPORT PARAMETERS'''''''''''''''
Dim k, NewParam , ParamDataType
'Retrieve the report interface.
Set ReportInterface = ReportObject.PluginInterface
response.write ReportInterface.ReportParameters.Count
'clifford shu reset parameter numbers
if NumParams > ReportInterface.ReportParameters.Count then
NumParams = ReportInterface.ReportParameters.Count
end if
With ReportInterface.ReportParameters
For k = 0 to NumParams-1
.Item(k+1).CurrentValues.Clear
Set NewParam = .Item(k+1).CreateSingleValue
ParamDataType = .Item(k+1).ValueType
Select Case ParamDataType
case 3 'Date( yyyy, mm, dd)
if FormatToCrystalDate(Params(k)) then
NewParam.Value = Params(k)
else
ScheduleReportWithParameters=FALSE
Exit Function
end if
case 5 ' DateTime( yyyy, mm, dd, 00, 00, 00)
if FormatToCrystalDateTime(Params(k)) then
NewParam.Value = Params(k)
else
ScheduleReportWithParameters=FALSE
Exit Function
end if
case else
NewParam.Value = Params(k)
End Select
'debugging
'Response.Write "Params("&k&")="&Params(k)&"<BR>"
.Item(k+1).CurrentValues.Add NewParam
Next
End With
''''''''''''''''''''''''END CHANGE REPORT PARAMETERS'''''
'Check that you have an object.
If Result.Count = 0 then
ScheduleReportWithParameters=False
Exit Function
End If
If Err.Number <> 0 then
ScheduleReportWithParameters=FALSE
Exit Function
End If
Dim ScheduleInfo
'Create an interface to the scheduling options for the report.
Set ScheduleInfo = ReportObject.SchedulingInfo
If Err.Number <> 0 then
ScheduleReportWithParameters=FALSE
Exit Function
End If
'Set schedule options.
'ScheduleInfo.RightNow = False
'ScheduleInfo.BeginDate = Date & " " & BeginHours & ":" & BeginMinutes & ":00"
'ScheduleInfo.EndDate = Date & " " & EndHours & ":" & EndMinutes & ":00"
'Indicate the report is to be scheduled once only.
ScheduleInfo.Type = 0
' Run the report once.
'****************************************************************************************************
' Run it right now.
ScheduleInfo.RightNow = true
'****************************************************************************************************
Dim repLogon
If CustomDBLogon <> "" Then
if CustomDBLogon then
For Each repLogon in ReportInterface.ReportLogons
RepLogon.CustomDatabaseDLLName= DBDriver
RepLogon.CustomDataBaseName = DataBaseName
RepLogon.CustomServerName = ServerName
RepLogon.CustomUserName = UserName
RepLogon.CustomPassword = Password
RepLogon.UseOriginalDataSource = false
Next
end if
End if
'debugging
For Each repLogon in ReportInterface.ReportLogons
if RepLogon.UseOriginalDataSource then
Response.Write "<BR><b>This Report uses <font color=green>Original DataBase Logon</font></b>"
else
Response.Write "<BR><b>This Report uses <font color=blue>Custom DataBase Logon</font></b>"
end if
Response.Write "<BR><BR>SubReportName=" & RepLogon.SubReportName & "<BR>"
'Original DB Logon Information
Response.Write "<BR><BR><b><font color=green>Original DB Logon Information:</font></b>"
Response.Write "<BR> ServerType: " & _
RepLogon.ServerType
Response.Write "<BR> DatabaseName: " & _
RepLogon.DataBaseName
Response.Write "<BR> ServerName: " & _
RepLogon.ServerName
Response.Write "<BR> Username: " & _
RepLogon.UserName
'Custom DB Logon Information
Response.Write "<BR><BR><b><font color=blue>Custom DB Logon Information:</font></b>"
Response.Write "<BR>Custom Database DLL Name: " & _
RepLogon.CustomDatabaseDLLName
Response.Write "<BR>Custom Database Name: " & _
RepLogon.CustomDataBaseName
Response.Write "<BR>Custom ServerName: " & _
RepLogon.CustomServerName
Response.Write "<BR>Custom Username: " & _
RepLogon.CustomUserName & "<BR><BR>"
Next
'Response.End
'change db logon
'Tell the APS to schedule the report.
IStore.Schedule Result
If Err.Number <> 0 then
ScheduleReportWithParameters=FALSE
Exit Function
End If
ScheduledInstanceID = Result.Item(1).Properties.Item("SI_NEW_JOB_ID")
ScheduleReportWithParameters=TRUE
End Function
Sub Main()
'debugiing information
'Response.Write "Request.Form(cmdScheduleReport) = " & Request.Form("cmdScheduleReport") & "<BR>"
'Response.Write "Request.Form(cmdNewScheduleReport) = " & Request.Form("cmdNewScheduleReport") & "<BR>"
'Response.End
If RetrieveIStore(IStore)=FALSE then
'If it failed, redirect the user to the logon page.
Call SSOLogon(IStore)
end if
Dim Result
Dim IStore
Dim Error, k
Dim NewName
Dim ReportID, CurrentFolderID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams, ScheduledInstanceID
'Request the hours and minutes that the user entered on the
'previous page.
'BeginHours = Request.Form("BeginHours")
'BeginMinutes = Request.Form("BeginMinutes")
'EndHours = Request.Form("EndHours")
'EndMinutes = Request.Form("EndMinutes")
'Retrieve the report ID from the page's parameter list.
ReportID = Request.QueryString("ReportID")
Dim ReportName
ReportName = Request.QueryString("ReportName")
'Retrieve the number of parameters, and then the parameter values.
NumParams = Request.QueryString("NumParams")
Redim Params(NumParams)
If ReportID <> "" Then
For k = 0 to NumParams-1
Params(k) = Request.Form("Param" & k+1)
Next
ElseIf ReportName <> "" Then
Dim FullPath , HyperLinkReportID
FullPath = UCase(Request.QueryString("FullPath"))
if GetReportID(ReportName,FullPath,Istore, HyperLinkReportID) Then
ReportID = HyperLinkReportID
For k = 0 to NumParams-1
Params(k) = Request.QueryString("Param" & k+1)
Next
else
Response.Write "Unable to retrieve CE ReportID and as a result I could not schedule this report."
Exit Sub
end if
else
Response.Write "Unable to retrieve CE ReportID/ReportName as a result I could not schedule this report."
Exit Sub
End if
'debugging
'Response.Write "ReportID = "&ReportID&"<BR>"
'Response.Write "NumParams = "&NumParams&"<BR>"
'response.write Params(1)
'Response.End
'Schedule the report with parameters.
If ScheduleReportWithParameters(IStore, ReportID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams,Session("CustomDBLogon"),Session("DBDriver"), Session("DataBaseName"),Session("ServerName"), Session("UserName"), Session("Password"), ScheduledInstanceID) = FALSE Then
Response.Write "There was an error and as a result I could not schedule this report."
Else
Response.Write "Successfully scheduled the report."
'Response.End
if Request.Form("cmdScheduleReport") <> "" or ReportName <> "" Then
Response.Redirect "viewreport.csp?ReportID=" & ReportID & "&ScheduledInstanceID=" & ScheduledInstanceID
else
Response.Write "<script>window.open('viewreport.csp?ReportID="&ReportID& "&ScheduledInstanceID=" & ScheduledInstanceID & "')</script>"
Response.Write "<script>history.go(-1)</script>"
end if
End If
End Sub
Main
%>
>>
We have developed CSP application on CE9, now we are moving to BO XI. For short time we are trying to make CSP app work in BO XI. I found some help on the net and converted csp to asp and made some changes to the code. I was able to browse the folders, reports and parameters.
I am failing on scheduling report. We have schedulreport.csp file is doing schedule report. I dont know what is wrong with the code. I am not good at crystal coding, we had a consultant to develop this app. Please help...
<< CODE
<%
'ScheduleReportWithParameters(IStore, ReportID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams,Session("CustomDBLogon"),Session("DBDriver"), Session("DataBaseName"),Session("ServerName"), Session("UserName"), Session("Password"), ScheduledInstanceID)
Function ScheduleReportWithParameters(ByRef IStore, ReportID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams,CustomDBLogon,DBDriver,DataBaseName,ServerName,UserName,Password, ScheduledInstanceID)
'This function schedules a report.
'
'Precondition:
'IStore - The InfoStore object that will schedule the report.
'ReportID - The ID of the report that is to be scheduled.
'BeginHours + EndHours - The begin and end hour of the day to schedule the report.
'BeginMinutes + EndMinutes - The begin and end minute of the hour to schedule the report.
'Params - An array containing the new parameter values.
'NumParams - The number of parameter values.
'
'Notes:
'The function returns TRUE if successful and FALSE otherwise.
'On Error Resume Next
Dim Result
Dim ReportInterface
Dim ReportObject
Set Result = IStore.Query( "Select SI_NAME, SI_PROCESSINFO.SI_PROMPTS, SI_PROCESSINFO.SI_LOGON_INFO From CI_INFOOBJECTS Where SI_ID="&ReportID)
If Err.Number <> 0 Then
ScheduleReportWithParameters = False
Exit Function
End If
Set ReportObject = Result.Item(1)
'''''''''''''''''CHANGE REPORT PARAMETERS'''''''''''''''
Dim k, NewParam , ParamDataType
'Retrieve the report interface.
Set ReportInterface = ReportObject.PluginInterface
response.write ReportInterface.ReportParameters.Count
'clifford shu reset parameter numbers
if NumParams > ReportInterface.ReportParameters.Count then
NumParams = ReportInterface.ReportParameters.Count
end if
With ReportInterface.ReportParameters
For k = 0 to NumParams-1
.Item(k+1).CurrentValues.Clear
Set NewParam = .Item(k+1).CreateSingleValue
ParamDataType = .Item(k+1).ValueType
Select Case ParamDataType
case 3 'Date( yyyy, mm, dd)
if FormatToCrystalDate(Params(k)) then
NewParam.Value = Params(k)
else
ScheduleReportWithParameters=FALSE
Exit Function
end if
case 5 ' DateTime( yyyy, mm, dd, 00, 00, 00)
if FormatToCrystalDateTime(Params(k)) then
NewParam.Value = Params(k)
else
ScheduleReportWithParameters=FALSE
Exit Function
end if
case else
NewParam.Value = Params(k)
End Select
'debugging
'Response.Write "Params("&k&")="&Params(k)&"<BR>"
.Item(k+1).CurrentValues.Add NewParam
Next
End With
''''''''''''''''''''''''END CHANGE REPORT PARAMETERS'''''
'Check that you have an object.
If Result.Count = 0 then
ScheduleReportWithParameters=False
Exit Function
End If
If Err.Number <> 0 then
ScheduleReportWithParameters=FALSE
Exit Function
End If
Dim ScheduleInfo
'Create an interface to the scheduling options for the report.
Set ScheduleInfo = ReportObject.SchedulingInfo
If Err.Number <> 0 then
ScheduleReportWithParameters=FALSE
Exit Function
End If
'Set schedule options.
'ScheduleInfo.RightNow = False
'ScheduleInfo.BeginDate = Date & " " & BeginHours & ":" & BeginMinutes & ":00"
'ScheduleInfo.EndDate = Date & " " & EndHours & ":" & EndMinutes & ":00"
'Indicate the report is to be scheduled once only.
ScheduleInfo.Type = 0
' Run the report once.
'****************************************************************************************************
' Run it right now.
ScheduleInfo.RightNow = true
'****************************************************************************************************
Dim repLogon
If CustomDBLogon <> "" Then
if CustomDBLogon then
For Each repLogon in ReportInterface.ReportLogons
RepLogon.CustomDatabaseDLLName= DBDriver
RepLogon.CustomDataBaseName = DataBaseName
RepLogon.CustomServerName = ServerName
RepLogon.CustomUserName = UserName
RepLogon.CustomPassword = Password
RepLogon.UseOriginalDataSource = false
Next
end if
End if
'debugging
For Each repLogon in ReportInterface.ReportLogons
if RepLogon.UseOriginalDataSource then
Response.Write "<BR><b>This Report uses <font color=green>Original DataBase Logon</font></b>"
else
Response.Write "<BR><b>This Report uses <font color=blue>Custom DataBase Logon</font></b>"
end if
Response.Write "<BR><BR>SubReportName=" & RepLogon.SubReportName & "<BR>"
'Original DB Logon Information
Response.Write "<BR><BR><b><font color=green>Original DB Logon Information:</font></b>"
Response.Write "<BR> ServerType: " & _
RepLogon.ServerType
Response.Write "<BR> DatabaseName: " & _
RepLogon.DataBaseName
Response.Write "<BR> ServerName: " & _
RepLogon.ServerName
Response.Write "<BR> Username: " & _
RepLogon.UserName
'Custom DB Logon Information
Response.Write "<BR><BR><b><font color=blue>Custom DB Logon Information:</font></b>"
Response.Write "<BR>Custom Database DLL Name: " & _
RepLogon.CustomDatabaseDLLName
Response.Write "<BR>Custom Database Name: " & _
RepLogon.CustomDataBaseName
Response.Write "<BR>Custom ServerName: " & _
RepLogon.CustomServerName
Response.Write "<BR>Custom Username: " & _
RepLogon.CustomUserName & "<BR><BR>"
Next
'Response.End
'change db logon
'Tell the APS to schedule the report.
IStore.Schedule Result
If Err.Number <> 0 then
ScheduleReportWithParameters=FALSE
Exit Function
End If
ScheduledInstanceID = Result.Item(1).Properties.Item("SI_NEW_JOB_ID")
ScheduleReportWithParameters=TRUE
End Function
Sub Main()
'debugiing information
'Response.Write "Request.Form(cmdScheduleReport) = " & Request.Form("cmdScheduleReport") & "<BR>"
'Response.Write "Request.Form(cmdNewScheduleReport) = " & Request.Form("cmdNewScheduleReport") & "<BR>"
'Response.End
If RetrieveIStore(IStore)=FALSE then
'If it failed, redirect the user to the logon page.
Call SSOLogon(IStore)
end if
Dim Result
Dim IStore
Dim Error, k
Dim NewName
Dim ReportID, CurrentFolderID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams, ScheduledInstanceID
'Request the hours and minutes that the user entered on the
'previous page.
'BeginHours = Request.Form("BeginHours")
'BeginMinutes = Request.Form("BeginMinutes")
'EndHours = Request.Form("EndHours")
'EndMinutes = Request.Form("EndMinutes")
'Retrieve the report ID from the page's parameter list.
ReportID = Request.QueryString("ReportID")
Dim ReportName
ReportName = Request.QueryString("ReportName")
'Retrieve the number of parameters, and then the parameter values.
NumParams = Request.QueryString("NumParams")
Redim Params(NumParams)
If ReportID <> "" Then
For k = 0 to NumParams-1
Params(k) = Request.Form("Param" & k+1)
Next
ElseIf ReportName <> "" Then
Dim FullPath , HyperLinkReportID
FullPath = UCase(Request.QueryString("FullPath"))
if GetReportID(ReportName,FullPath,Istore, HyperLinkReportID) Then
ReportID = HyperLinkReportID
For k = 0 to NumParams-1
Params(k) = Request.QueryString("Param" & k+1)
Next
else
Response.Write "Unable to retrieve CE ReportID and as a result I could not schedule this report."
Exit Sub
end if
else
Response.Write "Unable to retrieve CE ReportID/ReportName as a result I could not schedule this report."
Exit Sub
End if
'debugging
'Response.Write "ReportID = "&ReportID&"<BR>"
'Response.Write "NumParams = "&NumParams&"<BR>"
'response.write Params(1)
'Response.End
'Schedule the report with parameters.
If ScheduleReportWithParameters(IStore, ReportID, BeginHours, BeginMinutes, EndHours, EndMinutes, Params, NumParams,Session("CustomDBLogon"),Session("DBDriver"), Session("DataBaseName"),Session("ServerName"), Session("UserName"), Session("Password"), ScheduledInstanceID) = FALSE Then
Response.Write "There was an error and as a result I could not schedule this report."
Else
Response.Write "Successfully scheduled the report."
'Response.End
if Request.Form("cmdScheduleReport") <> "" or ReportName <> "" Then
Response.Redirect "viewreport.csp?ReportID=" & ReportID & "&ScheduledInstanceID=" & ScheduledInstanceID
else
Response.Write "<script>window.open('viewreport.csp?ReportID="&ReportID& "&ScheduledInstanceID=" & ScheduledInstanceID & "')</script>"
Response.Write "<script>history.go(-1)</script>"
end if
End If
End Sub
Main
%>
>>