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

Generating Report on MTS server and passing it to client

Status
Not open for further replies.

Shuchi

Programmer
Jan 10, 2002
29
GB
Hi,
I have an MTS server, on which my reportgeneration component resides.It has API calls to start crystal engine and generate a crystal report on MTS itself. Now i want to tranfer that file in the same format ( crystal .rpt) to the client , who ever has invoked it. I am not using any report server ( like actuate or seagateinfo) . Its just Crystal report.also there can be no drive mapping between MTS and client machines. How can i tranfer the file . FTP is one option.
Is anybody aware of any other option.

Pl. Help

Regards,
Shuchi
 
I've done that before a VB application. The client calls a MTS dll class method that has a return type of "Variant." The MTS method a) generates a Crystal report 2) reads the Crystal report file into a byte array using VB's "Get" function c) returns the byte array to the caller as the return value of the function.

Once the variant has returned to the client, it converts the variant back to a byte array and writes the byte array to a file locally using VB's "Put" function. You can then display the file in the Crystal Reports viewer control on a form. You could probably pass the byte array back using a Property Bag for better performance, but I have not yet tried that as of yet.

Here's an example:

MTS Function:
---------------------
Public Function GetReport() as Variant

Dim bteCrystalRpt() as Byte
Dim intFreeFile as Integer
Dim strTempFilename as String

' <Code that generates the Crystal
' report here...>

' *Assume the path to the Crystal
' report is held in the variable &quot;strTmpFileName&quot;

' Redimension the array to the size it will need
' to store the Crystal report.
ReDim bteCrystalRpt(FileLen(strTmpFileName) - 1) As Byte

' Open the Crystal report file.
intFreeFile = FreeFile
Open strTmpFilename For Binary Access Read As #intFreeFile

' Get the contents of the file into a byte array
Get #intFreeFile, , bteCrystalRpt

' Close the file and delete it.
Close #intFreeFile

' Clean up...
Kill strTmpFilename
Erase bteCrystalRpt

' Return the byte array as a variant
' to the client.
GetReport = bteCrystalRpt

End Function

Client Function:
--------------------------
Private Sub GoGetReport()

Dim X as SampleDLL.ReportMaker ' your MTS class object
Dim vntCrystalRpt as Variant
Dim bteCrystalRpt() as Byte
Dim intFreeFile as Integer

' Call the MTS function to retrieve
' the Crystal report as a variant.
Set X = CreateObject(&quot;SampleDLL.ReportMaker&quot;)
Set vntCrystalRpt = X.GetReport()

' Convert the variant to a byte array
' before you write it to disk, or Crystal
' will have errors trying to open the file.
bteCrystalRpt = vntCrystalRpt

' Now write the byte array to disk
Open &quot;C:\MyReport.rpt&quot; For Binary As #intFreeFile
Put #intFreeFile, , bteCrystalRpt
Close #intFreeFile

' Clean up...
Erase bteCrystalRpt
Set vntCrystalRpt = Nothing

' <Code to bring the Crystal Reports file
' into the Crystal viewer control here>

End Sub
 
Thanx a tonnnnn specise
I am working on it and will let u know whether it worked or not.
Just one question
There is one ERASE bteCrystalRpt command to erase the array
this u r doing before returning it to the client.Will it still hold the value as the actual &quot;Getreport = bteCrystalRpt&quot; is after this Erase command????


Thanx alot again
Regards,
Shuchi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top