Hello,
I wrote some code to generalize the process.
A loop over the cubes is done, skipping internal control cubes. Application cubes that use control dimensions are not skipped, though.
USE THIS CODE WITH CAUTION
Subsets and views are created on the fly, and destroyed afterwards. Cube cells are zero'ed out. No dimension elements will be removed. Rules will still apply if defined.
The code could be optimized to include only lowest-level elements (now all dimension elements are taken), but since you could have string elements in the last dimension and text on (some) consolidations, you would have to check for that first. I will post that code later.
Here is the code in the Prolog of a process with None as data source:
Code: Select all
###################
# Wim Gielis
# June 11, 2009
# ATTENTION: PLEASE KNOW WHAT YOU ARE DOING
# SINCE THIS CODE WILL CLEAR ALL DATA FROM ALL APPLICATION CUBES ON A CERTAIN SERVER
# No responsibility will be taken in case of unforeseen loss of data.
###################
vViewName='MyTempView';
vSubsetName='MyTempSubset';
# loop over the cubes
iCube=1;
While(iCube<=DIMSIZ('}Cubes'));
# the cube in the loop
vCube=DIMNM('}Cubes',iCube);
# exclude control cubes
If(Subst(vCube,1,1)@<>'}');
ViewDestroy(vCube,vViewName);
ViewCreate(vCube,vViewName);
# track the number of dimensions for this cube
vNrOfDimensions=0;
While(Long(Tabdim(vCube,vNrOfDimensions+1))>0);
vNrOfDimensions=vNrOfDimensions+1;
End;
# loop over the dimensions in this cube
iDim=1;
While(iDim<=vNrOfDimensions);
vDim=Tabdim(vCube,iDim);
SubsetDestroy(vDim,vSubsetName);
SubsetCreateByMDX(vSubsetName,'{TM1SUBSETALL( [' | vDim | '] )}');
ViewSubsetAssign(vCube,vViewName,vDim,vSubsetName);
iDim=iDim+1;
End;
ViewZeroOut(vCube,vViewName);
ViewDestroy(vCube,vViewName);
EndIf;
iCube=iCube+1;
End;
Here is the code in the Epilog of the process:
Code: Select all
###################
# Wim Gielis
# June 11, 2009
# ATTENTION: PLEASE KNOW WHAT YOU ARE DOING
# SINCE THIS CODE WILL CLEAR ALL DATA FROM ALL APPLICATION CUBES ON A CERTAIN SERVER
# No responsibility will be taken in case of unforeseen loss of data.
###################
# loop over the cubes
iCube=1;
While(iCube<=DIMSIZ('}Cubes'));
# the cube in the loop
vCube=DIMNM('}Cubes',iCube);
# exclude control cubes
If(Subst(vCube,1,1)@<>'}');
# loop over the dimensions in this cube
iDim=1;
While(Long(Tabdim(vCube,iDim))>0);
vDim=Tabdim(vCube,iDim);
SubsetDestroy(vDim,vSubsetName);
iDim=iDim+1;
End;
EndIf;
iCube=iCube+1;
End;
Wim