Page 1 of 1

DimensionElementComponentAdd issue

Posted: Wed Jan 18, 2017 4:53 pm
by Wim Gielis
Hello all,

I have a strange situation in TI with a very simple dimension, simplying further is not possible.

This code in the Prolog gives an error on the line with DimensionElementInsert, saying that the element that I want to insert already exists as an alias. This is correct.
But if I comment out the DimensionElementComponentAdd code, the Dtype function is honoured and the code continues without error (and does not try to insert the element).

Code: Select all

DimensionElementComponentAdd( 'dim', 'Total', 'A', 1 );

If( Dtype( 'dim', 'd' ) @<> 'N' );
 DimensionElementInsert( 'dim', '', 'd', 'N' );
EndIf;
Howcome......... ?

I know that using Dimix = 0 would be better than Dtype @<> 'N' but still, why does this happen ?
00.PNG
00.PNG (76.68 KiB) Viewed 2772 times

Re: DimensionElementComponentAdd issue

Posted: Wed Jan 18, 2017 7:00 pm
by gtonkin
Hi Wim,
From what I can see using a quick asciioutput, it looks like an inconsistent behaviour with the temporary dimension.
If you make a change to the dimension, the temporary dimension is created and used for the Prolog changes. The DType does not seem to resolve d=c and thus DType=N.
An ATTRS('dim','d','alias_1'); does however resolve to c which in turn returns d.
Moving the DimensionElementComponentAdd below the IF(DType...) section is as good as hashing it i.e. temporary dimension not created yet.
Setting a variable to the principal name e.g. sEl=DimensionElementPrincipalName('dim','d'); and then using sEl in the DType function seems to get around this.
Looks like you have discovered an obscure bug though as other functions behave as expected.

Re: DimensionElementComponentAdd issue

Posted: Wed Jan 18, 2017 7:38 pm
by Wim Gielis
Hello George,

Thank you for investigating.

In fact, originally, the code was put in the Metadata tab.
So reversing the statemens would help for the first record (ODBC table is the data source), but not for any subsequent records.
In fact, it was reversed originally, and then I saw that the Dtype = N is taken for the first record, and for any record where that dimension element occurs again.
Say a cost center that occurs 10 times in the data load, then 10 records are "fine" and all other do not get Dtype = N, even though these costcenters exist as alias values.

The background of this case is that the cost centers in the table were the element names in TM1, and the process always ran fine.
For unknown reasons, the table offered the alias values to TM1, not the element names anymore. Then I saw this issue coming up.