How create a parameter cube

Product:

Planning Analytics 2.0.9.13

Microsoft Windows 2019 server

Issue:

How easy create a parameter cube, where we can store common values like file paths or servername, that change when we move the TM1 application between servers.

Suggested solution:

Create a TI process with this PROLOG – update the values to your need:

#--------------------------------------------------------------------
# process to create a simple parameter cube
#--------------------------------------------------------------------

CubeName1 = 'SYS.ParameterCube';
DimName1 = 'sys.value' ;
DimName2 = 'sys.function' ;

# create dimension
IF ( DimensionExists ( DimName1 ) = 0 ) ;
DimensionCreate ( DimName1 ) ;
ENDIF ;

IF ( DimensionExists ( DimName2 ) = 0 ) ;
DimensionCreate ( DimName2 ) ;
ENDIF ;

#add elements to dimension
Elname1 = 'ExportFileArea';
Elname2 ='String';
Elname3 ='Number';
Elname4 = 'Explanation' ;
ElType1 = 's'; 
ElType2 = 'n';

DimensionElementInsert (DimName1, '' ,ElName2, ElType1 ) ;
DimensionElementInsert (DimName1, '' ,ElName3, ElType2 ) ;
DimensionElementInsert (DimName1, '' ,ElName4, ElType1 ) ;
DimensionElementInsert (DimName2, '' ,ElName1, ElType1 ) ;

# then only add extra rows for other functions
# Elname5 = 'Servername';
# DimensionElementInsert (DimName2, '' ,ElName5, ElType1 ) ;

# create a cube
IF( CubeExists( CubeName1 ) = 0 ) ;
CubeCreate ( CubeName1 , DimName2 , DimName1 ) ;
ENDIF ;


# add default values to the matrix
sFirstPath = '\\servername\filesharename\' ;
sExplain = 'The path to be used in beginning of filepath used in file exchange' ;

CellPutS ( sFirstPath , CubeName1 , Elname1 , Elname2 ) ;
CellPutS ( sExplain , CubeName1 , Elname1 , Elname4 ) ;

 

 

Run the TI process to create the dimensions and cube.

Then on the TI process that should use the parameters, include a code like this:

# use the values to write a file

# define variables
CubeName1 = 'SYS.ParameterCube';
Elname1 = 'ExportFileArea';
Elname2 ='String';
vFile = 'magicfile.txt';

# get value from parameter cube
vReplacePath = cellgets ( CubeName1 , Elname1, Elname2 ) ;

# create the new path and file name
vPath = vReplacePath | 'data\' ;
vFilePath = vPath | vFile ;

# write to the file
ASCIIOUTPUT ( vFilePath , 'This is the text written to the file' );

 

This code can be improved – that is up to you.

More Information:

https://exploringtm1.com/asciioutput-tm1-function-use-syntax/ 

https://www.wimgielis.com/tm1_clearingbigchunksofdata_EN.htm 

https://exploringtm1.com/dimensionelementinsert-tm1-function-use-syntax-and-examples/ 

https://exploringtm1.com/cellputs-tm1-function-use-syntax/