Moving Parentless N Level Element

Post Reply
winsonlee
Regular Participant
Posts: 180
Joined: Thu Jul 01, 2010 3:06 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2007
Location: Melbourne, Australia

Moving Parentless N Level Element

Post 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;
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Moving Parentless N Level Element

Post 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.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
winsonlee
Regular Participant
Posts: 180
Joined: Thu Jul 01, 2010 3:06 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2007
Location: Melbourne, Australia

Re: Moving Parentless N Level Element

Post by winsonlee »

Thanks for the answer. That works as expected.
Post Reply