0
votes

When I am trying pass paramaters from crystal report SDK and export my report to PDF. It is stand alone application so I can't user crystalreportviewer options but it is keep giving me error com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException: InternalFormatterException---- Error code:-2147217394 Error code name:missingParameterValueError My code is given below please help

import com.crystaldecisions.reports.sdk.DatabaseController;
import com.crystaldecisions.reports.sdk.ReportClientDocument;
import com.crystaldecisions.reports.sdk.ParameterFieldController;
import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
import com.crystaldecisions.sdk.occa.report.exportoptions.ExportOptions;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class Test {
public static void main(String args[]) throws ReportSDKException, SQLException,      FileNotFoundException, IOException{
try{

ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open("Report.rpt",0);
ParameterFieldController paramController = reportClientDoc.getDataDefController().getParameterFieldController();

paramController.setCurrentValue("","P_DP",new Integer(22));
//Here I was calling switch database code 
 ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getReportSource().export(ReportExportFormat.PDF);
 IOUtils.copy(byteArrayInputStream, new FileOutputStream("new.pdf"));

 reportClientDoc.close();

 }
}
1
I just swap the code setting parameters with switching database It starts working Now it is look like below code //Here I was calling switch database code ParameterFieldController paramController = reportClientDoc.getDataDefController().getParameterFieldController(); paramController.setCurrentValue("","P_DP",new Integer(22)); - Haroon

1 Answers

-1
votes

it starts working by just moving setting parameter code to above line. we need to set parameter before opening the report.



import com.crystaldecisions.reports.sdk.DatabaseController;
import com.crystaldecisions.reports.sdk.ReportClientDocument;
import com.crystaldecisions.reports.sdk.ParameterFieldController;
import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
import com.crystaldecisions.sdk.occa.report.exportoptions.ExportOptions;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class Test {
public static void main(String args[]) throws ReportSDKException, SQLException,      FileNotFoundException, IOException{
try{

ReportClientDocument reportClientDoc = new ReportClientDocument();

ParameterFieldController paramController = reportClientDoc.getDataDefController().getParameterFieldController();
paramController.setCurrentValue("","P_DP",new Integer(22));

reportClientDoc.open("Report.rpt",0);


//Here I was calling switch database code 
 ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getReportSource().export(ReportExportFormat.PDF);
 IOUtils.copy(byteArrayInputStream, new FileOutputStream("new.pdf"));

 reportClientDoc.close();

 }
}