Page 1 of 1
Combine ItemReject and ProcessQuit
Posted: Tue Oct 09, 2012 10:24 am
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
Re: Combine ItemReject and ProcessQuit
Posted: Tue Oct 09, 2012 11:10 am
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
Re: Combine ItemReject and ProcessQuit
Posted: Tue Oct 09, 2012 11:12 am
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.
Re: Combine ItemReject and ProcessQuit
Posted: Wed Oct 10, 2012 9:01 am
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
Re: Combine ItemReject and ProcessQuit
Posted: Wed Oct 10, 2012 6:23 pm
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.
Re: Combine ItemReject and ProcessQuit
Posted: Thu Oct 11, 2012 11:00 am
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
Re: Combine ItemReject and ProcessQuit
Posted: Thu Oct 11, 2012 12:21 pm
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.
Re: Combine ItemReject and ProcessQuit
Posted: Thu Oct 11, 2012 12:32 pm
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
Re: Combine ItemReject and ProcessQuit
Posted: Thu Oct 11, 2012 6:36 pm
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
Re: Combine ItemReject and ProcessQuit
Posted: Thu Oct 11, 2012 11:31 pm
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
Re: Combine ItemReject and ProcessQuit
Posted: Fri Oct 12, 2012 3:17 am
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.