|
发表于 2014-6-29 20:13:20
|
显示全部楼层
dutchaussie wrote:Alan,
I think you are right, I do have an infinite loop in there.
This is what I have:
# Plant
sPlant = NumberToString(vPlant_No);
# skip missing Plants
IF(DIMIX('Plant,sPlant)=0);
#ItemSkip;
ENDIF;
It seems I forgot the 'then' part of my if-statement as the itemskip is commented out?!
Does this look more like it?
# skip missing Plants
IF(DIMIX('Plant,sPlant)=0);
ItemReject('Plant not found: ' |sPlant);
ENDIF;
That's not a loop, it's a conditional block. The While function is used in a loop. This would be an infinite loop:
Code: l_DimNm = 1;
l_DimCnt = DimSiz ( 'Plant' );
While ( l_DimNm <= l_DimCnt );
AsciiOutput ( 'C:TempLoop.txt', DimNm ( 'Plant', l_DimNm ) );
End
That's because l_DimNm is not incremented inside the loop, and will therefore equal 1 each and every time. It will simply write the name of the first element again, and again, and again, and again until you have to use TM1 Top to kill the process because it's hanging your server.
A conditional block does something quite different; it executes a block of code inside itself, but it does that only once. (If the block is inside your Metadata or Data tabs it will do it once for each record in your data source, but the data source is the loop, not the code.)
All that would happen there is that as each record is processed the block of code will test the DimIx function to tell whether the element is in the dimension. The first one:
Code: # skip missing Plants
IF(DIMIX('Plant,sPlant)=0);
#ItemSkip;
ENDIF;
Will do absolutely nothing because there's no live code inside the If block. It will do the test for each record in your data source, then just continue on with whatever code follows it.
If you uncomment the ItemSkip statement, it will do the test, and if the element isn't in the dimension it will skip any remaining code on the Data or Metadata tab for that data source record only, then go on to the next record from the data source and start the code again from the beginning with that one.
The second one:
Code: # skip missing Plants
IF(DIMIX('Plant,sPlant)=0);
ItemReject('Plant not found: ' |sPlant);
ENDIF;
is essentially the same as the ItemSkip, except that in addition to skipping all of the code on the tab and moving on to the next record in your data source it will also write an error message out to the process' error log. |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|