Page 1 of 1

Create views/subsets dynamically in a CONTROL object

Posted: Sat Nov 09, 2019 7:12 pm
by lynnsong986
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!

Re: Create views/subsets dynamically in a CONTROL object

Posted: Sat Nov 09, 2019 8:05 pm
by Wim Gielis
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.

Re: Create views/subsets dynamically in a CONTROL object

Posted: Sat Nov 09, 2019 8:28 pm
by lynnsong986
Thank you so much Wim as usual!!