Skip to Content
avatar image
Former Member

Global Variables Loosing Scope?

To The Community:

I am currently developing a CR 2008 report (I know we're dinosaurs) where I am attempting to extract employee Roth deferrals and Safe-Harbor contributions from our Oracle database. I have two "Global CurrencyVar" variables declared and initialized in the top-most group which is the SSN. I then group my records according to a field called GRPTYPECD which value is either "EE" (employee) or "ER" (employer). Next, I group my records according to a field called "ROTHCONTRCD" which is either "Y" or "N" indicating if the associated record is Roth deferrals. ROTHCONTRCD is "Y" only if GRPTYPECD=EE since Roth money is employee contributions.

Then, in my first footer group which is the Roth, I have a simple formula "RothContribAmt := {dbfield}; " where I put the database field value into a Global CurrencyVar variable. This group has a suppression formula based upon the above criteria (GRPTYPECD<>EE Or ROTHCONTRCD=N).

My next group is for my Safe-Harbor where I do essentially the same only storing the value into a differently named variable. This group also has a suppression formula based upon the above criteria (GRPTYPECD<>ER Or ROTHCONTRCD=N).

My debug data shows the report correctly grouping and filtering the records and placing the values into the variables BUT ...

...when it drops down to the report data line and I attempt to output my two variables they are zero! If I change the scope to "Shared" I get whatever the last database record value was IN BOTH VARIABLES. It's almost as if CR is getting confused in the variable pool.

Any help is greatly appreciated!!

James

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 15 at 01:52 PM

    Hi James,

    Would you be able to attach a screenshot of the design and preview tabs, please?

    Also, when you assign a database field to a variable and place such a formula on the Group Footer, it can only 'see' and access the 'last' value in that group.

    What exactly are you trying to achieve with this formula?

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Abhilash, Thank you for the fast response to my question, I appreciate it. The formula is so simple as shown below...I am getting the correct record as there is only one of this type...I see the formula getting the value from the DB field, but if I follow this formula with another right under it that simply says "CurrencyVar Roth; Roth is=" + Roth;" I get zero!!

      I am open to letting you take a look at the actual .rpt report...I can send you a .pdf of the debug output that has data (PII information removed of course) ... it would save a lot of posting here... This problem is driving me insane!!!

      James

      CurrencyVar Roth;
      Roth := ${RPTEESRC.YTDCONTRAMT};
  • Jan 15 at 02:32 PM

    Hi James,

    If you're trying to print the value on this variable in another section, you should declare it as 'shared' or use the 'whileprintingrecords' keyword at the beginning of the formula.

    shared CurrencyVar Roth;
    Roth := ${RPTEESRC.YTDCONTRAMT};

    And then the formula that displays the value would be:

    shared CurrencyVar Roth;
    "Roth is = " & Roth;

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded