Solved

Report Engine API - Export to Report Definition in VB6

Posted on 2003-10-24
9
1,057 Views
Last Modified: 2007-12-19
Environment: VB6 SP5, CR 8.5, Using CRWRAP.BAS and GLOBAL32.BAS
Procedure Objective:
To export a Crystal Report Report Definition to a TXT file for further processing (parsing, extraction of table/field names).
There are over 600 reports to be examined. The program opens the appropriate folder, collects the names of all RPTs, exports each to a TXT file in the same (or different) directory.

Code Snippet (EXPORT):

Handle = PEOpenEngine
If Handle = 0 Then
    lbl = "Error opening RPT file"
Else
    lbl = "Crystal Print Engine Successfully Open"
End If
job = PEOpenPrintJob(FullName)
exportdll = "u2frdef.dll"
exportformat = 0 'crUXFReportDefinitionType
result = crPEExportToDisk(job, inpDest & FName & ".txt" + Chr(0), "u2frdef.dll" + Chr(0), exportformat, 0, 0, "", "")
If PEStartPrintJob(job, True) = 0 Then
    lbl = "Error starting print job"
    MsgBox "crPEExportToDisk Failed: " & Str$(PEGetErrorCode(job))
Else
    lbl = FullName & " exported"
End If
PEClosePrintJob (job)
PECloseEngine


Behaviour:
The proc runs fine returning no errors until PEStartPrintJob(job, True). A Parameter Input window is displayed and, on clearing the window, the proc terminates in an errotr 500. Since the export is of a Report efinition, I cannot understand WHY the DLL requires an ODBC call to the database (no data is being exported) or, if it is imperative an ODBC call be made, how to make it. There is NO example in rystal or on the Web which shows how to handle the crPEExportToDisk function when the type of export is Report Definition.

In order for this program to function correctly, it must access, open, export the Report Definition, closwe, then retrieve another RPT until the file list for the folder is exhausted.

After three days of head-banging, I've come to the conclusion that I cannot export a Report Def without an ODBC call being made, but I have zero idea as to how to make it within this code structure.

Suggestions are gratefully accepted!!
0
Comment
Question by:earljgray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 9615405
I don't use ODBC but do you have the code to open the report for viewing that includes the ODBC setup?  I suspect it is the same code.

The reference I have doesn't use any code to setup the database connection.  Can you view the report on your machine?  Does your machine have the appropriate ODBC connections?  If not can you create them?

mlmcc

0
 

Author Comment

by:earljgray
ID: 9616080
>I don't use ODBC but do you have the code to open the report for viewing >that includes the ODBC setup?  I suspect it is the same code.

>The reference I have doesn't use any code to setup the database >connection.  Can you view the report on your machine?  Does your machine >have the appropriate ODBC connections?  If not can you create them?

There is an ODBC connector on the machine - and I can view the report through CReports. I've not written any code (in this program) to view a report since there's no necessity to do so. My only intention is to export the Report Definition...

When I open Crystal Reports itself, I can FILE | OPEN the reprt, click on the Export Icon (in the icon toolbar) and immediately receive the Export Options window. If I select REPORT DEFINITION from the first dropdown, and SISK FILE from the second, the export takes place in a blink of an eye - the Crystal report is still in design mode (on the screen) and no logon dialogue window opens requiring me to 'connect' prior to the export. All of this makes sense to me, since I'm not asking Crystal to 'preview' the report - which would require a hit on the DB  - I'm simply asking it to extract its own report definition and send it out to a text file. That's why this confuses me -:(


0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9618548
I think the problem is that when the driver opens the report it doesn't yet know what you are trying to do while in the designer the connection is probably already open.  

mlmcc
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:earljgray
ID: 9635425
In the designer, the report opens (FILE | OPEN), but the ODBC Login Window does not appear until you click the  REFRESH icon. Up to that point, as long as you're in the Design tab, you can export to report definition without 'attaching' to a db...

 
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9638889

There is the key.  The design tab doesn't have the database open until you refresh the data.  

When you open the report from an application it assumes you want to display it therefore it tries to connect to the database.

Are you doing this on a machine with CR Developer edition loaded?  If so you may be able to do this using the CRAXDDRT library which would alow you to design reports from your application.  I haven't used it since it requires extra licenses for each client machine but in your case it just might do what you want.

mlmcc
0
 

Author Comment

by:earljgray
ID: 9641379
>Are you doing this on a machine with CR Developer edition loaded?  

No - this is a CR Professional setup. Given that the PE call crPEExportToDisk includes the exportdll  "u2frdef.dll", I imagine the engine assumes the report -won't- be opened and populated by the database - but will result in a .TXT file being produced.

All the reports I'm interested uin working with are located on the Seafate InfoServer and are already designed and used in current production. If the crPEExportToDisk doesn't 'care' about the particular export dll being used, then I'm stuck - any given report may have a UID and PWD different from another - which would make it impossible to export programmatically unless I knew every UID/PWD for every one of these reports...
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 9647152
CR Professional doesn't have the horsepower necessary to be run from an application.  I am not sure what is missing but some dlls are missing or disabled.

Starting with CR8 you need to have at least the Developer edition to call reports from an application.

mlmcc
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question