SAP Knowledge Base Article - Public

1713266 - How to pass Sub-Report Shared variable to Main Report chart

Symptom

Shared variable from a sub-report displays zero when used in Bar/pie chart.

Environment

  • Crystal Reports 2008
  • Crystal Reports 2011

Reproducing the Issue

  1. Insert a Sub-Report in Main Report’s Report Footer a (RFa) section
  2. Create a formula in Sub-Report as below
    1. WhilePrintingRecords;
    2. Shared NumberVar t:=200;
  3. Call the shared variable to Main Reports as below
    1. WhilePrintingRecords;
    2. Shared numberVar t;
  4. Insert a Bar Chart in Main report’s Report Footer b (RFb) section
  5. Right click on chart , select Chart Expert
  6. Select Data tab, in show values(s) add the formula which is created in Main Report
  7. Click on OK
  8. Place the Main Report formula in any section of main report
  9. Preview the report

Resolution

Workaround 1:

  1. Place the Sub-Report in Report Header Section
  2. Then place the Bar Chart in Report Footer section

Workaround 2:

  1. Insert another Sub-Report in the main report that is below the First Sub-Report section
  2. Pass the Sub-Report 1 shared variable  to Main-Reports
  3. From the Main Report  access the shared variable to the Sub-Report2 Bar Chart

See Also

1203069 -  Not all formulas appear on the Chart Expert's Data tab in Crystal Reports

1215558 - How to create a chart based on a print-time or WhilePrintingRecords() formula in Crystal Reports

This procedure is fully explained in the technical paper - Charting on Print Time Formulas

Keywords

GRAPH CHART PRINTTIME PRINT TIME WHILEPRINTINGRECORDS WHILE PRINTING RECORDS Crystal Reports Charts/Graphs Print-time formulas WhilePrintingRecords, C5156055 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem

Product

SAP Crystal Reports all versions