Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BOE XI Last Instance

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
0
0
US
We had created our own tool for reports working with prior versions of CE...there used to be a file named GetLastInstance.csp...I don't see an equivalent to this for XI...has anyone found this or used it?

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
...if anyone's interested, here's what I've done to accomplish this...

Basically this page will either show the last instance of an XI report or (if that's not available) it will run the report on demand...

Code:
<%@language="vbscript"%>
<%
' First, get the APS name and report ID from the form variables 
' sent from the html page via the POST method.

'removed default settings
'apsname=request.form("APS")
'ReportObjectID=request.form("roID")

apsname="ServerName"
ReportObjectID=request.querystring("ID")

' Start a new session with the CE SDK so we can logon or logoff to the APS
on error resume next
set oSessionMgr = Server.CreateObject("CrystalEnterprise.SessionMgr")
if err.number < 0 then
	' Lots of error checking is always a good idea
	' In this sample we'll just response.write errors to the browser,
	' but your application can do something slicker.
	response.write "Error " & err.number & ": [" & Err.Description & "] creating CE SessionManager session.<br>" 
	response.end
end if

on error resume next


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'set the infor for the viewer and account
set oEnterpriseSession = oSessionMgr.Logon("userName","Password",apsname,"secEnterprise")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


if err.number < 0 then
	response.write "Error " & err.number & ": [" & Err.Description & "] on logon to APS [" & apsname & "].<br>" 
	response.write "Can't logon.<br>"
	response.end
end if

' Get a handle to the logon token manager so we can get a token to use for calls
on error resume next
Set oLogonTokenMgr=oEnterpriseSession.LogonTokenMgr	
if err.number < 0 then
	response.write "Error " & err.number & ": [" & Err.Description & "] Getting tokenmgr handle.<br>" 
	response.end
end if

' Get the actual logon token - this can be saved/restored using response.cookies 
' so you can share it amongst CSP files.
on error resume next
apstoken = oLogonTokenMgr.CreateLogonToken(apsname,"1","1000")
if err.number < 0 then
	response.write "Error " & err.number & ": [" & Err.Description & "] getting aps token.<br>" 
	response.end
end if

'response.write apstoken

' Write the apstoken to a cookie - this can be used by other CSP files
response.cookies("apstoken")=cstr(apstoken)

' Get a handle to an Info Store object so we can query the APS database
on error resume next
Set oIStore = oEnterpriseSession.Service("", "InfoStore")
if err.number < 0 then
	response.write "Error " & err.number & ": [" & Err.Description & "] getting InfoStore handle.<br>" 
	' now logoff
	oLogonTokenMgr.ReleaseToken apstoken
	response.end
end if

' Get a handle to a collection of report objects with the specified ID
' (there should be exactly one report in the collection.)
on error resume next
Set cReports = oIStore.Query("Select SI_LAST_SUCCESSFUL_INSTANCE_ID, SI_ID From CI_INFOOBJECTS Where SI_ID=" & cstr(ReportObjectID))
if err.number < 0 then
	response.write "Error " & err.number & ": [" & Err.Description & "] getting InfoStore query.<br>" 
	oEnterpriseSession.ReleaseToken apstoken
	response.end
end if

' There should be exactly one report with this ID. If none, then there's no report 
' to view, if more than one, there's an error in the database (duplicates.)
if cReports.Count <> 1 then
	response.write "Error: " & cstr(cReports.count) & " objects found with ID " & cstr(ReportObjectID) & ".<br>" 
	oEnterpriseSession.ReleaseToken apstoken
	response.end
end if 

'Response.Write(cReports.Item(1).Properties("SI_ID") & "<BR>")

' OK now we have the report object and all we have to do is get the latest instance
' Fortunately, there's a property built-in for this!
' It's SI_LAST_SUCCESSFUL_INSTANCE_ID

' Now we are ready to view the report instance.

' This line will bring up the default ActiveX viewer
'This line checks to see if there is a Last Successful ID
'If there is, we will go to it, otherwise we will go to an On Demand page that allows you to post the parameters
if cReports.Item(1).Properties("SI_LAST_SUCCESSFUL_INSTANCE_ID") Is Nothing Then
  response.redirect("/businessobjects/enterprise/admin/en/viewrpt.cwr?id=" & ReportObjectID & "&apstoken=" & cstr(apstoken)  & "&init=actX:connect")
else
  response.redirect("/businessobjects/enterprise/admin/en/viewrpt.cwr?id=" & cReports.Item(1).Properties("SI_LAST_SUCCESSFUL_INSTANCE_ID")& "&apstoken=" & cstr(apstoken)  & "&init=actX:connect")
end if

' But we will take a few extra steps to ensure our logon token is released sooner
' By default logon tokens are timed-out after 20 minutes. 
' For this we will use files ActiveXViewer.csp and Cleanup.csp.

riID = cReports.Item(1).Properties("SI_LAST_SUCCESSFUL_INSTANCE_ID")
%>

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Hi checkai.

Thanks for the file - it is definitely a function i am missing. I have tried to follow your example but I am unsecure about some information in the file.

1. How do I get the report ID? (I am a CR novice).
2. I get a "Error -2147213821: [Not a valid query.] getting InfoStore query." - I can't decipher it.
3. Is it possible to mark the necessary fields / information in your asp file that needs to be changed for it to work in another configuration?

Thanks
Jonas
 
here's how we use this...

1) all of our reports get uploaded to BOE XI...if you right click the report name in there you'll see there is an ID field...that's how you get your reportID...(we have our own small reporting db to track these...
2) our page loads the reports and has a link for each name that sends them to this page with ID in the query string.
3) Put this file at the following location...
Business Objects\BusinessObjects Enterprise 11\Web Content\Enterprise11\admin

this are the line's you'd need to change...

apsname="ServerName"

set oEnterpriseSession = oSessionMgr.Logon("userName","Password",apsname,"secEnterprise")


"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Hi checkai.

Thanks for your help.

Regarding the prior post I have a question:

If I use CR XI - how do I retrieve the SI_ID? Nothing happens when I right-click the object in CR XI server. When I run the report I can see a ID in the URL, but I guess this is the instance ID and not the object or report ID.

Thanks for your time.

Jonas
 
now do you have BOE XI?

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Hi.

I run Crystal Reports Server. Not the Business Objects Enterprise server. If this is the cause I will look for other solutions.

Thanks
 
yeah, i'm not sure as to how the CRServer works...I'm using BOE XI.

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top