TM1 API Execute process

Post Reply
Jan
Posts: 14
Joined: Fri Sep 26, 2008 9:34 am
OLAP Product: TM1
Version: 9.0 SP2
Excel Version: 2003

TM1 API Execute process

Post by Jan »

Hello,

I've written a procedure in VB that uses the TM1 API calls to execute a process. This works perfectly, I can even detect if the process returns an error. I get a message from TM1, which I put in a message box, that TM1 executed the process but generated a logfile. Now my question is:
Can I show the errorlogfile to the user? The errorlogfile is written to a seperated disk on the server where the user has no access to but it must be possible to retrieve the errorlogfile through api calls, no? I can't find anything in the guide.
Can somebody help me?

Regards,

Jan
kest
Posts: 3
Joined: Wed Nov 17, 2010 7:01 am
OLAP Product: Cognos TM1
Version: 10.2.2 FP6 IF1
Excel Version: Prof Plus 2010 x32

Re: TM1 API Execute process

Post by kest »

First: Create three processes:

ChoreLoggingBegin with code in Epilog:

StringGlobalVariable('MailMessage');
MailMessage = CHAR(13) | '*** Start Logging ***' | CHAR(13);
ExecuteProcess('ChoreLoggingResult', 'bInit', 0, 'sProcessName', '');

ChoreLoggingEnd with code in Epilog:

SetInputCharacterSet('TM1CS_KOI8R');
StringGlobalVariable('MailMessage');
ScriptDir = 'D:\TM1SQL\VBScripts';
ExecuteProcess('ChoreLoggingResult', 'bInit',1, 'sProcessName', '*** Logging End ***' | CHAR(13));
IF (SCAN('ERRORS', MailMessage) <> 0);
MssgPath = 'D:\TM1SQL\VBScripts\Message\ErrorReport_' | NumberToString(NOW) | '.txt';
TextOutput(MssgPath, MailMessage);
S_Run='cmd /c ' | ScriptDir | '\SendMail.vbs ' | '"TM1 chore alert" " ' | MssgPath | '"';
ExecuteCommand(S_Run,0);
ENDIF;

ChoreLoggingResult with code in Epilog:

StringGlobalVariable( 'MailMessage');
NumericGlobalVariable( 'ProcessReturnCode');
IF (bInit = 1);
IF(ProcessReturnCode <> ProcessExitNormal());
MailMessage = MailMessage | CHAR(9) | '--- ' | 'ERRORS';
ELSEIF (ProcessReturnCode = ProcessExitNormal());
MailMessage = MailMessage | CHAR(9) | '--- ' | 'SUCCESSFUL';
ENDIF;
MailMessage = MailMessage | CHAR(13) | sProcessName;
ELSEIF (bInit = 0);
MailMessage = MailMessage | 'Инициализация';
ENDIF;

AND WITH TWO PARAMETERS
bInit - Numeric
sProcessName - String

Second:
In any Chore set First Process = ChoreLoggingBegin
ans set Last Process = ChoreLoggingEnd

Third:
Code of SendMail.vbs file:

Set oArgs = WScript.Arguments

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "tm1_server@mymaildomain.com"
objEmail.To = "tm1_group_of_users@mymaildomain.com"
objEmail.Subject = oArgs(0)
objEmail.Textbody = "See attachment"
objEmail.AddAttachment oArgs(1)
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/config ... /sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/config ... smtpserver") = _
"mailserver_ip_or_name"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/config ... serverport") = 25
objEmail.Configuration.Fields.Update

objEmail.Send
Post Reply