Symptom
In an application using our .NET or Java SDK packages there is no API to change/set a new location to a Linked subreport.
Environment
- Crystal Reports 2008 .NET SDK
- Crystal Reports Developer for Visual Studio
- BI 4.0 .NET SDK
- BI 4.1 .NET SDK
- Crystal reports for Eclipse ( SP 17 )
Resolution
Here is the code to use:
SubreportClientDocument subreportClientDocument = subreportController.GetSubreport("SubReport.rpt");
subreportClientDocument.SubreportLocation = "c:\\YourReportFolder\YourSubreport.rpt";
string rptLocation = subreportController.SubreportLocation;
The SDK API's will be available in the following products and Patches:
- Crystal Reports 2008 - Service Pack 7
- Crystal Reports Develoepr for Visual Studio ( 2010 and 2012 ) Service Pack 7
- BI 4.0 .NET SDK Support Pack 7
- BI 4.1 .NET SDK Support Pack 02
NOTE: BI 4.0 SDK packages are only available for downloads through SAP Service Market Pace
See attached sample application for the full feature and functionality ( for BI 4.x SDK - change the dependencies to match product installed )
In Java it is in the following class:
CrystalReportsSDK.jar has the following methods – BUT CrystalReportsRuntime.jar also has subreportcontroller.class – but these functions do not exist in it.
-----------------------
public String getSubreportImportLocation(String subreportName)
throws ReportSDKException
{
if(subreportName == null || subreportName.length() == 0)
throw new IllegalArgumentException();
ISubreportObject subObject = getSubreportObject(subreportName);
if(subObject == null)
{
throw new IllegalArgumentException();
} else
{
String location = "";
location = subObject.getReimportLocation();
return location;
}
}
-----------------------
public void setSubreportImportLocation(String subreportName, String reportURL)
throws ReportSDKException
{
SubreportClientDocument subClientDoc = (SubreportClientDocument)getSubreport(subreportName);
ISubreportObject subObject = getSubreportObject(subreportName);
if(subClientDoc == null || subObject == null)
throw new IllegalArgumentException();
if(reportURL == null)
reportURL = "";
subClientDoc.setReportURL(reportURL);
ISubreportObject newSubreportObject = (ISubreportObject)subObject.clone(true);
newSubreportObject.setReimportLocation(reportURL);
m_MainReport.getReportDefController().getReportObjectController().modify(subObject, newSubreportObject);
}
Keywords
Subreportcontroller, linked subreport, sdk , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem
Product
Attachments
Subreport_check.zip |