Product:
Cognos TM1 10.2.2 (works also in PA 2.0 Local)
Microsoft Windows 2012 R2 server
Problem:
Setup logging of TI processes execution to a Tm1 cube.
Solution:
Create two dimensions and build a cube of them.
Then add an EPILOG script to all TI process that should log information in that cube.
Go into your application – in our text we use planning sample.
In Tm1 Architect select Dimensions – Create New Dimension
Select Insert Element from Edit menu
Enter the following as Element Name
Time
User
Comment
Click OK
Select save from dimension menu and name the dimension to be Sys.Event
In Tm1 Architect select Dimensions – Create New Dimension
Select Insert Element from Edit menu
Enter the following as Element Name
Temp
Click OK
Select save from dimension menu and name the dimension to be Sys.Log
Right click on cubes and select Create new cube
Mark the two dimensions and click on the arrow icon to move them over to the cube.
Enter Cube name to Sys.Log
Click on Create Cube button.
Now you have a cube to view the logging in.
Then you need to paste below code in EPILOG in all TM1 TI process that you need logging in.
It is important you update the sStatusText line in each TI process to explain what has happen.
#—————————————————————————–
# Logging
#
# set sStatusText to information on what file create or values updated
# if the TI process is run by a Chore then the TM1 user is R*+chore name
# otherwise set the sUserText to the user running the chore
# dimensionelementinsertdirect will add the TI process to the dim if it does not exist
# timSt(now, ‘\Y-\m-\d \h:\i’) will create the time in format 2017-05-16 12:43
#—————————————————————————–
sStatusText = ‘ This the comment written to log ‘;
sCubeName = ‘Sys.Log’;
if(SUBST(TM1User(),1,2) @= ‘R*’);
sUserText = ‘Scheduled’;
else;
sUserText = attrs(‘}clients’, TM1User(), ‘}TM1_DefaultDisplayValue’);
If (sUserText @= ”);
sUserText = TM1User();
endif;
endif;
dimensionelementinsertdirect( sCubeName , ”, getProcessName(),’S’);
cellputs(timSt(now, ‘\Y-\m-\d \h:\i’), sCubeName ,’Time’, getProcessName());
cellputs(sUserText , sCubeName ,’User’, getProcessName());
cellputs(sStatusText, sCubeName ,’Comment’, getProcessName());
To test the TI process, you can enter following code in PROLOG tab.
#—————————————————–
# DEBUG LINE ONLY
#——————————————————
V1 = TM1User();
ASCIIOutput(‘c:\temp\tm1logging.txt’, V1, ‘ this is a variable result’ ) ;
Please note that TI process that is run from a scheduled core in TM1 is executed as a special user that have admin rights and is not listed in the Security dialog. If you run same TI process from TM1 Architect – it is processed as the user who logged in to TM1 Architect.
## The below is the smart code that will take the user name and show the Friendly name of it instead of the CAMID(“AD:u:6f2c060820fb2341bbcfd6”)
sUserText = attrs(‘}clients’, TM1User(), ‘}TM1_DefaultDisplayValue’);
## This extra test if it is blank, is for the case there is not a DisplayValue (alias).
If (sUserText @= ”);
sUserText = TM1User();
endif;
Ensure the ‘ character is correct in your code.
More information:
https://www.ibm.com/support/knowledgecenter/en/SS9RXT_9.5.0/com.ibm.swg.im.cognos.tm1_ref.9.5.2.doc/tm1_ref_id13786tifun_asciioutput.html