I am attempting to build a TI process which spins through the dimension elements and, based on the special attribute, attempts to delete only the alternate consolidation elements, leaving intact the "regular" hierarchy elements and the leaf elements. We are getting some elements deleted, but not all. There seems to be an issue with the DNEXT function not working correctly. I've been tracing the code, but can't get a handle on why some alternate consoildation elements are being left.
Here's the relevant code section of code. Note that this is not the entire code. Some variables have been set prior to this. There are also extra statements in this version just for testing/tracing. This code executes in the prolog of a TI process.
The basic logic is:
1) Start at the first element.
2) Loop until there are no more elements
a) Is the current element part of the standard hierarchy?
1) If no,
a) perform a DNEXT to get the next element in the dimension.
b) delete the current element.
2) If yes, perform a DNEXT
Code: Select all
# Initialize the loop.
# The All Element is known to be the first element in the dimension based on how the dim is initially built.
strProjTaskLoopElement = strProjTaskDimAllElemNm;
# Loop through all of the elements in the project task dimension.
While (strProjTaskLoopElement @<> '');
TextOutput(strTextOutputFileName, 'strProjTaskLoopElement: ', strProjTaskLoopElement);
nbrProjTaskLoopElemIndexNbr = DIMIX(strProjTaskDimNm, strProjTaskLoopElement);
TextOutput(strTextOutputFileName, ' nbrProjTaskLoopElemIndexNbr: ',
NUMBERTOSTRING(nbrProjTaskLoopElemIndexNbr));
strProjTaskLoopElemHierType = ATTRS(strProjTaskDimNm, strProjTaskLoopElement,strProjTaskHierTypeAttrNm );
TextOutput(strTextOutputFileName, 'strProjTaskLoopElemHierType: ', strProjTaskLoopElemHierType);
# Is this element in the "standard" Project Task hierarchy?
IF (strProjTaskLoopElemHierType @<> strProjTaskRegularHierType);
# It is not one of standard elements, thus it is part of a portfolio alternate hierarchy
# Save off the element to be deleted.
strProjTaskDeleteElement = strProjTaskLoopElement;
TextOutput(strTextOutputFileName, 'strProjTaskDeleteElement: ', strProjTaskDeleteElement);
# Get the next element
# This must be done prior to deleting the element b/c DNEXT needs the current element which is about to be deleted.
strProjTaskLoopElement = DNEXT(strProjTaskDimNm, strProjTaskLoopElement);
# Delete the alt hier element
DIMENSIONELEMENTDELETE(strProjTaskDimNm, strProjTaskDeleteElement);
ELSEIF (strProjTaskLoopElemHierType @= strProjTaskRegularHierType);
# It is one of the standard elements. No action needs to be taken. Skip to the next element.
# Move to the next element and increment the while loop counter
strProjTaskLoopElement = DNEXT(strProjTaskDimNm, strProjTaskLoopElement);
ENDIF;
# End the While
END;
Thanks.