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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport shared variables not acting as expected

Status
Not open for further replies.

satinsilhouette

Instructor
Feb 21, 2006
625
Hi,

I haven't written a subreport, with shared variables in over a year, but don't remember experiencing this issue before.

I have 2 groups in the report- Employer and Category. I have set up the subreport the same way as I need to pick up particpants vs. eligibles. The main report is the eligibles, the subreport is the participants.

My formulas going either way, subreport shared to main report or main report shared to subreport are written the same way.

The report is based off of a buisness objects universe, the universe has sql statements supporting both main and subreport.

Crystal XI R2, BO XI R2

enrolled formula:
whileprintingrecords;
shared numbervar enrolledcum :=
Sum ({Enrolled Group},{Activity Type})

Active formula:
whileprintingrecords;
shared numbervar ActivityCount :=
Sum ({Activity}, {Activity Type})

I have attached a screen shot of the results. What I don't understand is why it is offsetting by one record of 0 in either way I do this. Going up from subreport to main report or down from main report to subreport.

Huh apparently we can't upload for free anymore, so will type out results:

Here is the main report with the subreport info passed up via shared variable:

Activity 1 602(main report) 458 (subreport)
Activity 2 29 16
Activity 3 11 16 (this should be 0)

subreport SHared variable:
whileprinting records;
Active formula:
whileprintingrecords;
shared numbervar ActivityCount :=
Sum ({Activity}, {Activity Type})

Main report receiver formula:
whileprintingrecords;
shared numbervar ActivityCount;
ActivityCount;


Activity 1 458(sub report) 0 (subrprt, should be 602)
Activity 2 16 602 (This should be 29)
Activity 3 29 (this should be 11)


Main report passed down to subreport:
whileprintingrecords;
shared numbervar enrolledcum :=
Sum ({Enrolled}, {Enrolled Activity Type})

Subreport receiver formula:
whileprintingrecords;
shared numbervar enrolledcum;
enrolledcum;




Thanks so much!
satinsilhouette
 
The problem is likely where you are placing the subreports (in what sections). The shared variables must be in sections below the one in which the subreport is located, i.e., the shared variable should be in GH_b if the sub is in GH_a. You probably also need to reset the shared variable in a formula placed in a section just prior to the one containing the sub, or in a section after the shared variable executes.

-LB
 
Huh when did we need to start resetting the shared variable? I don't remember ever having to do that. I have placed it below the section in a section b and I still get offset numbers.

SO how does one reset the formula please?

thanks!

Thanks so much!
satinsilhouette
 
The location of the formula depends upon where the shared variable is being set to a value. The formula would look like:

whileprintingrecords;
shared numbervar enrolledcum;
if not inrepeatedgroupheader then
enrolledcum := 0;

Please identify the sections containing the formulas you showed above and whether they are in the main or in the subreport, and also explain where the sub is located, and where the formula is in which you are referencing the results from the sub.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top