Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use charts with subreports

Status
Not open for further replies.

ewarr

Technical User
Nov 25, 2008
31
0
0
US
The main report includes 2 subreports and I need to build a chart using data from all subreports along with main. I understand that I must use global variables in subreports for the chart to work. Can someone provide example code for the subreports along with main report?

Main Report=forecast sales
Subreport1=actual sales
Subreport2=actual inventory

Thanks

 
To pass data back from a subreport, use a shared variable. For a date, put a formula field in the subreport like
Code:
Shared dateVar    
V_Today := {LoadStatus.LastDLoad}
To access it in the main report, create another formula field with
Code:
Shared dateVar 
V_Today := V_Today

If it was a currency value, you'd do it differently, e.g.
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved

Note that the shared variable is only available in the section after the section which contains the subreport. Display it to confirm that it is OK.

From that you should be able to build a chart.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Actually you can just click OK and you can get in.

-LB
 
No idea what's wrong with my connection, but when I click on your link I have to sign in to SAP with my Forum logon and it takes me to SAP search results. When the document is listed.

Hey Ho that's life!

Ian
 
Madawc,
I was able to pass only 1 shared variable to main report but I need to pass many values in each subreport to main report.

Here's what I'm using right now just to see if I can pass 2 variables from one of the subreports:

Subreport formulas:

shared numberVar July_Sales := Sum ({@July Sales}, {F56SLSJN.LITM})

shared numberVar Aug_Sales := Sum ({@Aug Sales}, {F56SLSJN.LITM})

Main report formulas:

shared numberVar July_Sales := July_Sales

shared numberVar Aug_Sales := Aug_Sales

I placed both formulas from main report into report footer section and only 1 will display passed value, other is blank.

Can I pass more than 1 shared variable to main?
 
Before you go too far using shared variables, please know that you cannot chart on them.

-LB
 
I've never needed to try passing large numbers of shared variables, nor making charts from them. Some different approach is needed.

The best I can think of is an additional subreport that gets all of the relevant data and then draws the chart within the subreport.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
I think your best bet is to build a command.

Looks like your data is coming from three different tables use a command to union the data

Select 'Forecast' as Type, Field1, .....Fieldx from
Forecast
where .. whatever filter condition using parameters as required
Union All
Select 'Actual' as Type, Field1, .....Fieldx from
Actual
where ..
Union All
Select 'Inventory' as Type, Field1, .....Fieldx from
Inventory
where ..

Each query must have same number of columns and data should be the same.

If that is not possible then pad each query
using '' or 0 to coorespond with columns from other queries.

you will then be able to build report without using sub reports.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top