Skip to Content
avatar image
Former Member

How to export a report as pdf using java without executing the report?

I am facing an issue while exporting crystal report as a pdf from my java application. I am using SAP API's and In Normal case it is working.

But below is my scenario,

I have a report/subreport and it has parameters and query.This report is already executed so I don't want to execute it again form my java application. But while using SAP API for exporting report (reportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF)) . I am getting an exception."Field Parameter not found". because API is expecting Parameter/DB details for fetching data which means Report will execute again from java application.

My Question is,

Can I export this report as pdf using java without executing the report?

OR

When we open reports in SAP Crystal Reports we can see preview of the report without passing parameters/Database Details , same logic I required in my java application for export , Is this possible?


Any advice (sample links) would be much appreciated.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 19, 2017 at 03:57 PM

    If it prompts then the issue may be missing data in the subreport or main report.

    Try previewing the report in CR Designer and go to the last page and then drill into any subreport you have embedded in the main report.

    Now save the report with data, or you could export to RPT format, that will save data with the report also.

    Now test the exported report in your app, and make sure the Viewer properties or in code is not discarding saved data or prompt for Parameter on refresh or the Refresh api is being used.

    Don

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Don,

      Thanks @Don Williams

      As per your answer,I have to update the existing report but I do not have permission to do that.

      Is there any other way to export the saved data from reports using API?

      I just want to export the saved data.

      I am getting below exception while executing the code

      11688 [main] ERROR com.businessobjects.reports.sdk.JRCCommunicationAdapter - detected an exception: java.lang.NullPointerException at com.crystaldecisions.reports.queryengine.RangeInfoNode.if(SourceFile:128) at com.crystaldecisions.reports.datafoundation.DFQuery.a(SourceFile:448) at com.crystaldecisions.reports.datafoundation.DFQuery.a(SourceFile:560) at com.crystaldecisions.reports.datafoundation.DFQuery.<init>(SourceFile:142) at com.crystaldecisions.reports.datafoundation.DFRuntime.if(SourceFile:122) at com.crystaldecisions.reports.datafoundation.DFRuntime.a(SourceFile:53) at com.crystaldecisions.reports.datalayer.a.if(SourceFile:1960) at com.crystaldecisions.reports.datalayer.a.char(SourceFile:2345) at com.crystaldecisions.reports.datalayer.a.void(SourceFile:770) at com.crystaldecisions.reports.datalayer.a.g(SourceFile:1196) at com.crystaldecisions.reports.datalayer.a.d(SourceFile:1262) at com.crystaldecisions.reports.datalayer.a.case(SourceFile:1219) at com.crystaldecisions.reports.dataengine.m.b(SourceFile:324) at com.crystaldecisions.reports.dataengine.j.b(SourceFile:515) at com.crystaldecisions.reports.dataengine.m.o(SourceFile:408) at com.crystaldecisions.reports.dataengine.m.a(SourceFile:173) at com.crystaldecisions.reports.dataengine.ContextNode.a(SourceFile:114) at com.crystaldecisions.reports.dataengine.ContextNode.a(SourceFile:95) at com.crystaldecisions.reports.dataengine.j.case(SourceFile:1080) at com.crystaldecisions.reports.dataengine.h.<init>(SourceFile:108) at com.crystaldecisions.reports.dataengine.DataContext.a(SourceFile:254) at com.crystaldecisions.reports.dataengine.DataProcessor2.a(SourceFile:4660) at com.crystaldecisions.reports.dataengine.DataProcessor2.a(SourceFile:4574) at com.crystaldecisions.reports.dataengine.DataProcessor2.new(SourceFile:2652) at com.crystaldecisions.reports.dataengine.DataProcessor2.byte(SourceFile:2610) at com.crystaldecisions.reports.dataengine.DataProcessor2.try(SourceFile:2282) at com.crystaldecisions.reports.dataengine.DataProcessor2.int(SourceFile:2442) at com.crystaldecisions.reports.dataengine.DataProcessor2.I(SourceFile:1013) at com.crystaldecisions.reports.dataengine.DataProcessor2.if(SourceFile:4816) at com.crystaldecisions.reports.dataengine.DataProcessor2.a(SourceFile:2020) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.a(SourceFile:309) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.a(SourceFile:250) at com.crystaldecisions.reports.formatter.formatter.objectformatter.u.a(SourceFile:922) at com.crystaldecisions.reports.formatter.formatter.objectformatter.u.e(SourceFile:784) at com.crystaldecisions.reports.formatter.formatter.objectformatter.f.e(SourceFile:383) at com.crystaldecisions.reports.formatter.formatter.objectformatter.u.for(SourceFile:242) at com.crystaldecisions.reports.formatter.formatter.objectformatter.aa.a(SourceFile:64) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.a(SourceFile:243) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.a(SourceFile:210) at com.crystaldecisions.reports.formatter.formatter.objectformatter.v.a(SourceFile:185) at com.crystaldecisions.reports.formatter.formatter.objectformatter.v.a(SourceFile:230) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.for(SourceFile:359) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.for(SourceFile:133) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ColumnFormatter.for(SourceFile:120) at com.crystaldecisions.reports.formatter.formatter.objectformatter.aa.a(SourceFile:64) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.a(SourceFile:511) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.a(SourceFile:452) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.a(SourceFile:369) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ah.a(SourceFile:72) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ReportColumnFormatter.a(SourceFile:86) at com.crystaldecisions.reports.formatter.formatter.paginator.SinglePageFormatter.a(SourceFile:332) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.for(SourceFile:359) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ai.for(SourceFile:133) at com.crystaldecisions.reports.formatter.formatter.objectformatter.ColumnFormatter.for(SourceFile:120) at com.crystaldecisions.reports.formatter.formatter.paginator.SinglePageFormatter.for(SourceFile:177) at com.crystaldecisions.reports.formatter.formatter.objectformatter.aa.a(SourceFile:64) at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.do(SourceFile:737) at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.X(SourceFile:399) at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.moveToPageN(SourceFile:339) at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.do(SourceFile:677) at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.formatPage(SourceFile:236) at com.crystaldecisions.reports.formatter.export2.a.a(SourceFile:97) at com.crystaldecisions.reports.formatter.export2.a.a(SourceFile:253) at com.crystaldecisions.reports.formatter.export2.ExportSupervisorEx.if(SourceFile:642) at com.crystaldecisions.reports.formatter.export2.ExportSupervisorEx.a(SourceFile:586) at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(SourceFile:637) at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.int(SourceFile:673) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(SourceFile:1943) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:660) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(SourceFile:166) at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(SourceFile:528) at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(SourceFile:526) at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(SourceFile:102) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(SourceFile:524) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(SourceFile:423) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(SourceFile:351) at com.businessobjects.sdk.erom.jrc.a.a(SourceFile:54) at com.businessobjects.sdk.erom.jrc.a.execute(SourceFile:67) at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(SourceFile:716) at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(SourceFile:125) at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:537) at com.crystaldecisions.sdk.occa.report.application.ds.a(SourceFile:186) at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:1558) at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:337) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:223) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:147) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:128) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:111) at main.java.com.arrow.crystal.CrystalReportParser.main(CrystalReportParser.java:162) 11689 [main] INFO com.businessobjects.reports.sdk.JRCCommunicationAdapter.JRCLicenseThrottler - releasing engine request 11689 [main] DEBUG com.crystaldecisions.reports.common.commandmanager - command SETUP: NotUndoableCommand 11689 [main] DEBUG com.crystaldecisions.reports.common.commandmanager - command PERFORM: NotUndoableCommand 11689 [main] DEBUG com.crystaldecisions.reports.common.commandmanager - -- command is NOT UNDOABLE -> purge undo stack 11694 [main] ERROR main.java.com.arrow.crystal.CrystalReportParser - ReportSDKException com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.NullPointerException---- Error code:-2147467259 Error code name:failed com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.NullPointerException---- Error code:-2147467259 Error code name:failed at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:237) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:147) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:128) at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:111) at main.java.com.arrow.crystal.CrystalReportParser.main(CrystalReportParser.java:162) Caused by: java.lang.NullPointerException

      Thanks,

      Sarath