SAP Knowledge Base Article - Public

1603154 - Shared variable display the incorrect value in Crystal Reports

Symptom

  • Shared variable display the incorrect value
  • Shared variable values is double
  • In Crystal Reports, when accumulating values in a subreport using shared variables, the value is incorrect

Environment

  • Crystal Reports 2008
  • SAP Crystal Reports 2011
  • Crystal Reports for Visual Studio 2010

Reproducing the Issue

  1. Create a report off any data source.
  2. Create a group and check the group option: New Page After
    • Under the menu “Insert”, select “Group”
    • In the “Insert Group” window, select the database fields to group by. ( For example: Country database fields )
    • Under the tab: “Options”, check the option: “New Page After 1 Visible Groups”
    • Click “OK” to accept the change
  3. Insert a subreport in the Group Footer section
  4. In the subreport suppress all section expect the Report Footer section
  5. In the subreport, create a formula that accumulate values from each subreport using shared variable. The formula will look like:
WhilePrintingRecords;
Shared NumberVar MySharedVariable := MySharedVariable + 1;
  1. In the subreport, insert the formula in the Report Footer section
  2. On the Main Report, suppress all section except your Group Footer section
  3. Preview the report, and on page 1, the value in the subreport is 1
  4. Go to the next page, and notice the shared variable value in the subreport is equal to 3, when we expected 2. As 1 + 1 should equal 2, and not 3

 Basically, the subreport is doubling the value to accumulate on each page.

Cause

  • Shared Variable values double when accumulating values in a subreport, if the subreport is located in a group that have the group option: New Page After checked.
  • The issue has been identified and logged under Problem Report ID ADAPT01521953

 

Resolution

  • The issue has been resolved in the following product updates:
    • For Crystal Reports 2008: Fix Pack 3.6 and higher.
    • For Crystal Reports 2011: Support Pack 04, and higher.
    • For Crystal Reports for Visual Studio 2010: Service Pack 2, and higher.

Keywords

Crystal Reports, CR, shared variables, value, double , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , BI-DEV-NET-SDK , .NET SDK / COM SDK , Problem

Product

Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2011, feature pack 03