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!

Shared Var Tip (not a question), reset/display in same step 1

Status
Not open for further replies.

scottostanek

Programmer
Oct 1, 2001
89
US
I had this ugly problem involving reporting against budget data that exists in the database in year format and reporting against it using Fiscal year ranges. Here is how I got one piece out (imagine doing this over multiple columns and groupings)
[Formula YearLbsBudget]
WhilePrintingRecords;
numberVar YLbs := 0;
shared Numbervar CustYrBudLbs;
shared Numbervar SalesYrBudLbs;
if not isnull({CUST-SHIPTO-PROD-BUDGET.Quantity@1}) then
(
if Month({?CurrentMonth}) >= 6 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@1};
if Month({?CurrentMonth}) >= 7 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@2};
if Month({?CurrentMonth}) >= 8 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@3};
if Month({?CurrentMonth}) >= 9 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@4};
if Month({?CurrentMonth}) >= 10 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@5};
if Month({?CurrentMonth}) >= 11 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@6};
if Month({?CurrentMonth}) >= 12 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@7};
if(Month({?CurrentMonth}) < 6) then //always need June-Dec if hitting months Jan on in Fiscal year
(
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@1} + {CUST-SHIPTO-PROD-BUDGET.Quantity@2} +
{CUST-SHIPTO-PROD-BUDGET.Quantity@3};+ {CUST-SHIPTO-PROD-BUDGET.Quantity@4} +
{CUST-SHIPTO-PROD-BUDGET.Quantity@5} + {CUST-SHIPTO-PROD-BUDGET.Quantity@6}+
{CUST-SHIPTO-PROD-BUDGET.Quantity@7} + {CUST-SHIPTO-PROD-BUDGET.Quantity@8};
);
if Month({?CurrentMonth}) = 2 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@9};
if Month({?CurrentMonth}) = 3 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@9} + {CUST-SHIPTO-PROD-BUDGET.Quantity@10};
if Month({?CurrentMonth}) = 4 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@9} + {CUST-SHIPTO-PROD-BUDGET.Quantity@10} +
{CUST-SHIPTO-PROD-BUDGET.Quantity@11};
if Month({?CurrentMonth}) = 5 then
YLbs := YLbs + {CUST-SHIPTO-PROD-BUDGET.Quantity@9} + {CUST-SHIPTO-PROD-BUDGET.Quantity@10} +
{CUST-SHIPTO-PROD-BUDGET.Quantity@11} + {CUST-SHIPTO-PROD-BUDGET.Quantity@12};
);
CustYrBudLbs := CustYrBudLbs + YLbs;
SalesYrBudLbs := SalesYrBudLbs + YLbs;
YLbs

[YearLbsBudgSales] //ie in the salesman grouping level
shared Numbervar SalesYrBudLbs;
numbervar holder := SalesYrBudLbs;
SalesYrBudLbs := 0;
holder


Note: I had had some trouble with complex reports using shared variables, in the fact that I kept losing amidst the rest the formula that held the shared declaration that reset it to 0. This accomplishes it every time, it is much harder to &quot;lose&quot; and I never have to worry that I reset the variable in the wrong place! ;)

Scotto the Unwise
 
very cool stuff

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top