Page 1 of 1
Adding element to a dimension at run time in TI
Posted: Wed Aug 02, 2017 9:42 pm
by Analytics123
Hi ,
I have a TI process which adds an element to the dimension in run time .
IF (DIMIX('Inventory Movement Types', vMovementType) = 0);
DIMENSIONELEMENTCOMPONENTADD('Inventory Movement Types','All Inventory Movement Types', vMovementType,1.000000);
I have a parent All Inventory Movement Types created in the inventory movement type dimension .
now the load file has a new value Z21 and this is added to the dimension but it is added as COnsolidated Element . I want it to be a leaf level element .
Not sure why its adding as a consolidated . Am i doing something wrong in the above code.
Thanks,
Re: Adding element to a dimension at run time in TI
Posted: Wed Aug 02, 2017 9:49 pm
by Wim Gielis
Code: Select all
IF( DIMIX('Inventory Movement Types', vMovementType ) = 0 );
DIMENSIONELEMENTINSERT('Inventory Movement Types','', vMovementType,'N');
DIMENSIONELEMENTCOMPONENTADD('Inventory Movement Types','All Inventory Movement Types', vMovementType,1);
ENDIF;
Re: Adding element to a dimension at run time in TI
Posted: Thu Aug 03, 2017 8:58 pm
by Analytics123
Thanks !! But its odd some time with just dimensionelement component add some items are added as n level .
But its safer to have the above code .
Re: Adding element to a dimension at run time in TI
Posted: Thu Aug 03, 2017 9:09 pm
by Wim Gielis
Absolutely, use both functions.
Re: Adding element to a dimension at run time in TI
Posted: Thu Aug 03, 2017 9:35 pm
by declanr
I always just use dimensionelementcomponentadd without first doing an insert when it's for n level elements.
TM1 will always make an element be an N level if it is put through a dimensionelementcomponentadd and doesn't already exist.
The only time it will be a C level is if it already existed before the component add and was already a C level element.
If the element already exists at C level and you do a dimensionelementinsert with an N flag; it will be converted to an N. You can consider this safer but I would be inclined to spend more time understanding why it already existed as a C level element.
Re: Adding element to a dimension at run time in TI
Posted: Thu Aug 03, 2017 9:52 pm
by Wim Gielis
declanr wrote: ↑Thu Aug 03, 2017 9:35 pmTM1 will always make an element be an N level if it is put through a dimensionelementcomponentadd and doesn't already exist.
That's the question of the OP I guess. There is a Dimix and still (based on what I read in the question) an element gets created as a C-type element.
declanr wrote: ↑Thu Aug 03, 2017 9:35 pmIf the element already exists at C level and you do a dimensionelementinsert with an N flag; it will be converted to an N.
Are you sure about that Declan ?
If an element exists as C and you try to insert the same element as N, nothing happens.
Re: Adding element to a dimension at run time in TI
Posted: Thu Aug 03, 2017 10:00 pm
by declanr
Wim Gielis wrote: ↑Thu Aug 03, 2017 9:52 pm
Are you sure about that Declan ?
If an element exists as C and you try to insert the same element as N, nothing happens.
Sorry you are correct about this, a dimensionelementinsert statement is completely ignored if the element already exists. I should have said if you do dimensionelementdelete and then dimensionelementinsert it changes.
Wim Gielis wrote: ↑Thu Aug 03, 2017 9:52 pm
That's the question of the OP I guess. There is a Dimix and still (based on what I read in the question) an element gets created as a C-type element.
Yes, the dimix would stop it ever running the code if the element already exists. But a dimensionelementcomponentadd has never created a new C-level element in my experience; so all I can assume is that the element already existed as C as a child of that element; or there is another section of code somewhere that adds it in as a C.
Re: Adding element to a dimension at run time in TI
Posted: Thu Aug 03, 2017 10:04 pm
by Wim Gielis
I agree on both points
