Page 1 of 1

Problem reading TM1 transaction log via TM1Api

Posted: Wed Feb 24, 2016 2:48 pm
by Alexander Jell
Hi All,

I have a little problem reading the transaction Log of my running Tm1 Instance. (tm1s.log)

I want to get the information within an C# application using the TM1 C Api. I am already using this Api successful for many querys, but i cant figure out the TM1ServerLogOpen and TM1ServerLogNext functions. I don't know if i understood them correctly, but these two functions should be able to read the transaction log while the TM1 server instance is running.

I hope somebody already used this function and can help me. Here is the related code:

Code: Select all

int Timestamp = TM1API.TM1ValString(hPool, "2015122000000", 0);
int Cubefilter = TM1API.TM1ValString(hPool, "*", 0);
int sUserfilter = TM1API.TM1ValString(hPool, "*", 0);
int Flagfilter = TM1API.TM1ValString(hPool, "*", 0);
int opened = TM1API.TM1ServerLogOpen(hPool, hServer, Timestamp, Cubefilter, sUserfilter, Flagfilter);

String error = TM1API.TM1ValErrorString2(hUser, opened);
          
int entry = TM1API.TM1ServerLogNext(hPool, hServer);

error = TM1API.TM1ValErrorString2(hUser, entry);
int entryone = TM1API.TM1ValArrayGet(hUser, entry, 1);
String entryvalue = TM1API.TM1ValStringGet2(hUser, entryone);
hPool, hServer and hUser are definitly set correctly, i use them in other TM1Api functions that work correctly.
The Timestamp should resemble the date December 20, 2015. (Looking into the transaction log via architect shows, that i have data since this date)
All three filters are set to *, because i would be happy if I get any sort of data. :)

I also check the result for errors. Both checks return "Error code out of range", which should be fine, however the entryvalue is always null.
I dont even know, if that is the correct way to use those two functions. (The documentation in the reference guide is pretty wanky in my opinion)

Thanks in advance!

Sincerely,

Alexander Jell

Re: Problem reading TM1 transaction log via TM1Api

Posted: Wed Feb 24, 2016 3:52 pm
by BrianL
First a disclaimer: I have no experience with the C#, but have extensively used the C API.

What is the actual return from TM1ServerLogOpen? The docs specify a TM1V containing a bool. Are you getting a boolean type or an error type? Is the boolean return 0 or 1? If you're getting 1 (indicating success in opening the log file), what is the TM1V datatype returned by TM1ServerLogNext? I'd expect it to be an array, if so what's the array size?

I have no idea from your post which call is returning "Error code out of range". Is it TM1ServerLogOpen, TM1ServerLogNext, or TM1ValArrayGet? This might be expected if you're trying to retrieve an error message for a TM1V that doesn't even contain an error.

Re: Problem reading TM1 transaction log via TM1Api

Posted: Thu Feb 25, 2016 9:21 am
by Alexander Jell
Hi BrianL.

First of all, thanks for your answer!

TM1ServerLogOpen returns a 1 so it should be ok. The weird thing is: It always returns 1. If i use a Starttimestamp for some date in 2017 i get a 1 and if i use a user within the filter, that doesn't even exist, it also returns 1. (Even though no data should be found)

I get the message "Error code out of range" from the return values of TM1ServerLogNext and TM1ServerLogOpen, but you are probably right that this message doesn't mean anything, because the values don't contain an error.

I dont know what type of value TM1ServerLogNext returns, but if everything is ok it should be an array right?

If i use TM1ValArrayGet(hUser, entry, index), which should be able to retrieve the value of the array, i only get a value at index 1. All other index have the value 0.

If i use TM1ValStringGet2 on the value within the index 1 it returns null.

Is there any way to get the data type of the returned value?

Sincerely,

Alexander

Re: Problem reading TM1 transaction log via TM1Api

Posted: Thu Feb 25, 2016 4:04 pm
by BrianL
Alexander Jell wrote: Is there any way to get the data type of the returned value?
In the C API there is the TM1ValType() function. Not sure how that's exposed in .NET.

The documentation really is horrible for this function, I'd have to play around to see if there are other return types besides an array that can happen.

Re: Problem reading TM1 transaction log via TM1Api

Posted: Fri Feb 26, 2016 8:16 am
by Alexander Jell
Ok i just checked the ValType of the returnvalue, and it is an array. (Thanks for the tipp)

But the content of the array is pretty useless. All entries are null

Any idea what i could be doing wrong?

Sincerely,
Alexander

Re: Problem reading TM1 transaction log via TM1Api

Posted: Wed Mar 09, 2016 10:37 am
by Alexander Jell
Okay, i finally got it.

The first entry of the returned array is the reference to the real array of values.

Ok all seems fine.

Now i only need to use the cube filter. What syntax should this cube filter have, to reference to a specific cell?

For Example:

From the Cube 'Sales' i want 'Canada;2015;Sum'.

Sincerely
Alexander