Create logging of TI process to cube

Product:
Cognos TM1 10.1.1
Windows 2008 R2 server

Problem:
How can I to simple log, when process have been run. Best into a cube, as a status log?

Solution:
Log into TM1 Architect
Create first a dimension SYS.EVENTS
Right click on dimensions and select “create new dimension”
Right click and select “insert element”
Enter 1
Select “string” for Element type.
Click Add.
Click OK
Click OK in the top right of the dialog.
Enter the name Sys.Events.

Right click on dimensions and select “create new dimension”
Right click and select “insert element”
Enter event
Select “string” for Element type.
Click Add.
Enter time
Select “string” for Element type.
Click Add.
Enter type
Select “string” for Element type.
Click Add.
Click OK
Click OK in the top right of the dialog.
Enter the name Sys.Log

Right click on cubes and select “create new cube”
Enter cube name: Sys.Log
Move the two dimensions to the right side column by mark sys.log and sys.events and click on the arrow button to move them over.
Click create cube.

Now you have created a cube to store the values from the logging.
Then in each process you have in your application, you add this lines to get a logging going for when the process was run.

In the PROLOG tab enter this line of code last;
#—————————————————————————
# Logging
#—————————————————————————
currentEvent = dimnm(‘sys.events’,dimsiz(‘sys.events’));
currentEvent = numbertoString(stringToNumber(currentEvent)+1);
DimensionElementInsert(‘sys.events’, ”, currentEvent,’N’);

Above code will update the sys.events dimension with one value, so it is ready to accept more values.

In the EPILOG tab enter this lines of code last, update the text with valid text describing the process that have happened.

#—————————————————————————
# Logging
#—————————————————————————
cellputs(‘Moved data for =’|pCompany |’ ‘ |pPeriod, ‘Sys.Log’,currentEvent, ‘event’);
cellputs(timSt(now, ‘\Y-\m-\d \h:\i’), ‘Sys.Log’,currentEvent, ‘time’);
cellputs(‘Name of the process that was run’,’Sys.Log’,currentEvent, ‘type’);

Replace the italic text with your function for that process, this is the text that is stored in the sys.log cube.

‘| is concatenation and will bring text ‘ ‘ together with the value of the variable pCompany.
So it will in the log show Moved data for= Office1 201401, in the case pCompany contains the value Office1.
timSt(now, ‘\Y-\m-\d \h:\i’) will give you the date and time in format YYYY-MM-DD HH:MM.
You need to ensure that all parameters you use are in STRING format when they are called here;
cellputs(‘Moved data for =’|pCompany |’ ‘ |pPeriod, ‘Sys.Log’,currentEvent, ‘event’);
Cellputs function sends a string value to a cube cell. Use the format;
Cellputs( ‘string to enter’, The name of the cube to which you want to send the string, Dimension element names that define the intersection of the cube to receive the string in our case the number, and the dimension name.)
DIMNM returns the element of a dimension that corresponds to the Index argument.
DIMSIZ returns the number of elements within a specified dimension.
Will give that dimnm(‘sys.events’,dimsiz(‘sys.events’)); returns the last element in the dimension.
DimensionElementInsert function adds an element to a dimension.
You can use this function to add numeric, string, or consolidated elements. Note that you cannot use this function in the Data or Epilog procedures of a TurboIntegrator process.
DimensionElementInsert(‘sys.events’, ”, currentEvent,’N’);
will increase the dimension sys.events with one more row.
Save and run your process, then you will se that the Sys.Log cube is updated with valid information.

This can be used as a simple time stamp log for when processes have been run, and can be easy accessed by the end-user from a TM1 view.