TM1 lint

alias.pl is a very basic lint tool whose task is to flag "dangerous" TM1 rules.
For now it is only checking for aliases in rules.

Indeed, if an alias is changed or deleted, any rule based on that alias will stop working without any warning from the system. The values will remain in place until the cube or its rules gets reloaded but you will only get a "silent" warning in the messages log after reloading the cube.

How to proceed:
.configure and execute the following TI process (to put in prolog), this will generate a list of all cubes and associated dimensions, and a dictionary of all aliases on the system in .csv format

### PROLOG
#configure the 2 lines below for your system
report = 'D:\alias.dictionary.csv';
report1 = 'D:\cubes.csv';

#
##############################################

#it is assumed that none of the aliases contain commas
DataSourceASCIIQuoteCharacter = '';


######create a list of all cubes and associated dimensions
c = 1;
while(c <= DimSiz('}Cubes'));
    cube = DIMNM('}Cubes',c);
    
    d = 1;
    while(tabdim(cube,d) @<> '');
         asciioutput(report1, cube, tabdim(cube, d));
         d = d + 1;
    end;
    c = c + 1;
end;


######create a dictionary of all aliases
d = 1;
while(d <= DimSiz('}Dimensions'));
  dim = DIMNM('}Dimensions',d);

  #skip control dimensions
  If(SUBST(dim,1,1) @<> '}');
      attributes = '}ElementAttributes_' | dim;
      #any aliases?
      If(DIMIX('}Dimensions',attributes) <> 0);
          a = 1;
          while(a <= DimSiz(attributes));
              attr = DIMNM(attributes,a);

              #is it an alias?
              If(DTYPE(attributes,attr) @= 'AA');
                  #go through all elements and report the ones different from the principal name
                  e = 1;
                  while(e <= DimSiz(dim));
                          element = DIMNM(dim,e);

                          If(element @<> ATTRS(dim,element,attr) & ATTRS(dim,element,attr) @<> '');
                               asciioutput(report,dim,attr,ATTRS(dim,element,attr));
                          Endif;
                          e = e + 1;
                  end;
              Endif;
              a = a + 1;
          end;
      Endif;
  Endif;
  d = d + 1;
end;

.configure and execute the perl script attached below
that script will load the csv files generated earlier in hash tables, scan all rules files and finally report any aliases.

If the element is ambiguous because it is present in 2 different dimensions then you should write it as dimension:'element' instead of using aliases (e.g. write Account:'71010' instead of '71010').

related: Wim Gielis' rule area definition tool

Categories

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.