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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports from the web 3

Status
Not open for further replies.

DirtyB

Programmer
Mar 13, 2001
159
US
I have ASP pages that hit Access and SQL Server databases. I now am writing ASP pages to show Crystal reports from these databases. I have been told that you can call the report simply from a hyperlink. I have also been told that you must set the report as an object and write tons of extra ASP code to get the reports to show properly? I looked at some sample ASP code from Seagate and there are HUNDREDS of lines of code to get the reports to show over the web. I am using Crystal 8. Can someone please tell me the definitive most effecient way to show Crystal Reports through ASP code? If I have a report that does not need to be dynamic, what is the simplest way to show it? no parameters, or anything.
 
Allright guys, here you go, this was a Seagate sample that we modified to make it work for us. Sorry if it's formatted kinda funny. Also, I did find a piece in there that forces a refresh from the database.



<%
' This script assumes that the Session contains the following Crystal Report Engine
' Objects:
'
' &quot;oApp&quot; - Crystal Report Engine Application Object
' &quot;oRpt&quot; - Crystal Report Engine Report Object
' &quot;oPageEngine - Crystal Report Engine Page Engine Object
' HTML_FRAME viewer only
' &quot;tabArray&quot; - Array used to keep drilldown tab information
' &quot;CurrentPageNumber&quot; - Current Page Number requested.
' &quot;lastknownpage&quot; - Previous page number requested.
' &quot;LastPageNumber&quot; - Last known page number requested.
' Note: Before creating the PageEngine object, call ReadRecords on the
' report object to that all the database records have been read.
'
' Modifications
' 05/02/98
' Added the following features:
' Tab Query String Parameter
' - This is the selected HTML_FRAME viewer tab's tabArray index value.
' Page Expiry Time
' - The page will expire when downloaded by browser so that user is insured that all data
' will be current.
' DrillDown Tabs
' - Added in the session(&quot;tabArray&quot;) object to keep track of the HTML_FRAME drill down tabs.
' RFSH Query String Parameter
' - Database is refreshed and ErrorValue 0 is sent to Java and active X viewers on success.
'This causes viewers to NOT refresh browser window.
' SRCH Query String Parameter and HTML_FRAME Viewer
' - Added javascript window.alert function call to indicate when text is not found in rpt view.

' 09/08/98
' Added the following features:
' - cmd handling for map_dd(Map Drill Down) and export(Exporting reports from viewers).
' - PageGenerator object creation for Out of Place Subreports. Modification was made to RetrieveObjects procedure.
' - Modified the get_ttl handling to call the PageGenerator object's RenderTotallerETF method
' instead of the PageEngine's method. This was done to support the group by feature.
' 08/03/99
' Added the following features
' - cmd/rfsh handling for pages with and without place holders.
' - cmd/rfsh handling for pages requiring and not requiring total page count.


On Error Resume Next

' The oEMF object is a helper object to create EMFs (Ecapsulated Messages) for the viewers.
' The viewers use EMFs to display errors and navigate to specific pages of the report.

If Not IsObject(session(&quot;oEMF&quot;)) then
Set session(&quot;oEMF&quot;) = Server.CreateObject(&quot;CREmfgen.CREmfgen.1&quot;)
Call CheckForError
End if


' Initialize all Global variables
' These will contain the page generator and page collection

Dim goPageGenerator ' page generator object
Dim goPageCollection ' page collection object
Dim goPageGeneratorDrill' page generator object in Drill Down Context
Dim goPage ' the page object
Dim gvGroupPathDD ' drill down group path, this is an array.
Dim gvGroupPath ' this is branch, aka Group Path converted from string passed on the QS, it is an Array
Dim gvGroupLevel ' this is the Group level, converted from the string passed on the QS, it is an Array
Dim gvMaxNode ' this represents the number of nodes to retrieve for the totaller, it is set to an empty array
Dim gvTotallerInfo ' this represents the group path of the requested totaller.
Dim glX ' this is the X Coordinate for a drill down on a graph or Map
Dim glY ' this is the Y Coordinate for a drill down on a graph or Map
Dim gvPageNumber ' holds the requested page number
Dim gvURL ' URL to redirect to
Dim gsErrorText ' holds the error text to be sent to the viewer.
Dim ExportOptions ' Export Options Object
Dim slX ' this is the X Coordinate for a selection of Out of Place subreport
Dim slY ' this is the Y Coordinate for a selection of Out of Place subreport

' Vaiables that represent what was passed on the Query String
Dim CMD ' This determines the main function to perform
Dim PAGE ' the page to return
Dim BRCH ' the branch is a mechanism to determine the drill down level.
' A drill down level is like a view of the report, a new tab
' is created to indicate that it is a new view
Dim VIEWER ' This is the viewer that is calling the server
Dim VFMT ' the format that the viewer understands
Dim NODE ' Currently not used??
Dim GRP ' this is a way of specifing the actual group
Dim COORD ' these are the coordinates on the graph to process
Dim DIR ' this is the search direction
Dim CSE ' indicates if the search is case sensitive
Dim TEXT ' this is the text to search for.
Dim INIT ' used to build the frames for the html viewer
Dim NEWBRCH ' used to keep track of when a new branch is to be viewed.
Dim EXPORT_FMT ' used to hold the export format and type
Dim SUBRPT ' used to hold the Out Of Place Subreport page, number,
' and coordinates on the main report.
Dim INCOMPLETE_PAGE ' used to indicate whether the page generated should contain placeholders.
Dim INCOMPLETE_PAGE_COUNT ' used to indicate whether the page should contain the total page count if not yet generated.
Dim PVERSION ' used to indicate the protocol version of the viewer.
Dim TTL_INFO ' used to indicate the group path of the totaller request.
' Constant Values
Dim CREFTWORDFORWINDOWS
Dim CREFTRICHTEXT
Dim CREFTEXCEL21
Dim CREFTCRYSTALREPORT
Dim CREDTDISKFILE
Dim EMFMIMETYPE
CREFTWORDFORWINDOWS = 14
CREFTRICHTEXT = 4
CREFTEXCEL21 = 18
CREFTCRYSTALREPORT = 1
CREDTDISKFILE = 1
crAllowPlaceHolders = 2
crDelayTotalPageCountCalc = 1
EMFMIMETYPe = &quot;application/x-emf&quot;
EPFMIMETYPE = &quot;application/x-epf&quot;
ETFMIMETYPE = &quot;application/x-etf&quot;
' Initialize Arrays
gvGroupPath = Array()
gvGroupLevel = Array()
gvMaxNode = Array() ' reteive all nodes
gvTotallerInfo = Array()
NEWBRCH = &quot;0&quot;
' To ensure that the browser does not cache the html pages for the group trees.
Response.Expires = 0
' Parse Query String for paramaters
Call ParseQS()

' INIT is a special QS case, we only care about HTML viewer, if it is then save send page and branch info
' to the frame page

if INIT = &quot;HTML_FRAME&quot; then
' build URL and send the QS
if BRCH <> &quot;&quot; and NEWBRCH = &quot;1&quot; then
' htmstart is the base page that creates the frames for the HTML viewer
' if there is branch information it needs to be passed along.
tmpArray = session(&quot;tabArray&quot;)
if tmpArray(0) <> &quot;EMPTY&quot; then
val = UBound(tmpArray, 1) + 1
redim preserve tmpArray(val + 4)
else
val = 0
end if
tmpArray(val) = CStr(val)
tmpArray(val + 1) = session(&quot;lastBrch&quot;)
session(&quot;lastBrch&quot;) = BRCH
tmpArray(val + 2) = session(&quot;CurrentPageNumber&quot;)
tmpArray(val + 3) = session(&quot;lastknownpage&quot;)
tmpArray(val + 4) = session(&quot;LastPageNumber&quot;)
session(&quot;tabArray&quot;) = tmpArray
gvURL = &quot;htmstart.asp?brch=&quot; & BRCH & &quot;&&quot;
else
if BRCH <> &quot;&quot; then
gvURL = &quot;htmstart.asp?brch=&quot; & BRCH
else
gvURL = &quot;htmstart.asp&quot;
end if
end if
response.redirect gvURL
end if



' If there is a BRCH then create the gvGroupPath array that represents it.

if BRCH <> &quot;&quot; then
gvGroupPath = CreateArray(BRCH)
end if

' If there is a GRP then create the gvGroupLevel array that represents it.

if GRP <> &quot;&quot; then
gvGroupLevel = CreateArray(GRP)
end if

' If there is a TTL_INFO then create the gvTotallerInfo array that represents it.

if TTL_INFO <> &quot;&quot; then
gvTotallerInfo = CreateArray(TTL_INFO)
end if



' If there are COORDs, then get them
if COORD <> &quot;&quot; then
Call GetDrillDownCoordinates(COORD, glX, glY)
end if

' This case statement determines what action to perform based on CMD
' there are sub cases for each viewer type



Select Case CMD

Case &quot;GET_PG&quot;

Call RetrieveObjects

' create the actual page
Set goPage = goPageCollection(PAGE)
' check for an exception on the page number
Call ValidatePageNumber

' 0 is for epf, 8209 is a SafeArray
Select Case VFMT

Case &quot;ENCP&quot;
session(&quot;oPageEngine&quot;).PlaceHolderOptions = 0
if(PVERSION > 2)then
if INCOMPLETE_PAGE > 0 then
session(&quot;oPageEngine&quot;).PlaceHolderOptions = crAllowPlaceHolders
end if
if INCOMPLETE_PAGE_COUNT > 0 then
session(&quot;oPageEngine&quot;).PlaceHolderOptions = session(&quot;oPageEngine&quot;).PlaceHolderOptions + crDelayTotalPageCountCalc
end if
end if
session(&quot;oPageEngine&quot;).ImageOptions = 1
temp = goPage.Renderepf(8209)
Response.AddHeader &quot;CONTENT-LENGTH&quot;, lenb(temp)
Response.ContentType = EPFMIMETYPE
response.binarywrite temp

Case &quot;HTML_FRAME&quot;
session(&quot;oPageEngine&quot;).ImageOptions = 1
response.binarywrite goPage.Renderhtml(1,2,1,request.ServerVariables(&quot;SCRIPT_NAME&quot;),8209)
' Need to know if it is the last page to construct the toolbar correctly
if goPage.IsLastPage then
session(&quot;LastPageNumber&quot;) = goPage.pagenumber
session(&quot;CurrentPageNumber&quot;) = session(&quot;LastPageNumber&quot;)
end if
Case &quot;HTML_PAGE&quot;
session(&quot;oPageEngine&quot;).ImageOptions = 1
response.binarywrite goPage.Renderhtml(1,3,3,request.ServerVariables(&quot;SCRIPT_NAME&quot;),8209)

end select

Case &quot;GET_TTL&quot;

Call RetrieveObjects

Select Case VFMT

Case &quot;ENCP&quot;
Response.ContentType = ETFMIMETYPE
if(PVERSION > 2)then
temp = goPageGenerator.RenderTotallerETF(gvTotallerInfo, 0, 1, gvMaxNode, 8209)
else
temp = goPageGenerator.RenderTotallerETF(gvGroupPath, 0, 0, gvMaxNode, 8209)
end if
Response.AddHeader &quot;CONTENT-LENGTH&quot;, lenb(temp)
response.binarywrite temp

Case &quot;HTML_FRAME&quot;
response.binarywrite goPageGenerator.RenderTotallerHTML(gvGroupPath, 1, 0, gvMaxNode, gvGroupLevel, 1, request.ServerVariables(&quot;SCRIPT_NAME&quot;), 8209)

end select


Case &quot;RFSH&quot;

' This command forces the database to be read again.
session(&quot;oRpt&quot;).DiscardSavedData
session(&quot;oRpt&quot;).ReadRecords
If Err.Number <> 0 Then
Call CheckForError
Else
session(&quot;oRpt&quot;).EnableParameterPrompting = False
Set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine
End If
Call RetrieveObjects
Set goPage = goPageCollection(PAGE)
Call ValidatePageNumber
session(&quot;oPageEngine&quot;).ImageOptions = 1
Select Case VFMT
Case &quot;ENCP&quot;
' Java and Active X Viewers will make a get page command when receiving 0 error msg value
if VIEWER = &quot;JAVA&quot; then
session(&quot;oPageEngine&quot;).PlaceHolderOptions = 0
if(PVERSION > 2)then
if INCOMPLETE_PAGE > 0 then
session(&quot;oPageEngine&quot;).PlaceHolderOptions = crAllowPlaceHolders
end if
if INCOMPLETE_PAGE_COUNT > 0 then
session(&quot;oPageEngine&quot;).PlaceHolderOptions = session(&quot;oPageEngine&quot;).PlaceHolderOptions + crDelayTotalPageCountCalc
end if
end if
temp = goPage.Renderepf(8209)
Response.AddHeader &quot;CONTENT-LENGTH&quot;, lenb(temp)
Response.ContentType = EPFMIMETYPE
response.binarywrite temp
else
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 0,&quot;&quot;
end if

Case &quot;HTML_FRAME&quot;
InitializeFrameArray()
gvURL = &quot;htmstart.asp&quot;
response.redirect gvURL

Case &quot;HTML_PAGE&quot;
session(&quot;oPageEngine&quot;).ImageOptions = 1
response.binarywrite goPage.Renderhtml(1,3,1,request.ServerVariables(&quot;SCRIPT_NAME&quot;),8209)

end select


Case &quot;NAV&quot;
Call RetrieveObjects
Call CheckForError
' Get the page number that the group in on, for this particular branch
gvPageNumber = goPageGenerator.GetPageNumberForGroup(gvGroupLevel)

Select Case VFMT
' 0 is for epf, 8209 is a SafeArray, 8 is a BSTR
Case &quot;ENCP&quot;
' Create a byte array for the EMF, which will contain the page number
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).sendpagenumberrecord(gvPageNumber)

Case &quot;HTML_FRAME&quot;
' for html browser send back the page
dim appendQuery
appendQuery = &quot;?&quot;
session(&quot;CurrentPageNumber&quot;) = gvPageNumber
if BRCH <> &quot;&quot; then
appendQuery = appendQuery & &quot;BRCH=&quot; & BRCH & &quot;&&quot;
end if
if GRP <> &quot;&quot; then
appendQuery = appendQuery & &quot;GRP=&quot; & GRP
end if
response.redirect &quot;framepage.asp&quot; & appendQuery

end select


Case &quot;CHRT_DD&quot;
' only supported in java and active X smart viewers
Select Case VFMT

Case &quot;ENCP&quot;

' Get page collection
Call RetrieveObjects
Call CheckForError
' Pass the coordinates to the report engine to determine what
' branch the drill down goes to.
Set goPageGeneratorDrill = goPageGenerator.DrillOnGraph(PAGE, glX, glY)
' Check for an exception because of coordinates
if err.number <> 0 then
gsErrorText = &quot;Not part of the Graph &quot;
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 40, gsErrorText
err.clear
response.end
end if
' pass the group level and group path to helper function to create
' the EMF message, this tells the viewer where to get the page.

gvGroupPathDD = goPageGeneratorDrill.grouppath
gvGroupNameDD = goPageGeneratorDrill.groupname
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).GroupName = gvGroupNameDD
session(&quot;oEMF&quot;).sendbranchesemf(gvGroupPathDD)


end select

Case &quot;GET_LPG&quot;

' only support in smart viewers
Select Case VFMT

Case &quot;ENCP&quot;
' this command returns the page number of the last page
' Get page collection
Call RetrieveObjects
Call CheckForError
' Get the count from the Pages collection
gvPageNumber = goPageCollection.Count

' Send the EMF representing the page number
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).sendpagenumberrecord(gvPageNumber)
end select

Case &quot;SRCH&quot;
Call RetrieveObjects
Call CheckForError
' create page variable
gvPageNumber = CInt(PAGE)

Select Case VFMT
Case &quot;ENCP&quot;
if goPageGenerator.FindText(TEXT, 0, gvPageNumber) then
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).sendpagenumberrecord(gvPageNumber)
else
gsErrorText = &quot;The specified text, '&quot; & TEXT & &quot;' was not found in the report&quot;
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 33, gsErrorText
end if

Case &quot;HTML_FRAME&quot;
' We are being called by HTML viewer
' need to get the text from the form post
dim searchFound
TEXT = request.form(&quot;text&quot;)
' Now find out what page the text is on
tempNumber = gvPageNumber + 1
If(CBool(goPageGenerator.FindText(TEXT, 0, tempNumber))) then
session(&quot;CurrentPageNumber&quot;) = tempNumber
searchFound = 1
else
session(&quot;CurrentPageNumber&quot;) = gvPageNumber
searchFound = 0
End If
if BRCH <> &quot;&quot; then
gvURL = &quot;framepage.asp?brch=&quot; & BRCH & &quot;&SEARCHFOUND=&quot; & searchFound
else
gvURL = &quot;framepage.asp?SEARCHFOUND=&quot; & searchFound
end if
response.redirect gvURL

Case &quot;HTML_PAGE&quot;
' We are being called by HTML viewer
' need to get the text from the form post
TEXT = request.form(&quot;text&quot;)
' Now find out what page the text is on
tempNumber = gvPageNumber
If(CBool(goPageGenerator.FindText(TEXT, 0, tempNumber))) then
gvPageNumber = tempNumber
Set goPage = goPageCollection(gvPageNumber)
session(&quot;oPageEngine&quot;).ImageOptions = 1
response.binarywrite goPage.Renderhtml(1,3,3,request.ServerVariables(&quot;SCRIPT_NAME&quot;),8209)
else
' Send back an html page indicating the text was not found.
Response.Write &quot;<html><title>Seagate ASP Reports Server</title><body bgcolor='white'><center><h1>The text cannot be found in this report.</h1></center></body></html>&quot;
End If

end select


Case &quot;TOOLBAR_PAGE&quot;

' Redirect to the framepage, need to know if we are
' on the last page.

if session(&quot;LastPageNumber&quot;) <> &quot;&quot; then
if CInt(PAGE) > CInt(session(&quot;LastPageNumber&quot;)) then
session(&quot;CurrentPageNumber&quot;) = session(&quot;LastPageNumber&quot;)
else
session(&quot;CurrentPageNumber&quot;) = PAGE
end if
else
Call RetrieveObjects
Call CheckForError
' create the actual page
Set goPage = goPageCollection(PAGE)
' check for an exception on the page number
Call ValidatePageNumber
if goPage.IsLastPage then
session(&quot;LastPageNumber&quot;) = goPage.pagenumber
session(&quot;CurrentPageNumber&quot;) = session(&quot;LastPageNumber&quot;)
else
session(&quot;CurrentPageNumber&quot;) = PAGE
end if
end if
if BRCH <> &quot;&quot; then
gvURL = &quot;framepage.asp?brch=&quot; & BRCH
else
gvURL = &quot;framepage.asp&quot;
end if

response.redirect gvURL

Case &quot;EXPORT&quot;
Set ExportOptions = Session(&quot;oRpt&quot;).ExportOptions
if(FillExportOptionsObject( EXPORT_FMT)) Then
Call RetrieveObjects
response.binarywrite goPageGenerator.Export(8209)
Call CheckForError
else
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 1, &quot;Invalid Export Type Specified&quot;
end if

Case &quot;MAP_DD&quot;
' only supported in java and active X smart viewers
Select Case VFMT

Case &quot;ENCP&quot;

' Get page collection
Call RetrieveObjects
Call CheckForError
' Pass the coordinates to the report engine to determine what
' branch the drill down goes to.
Set goPageGeneratorDrillonMap = goPageGenerator.DrillOnMap(PAGE, glX, glY)
' Check for an exception because of coordinates
if err.number <> 0 then
gsErrorText = &quot;No Values Exist for Selected Region of Map&quot;
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 40, gsErrorText
err.clear
response.end
end if
' pass the group level and group path to helper function to create
' the EMF message, this tells the viewer where to get the page.

gvGroupPathDD = goPageGeneratorDrillonMap.grouppath
gvGroupNameDD = goPageGeneratorDrillonMap.groupname
session(&quot;oEMF&quot;).GroupName = gvGroupNameDD
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).sendbranchesemf(gvGroupPathDD)

end select

end select



SUB RetrieveObjects()
' This procedure simply retrieves the session objects into global variables.
' In the case of Out of Place Subreports, the SUBRPT parameter must be parsed and the
' Subreport page generator object must be created.
Dim oRptOptions 'Report Options
Dim charIndexVal,tmpCharIndexVal
Dim tmpStr
Dim tmpPageGenerator
Dim subPageGenerator
Dim OOPSSeqNo 'holds the page's OOPS sequence number
Dim OOPSSubName 'holds the OOPS's name
Dim subCoords 'holds the coordinates of the OOPS in the main report
Dim subgvGroupPath 'holds the group path for the main report in subrpt parameter
Dim mainRptPageNumber 'holds the page number for the main report in the subrpt parameter

subgvGroupPath = Array()
if IsObject(session(&quot;oPageEngine&quot;)) then
' make sure dialogs have been disabled
if SUBRPT <> &quot;&quot; Then
' Obtain the subreport sequence number
charIndexVal = findChar(SUBRPT, &quot;:&quot;)
if charIndexVal > 1 then
OOPSSeqNo = Mid(SUBRPT,1,charIndexVal - 1)
end if
' Obtain the subreport's name
tmpStr = Mid(SUBRPT,charIndexVal + 1)
charIndexVal = findChar(tmpStr, &quot;:&quot;)
if charIndexVal > 1 then
OOPSSubName = Mid(tmpStr,1,charIndexVal - 1)
end if
tmpStr = Mid(tmpStr,charIndexVal + 1)
charIndexVal = findChar(tmpStr, &quot;:&quot;)
' Obtain the group path for the Out of Place Subreport
if charIndexVal > 1 then
subgvGroupPath = CreateArray(Mid(tmpStr, 1, charIndexVal - 1))
end if
'Obtain the main report page number after the fourth : character
tmpStr = Mid(tmpStr,charIndexVal + 1)
'Get the location of the fourth : seperator
charIndexVal = findChar(tmpStr, &quot;:&quot;)
mainRptPageNumber = Mid(tmpStr, 1, charIndexVal - 1)
'Get the coordinates portion of the SUBRPT parameter
subCoords = Mid(tmpStr, charIndexVal + 1)
Call GetDrillDownCoordinates(subCoords, slX, slY)
' Get the main reports page generator for the view
Set tmpPageGenerator = session(&quot;oPageEngine&quot;).CreatePageGenerator(subgvGroupPath)
Set subPageGenerator = tmpPageGenerator.DrillOnSubreport(mainRptPageNumber, slX, slY)
Set goPageGenerator = subPageGenerator.CreateSubreportPageGenerator(gvGroupPath)
else
Set goPageGenerator = session(&quot;oPageEngine&quot;).CreatePageGenerator(gvGroupPath)
end if
Set goPageCollection = goPageGenerator.Pages
else
' must have timed out return an error, you may wan to Append to the
' IIS log here.
if VFMT = &quot;ENCP&quot; then
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 1, &quot;User Session has expired&quot;
else
response.write &quot;User Session has expired&quot;

end if
response.end
end if

END SUB

SUB ParseQS()
' Parse the Query String
CMD = UCase(request.querystring(&quot;cmd&quot;)) ' This determines the main function to perform
PAGE = UCase(request.querystring(&quot;page&quot;)) ' the page to return
BRCH = UCase(request.querystring(&quot;BRCH&quot;)) ' the branch is a mechanism to determine the drill down level.
' A drill down level is like a view of the report, a new tab
' is created to indicate that it is a new view
VIEWER = UCase(request.querystring(&quot;VIEWER&quot;)) ' This is the viewer that is calling the server
VFMT = UCase(request.querystring(&quot;VFMT&quot;)) ' the format that the viewer understands
NODE = UCase(request.querystring(&quot;NODE&quot;))
GRP = UCase(request.querystring(&quot;GRP&quot;)) ' this is a way of specifing the actual group
COORD = UCase(request.querystring(&quot;COORD&quot;)) ' these are the coordinates on the graph to process
DIR = UCase(request.querystring(&quot;DIR&quot;)) ' this is the search direction
CSE = UCase(request.querystring(&quot;CASE&quot;)) ' indicates if the search is case sensitive
TEXT = request.querystring(&quot;TEXT&quot;) ' this is the text to search for.
INIT = UCase(request.querystring(&quot;INIT&quot;)) ' used to build the frames for the html viewer
TAB = UCase(request.querystring(&quot;TAB&quot;)) ' used to keep track of TABS on drill down.
EXPORT_FMT = UCase(request.querystring(&quot;EXPORT_FMT&quot;)) ' Used to specify export format and type.
SUBRPT = UCase(request.querystring(&quot;SUBRPT&quot;)) ' The Out of Place Subreport coordinates.
INCOMPLETE_PAGE = CInt(request.querystring(&quot;INCOMPLETE_PAGE&quot;))' Used to specify whether the page is to contain placeholders.
INCOMPLETE_PAGE_COUNT = CInt(request.querystring(&quot;INCOMPLETE_PAGE_COUNT&quot;))' Used to specify whether the page has to contain a total page count.
PVERSION = CInt(request.querystring(&quot;PVERSION&quot;))' Used to indicate the protocol version the viewer is utilizing.
TTL_INFO = UCase(request.querystring(&quot;TTL_INFO&quot;))'Used to indicate the group path of the totaller request.
' Initialize variables to a default if they are not provided on the query string.
' Check for Parameter Values that are passed by the HTTP Post Command.
if CMD = &quot;&quot; then
CMD = UCase(request.form(&quot;cmd&quot;))
if CMD = &quot;&quot; then
CMD = &quot;GET_PG&quot;
end if
end if

if INIT = &quot;&quot; then
INIT = UCase(request.form(&quot;INIT&quot;))
end if

if BRCH = &quot;&quot; then
BRCH = UCase(request.form(&quot;BRCH&quot;))
end if

if BRCH = &quot;&quot; and INIT = &quot;HTML_FRAME&quot; then
Call InitializeFrameArray
end if


if BRCH <> &quot;&quot; and INIT = &quot;HTML_FRAME&quot; then
if session(&quot;lastBrch&quot;) <> BRCH then
NEWBRCH = &quot;1&quot;
end if
end if


if VIEWER = &quot;&quot; then
VIEWER = UCase(request.form(&quot;VIEWER&quot;))
if VIEWER = &quot;&quot; then
VIEWER = &quot;HTML&quot;
end if
end if

if VFMT = &quot;&quot; then
VFMT = UCase(request.form(&quot;VFMT&quot;))
if VFMT = &quot;&quot; then
VFMT = &quot;HTML_PAGE&quot;
end if
end if

if GRP = &quot;&quot; then
GRP = UCase(request.form(&quot;GRP&quot;))
end if

if TTL_INFO = &quot;&quot; then
TTL_INFO = UCase(request.form(&quot;TTL_INFO&quot;))
end if

if COORD = &quot;&quot; then
COORD = UCase(request.form(&quot;COORD&quot;))
end if

if NODE = &quot;&quot; then
NODE = UCase(request.form(&quot;NODE&quot;))
end if

if DIR = &quot;&quot; then
DIR = UCase(request.form(&quot;DIR&quot;))
if DIR = &quot;&quot; then
DIR = &quot;FOR&quot; ' forward
end if
End if

if CSE = &quot;&quot; then
CSE = UCase(request.form(&quot;CASE&quot;))
if CSE = &quot;&quot; then
CSE = &quot;0&quot; ' case insensitive
end if
end if

if TEXT = &quot;&quot; then
TEXT = request.form(&quot;TEXT&quot;)
end if

if EXPORT_FMT = &quot;&quot; then
EXPORT_FMT = UCase(request.form(&quot;EXPORT_FMT&quot;))
end if

if SUBRPT = &quot;&quot; then
SUBRPT = UCase(request.form(&quot;SUBRPT&quot;))
end if

if request.form(&quot;INCOMPLETE_PAGE&quot;) <> &quot;&quot; then
INCOMPLETE_PAGE = CInt(request.form(&quot;INCOMPLETE_PAGE&quot;))
end if

if request.form(&quot;INCOMPLETE_PAGE_COUNT&quot;) <> &quot;&quot; then
INCOMPLETE_PAGE_COUNT = CInt(request.form(&quot;INCOMPLETE_PAGE_COUNT&quot;))
end if

if PVERSION = 0 then
PVERSION = CInt(request.form(&quot;PVERSION&quot;))
end if

' Check to make sure there is a page requested, if not use 1 as a default
if PAGE = &quot;&quot; then
PAGE = UCase(request.form(&quot;page&quot;))
if PAGE = &quot;&quot; then
PAGE = &quot;1&quot;
end if
end if

if PAGE <> &quot;&quot; and NOT IsNumeric(PAGE) then
PAGE = &quot;1&quot;
end if

END SUB

Function CreateArray(ByVal vsStringArray)
' this function takes an string like 0-1-1-0 and converts
' it into an array of integers

Dim lvArray
Dim lvNewArray
Dim liCount
Dim liCurrentPos
Dim lsBuf
lvArray = Array()
lvNewArray = Array()
ReDim lvArray(256)

liStringLength = Len(vsStringArray)
liCount = 0
liCurrentPos = 1
lsBuf = &quot;&quot;

While liCurrentPos <= liStringLength

'ignore this character
If Mid(vsStringArray, liCurrentPos, 1) <> &quot;-&quot; Then
lsBuf = lsBuf & Mid(vsStringArray, liCurrentPos, 1)
If liCurrentPos = liStringLength Then
lvArray(liCount) = CInt(lsBuf)
lsBuf = &quot;&quot;
liCount = liCount + 1
End If

Else
lvArray(liCount) = CInt(lsBuf)
lsBuf = &quot;&quot;
liCount = liCount + 1
End If
liCurrentPos = liCurrentPos + 1
Wend

ReDim lvNewArray(liCount - 1)

For x = 0 To (liCount - 1)
lvNewArray(x) = lvArray(x)
Next


CreateArray = lvNewArray

End Function

' Helper function to parse coordinates passed by viewers and place into independent variables.
SUB GetDrillDownCoordinates(ByVal strParam, ByRef xCoord, ByRef yCoord)
Dim liStringLength
Dim lbDone
Dim lsBuf

liStringLength = Len(strParam)
lbDone = FALSE
lsBuf = &quot;&quot;
xCoord = &quot;&quot;
yCoord = &quot;&quot;
For x = 1 To liStringLength
lsBuf = Mid(strParam, x, 1)

'ignore this character
If lsBuf = &quot;-&quot; Then
lsBuf = &quot;&quot;
lbDone = TRUE
End if

if lbDone then
yCoord = yCoord + lsBuf
else
xCoord = xCoord + lsBuf
end if

Next

END SUB

' This helper procedure will check if the requested page number exists.
' If it does not, it will set it to the last available page.
SUB ValidatePageNumber()
if err.number <> 0 then
if err.number = 9 then
' just return the last page
PAGE = goPageCollection.count
Set goPage = goPageCollection(PAGE)
' these session variables are used for the HTML Frame viewer
session(&quot;LastPageNumber&quot;) = PAGE
session(&quot;CurrentPageNumber&quot;) = PAGE
err.clear
else
' A more serious error has occurred. Error message sent to browser.
Call CheckForError
end if
end if
END SUB



' This helper procedure will send an error msg to the browser based on what viewer is being used.
SUB CheckForError()
If Err.Number <> 0 Then
if VFMT = &quot;ENCP&quot; then
Response.ContentType = EMFMIMETYPE
session(&quot;oEMF&quot;).SendErrorMsg 1, &quot;CRAXDRT Error Occured on Server. &quot; & Err.Number & &quot; : &quot; & Err.Description
else
Response.Write &quot;CRAXDRT Error Occured on Server. Error Number: &quot; & Err.Number & &quot; Error Description: &quot; & Err.Description
end if
Response.end
End if
END SUB

SUB InitializeFrameArray()
'initialize the html_frame array
set session(&quot;tabArray&quot;) = Nothing
session(&quot;lastBrch&quot;) = &quot;&quot;
dim tmpArray
tmpArray = Array(4)
redim tmpArray(4)
'Initialize the sequence number
tmpArray(0) = &quot;EMPTY&quot;
session(&quot;tabArray&quot;) = tmpArray
END SUB

' Helper function to parse the EXPORT_FMT parameter and fill in the properties of the
' Export object.
FUNCTION FillExportOptionsObject(export_fmt_options)
dim charIndex
dim exportType
dim exportDLLName
charIndex = findChar(export_fmt_options,&quot;:&quot;)
'Set session(&quot;ExportOptions&quot;) = Session(&quot;oRpt&quot;).ExportOptions
if(charIndex > 0) Then
'Get the export format type value
exportType = Mid(export_fmt_options, charIndex + 1)
exportDLLName = UCase(Mid(export_fmt_options, 1, charIndex - 1))
Select Case exportDLLName
Case &quot;U2FWORDW&quot;
ExportOptions.FormatType = CREFTWORDFORWINDOWS + CInt(exportType)
Response.ContentType = &quot;application/msword&quot;
Case &quot;U2FRTF&quot;
ExportOptions.FormatType = CREFTRICHTEXT + CInt(exportType)
Response.ContentType = &quot;application/rtf&quot;
Case &quot;U2FXLS&quot;
ExportOptions.FormatType = CREFTEXCEL21 + CInt(exportType)
Response.ContentType = &quot;application/x-msexcel&quot;
Case &quot;U2FCR&quot;
ExportOptions.FormatType = CREFTCRYSTALREPORT + CInt(exportType)
Response.ContentType = &quot;application/x-rpt&quot;
Case Else
FillExportOptionsObject = False
Exit Function
End Select
ExportOptions.DestinationType = CREDTDISKFILE
FillExportOptionsObject = True
else
FillExportOptionsObject = False
end if

end FUNCTION

' Helper function that returns the index of the character in the given string.
Function findChar(findStr, charToFind)
dim lenStr
dim result
lenStr = len(findStr)
result = -1
if(lenStr > 0) Then
charCounter = 1
do While(charCounter <= lenStr)
tmpChar = Mid(findStr,charCounter,1)
if(tmpChar = charToFind) Then
result = charCounter
Exit Do
end if
charCounter = charCounter + 1
loop
end if

findChar = result
End Function

%>


 
That's strange, I tried to upload it a few times and it kept timing out on me, so I emailed it to everyone who posted their address.
 
If you are a registered user of crystal decisions web site, you will be able to download this sample from their website


and search for aspxmps85 or asp*

you will get a zip file containing a set of sample ASPs

Required_App_Components pack has the basic files needed for creating the web rteports.

rptserver.asp, Template, AlwaysrequiredSteps, MoreRequiredsteps are the four basic ASPs. All the rest will be used based on necessity. The Template asp is the one, you need to start with.
Hope this helps
Poorani
 
Have any of you tried to export the report from any of the viewers to a PDF format using the crxf_pdf.dll provided on the enterprise edition? [surprise]

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top