Using ItemReject in the Prolog of a TI

Post Reply
User avatar
Steve Rowe
Site Admin
Posts: 1920
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: 10.2.2., PAW
Excel Version: Nearly all of them

Using ItemReject in the Prolog of a TI

Post by Steve Rowe » Thu Jul 23, 2009 3:19 pm

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,

Wim Gielis
MVP
Posts: 2084
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1
Version: PAL 2.0.7
Excel Version: Office 365 - latest
Location: Brussels, Belgium
Contact:

Re: Using ItemReject in the Prolog of a TI

Post by Wim Gielis » Thu Jul 23, 2009 4:43 pm

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
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
http://www.wimgielis.com ==> 109 TM1 articles and a lot of custom code
Newest blog article: Set up a TM1 service with AutoHotKey

User avatar
Steve Rowe
Site Admin
Posts: 1920
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: 10.2.2., PAW
Excel Version: Nearly all of them

Re: Using ItemReject in the Prolog of a TI

Post by Steve Rowe » Thu Jul 23, 2009 5:55 pm

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.

Wim Gielis
MVP
Posts: 2084
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1
Version: PAL 2.0.7
Excel Version: Office 365 - latest
Location: Brussels, Belgium
Contact:

Re: Using ItemReject in the Prolog of a TI

Post by Wim Gielis » Thu Jul 23, 2009 6:15 pm

And the ItemReject in the Prolog and the ProcessBreak in the Metadata/Data tab :?:
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
http://www.wimgielis.com ==> 109 TM1 articles and a lot of custom code
Newest blog article: Set up a TM1 service with AutoHotKey

User avatar
Alan Kirk
Site Admin
Posts: 5928
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2 Classic (PAW-free zone)
Excel Version: 2010 and 2016
Location: Sydney, Australia
Contact:

Re: Using ItemReject in the Prolog of a TI

Post by Alan Kirk » Thu Jul 23, 2009 9:31 pm

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.
"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.

Jeroen Eynikel
Community Contributor
Posts: 139
Joined: Mon Sep 15, 2008 1:45 pm

Re: Using ItemReject in the Prolog of a TI

Post by Jeroen Eynikel » Fri Jul 24, 2009 8:49 am

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.

jyoung66
Posts: 24
Joined: Fri Aug 13, 2010 2:14 am
OLAP Product: TM1
Version: PAW 2 PAX
Excel Version: 2016

Re: Using ItemReject in the Prolog of a TI

Post by jyoung66 » Mon Oct 21, 2013 12:17 am

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;

Wim Gielis
MVP
Posts: 2084
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1
Version: PAL 2.0.7
Excel Version: Office 365 - latest
Location: Brussels, Belgium
Contact:

Re: Using ItemReject in the Prolog of a TI

Post by Wim Gielis » Mon Oct 21, 2013 6:43 am

That's because of the reasons Steve mentioned in the first post of this topic.
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
http://www.wimgielis.com ==> 109 TM1 articles and a lot of custom code
Newest blog article: Set up a TM1 service with AutoHotKey

zbhmida
Posts: 6
Joined: Thu Mar 28, 2013 10:12 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2016
Location: Paris, France

Re: Using ItemReject in the Prolog of a TI

Post by zbhmida » Thu Nov 28, 2013 10:51 am

hi

You have to put this script on DATA tab
It works for me:

#***************************************************************
If ( vtest = 1 );
ItemReject ('Error Msg');
ProcessBreak;
EndIf;
#**************************************************************
Last edited by zbhmida on Thu Nov 28, 2013 1:30 pm, edited 1 time in total.

User avatar
qml
MVP
Posts: 1073
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.6 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Using ItemReject in the Prolog of a TI

Post by qml » Thu Nov 28, 2013 11:40 am

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.
Kamil Arendt

User avatar
macsir
Community Contributor
Posts: 630
Joined: Wed May 30, 2012 6:50 am
OLAP Product: TM1, SSAS
Version: 9.5 - 10.2
Excel Version: 97 - 2013
Contact:

Re: Using ItemReject in the Prolog of a TI

Post by macsir » Tue Apr 29, 2014 11:49 pm

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. :D
In TM1,the answer is always yes though sometimes with a but....
http://tm1sir.blogspot.com.au/

User avatar
Steve Rowe
Site Admin
Posts: 1920
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: 10.2.2., PAW
Excel Version: Nearly all of them

Re: Using ItemReject in the Prolog of a TI

Post by Steve Rowe » Wed Apr 30, 2014 8:15 am

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,

Post Reply