Page 1 of 1
Using ItemReject in the Prolog of a TI
Posted: Thu Jul 23, 2009 3:19 pm
by Steve Rowe
Something that has just caught me out which I don't remember seeing before.
I wanted to conditionally exit from the prolog of a TI and write a message to the error log.
So I wrote this in the prolog
Code: Select all
If ( test=fail );
ItemReject ('Error Msg');
ProcessBreak;
EndIf;
It doesn't work however since ItemReject forces the rest of the prolog to be skipped and so has the exact opposite affect to the one I wanted, since the ProcessBreak is never executed.
This sort of makes sense I suppose since ItemReject is intended for use in the Meta/Data tabs and does skip the single records. Anyway I just thought I'd post this so that it doesn't catch anyone else out in the future.
Cheers,
Re: Using ItemReject in the Prolog of a TI
Posted: Thu Jul 23, 2009 4:43 pm
by Wim Gielis
Hi Steve,
Just a thought... can't you execute the remainder of the Prolog conditionally (this is, if test<>fail) and then write the
Code: Select all
ItemReject ('Error Msg');
ProcessBreak;
statements at the top of the Metadata or Data tab if test=fail?
Wim
Re: Using ItemReject in the Prolog of a TI
Posted: Thu Jul 23, 2009 5:55 pm
by Steve Rowe
I don't think that would work for the same reason Wim, as soon as the ItemReject is executed the rest of that page of script is skipped so the ProcessBreak would not get executed.
Re: Using ItemReject in the Prolog of a TI
Posted: Thu Jul 23, 2009 6:15 pm
by Wim Gielis
And the ItemReject in the Prolog and the ProcessBreak in the Metadata/Data tab

Re: Using ItemReject in the Prolog of a TI
Posted: Thu Jul 23, 2009 9:31 pm
by Alan Kirk
Steve Rowe wrote:Something that has just caught me out which I don't remember seeing before.
I wanted to conditionally exit from the prolog of a TI and write a message to the error log.
So I wrote this in the prolog
Code: Select all
If ( test=fail );
ItemReject ('Error Msg');
ProcessBreak;
EndIf;
It doesn't work however since ItemReject forces the rest of the prolog to be skipped and so has the exact opposite affect to the one I wanted, since the ProcessBreak is never executed.
This sort of makes sense I suppose since ItemReject is intended for use in the Meta/Data tabs and does skip the single records. Anyway I just thought I'd post this so that it doesn't catch anyone else out in the future.
The behaviour kinda makes sense, though as I've opined before syntax like this should, IMHO, generate a syntax error given that any "Item" statement has no context in either the prolog or the epilog.
When we want to do something like this, we just write a log using AsciiOutput. Our standard "copy and paste" code for the prolog includes a lookup of log file directories (stored in a control cube) and creates an output file name which is specific to the process. (The file name is different to the "standard" error log, which helps us distinguish error outputs that we generate from those that TI generates itself.) We then just do a conditional test, spit the log out and ProcessQuit.
Re: Using ItemReject in the Prolog of a TI
Posted: Fri Jul 24, 2009 8:49 am
by Jeroen Eynikel
Keep the processbreak and move the itemreject to the epilogue should work I think.
Processbreak will make the process proceed to the epilogue, so you should still be able to have the itemreject statement in there.
Re: Using ItemReject in the Prolog of a TI
Posted: Mon Oct 21, 2013 12:17 am
by jyoung66
Thanks Jeroen Eynikel
That worked for me as well.
I too had a strange situation from this that I had not seen before the below code did not quit the process, it seemed to go to the data tab.
Any ideas why this might be happening?
sIssue = ATTRS('POS_ID',pPOS_ID,'RelIssue');
If(sIssue @= '' % DIMIX('Issue',sIssue) = 0 );
ITEMREJECT('Either there is no related issue or it is not a member of the Issue dimension');
ProcessBreak;
EndIf;
Re: Using ItemReject in the Prolog of a TI
Posted: Mon Oct 21, 2013 6:43 am
by Wim Gielis
That's because of the reasons Steve mentioned in the first post of this topic.
Re: Using ItemReject in the Prolog of a TI
Posted: Thu Nov 28, 2013 10:51 am
by zbhmida
hi
You have to put this script on DATA tab
It works for me:
#***************************************************************
If ( vtest = 1 );
ItemReject ('Error Msg');
ProcessBreak;
EndIf;
#**************************************************************
Re: Using ItemReject in the Prolog of a TI
Posted: Thu Nov 28, 2013 11:40 am
by qml
zbhmida wrote:You have to put this scrit on DATA tab
It works for me
No, it doesn't. At least not the way you think.
ProcessBreak is never executed, your TI still cycles through all Data Source rows and does a separate ItemReject for. Each. And. Every. One. Of. Them.
Re: Using ItemReject in the Prolog of a TI
Posted: Tue Apr 29, 2014 11:49 pm
by macsir
HAHA, That is interesting. I found this funny behavior for ITEMREJECT too. I have to be careful to use it next time. We can't simply combine ITEMREJECT and PROCESSBREAK/ERROR/QUIT.
It is so powerful and can skip the rest of the codes in the tab where it sits.

Re: Using ItemReject in the Prolog of a TI
Posted: Wed Apr 30, 2014 8:15 am
by Steve Rowe
How I normally do this type of thing for error handling in the prolog.
If (ErrorCondition=True);
nErrorNumber=1;
ProcessBreak;
EndIf;
Then at the start of the epilog you can take action depending on the error number you set, using itemreject or other error handling messages to flat file.
Cheers,