Page 1 of 1

Moving Parentless N Level Element

Posted: Mon Oct 22, 2012 10:39 pm
by winsonlee
After I delete all the element relationship, what level is a consolidation element ? What i am trying to do is to delete consolidation element and move N level element to "DO NOT USE". On the first code, the output on text file is as expected which the consolidation element appear to be at Level 1. On the second code, after putting in DimensionElementComponentAdd and DimensionElementDelete, the consolidation element appear to be Level 0. Would like to find out why the level would change for two similar codes.

Code: Select all

vDim = 'CustomerHierarchy';
i = DIMSIZ(vDim) ;
WHILE( i > 0) ;
            vElem = DIMNM(vDim, i) ;
            IF (Ellev(vDim,vElem) = 0 & ELPARN(vDim, vElem) = 0 & vElem @<> 'DO NOT USE');
                  ASCIIOUTPUT('d:\move2.txt', vElem);
            ENDIF;
            IF (Ellev(vDim,vElem) = 1 & ELPARN(vDim, vElem) = 0 & vElem @<> 'DO NOT USE');
                  ASCIIOUTPUT('d:\delete2.txt', vElem);
            ENDIF;

        i = i -1 ;
END;

Code: Select all

vDim = 'CustomerHierarchy';
i = DIMSIZ(vDim) ;
WHILE( i > 0) ;
            vElem = DIMNM(vDim, i) ;
            IF (Ellev(vDim,vElem) = 0 & ELPARN(vDim, vElem) = 0 & vElem @<> 'DO NOT USE');
                  DimensionElementComponentAdd(vDim, 'DO NOT USE', vElem, 0);
                  ASCIIOUTPUT('d:\move2.txt', vElem);
            ENDIF;
            IF (Ellev(vDim,vElem) = 1 & ELPARN(vDim, vElem) = 0 & vElem @<> 'DO NOT USE');
                 DimensionElementDelete( vDim,  vElem );
                  ASCIIOUTPUT('d:\delete2.txt', vElem);
            ENDIF;

        i = i -1 ;
END;

Re: Moving Parentless N Level Element

Posted: Mon Oct 22, 2012 10:44 pm
by Alan Kirk
winsonlee wrote:After I delete all the element relationship, what level is a consolidation element ? What i am trying to do is to delete consolidation element and move N level element to "DO NOT USE". On the first code, the output on text file is as expected which the consolidation element appear to be at Level 1. On the second code, after putting in DimensionElementComponentAdd and DimensionElementDelete, the consolidation element appear to be Level 0. Would like to find out why the level would change for two similar codes.
I don't have time to look at the code at the moment, but to save yourself the grief of this problem you may want to use DType rather than ElLev to determine whether an element is a consolidation and therefore deletable.

Re: Moving Parentless N Level Element

Posted: Mon Oct 22, 2012 10:49 pm
by winsonlee
Thanks for the answer. That works as expected.