Variable not registering in Advanced tabs

lotsaram
MVP
Posts: 3698
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Variable not registering in Advanced tabs

Post by lotsaram »

Steve Vincent wrote:Would you mind expanding on that? I recently got a need to have one TI to run after another and they use the same ASCII data source. I'd like the 2nd one to read the path the 1st one is using, is that what you are meaning and if so how?
Either parametrize the second process and call from the Epilog of the first process
Eg.
ExecuteProcess('Proc 2', 'pDataSource', DatasourceNameForServer);

Or
Run both processes from a shell process, declare a global process variable and set it to DatasourceNameForServer of the 1st process within that process.

Or
Write DatasourceNameForServer to a string value in a control cube as per Alan's suggestion. This is the option that I would go with most of the time.
Alan Kirk
Site Admin
Posts: 6645
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Variable not registering in Advanced tabs

Post by Alan Kirk »

lotsaram wrote:
Steve Vincent wrote:Would you mind expanding on that? I recently got a need to have one TI to run after another and they use the same ASCII data source. I'd like the 2nd one to read the path the 1st one is using, is that what you are meaning and if so how?
Either parametrize the second process and call from the Epilog of the first process
Eg.
ExecuteProcess('Proc 2', 'pDataSource', DatasourceNameForServer);

Or
Run both processes from a shell process, declare a global process variable and set it to DatasourceNameForServer of the 1st process within that process.
Also good ideas. Alas I often overlook them because on 8.2.12 we don't have ExecuteProcess. :(
"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.
User avatar
Martin Ryan
Site Admin
Posts: 1989
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Variable not registering in Advanced tabs

Post by Martin Ryan »

Alan Kirk wrote: Although I haven't tested it, I would expect any process (Variables tab) variables to retain the values that they had from the last row of data when the Epilog is executed...
Coming to this late, but yes, this is the case. For example, when I'm feeling too lazy to run an asciioutput and I want to see how many rows are being processed I can put count=0; in the prolog tab, count=count+1; in the data tab then itemreject(trim(str(count, 10,0))); in the Epilog.

Another point out of the above, is that data held variables can be retained from one iteration of the metadata or data tab to the next.

Variables are not destroyed until the end of the Epilog.

Martin
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
Alan Kirk
Site Admin
Posts: 6645
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Variable not registering in Advanced tabs

Post by Alan Kirk »

Martin Ryan wrote:
Alan Kirk wrote: Although I haven't tested it, I would expect any process (Variables tab) variables to retain the values that they had from the last row of data when the Epilog is executed...
Coming to this late, but yes, this is the case. For example, when I'm feeling too lazy to run an asciioutput and I want to see how many rows are being processed I can put count=0; in the prolog tab, count=count+1; in the data tab then itemreject(trim(str(count, 10,0))); in the Epilog.
Technically this is dodgy as well. While it does indeed spit an error log containing the item reject information, it's a syntax error rather than a true ItemReject. Neither ItemReject nor ItemSkip have any context in the Epilog tab either since there isn't any "item". I'd rather do an AsciiOutput since at least that way I avoid a bogus error message if I'm triggering the chore manually. (Cue John with a sermon on TI Errors and the relative use/fulness/lesness thereof. :D )

It works, but it's not something I'd want the kids to see me doing. ;)

Though in reality I do indeed do a count of how many items are (a) in the data set (b) Have been intentionally rejected (c) have been intentionally skipped and (d) have been processed, and write the whole lot to my control cube.

But we all know that I'm a rivet-counter. :?
Martin Ryan wrote: Another point out of the above, is that data held variables can be retained from one iteration of the metadata or data tab to the next.

Variables are not destroyed until the end of the Epilog.
Generally that's true, and in the case of code-defined variables it's always true (the values will carry from one tab to the other), but I was referring to the special case of the variables which are defined on the Variables tab rather than those which are defined within the Advanced tabs.

I decided it was time to test it out to confirm it one way or t'other and have found what others have suggested in this thread... the variables tab variables will ONLY have a value if there is code in the Metadata or Data tabs. This was the part that I wasn't sure about. If you don't have any code in either of those tabs, then the data set will never be iterated, and the variables will never be populated. In such a case what you'll find in the Epilog wouldn't be the values from the last row of data, but rather the "uninitialised" (if I may use the term loosely) values of 0 or an empty string, depending on the data type.

If you DO have code in either of those tabs, then when the Epilog is reached the variables will hold the values that they had from the last row of data in the dataset.

(Tested in 9.0 SP3.)
"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.
User avatar
Martin Ryan
Site Admin
Posts: 1989
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Variable not registering in Advanced tabs

Post by Martin Ryan »

Alan Kirk wrote: Technically this is dodgy as well. While it does indeed spit an error log containing the item reject information, it's a syntax error rather than a true ItemReject. Neither ItemReject nor ItemSkip have any context in the Epilog tab either since there isn't any "item". I'd rather do an AsciiOutput since at least that way I avoid a bogus error message if I'm triggering the chore manually. (Cue John with a sermon on TI Errors and the relative use/fulness/lesness thereof. :D )
My point was that (user defined) variables are persistent. I completely agree the use of an ItemReject in either the prolog or epilog is not "robust" coding, it does however serve my purposes on the odd occasion.

Martin
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