ItemSkip; not working; not skipping record

Post Reply
Paul-TM1
Regular Participant
Posts: 151
Joined: Tue Jun 13, 2017 3:20 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2010

ItemSkip; not working; not skipping record

Post by Paul-TM1 »

Hi,
I am working on version 2.1.14 and found a strange issue that ItemSkip is not skipping a record, but coming out of the while loop. I have pasted the code below. The moment 'Factor' is hit, it's coming out of the loop. I ran the same code in on our old server - 2.0.92 and found it does the same - exit out of the loop. If I comment the line ITEMSKIP; the code runs all records.
Can someone help me?

Thanks,
Paul.

Code: Select all

processName = 'dimUpdateMonths-Test' ;
logFile = GetProcessErrorFileDirectory | processName | '.txt' ;

dim = 'months' ;
nCounter = 1;
nMaximum = DimSiz(Dim) ;
asciiOutPut ( logFile, 'Max Dim Size', NumberToString( nMaximum ) , NumberToString(nCounter));
WHILE(nCounter <= nMaximum);
  sElName = DimNm(Dim , nCounter);

    asciiOutPut ( logFile, 'nCounter',  NumberToString( nMaximum ) , NumberToString( nCounter ), 'sElName' , sElName);
    
  if (sElName @= 'Factor');
     ITEMSKIP;
  endif;

      nCounter = nCounter + 1;

END;
declanr
MVP
Posts: 1833
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: ItemSkip; not working; not skipping record

Post by declanr »

I think you've just misinterpreted what ItemSkip is supposed to do.

Itemskip is intended to cancel further processing of the DATA SOURCE record.
e.g. if you have a datasource with 10 rows, when processing the third row on the data tab (or metadata) and you hit an ITEMSKIP - it will just stop doing anything for the third record and move onto processing the fourth record (start of the data tab.)

From memory (I haven't used this application of the function in a while), I think that ItemSkip also works on the prolog/epilog even though there isn't technically a datasource record, it would just skip straight to the next processing tab (e.g. Prolog would skip straight to metadata, and epilog would end the process.)


In relation to your code - itemskip has nothing to do with the variable sElName. I *think* you are after code more like:

Code: Select all

processName = 'dimUpdateMonths-Test' ;
logFile = GetProcessErrorFileDirectory | processName | '.txt' ;

dim = 'months' ;
nCounter = 1;
nMaximum = DimSiz(Dim) ;
asciiOutPut ( logFile, 'Max Dim Size', NumberToString( nMaximum ) , NumberToString(nCounter));
WHILE(nCounter <= nMaximum);
  sElName = DimNm(Dim , nCounter);

    asciiOutPut ( logFile, 'nCounter',  NumberToString( nMaximum ) , NumberToString( nCounter ), 'sElName' , sElName);
    
  if (sElName @<> 'Factor');
     # Do stuff
  endif;

      nCounter = nCounter + 1;

END;
Declan Rodger
Paul-TM1
Regular Participant
Posts: 151
Joined: Tue Jun 13, 2017 3:20 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2010

Re: ItemSkip; not working; not skipping record

Post by Paul-TM1 »

Thanks Declanr.
I too found it the hard way yesterday. ItemSkip works only in the metaData or Data tabs.
I too applied the same logic you sent. Thanks again.

Paul.
ardi
Community Contributor
Posts: 167
Joined: Tue Apr 02, 2013 1:41 pm
OLAP Product: tm1, cognos bi
Version: from TM1 9.4 to PA 2.0.9.6
Excel Version: 2010
Location: Toronto, ON

Re: ItemSkip; not working; not skipping record

Post by ardi »

What are you exactly trying to achieve? As you mentioned, ItemSkip will just move the execution to next TAB (metadata, data or epilog), but are you just trying to end the while loop, or are you just trying to skip processing certain elements from your dimension?
Ardian Alikaj
Post Reply