Page 1 of 1

Prefix to Consolidation Element

Posted: Wed Jan 18, 2012 3:38 am
by pradeep.k.jagadeesan
I want to add prefix to a consolidation element after copying all the consolidation to a new dimension.

If I have a consolidation, Total, I want to add ''2011-'' along with the Total consolidation.

Given is the logic that I am adding consolidation and its N level elements:

sElType = DType( pSourceDim, vElement );

DimensionElementInsert( pTargetDim, '', vElement, sElType );

IF( sElType @= 'C' & ElCompN( pSourceDim, vElement ) > 0 );
nChildren = ElCompN( pSourceDim, vElement );
nCount = 1;
While( nCount <= nChildren );
sChildElement = ElComp( pSourceDim, vElement, nCount );
sChildType = DType( pSourceDim, sChildElement );
sChildWeight = ElWeight( pSourceDim, vElement, sChildElement );
DimensionElementInsert( pTargetDim, '', sChildElement, sChildType );
DimensionElementComponentAdd( pTargetDim, vElement, sChildElement, sChildWeight );
nCount = nCount + 1;
End;
EndIf;

EndIf;

Any Idea!!

Thanks in advance.
Pradeep J

Re: Prefix to Consolidation Element

Posted: Wed Jan 18, 2012 8:56 am
by Christopher Kernahan
Hi Pradeep J,

If you only want to add it to the element 'Total' then test for the name of the element ie IF( vElement @= 'Total')

If you want to add it to all C level elements then create an addition variable,

vElementNew = '2011 - ' | vElement;

and use this as the name of the element when inserting. When looking up the original element, use vElement.

If you've written the code below you shouldn't have any trouble with this, just a matter of thinking about what test to use and when to substitute the variables from old to new.