Global Variables in TI

Post Reply
User avatar
Steve Rowe
Site Admin
Posts: 2456
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Global Variables in TI

Post by Steve Rowe »

Just wanted to ask if anyone has encountered any issues using these? I have and just wanted to ask if anyone has experienced similar. Using v951 with HF15.

So two TIs, one calls the other.
In the prolog of both TIs I define sCubeName to be a global string variable.
I populate it in the prolog of the first TI, it's a hardcoded reference to the same cube on every run.

In the second TI I have
sTS=CellGetS( sCubeName, etc all hardcoded);

99% of the time this works fine and the 2nd TI correctly references sCubeName

On a small number of occasions I get an error saying that cube "" not found relating to the line above. I'm taking this to mean that sCubeName is not populated when CellGet is run, this implies that global vars are not 100% reliable. (It's early days in this so don't go rewriting your TIs just yet!). I don't normally use global vars, tending to pass parameters from one TI to another so just wanted to check if I am missing a trick?

Does anyone know how global vars work under the hood?

The issue seems erratic with a tendancy to occur if I run the TI sequence twice in quick succession so I am wondering if the global var is cached in some way. When the cache from the first run is cleared it's impacting the global vars from the second run which has already started.

Something like this.

Second 1 : TI 1 Pass 1 ; declare sCubeName to be a global var and populated it, call TI2
Second 2 : TI 2 Pass 1 ; correctly reference sCubeName
Second 3 : Pass 1 ends.
Second 4 : TI 1 Pass 2 ; declare sCubeName to be a global var and populated it, call TI2
Second 4.5 : Global var cache from pass 1 is cleared.
Second 5 : TI 2 Pass 2 ; reference to sCubeName fails following destruction of cahce.

The above is just conjecture, anyone have a better idea if this is a bug or a feature? I'm 99.99% this is not user/code error.

Anyway I'm off on two weeks leave, woo hoo, so consider this a parting gift.

Cheers,

Steve
Technical Director
www.infocat.co.uk
Wim Gielis
MVP
Posts: 3230
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Global Variables in TI

Post by Wim Gielis »

Apologies to go a bit off-topic, but I have no experience with global variables. Either I pass the information as arguments, either I use a small cube or a temporary dimension.
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
dubs
Posts: 131
Joined: Fri May 22, 2009 10:43 am
Version: 9.4
Excel Version: 2003

Re: Global Variables in TI

Post by dubs »

I have not had time to properly read you post yet but have certainly had trouble with GlobalVars being reinitialised by processes called by the main process

when I get a mo I'll have a proper read and see if I can help
ajain86
Community Contributor
Posts: 132
Joined: Thu Oct 15, 2009 7:45 pm
OLAP Product: TM1
Version: 9.4.1 9.5 9.5.1
Excel Version: 2003 2007

Re: Global Variables in TI

Post by ajain86 »

have you tried using session variables instead. I have used this instead of global variables as they will be removed when the user logs out.

Also, at the end of your second TI, try setting the global variable to blank to clear it out there. I tend to clear out session variables whenever I can and have not experienced the issue you described.
Ankur Jain
Post Reply