Page 1 of 1

WHILE Statement Wants Another End?

Posted: Tue May 30, 2017 9:38 pm
by Thurston Howell III
I am working on a TI process that will re-organize some elements within a dimension into two consolidations, both meeting the same rollup point.

I set up a loop using a While/End statement, but when I save it I get an error pointing to the line with the END; and asking "END OF ENDIF statement missing". I believe my code follows the Reference Guide, but I might be mistaken. The code is only on the prolog.

Code: Select all

Dim = 'bpmSubAccountTarget';
Subset = 'Base Level Elements';

IF ( DIMIX ( Dim , 'InactiveSubAccounts' ) = 0 ) ;
    DIMENSIONELEMENTINSERT ( Dim , '' , 'InactiveSubAccounts' , 'C' );
     DIMENSIONELEMENTCOMPONENTADD ( Dim , 'Total SubAccounts' , 'InactiveSubAccounts' , 1 );
IF ( DIMIX ( Dim , 'ActiveSubAccounts' ) = 0 ) ;
    DIMENSIONELEMENTINSERT ( Dim , '' , 'ActiveSubAccounts' , 'C' );
     DIMENSIONELEMENTCOMPONENTADD ( Dim , 'Total SubAccounts' , 'ActiveSubAccounts' , 1 );

   

SUBSETCREATEBYMDX ( Subset , '{TM1FILTERBYLEVEL( {TM1DRILLDOWNMEMBER( {TM1FILTERBYPATTERN( {TM1SUBSETALL( [bpmSubAccountTarget] )}, "total subaccounts")}, ALL, RECURSIVE )}, 0)}' ) ;



n = SUBSETGETSIZE ( Dim , Subset );
i = 1;

WHILE ( i <= n );

     Element = SUBSETGETELEMENTNAME ( Dim , Subset , i );
     ElementAttribute = ATTRS ( Dim , Element , 'Name' ); 
     IF ( SCAN ( 'INACTIVE' , ElementAttribute ) >0 ) ;
        DIMENSIONELEMENTCOMPONENTADD ( Dim , 'InactiveSubAccounts' , Element , 1 );
          ELSE;
              DIMENSIONELEMENTCOMPONENTADD ( Dim , 'ActiveSubAccounts' , Element , 1 );
       ENDIF;

       IF ( ELISPAR ( Dim , Element , 'Total SubAccounts' ) <> 0 );
             DIMENSIONELEMENTCOMPONENTDELETE ( Dim , 'Total SubAccounts' , Element );
                  ENDIF;

i = i + 1;

END;

Re: WHILE Statement Wants Another End?

Posted: Tue May 30, 2017 9:41 pm
by Alan Kirk
You're missing an EndIf after your first If. You go straight into another If instead of an ElseIf. You're also missing one after your second If.

Note that the one line Rules If() function has a different format (and, usually, a different purpose) to the TI block If statement that you're trying to use. The first returns a value depending on the condition, the second regulates code flow. Although they can sometimes substitute for each other they aren't interchangeable and the block If statement always requires an EndIf.

Re: WHILE Statement Wants Another End?

Posted: Tue May 30, 2017 10:09 pm
by Thurston Howell III
Alan,

Thank you for spotting that! That fixed my error. Thank you.