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

using shared variable in total when null

Status
Not open for further replies.

atarrqis

IS-IT--Management
Nov 26, 2004
155
US
CR11 and Oracle
Main report has 2 groups
1 = part_no
2 = dept
Subreport has no groups, linked by part_no and dept., sums std_hrs
Subreport formula in Subreport Report Footer called stdhrs:
WhilePrintingRecords;
Shared NumberVar SH := Sum ({PRS.STD_HRS});

Subreport formula in Subreport Report Header called stdhrs_reset:
WhilePrintingRecords;
Shared NumberVar SH := 0;

Subreport is in main section 2a footer

Main formula in section 2b footer called main_stdhrs:
WhilePrintingRecords;
Shared NumberVar SH;
Shared NumberVar MSH := MSH + SH;

Main formula in section 1 header called main_stdhrs_reset:
WhilePrintingRecords;
Shared NumberVar MSH :=0;

This works ok but some part_no/dept have no std_hrs.
It seems when this is true SH keeps the previous value so my total (MSH) is too high.
 
In the same formula where you're resetting the value on MSH, you also need to reset the value on SH. Yes, you need to do this even though you're defaulting to 0 in the subreport.

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
Ok I did that but it didn't make any difference.
whileprintingrecords;
Shared NumberVar SH :=0;
shared numbervar MSH :=0;

It still double counts the previous record when the subreport is null.
 
OK, try putting something like the following in the formula in the subreport:

WhilePrintingRecords;
Shared NumberVar SH := 0;
If not IsNull(Sum ({PRS.STD_HRS})) then SH := Sum ({PRS.STD_HRS});

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
No, still no change. I think it doesn't run the subreport when there is no match to dept. so it doesn't touch SH.
 
Place your SH reset formual in Dept group footer.

WhilePrintingRecords;
Shared NumberVar SH := 0;

That way it will always be reset even if no data in SR

Ian
 
That worked but thought I had tried that previously. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top