WHILE Statement Wants Another End?

Post Reply
Thurston Howell III
Posts: 36
Joined: Fri Mar 10, 2017 8:26 pm
OLAP Product: TM1
Version: PA 2.0.8
Excel Version: 2016
Location: Dallas, TX

WHILE Statement Wants Another End?

Post 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;
User avatar
Alan Kirk
Site Admin
Posts: 6606
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: WHILE Statement Wants Another End?

Post 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.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Thurston Howell III
Posts: 36
Joined: Fri Mar 10, 2017 8:26 pm
OLAP Product: TM1
Version: PA 2.0.8
Excel Version: 2016
Location: Dallas, TX

Re: WHILE Statement Wants Another End?

Post by Thurston Howell III »

Alan,

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