Page 1 of 1

Manual setting new dimension with names and aliases

Posted: Tue Aug 07, 2012 2:10 pm
by ioscat
Hello again,
And again I'm trying to defeat TM1.
I have file .CSV with just 2 important columns. First is item code and thirteenth is item name. I want to create via TI process:
- New dimension;
- New elements (named 0001, 0002, etc);
- Create many aliases (ItemName + Code, Code, ... etc).
In variables tab important colums assigned to variables ElementsCode and ElementsName.
Now my code is (with cyrillyc retyped carefully to not make any typo):

Code: Select all

#Prolog:
#--------------------------------------
user.MyDimension = 'protfcp_SubsidariesAccount';

IF ( DimensionExists (user.MyDimension) = 0);
    DimensionCreate (user.MyDimension);
ELSEIF (DimensionExists (user.MyDimension) = 1);
    DimensionDestroy (user.MyDimension); 
    DimensionCreate (user.MyDimension);
ENDIF;

DIMENSIONDELETEALLELEMENTS (user.MyDimension);
DIMENSIONSORTORDER(user.MyDimension,'','','ByInput','ASCENDING');

user.AliasName1 = 'Code';
AttrInsert ( user.MyDimension, '' , user.AliasName1 , 'A');
user.AliasName2 = 'Name';
AttrInsert ( user.MyDimension, '' , user.AliasName2 , 'A');
#========================================
#Meta:
#-------------------------------------------------------
user.NewElementName = SubSt ( NumberToString ( 1000000 + DimSiz ( user.MyDimension ) + 1) , 4 , 4 );
DIMENSIONELEMENTINSERT(user.MyDimension,'', user.NewElementName, 's');
AttrPutS ( ElementsCode , user.MyDimension , user.NewElementName , user.AliasName1);
AttrPutS ( ElementsName , user.MyDimension , user.NewElementName , user.AliasName2);
Saving performs, but running process finishes with errors like: "Element 0001 not found" in line 9 of Meta tab.

Ninth string corresponds to AttrPutS function.

Finaly I got new dimension with elements 0001, 0002, etc with Aliases filled with elements pincipal names. Where am I mistaken?

Re: Manual setting new dimension with names and aliases

Posted: Tue Aug 07, 2012 2:25 pm
by tomok
Your AttrPutS functions need to be moved to the Data tab.

Re: Manual setting new dimension with names and aliases

Posted: Tue Aug 07, 2012 2:46 pm
by ioscat
Thanks,
Thought tabs just performes usability...

Re: Manual setting new dimension with names and aliases

Posted: Wed Aug 08, 2012 3:46 pm
by Steve Rowe
Just to explain why your initial code didn't work.

The metadata tab builds the dimension and the new elements are not available from a data perspective until the metadata completes. Attributes are data and so need to go in the data tab.

Just in case it wasn't clear...
Cheers

Re: Manual setting new dimension with names and aliases

Posted: Thu Aug 09, 2012 6:56 am
by ioscat
thanks again,
in guide this was not clearly stated

Re: Manual setting new dimension with names and aliases

Posted: Thu Aug 09, 2012 2:57 pm
by qml
It is stated in the TI Guide in the following way (admittedly not really very clear):
TM1 TurboIntegrator 9.5.2 wrote:TurboIntegrator compiles a new or altered dimension only at the conclusion of the procedure in which the dimension is created or altered.

In the case of a new dimension, this means that you cannot access the new dimension (through TurboIntegrator or otherwise) until the procedure in which the dimension is created has finished processing all records in the data source. In the case of an altered dimension, this means that you cannot access any new elements in the dimension until the procedure in which the dimension is altered has finished processing.
The meaning of "procedure" here is synonymous to "advanced tab", so elements created in Metadata are only compiled and made available after all Metadata iterations have finished.