Symptom
- Table alias names can't be changed after applying Service Pack 8
Environment
- SAP Crystal Reports, developer version for Microsoft Visual Studio SP3
- SAP Crystal Reports, developer version for Microsoft Visual Studio SP8, SP9 and SP10
Reproducing the Issue
- Execute the following C# code in SP7
e.g.
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load("C:\testA.rpt");
foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in rptDoc.Database.Tables)
{
tbl.Location = tbl.Location.Replace("A", "B");
tbl.ApplyLogOnInfo(tbl.LogOnInfo);
tbl.LogOnInfo.TableName = tbl.LogOnInfo.TableName.Replace("A", "B");
tbl.ApplyLogOnInfo(tbl.LogOnInfo);
}
rptDoc.SaveAs("C:\testB.rpt");
rptDoc.Close();
- Table alias names can be changed properly.
- After applying SP8 into the same runtime environment.
- Execute the same above code.
- Table alias names can't be changed.
Cause
The replace Alias feature is removed from SP8 due to regression.
It's by design that the Alias of table name must not be replaced via TableName.Replace function.
Resolution
Workaround: To use ModifyTableAlias of RAS SDK instead of TableName.Replace function.
e.g. (C#)
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load("C:\\testA.rpt");
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rd = rptDoc.ReportClientDocument;
foreach (CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable tbl in rd.Database.Tables)
{
// Replace A with B
rd.DatabaseController.ModifyTableAlias(tbl,"B");
}
string saveDirectory = "C:\\";
object saveDir = (object)saveDirectory;
rd.SaveAs("testB.rpt", ref saveDir, (int)CrystalDecisions.ReportAppServer.ClientDoc.CdReportClientDocumentSaveAsOptionsEnum.cdReportClientDocumentSaveAsOverwriteExisting);
rd.Close();
Keywords
cr, rpt, sdk, c#, c sharp, alias name, change data source, location, xml, merge module , KBA , BI-RA-CR-SDK , SDK related, including Java/.NET etc. , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem