If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Simple TI process - Results have me Stumped!

Started by donap, 17 Nov 2017 10:56:08 AM

Previous topic - Next topic

donap

OK -- SO I still cannot Insert an IMAGE here... Please reference the attachment. ...
The image shows my  Dimension after an update - some fields in the SOURCE data got changed, and caused the Elements "601_input" ,  "622_input", "789_input", and "798_input" to become UNMAPPED from their correct Parents -- which appear under the Hierarchy - TOTAL --> DVU -->DU-->DUO-->NHC-->"601" ... etc.

As this could happen every time the scheduled job to update this dimension is run .. I put together a TI Process.
In my PROLOG TAB  I have the code shown below.

PART 1 - Works like a charm -- Moves Element "601_Input"  under the "601" Consolidated level in the hierarchy location as noted above.

When I   UN-COMMENT Part 2 -   (comment out Part 1)
The result is "Process completely successfully".  ** BUT NO ELEMENTS HAVE BEEN MOVED ***
The 4   "_input" elements are STILL in this same level (no ancestors) and the Corresponding 3-Digit Consolidated levels have NO CHILD elements !

What am I missing? Why is PART 2 not working as I expect ??  TIA

#====================================================================================================
#Part 1 - TEST - Forcing Element to process
#===================================================================================================

sDim = pDim;
sTop = pTop;
sUnmapped = pUnmapped;
weight=1;

topCount=elcompn(sDim,sTop);

vChkElement = '601_input';
vParentLkup = SUBST(vChkElement, 1, 3);
vParIndex = DIMIX(sdim, vParentLkup);
If (vParIndex <> 0 ) ;
    DimensionElementComponentAdd(sDim, vParentLkup, vChkElement, weight);
endif;

#====================================================================================================
#Part 2 - Generic LOOP - should Identify Elements dynamically
#===================================================================================================
# ==== vIndex = 1;

# ====WHILE (vIndex <= topCount);
# ====       vChkElement = DIMNM( sDim, vIndex );

# ====       if (DTYPE(sDim, vChkElement ) @<> 'C');
          
# ====                   DimensionElementComponentDelete(sDim, sTop, vChkElement );
           
#===                       vParentLkup = SUBST(vChkElement, 1, 3);
#===                        vParIndex = DIMIX(sdim, vParentLkup);
#===                       If (vParIndex <> 0 ) ;
#===                            DimensionElementComponentAdd(sDim, vParentLkup, vChkElement, weight);
#===                     else;
# ====                       DimensionElementComponentAdd(sDim, sUnmapped, vChkElement, weight);
#===                      endif;
# ====        endif;
 
# ==== vIndex = vindex + 1;
# =  end;



PS> Any hint on how to designate CODE  or insert the image would be helpful for future reference. When I click on the Insert Image Tool. it generates the "img" with brackets, but does not allow me to insert the image or reference the PNG file in between or anywhere else in this comment box.

AJAYC

Hi Donap

I think there may be a small discrepancy in the logic of Part 2 just before the WHILE loop.

In the code you are defining the number of loops based on the following variable for:

topCount=elcompn(sDim,sTop);

However the required element is tested here:


vIndex = 1;

WHILE (vIndex <= topCount);
            vChkElement = DIMNM( sDim, vIndex );



I think you might be getting an issue because your code appears to retrieve a dimension element based on vIndex to assign to the variable vChkElement. You may be missing your "xxx_input" elements because they may be at index numbers within the dimension beyond the topcount value.

Your Part 1 Code doesn't use this as you effective hard code the test.

I'd also recommend you change the WHILE counter to:

vIndex = vIndex - 1;

This is recommended as the index numbers in the dimensions are continually changing, so best to go from the bottom of the list to the top.

Obviously, I don't know what you are processing as parameters nor do I know the index values of the elements within the dimension, so I could be "barking up the wrong tree", but these could be places to look at.

HTH
Ajay

donap

Thank you AJAYC.

That leads me to a question though - I thought :
topCount=elcompn(sDim,sTop);

returns the TOTAL NUMBER of elements in the dimension. 
Thinking about your answer - are you saying the number of elements might be 50, but the INDEX values  might be 45-95 ??
A loop testing 1-50 would mix the element at index values higher than 50  ?

IS there a way to retrieve the HIGHEST INDEX value ??

THanks





AJAYC

Hi Donap

The ELCOMPN function returns the number of components of an element and not the total number of elements within a dimension.

In order to return the total number of elements and hence the highest indexed value you will want to use the DIMSIZ function:

DIMSIZ( YourDimension )

HTH
Ajay


donap

#4
AJAYC -
OK -
On further reflection --
I have a Dimension that has approx 600 elements.

Some of the index values I know are in the upper 800's range.

A particular PARENT/CONSOLIDATED Element may have only 5 leaf level elements.
The TOP TOTAL LEVEL Consolidated Element may have 6 "valid" elements.

After I unwind the dimension, and rerun the update (which would be happening Weekly), some Leaf level elements got moved, or parents renamed.
FOUR leaf elements could not find their parent level, and since the Unwind, are now sitting at the SAME LEVEL as the TOP "TOTAL".
I was using "topCount=elcompn(sDim,sTop);"   hoping it would give me a count of "5" - "Total" and the 4 leaf elements.
I now understand that it may have returned "5", but my loop index won't find the elements I want due to their index being higher than 5.
DIMSIZ would give me the 600 number, but I still wouldn't necessarily find the indexes that exist in the 800 number range.
SO - how do I loop through only the PARENT I want -- I would want to loop through only those 5 elements.
Is this possible?

MODIFIED:
PS>> I think a better way to say this is the ROOT LEVEL of my dimension has 5 members  -
  a> TOTAL  - -Consolidated level
  b> the 4 "xx_input"  leaf level 0 elements

TO simplify what I am trying to accomplish:

I want to create a TI process that will look at this ROOT level -- loop through the 5 elements, handle the leaf level elements differently than the consolidated level.
my entire dimension has less than 600 total elements. 
The 4 orphan leaf elements have index values 826-829.

Thanks



AJAYC

Hi Donap

Try this:

nChildren = ELCOMPN( vDim, vElement );

WHILE ( nChildren > 0 );

   sChild = ELCOMP( vDim, vElement, nChildren );
   DimensionElementComponentDelete( vDim, vElement, sChild );

   nChildren = nChildren - 1;
END ;



HTH
Ajay




donap

THANK YOU!
so using the " sChild = ELCOMP( vDim, vElement, nChildren );"  will access  Child 1, child 2, etc -- not really using the INDEX value of the element!
Just what I was trying to accomplish.

Thanks