Skip to Content
0

Global Variables Loosing Scope?

Jan 14 at 09:52 PM

59

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Abhilash Kumar
Jan 15 at 01:52 PM
0

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

Show 1 Share
10 |10000 characters needed characters left 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};
0
Abhilash Kumar
Jan 15 at 02:32 PM
0

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

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

I've been down that road and things get really crazy when I share the variables...besides, I am not using subreports therefore why "Shared"? I thought CR variables by default are Global?

When I share the variables, this is what happens:

Group "A" pulls Roth money value from the DB and puts it into variable Roth

Group "B" pulls Safe-Harbor value from the DB and puts it into variable Safe-Harbor

This works until I "Share" the variable names and CR then does Group A correctly, Group B correctly, but on my output record the value from Group B is in both variables!! My Roth value has been replaced ... our DB Engineers are looking into this as well but still cannot figure out why CR is losing the values even though they are Globalized...

I mis-copied my "Roth is =" ... it should have read "Roth is =" + cstr(Roth); ... sorry!

Thanks for all the help Abhilash!

0

Would you be able to send me the .rpt with saved data?

You could also attach it to drive/dropbox.

P.S: I use 'shared' variables to avoid typing 'whileprintingrecords' in all my formulas!

-Abhilash

0
Former Member

Abhilash, I am more than grateful to send you the .rpt and a .pdf of the output and debug information...unfortunately sending saved data is an issue due to how CR is integrated into our vendor's software system. The software actually pulls in the .rpt files, "compiles" it, kicks off the necessary stored procedures, and then applies the report to a series of dynamically allocated report tables (called RPT tables) for the output report which comes out of our system in PDF format...I cannot run the CR report directly against the Oracle because it will not trigger the procedures. I can export the data into Excel or RTF but I cannot store the data with the CR file... :(

I'm hoping that by just looking at the report file and my output data report you should be able to see what the issue is that I'm missing. I can make whatever changes you suggest and run them against the database for as long as you are willing to help us on this...I can email everything to you or use Dropbox (I've never used that before but I can figure it out)...let me know what you prefer.

Our DB group has come back without a solution...they can't figure out what's going on...they've had me put some things into the report but with no success...you are rapidly becoming my last resort!

Thanks! -------James

0
Former Member

Abhilash -

I have done some work today on the report and I have worked out a way to store the data with the report if you are still willing to make an attempt to troubleshoot the report...

...if not, I appreciate the effort that you made today in attempting to fix my problem.

James

0

Hi James,

Please attach the report to google drive or any other share-able location and send the URL to me.

-Abhilash

0
Former Member
Abhilash Kumar

Abhilash -

Sorry to get back to you so late, we've been having bad weather here and I've had to deal with making sure our fail-over site was in hot-standby in case we had to transfer our operations.

I apologize for jumping the pre-decision about sending the report with the data in my previous message...when I save the data with the report it is saving the raw data from the RPT tables in Oracle which included all of the employee's PII (social security number, DOB, etc.) despite having removed the fields from the template, so therefore I cannot legally share that data with you. The best I can do is give you the report and the .pdf output report that shows what CR is doing.

I also know have set up a DropBox account so I just need your address to share the folder with you if you are still open to assisting us. Let me know.

Thanks! -----James

0

Hi James,

Yes the .rpt and pdf would be a good start.

I just DM'ed you my email.

-Abhilash

0