Create views/subsets dynamically in a CONTROL object

Post Reply
lynnsong986
Posts: 73
Joined: Wed Feb 28, 2018 2:20 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2016

Create views/subsets dynamically in a CONTROL object

Post by lynnsong986 » Sat Nov 09, 2019 7:12 pm

Hello,
I came across a TI that dynamically creates a view after a bunch of dimensioncreatebyMDX, subsetelementinsert, viewsubsetassign and finally using this newly created view as data source (then copy the data in this view to a target view in data). I understand everything except the part that it created the view using control objects as below:

View_name = ‘}copy_scenario’;
Sub_name = ‘}FromScenario’;

I’m not too familiar with control cubes, can someone please let me know why it uses control objects instead of just creating a normal view in that cube?

Also where the TI tests if a subset exists, if it does, delete all elements in it, if does not, create it. The codes are like:

If subsetexists(Dim, Sub)=1;
Subsetdeleteallelements(dim, sub);
Else
Subserdestroy(dim, sub);
Subsetcreate(dim, sub);
Endif;

The part I don’t understand is that if the sub doesn’t exist, why it needs to be destroyed (the else part), is the destroy part necessary here??



Thanks!

Wim Gielis
MVP
Posts: 2258
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365 - latest
Location: Brussels, Belgium
Contact:

Re: Create views/subsets dynamically in a CONTROL object

Post by Wim Gielis » Sat Nov 09, 2019 8:05 pm

One uses control objects to make objects less probable to appear in the user interface for the people interacting with the application.

Should a view or subset still exist after the process, then it's most probably not meant for users. So they are hidden in the control objects.

However, now that you find that code, you will notice that 'permanent' subsets and views are used. Since some time now, we can use temporary views and subsets. These objects will not exist anymore when the process finishes, they only exist during the process run.

I'm afraid your teacher, or whoever you got this code from or where you found it, did not know this. The advise is to use temporary subsets and views as much as possible. If still permanent objects are used, make sure they are removed by the code when the process has run. These objects, temporary in nature, should not clutter up the TM1 data directory.
Last edited by Wim Gielis on Sat Nov 09, 2019 8:32 pm, edited 1 time in total.
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
http://www.wimgielis.com ==> 109 TM1 articles and a lot of custom code
Newest blog article: Set up a TM1 model with AutoHotKey as a service or application

lynnsong986
Posts: 73
Joined: Wed Feb 28, 2018 2:20 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2016

Re: Create views/subsets dynamically in a CONTROL object

Post by lynnsong986 » Sat Nov 09, 2019 8:28 pm

Thank you so much Wim as usual!!

Post Reply