Combine ItemReject and ProcessQuit

Post Reply
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Combine ItemReject and ProcessQuit

Post by Wim Gielis »

Hello all

In the Prolog tab of a TI process, we usually do sanity checks.
When a check fails, I would like to inform the user: the ItemReject function comes to mind.
But the process should also give a warning and a status that the process executed with errors.
It seems that ItemReject does not lead to a status of ERROR in the message log.

If I first use ItemReject, followed by ProcessQuit, I get the ERROR status but the message in the ItemReject is not visible.

Anyone a solution/easy workaround (I mean 'easy' workaround: without using a separate cube, text files and so on)?

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Michel Zijlema »

Hi Wim,

What I usually do to get around this is to have a variable v_msg (initialized to '') to which, in case of an error (fatal) I assign a message on the Prolog tab. After setting the message I call ProcessBreak, which makes the process jump to the Epilog. On the Epilog I check whether v_msg @<> '' - if so I call ItemReject(v_msg). In this case an error will be generated.

Michel
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Wim Gielis »

Good trick. I was also experimenting with the ItemReject, but I put it in the Prolog tab.
Thanks for sharing, I will have a play with it.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Wim Gielis »

Hello

After doing this, this is what I get in the message log:

7020 [2] INFO 2012-10-10 08:57:20.067 TM1.Process Process "Budget Scenario_KickOff": finished executing normally. Check new message in the file: <TM1ProcessError_20121010085720_Budget Scenario_KickOff.log>

The status is INFO, not ERROR. And also, "finished executing normally" does not seem to indicate that the user chose an invalid parameter value.
So it's not really what I was after.

Any thoughts on this? Thanks.

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
lotsaram
MVP
Posts: 3654
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Combine ItemReject and ProcessQuit

Post by lotsaram »

Hi Wim

You can't use ProcessQuit afterItemReject on the Prolog like I think you're trying to do as code on the Prolog is executed only once and as the ItemReject will cause all subsequent code on the tab ro be skipped then the ProcessQuit is never executed hence you don't get a major error on the process.

If I have a need to do what you are attempting I use a similar method to Michel and initialize a variable for the error condition and depending on need might concatenate several fail messages together and call the ItemReject last on the Prolog just to get the message into the log. then on the next tab Data if there is a source or Epilog if there isn't then the first thing I'll do is check the error variable and ProcessQuit if it is fulfilled.

This should do what you want.
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Wim Gielis »

Hello Lotsa

Thank you for posting.

However, I do not see the ItemReject's in the Message Log. This is my code:

Prolog:

Code: Select all

# check that the new scenario does not exist yet
If(Dimix(vDim,vScenario)>0);
vErrorMessage='The new scenario already exists.';
ItemReject(vErrorMessage);
EndIf;
Epilog:

Code: Select all

If(Long(vErrorMessage)>0);
ProcessQuit;
EndIf;
I get the message in the logs that Execution was aborted by ProcessQuit function.
AND in the logs directory, I see my ItemReject message.
But in the message log, I see no line where I can double click to show me the contents of the ItemReject.

Is this also what you observe or am I missing something?

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Combine ItemReject and ProcessQuit

Post by Duncan P »

Hi Wim,
Michel Zijlema wrote:Hi Wim,

What I usually do to get around this is to have a variable v_msg (initialized to '') to which, in case of an error (fatal) I assign a message on the Prolog tab. After setting the message I call ProcessBreak, which makes the process jump to the Epilog. On the Epilog I check whether v_msg @<> '' - if so I call ItemReject(v_msg). In this case an error will be generated.

Michel
It appears that Michel is calling ItemReject in the epilog whereas you are calling it in the prolog. Have you tried it in the epilog?

Cheers,
Duncan.
Wim Gielis
MVP
Posts: 3120
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Wim Gielis »

Hello Duncan

I tried that, yes, thanks.

The result is that you can double click in the Message Log and see the ItemReject contents (message).
But the line in the Message Log appears as INFO and also it states "Process ... finished executing normally. ..."
Which is not really what I need: the process runs fine but the user chose wrong input values.
So anyhow, I would like to see this (that there are errors), plus a message that I want to set.
(I have several parameters to check, so 1 mesage for each check.)

Difficult problem it seems!

Wim
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Michel Zijlema »

Wim Gielis wrote: I get the message in the logs that Execution was aborted by ProcessQuit function.
AND in the logs directory, I see my ItemReject message.
But in the message log, I see no line where I can double click to show me the contents of the ItemReject.
Hi Wim,

I misread your initial question - I thought your problem actually was the fact that the user was not receiving an error message. It appears that (in some situations and/or TM1 versions?) the ItemReject is not giving the error notfication to the user when called from the Prolog, but will give the message when called from the Epilog... That's what my first reply was based on.
I now see that for some strange reasons an ItemReject on the Prolog or Epilog is generating an INFO message, while called from the MetaData or Data tab generated an ERROR message.
Maybe the solution Lotsa provided will help - but then using ProcessError instead of ProcessQuit?
BTW, why do you specifically need an ERROR labeled message in the message log (even if the user is notified at the end of the process)?

Michel
User avatar
paulsimon
MVP
Posts: 808
Joined: Sat Sep 03, 2011 11:10 pm
OLAP Product: TM1
Version: PA 2.0.5
Excel Version: 2016
Contact:

Re: Combine ItemReject and ProcessQuit

Post by paulsimon »

Hi Wim

I usually do this on the Prolog

Initialise an error flag

vError = 0 ;

Then do the various checks

IF( Dimix( vDim, vMyParameterElement ) = 0 ) ;
vError = 1 ;
ItemReject( 'Error ' | vMyParameterElement | ' does not exist in Dimension ' | vDim ) ;
ENDIF ;

Then at the top of the MetaData and Data Tab (depending on which is used), and the Epilog, I have

IF( vError = 1 ) ;
ProcessQuit ;
ENDIF ;

I may be imagining it but I am pretty sure that in older versions of TM1 an ItemReject on the Prolog alone was enough to stop further processing but in some version or other this changed so that it continued to the MetaData and Data Tabs, hence the need for the vError flag and the ProcessQuit. The ProcessQuit on the Epilog is needed in case there are no records on the Source and therefore the MetaData and Data Tabs don't get executed.

Anyway this works in that it stops further processing on the Prolog as soon as the error is encountered and then stops further processing on later Tabs in the Process. The process fails with an error, and you can see the error in the TM1ProcessError Log

Regards

Paul Simon
User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Combine ItemReject and ProcessQuit

Post by Martin Ryan »

Michel Zijlema wrote: What I usually do to get around this is to have a variable v_msg (initialized to '') to which, in case of an error (fatal) I assign a message on the Prolog tab. After setting the message I call ProcessBreak, which makes the process jump to the Epilog. On the Epilog I check whether v_msg @<> '' - if so I call ItemReject(v_msg). In this case an error will be generated.
Glad I'm not the only one. I always thought I was hacking things by doing this as I don't think ItemReject was really intended for the Prolog or Epilog. But at least I'm in good company.
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Post Reply