• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

Need help with ACCUMULATION VARIABLE.....?

Experts:

I'm having a problem with a variable not accumulating correctly.

This is in GROUP HEADER:
//GF1
whileprintingrecords;
global numbervar APPROVEDACTAMT1:=0;


This is in DETAILS SECTION:

//ACCUMULATION FORMULA
whileprintingrecords;
global numbervar APPROVEDACTAMT1:=
IF({@Installment})="Activation" then
IF({@DisplayAttempts}) = '1' THEN
if({tblPaymentTransactionResult.resultCode})= '1'
then {tblPaymentTransaction.amt}+ APPROVEDACTAMT1
ELSE 0;



This is the display formula in GROUP FOOTER:

//GF1
whileprintingrecords;
global numbervar APPROVEDACTAMT1;


I think the problem may related to this formula that is a part of the ACCUMULATION formula that is in the DETAILS SECTION:

//@DisplayAttempts
whileprintingrecords;
Global numberVar intAttempts;
If OnFirstRecord OR {@Installment}
   <> Previous({@Installment}) then
      intAttempts := 1
else
If OnFirstRecord OR {Order_Details.OrderID}
   <> Previous({Order_Details.OrderID}) then
      intAttempts := 1
else
   intAttempts :=    intAttempts + 1;

If intAttempts >= 3 then
    "3"
else
    CStr(intAttempts,0);




OR ....IT could be an issue with the formula that I'm using to GROUP ON:
  (incidentally, I cannot use WHILEPRINTINGRECORDS as I get an error
     group chosen on a NON-RECURRING field)



//Frequency
//whileprintingrecords;
if ubound(split({tblProducts.ProductName},"-")) < 3
then "N/A"
else
if split({tblProducts.ProductName},"-")[3] = 'BW' then 'BW'
else if split({tblProducts.ProductName},"-")[3] = 'E2W' then 'BW'
else
if split({tblProducts.ProductName},"-")[2] = 'BW' then 'BW'
else if split({tblProducts.ProductName},"-")[2] = 'E2W' then 'BW'
else
if left({tblProducts.ProductName},3)='18M'
then split({tblProducts.ProductName},"-")[4]
else
if left({tblProducts.ProductName},3)='MPD'
then split({tblProducts.ProductName},"-")[2]
else
if left({tblProducts.ProductName},3)='DLU'
then split({tblProducts.ProductName},"-")[2]
else
split({tblProducts.ProductName},"-")[3]


I realize that this is not alot to go on...but let me know if you have questions......ANY AND ALL advice on WHY my ACCUMULATION FORMULA is not working would be much appreciated. The formula DOES start to accumulate, but It appears to reset itself to ZERO for no apparent reason.


Thanks
MikeV
0
MIKE
Asked:
MIKE
  • 3
  • 3
  • 2
1 Solution
 
peter57rCommented:
'I'm having a problem with a variable not accumulating correctly. '

All we need to know now is what the problem is (:-)


0
 
frodomanCommented:
>>> It appears to reset itself to ZERO for no apparent reason.

I would expect that to happen based on this:

global numbervar APPROVEDACTAMT1:=
IF ........  then
   {tblPaymentTransaction.amt}+ APPROVEDACTAMT1
ELSE
    0;

If you don't want to zero out this variable make your else clause be:

ELSE
   APPROVEDACTAMT1;

0
 
MIKESoftware Solutions ConsultantAuthor Commented:
Thats not what I meant....I had it the way you suggested and it still does not "hold" the accumulated total correctly...

EVEN when I do change it to the above recommendation...I still get a ZERO...the formula is defaulting back to zero...and I can't see why it is doing this.

Again,...I think it might have something to do with this formula,....WHICH THE GROUP IS BASED ON...

//Frequency
//whileprintingrecords;
if ubound(split({tblProducts.ProductName},"-")) < 3
then "N/A"
else
if split({tblProducts.ProductName},"-")[3] = 'BW' then 'BW'
else if split({tblProducts.ProductName},"-")[3] = 'E2W' then 'BW'
else
if split({tblProducts.ProductName},"-")[2] = 'BW' then 'BW'
else if split({tblProducts.ProductName},"-")[2] = 'E2W' then 'BW'
else
if left({tblProducts.ProductName},3)='18M'
then split({tblProducts.ProductName},"-")[4]
else
if left({tblProducts.ProductName},3)='MPD'
then split({tblProducts.ProductName},"-")[2]
else
if left({tblProducts.ProductName},3)='DLU'
then split({tblProducts.ProductName},"-")[2]
else
split({tblProducts.ProductName},"-")[3]


DO YOU see any potential issues / problems...?

MikeV
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
frodomanCommented:
I don't think so - this formula doesn't even use the shared variable.  Give me a minute to look again and I'll post right back...
0
 
frodomanCommented:
I think the problem is with your accumulation formula.  You *DO* need the change I suggested but there are other changes as well.  Because you are setting your shared variable equal to the result of a nested 'if...then' statement - what happens if {@Installment} is <> "Activation"?  You don't have any result because there is no "else" clause associated so your variable gets set to null or zero at that time.

Try your formula like this:

//ACCUMULATION FORMULA
whileprintingrecords;
global numbervar APPROVEDACTAMT1:=
IF({@Installment})="Activation" then
   IF({@DisplayAttempts}) = '1' THEN
      if({tblPaymentTransactionResult.resultCode})= '1' then
          {tblPaymentTransaction.amt}+ APPROVEDACTAMT1
      ELSE
          APPROVEDACTAMT1
   Else
      APPROVEDACTAMT1
Else
   APPROVEDACTAMT1;


Or another alternative is to use a local variable to hold the incremental amount:

//ACCUMULATION FORMULA
whileprintingrecords;
numberVar Incremental := 0;
global numbervar APPROVEDACTAMT1;
IF({@Installment})="Activation" then
IF({@DisplayAttempts}) = '1' THEN
if({tblPaymentTransactionResult.resultCode})= '1'
then Incremental := {tblPaymentTransaction.amt};
APPROVEDACTAMT1 := APPROVEDACTAMT1 + Incremental;

I prefer the second method myself because it avoids getting a null value into a shared variable - even if you make a mistake in your if..then part of the formula the worst that would happen is the value won't increment.

0
 
peter57rCommented:
global numbervar APPROVEDACTAMT1:=
IF({@Installment})="Activation" then
IF({@DisplayAttempts}) = '1' THEN
if({tblPaymentTransactionResult.resultCode})= '1'
then {tblPaymentTransaction.amt}+ APPROVEDACTAMT1
ELSE 0;

ARe you satisfied that the Ifs are ok here?
It will rest to zero if installment is not 'Activation' Or if DiplayAttempts' is not 1
or if resultcode is not 1
0
 
MIKESoftware Solutions ConsultantAuthor Commented:
YOU know what else....this may also be a potential issue.....

I have approximately...78 GROUP FOOTER sections..that I added to GF1. I did this to format the report to look like I want it to...I'm going to DISPLAY variables based on Payment NUMBER...for each GroupFooter.

so my reoprt looks like this;

GHeader1    
      //GF1
     whileprintingrecords;
      global numbervar APPROVEDACTAMT1:=0;

    This is the MAIN GROUP FORMULA used:
     //whileprintingrecords;
if ubound(split({tblProducts.ProductName},"-")) < 3
then "N/A"
else
if split({tblProducts.ProductName},"-")[3] = 'BW' then 'BW'
else if split({tblProducts.ProductName},"-")[3] = 'E2W' then 'BW'
else
if split({tblProducts.ProductName},"-")[2] = 'BW' then 'BW'
else if split({tblProducts.ProductName},"-")[2] = 'E2W' then 'BW'
else
if left({tblProducts.ProductName},3)='18M'
then split({tblProducts.ProductName},"-")[4]
else
if left({tblProducts.ProductName},3)='MPD'
then split({tblProducts.ProductName},"-")[2]
else
if left({tblProducts.ProductName},3)='DLU'
then split({tblProducts.ProductName},"-")[2]
else
split({tblProducts.ProductName},"-")[3]

DETAILS SECTION
  //ACCUMULATION FORMULA
whileprintingrecords;
global numbervar APPROVEDACTAMT1:=
IF({@Installment})="Activation" then
IF({@DisplayAttempts}) = '1' THEN
if({tblPaymentTransactionResult.resultCode})= '1'
then {tblPaymentTransaction.amt}+ APPROVEDACTAMT1
ELSE 0;

GROUP FOOTER SECTION
//GF1
whileprintingrecords;
global numbervar APPROVEDACTAMT1;


M
0
 
MIKESoftware Solutions ConsultantAuthor Commented:
Awesome.....I think you did it!

Whew...nice.... I know I could count on the Experts...ahhh..

I have many variables I need to create like this...and so this is a big relief to know it can be done and work...

THanks for the help to all....thanks Frodo

MIkeV
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now