Page 1 of 1

ItemSkip; not working; not skipping record

Posted: Tue Dec 09, 2025 2:38 pm
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;

Re: ItemSkip; not working; not skipping record

Posted: Tue Dec 09, 2025 6:13 pm
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;

Re: ItemSkip; not working; not skipping record

Posted: Wed Dec 10, 2025 2:21 pm
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.

Re: ItemSkip; not working; not skipping record

Posted: Tue Dec 16, 2025 6:12 pm
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?