Hi,
I'm trying to remove all consolidations elements without any children from dimension. This code below not working properly because deleting only some elements. What is wrong in this code below??
In this dimension I have multiple hierarchy.
Thanks for any suggestion.
sDimName = 'DestCustomer';
nX = 1;
nLimit = DIMSIZ(sDimName);
WHILE(nX<=nLimit);
sElementName = DIMNM(sDimName,nX);
sConElement = DTYPE(sDimName,sElementName);
sNumberOfChildren = ELCOMPN(sDimName,sElementName);
IF (sConElement @='C');
IF(sNumberOfChildren = 0);
DIMENSIONELEMENTDELETE(sDimName,sElementName);
ENDIF;
ENDIF;
nX = nX + 1;
END;
Regards
Rafal
Deleting elements without children
-
- MVP
- Posts: 1828
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: Deleting elements without children
Look at the advice I gave in your last post (that was irrelevant in that scenario.)
You also have a risk that you check element 1 and ignore it as it has child element 2... you then check element 2 which is a c with no children and delete it. Now element 1 still exists as a c with no children... follow?
You also have a risk that you check element 1 and ignore it as it has child element 2... you then check element 2 which is a c with no children and delete it. Now element 1 still exists as a c with no children... follow?
Declan Rodger
-
- Posts: 15
- Joined: Mon Apr 07, 2014 4:02 pm
- OLAP Product: Cognos Express
- Version: 10.1.1
- Excel Version: 2010
Re: Deleting elements without children
Hi,
I fixed the issue this code below working :
sDimName = 'DestCustomer';
nX = 1;
nLimit = DIMSIZ(sDimName);
WHILE(nX<=nLimit);
sElementName = DIMNM(sDimName,nX);
sConElement = DTYPE(sDimName,sElementName);
sNumberOfChildren = ELCOMPN(sDimName,sElementName);
IF (sConElement @='C');
IF(sNumberOfChildren = 0);
DIMENSIONELEMENTDELETE(sDimName,sElementName);
ENDIF;
ELSE;
nX = nLimit + 1;
ENDIF;
IF(sElementName@=DIMNM(sDimName,nX));
nX = nX + 1;
ENDIF;
END;
I fixed the issue this code below working :
sDimName = 'DestCustomer';
nX = 1;
nLimit = DIMSIZ(sDimName);
WHILE(nX<=nLimit);
sElementName = DIMNM(sDimName,nX);
sConElement = DTYPE(sDimName,sElementName);
sNumberOfChildren = ELCOMPN(sDimName,sElementName);
IF (sConElement @='C');
IF(sNumberOfChildren = 0);
DIMENSIONELEMENTDELETE(sDimName,sElementName);
ENDIF;
ELSE;
nX = nLimit + 1;
ENDIF;
IF(sElementName@=DIMNM(sDimName,nX));
nX = nX + 1;
ENDIF;
END;
-
- MVP
- Posts: 170
- Joined: Fri Dec 10, 2010 4:07 pm
- OLAP Product: TM1
- Version: [2.x ...] 11.x / PAL 2.0.9
- Excel Version: Excel 2013-2016
- Location: Germany
Re: Deleting elements without children
sDimName = 'DestCustomer';
nLimit = DIMSIZ( sDimName );
nX = nLimit;
WHILE( nX >= 1 );
sElementName = DIMNM( sDimName, nX );
nlevel = ELLEV( sDimName, sElementName );
IF ( nLevel > 0 );
DIMENSIONELEMENTDELETE( sDimName, sElementName );
ENDIF;
nX = nX - 1;
END;
nLimit = DIMSIZ( sDimName );
nX = nLimit;
WHILE( nX >= 1 );
sElementName = DIMNM( sDimName, nX );
nlevel = ELLEV( sDimName, sElementName );
IF ( nLevel > 0 );
DIMENSIONELEMENTDELETE( sDimName, sElementName );
ENDIF;
nX = nX - 1;
END;
-
- MVP
- Posts: 170
- Joined: Fri Dec 10, 2010 4:07 pm
- OLAP Product: TM1
- Version: [2.x ...] 11.x / PAL 2.0.9
- Excel Version: Excel 2013-2016
- Location: Germany
Re: Deleting elements without children
Just saw your own feedback, so maybe I didn't catch your requirement. The above code simply deletes all consolidations.
-
- Posts: 15
- Joined: Mon Apr 07, 2014 4:02 pm
- OLAP Product: Cognos Express
- Version: 10.1.1
- Excel Version: 2010
Re: Deleting elements without children
Hi Gabor,
Many thanks for your help.
Regards
Rafal
Many thanks for your help.
Regards
Rafal