ExecuteProcess - parse string

Post Reply
cfm04
Posts: 13
Joined: Fri Aug 31, 2012 6:30 am
OLAP Product: TM1
Version: 10.1
Excel Version: Excel 2007

ExecuteProcess - parse string

Post by cfm04 »

Dear all,
I'm trying to parse a string in order to use it with ExecuteProcess().

Code: Select all

tmpReturnValue = ExecuteProcess (tmpProcessString);

	IF (tmpReturnValue = ProcessExitNormal()); 			tmpReturnValueString = 'OK'; ENDIF;
	IF (tmpReturnValue = ProcessExitMinorError()); 		tmpReturnValueString = 'Minor_Error'; ENDIF;
	IF (tmpReturnValue = ProcessExitByQuit()); 			tmpReturnValueString = 'Exit_by_Quit'; ENDIF;
	IF (tmpReturnValue = ProcessExitSeriousError()); 	tmpReturnValueString = 'Serious_Error'; ENDIF;
	IF (tmpReturnValue = ProcessExitByBreak()); 		tmpReturnValueString = 'Exit_by_Break'; ENDIF;

tmpProcessString is parsed out of stored values in a cube.
I'm writing the final string to a log file which looks good to me to call the process.

From the Log file:
'RC_Create_Report_Reservation_OTB', 'PmDirectory','RC_Rep00002', 'PmFileName','REP001_ResOTB', 'PmID','1170', 'PmDate','10.01.2014', 'PmOutput','PDF'
Calling the process with the string also works. But if I try to use the shown string as a variable I get an error message:
2764 [3c] ERROR 2014-02-11 09:41:14.700 TM1.Process Process "RC_Create_Report_from_RC_Report_Config": : Could not initialize process
2764 [3c] ERROR 2014-02-11 09:41:14.700 TM1.Process RC_Create_Report_from_RC_Report_Config: No such process name: "'RC_Create_Report_Reservation_OTB','PmDirectory','RC_Rep00002','PmFileName','REP001_ResOTB','PmFMTGID','ZSys_PickUp','PmDate','01.01.2014','PmOutput','PDF'"
Any ideas?
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: ExecuteProcess - parse string

Post by Wim Gielis »

Hi

You should break it down in your cube, and retrieve the process name, parameter names and parameter values from the cube.
After that, you can execute your process with the correct parameters.
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
cfm04
Posts: 13
Joined: Fri Aug 31, 2012 6:30 am
OLAP Product: TM1
Version: 10.1
Excel Version: Excel 2007

Re: ExecuteProcess - parse string

Post by cfm04 »

Wim Gielis wrote:Hi

You should break it down in your cube, and retrieve the process name, parameter names and parameter values from the cube.
After that, you can execute your process with the correct parameters.
Actually it is broken down in the cube. But the cube has space for up to 10 parameters.
The tmpProcessString collects all necessary parameters for the specific TI.

I'm confused because if I use the string explicit in the funtion it works. If I use the variable containing the same string it doesn't.
declanr
MVP
Posts: 1815
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: ExecuteProcess - parse string

Post by declanr »

cfm04 wrote: Actually it is broken down in the cube. But the cube has space for up to 10 parameters.
The tmpProcessString collects all necessary parameters for the specific TI.

I'm confused because if I use the string explicit in the funtion it works. If I use the variable containing the same string it doesn't.

In terms of your variable; as Wim pointed out, you are (as far as TM1 is concerned) just passing in 1 string, it is not smart enough to know that you want it to split that 1 string every time it hits a comma. As such it is looking for a TI process that is called the name of your whole string (parameters, commas, spaces etc all included.)

When you type the string in manually, TM1 uses the commas and apostrophes that you type to differentiate different strings, hence why that would work.
Declan Rodger
cfm04
Posts: 13
Joined: Fri Aug 31, 2012 6:30 am
OLAP Product: TM1
Version: 10.1
Excel Version: Excel 2007

Re: ExecuteProcess - parse string

Post by cfm04 »

declanr wrote: In terms of your variable; as Wim pointed out, you are (as far as TM1 is concerned) just passing in 1 string, it is not smart enough to know that you want it to split that 1 string every time it hits a comma. As such it is looking for a TI process that is called the name of your whole string (parameters, commas, spaces etc all included.)

When you type the string in manually, TM1 uses the commas and apostrophes that you type to differentiate different strings, hence why that would work.

Ok now I understand thank you for the explanation.
So I need to find another way to call the TIs.
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: ExecuteProcess - parse string

Post by Wim Gielis »

Yes, that's true.
It depends on how you set up the other cube.
I can image that there is a dimension in that cube with "measures": for example, TI process name, parameter name 1, parameter value 1, parameter name 2, parameter value 2, parameter name 3, parameter value 3, and so on.
You should need to get the TI process name, and then loop over the parameters. If filled in, consider its value. If not filled in, do not consider that parameter.
That information will all lead to a number of IF statements because everything is so dynamic. Very clumsy...
Honestly, I do not understand the way you are working. Do you have the dimension }Processes in the cube?
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
cfm04
Posts: 13
Joined: Fri Aug 31, 2012 6:30 am
OLAP Product: TM1
Version: 10.1
Excel Version: Excel 2007

Re: ExecuteProcess - parse string

Post by cfm04 »

Wim Gielis wrote:Honestly, I do not understand the way you are working. Do you have the dimension }Processes in the cube?
Well I have the dimension }Processes but this is for an automatic report distribution based on processes and input parameters.
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: ExecuteProcess - parse string

Post by Wim Gielis »

As far as I can tell with the current information, I *think* that you want to make it too generic and too few hardcoded things in the code.
In itself, this is not bad, but first you need to get it working. After that, you can go generic and reduce the maintenance burden of the application.
Unless I don't understand your situation...
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
Harvey
Community Contributor
Posts: 236
Joined: Mon Aug 04, 2008 4:43 am
OLAP Product: PA, TM1, CX, Palo
Version: TM1 8.3 onwards
Excel Version: 2003 onwards
Contact:

Re: ExecuteProcess - parse string

Post by Harvey »

As others have noted, you need multiple variables to pass to ExecuteProcess, or it'll just assume the entire string is the name of the process.

If you want to create a way for users to call an unknown process with an unknown number of parameters, this could be done if you make an assumption of the maximum number of parameters that may be passed. I don't like using cubes to store temporary stuff to communicate between TI processes, I much prefer to use parameters and global variables.

Check out this article on my blog that talks about such issues, perhaps it'll give you some ideas how to achieve what you need.
Take your TM1 experience to the next level - TM1Innovators.net
cfm04
Posts: 13
Joined: Fri Aug 31, 2012 6:30 am
OLAP Product: TM1
Version: 10.1
Excel Version: Excel 2007

Re: ExecuteProcess - parse string

Post by cfm04 »

Wim Gielis wrote:As far as I can tell with the current information, I *think* that you want to make it too generic and too few hardcoded things in the code.
In itself, this is not bad, but first you need to get it working. After that, you can go generic and reduce the maintenance burden of the application.
Unless I don't understand your situation...
That migh be true. But I don't like to recode the cmoplete process afterwards.
I rewrote the code using some IF statements and now it's working. Nevertheless It would be nice if it wold work the other way where I can use a paresd string to start ExecuteProcess(). :)
cfm04
Posts: 13
Joined: Fri Aug 31, 2012 6:30 am
OLAP Product: TM1
Version: 10.1
Excel Version: Excel 2007

Re: ExecuteProcess - parse string

Post by cfm04 »

Harvey wrote: Check out this article on my blog that talks about such issues, perhaps it'll give you some ideas how to achieve what you need.
Nice article right now I also have my processes to write/create temporary dimensions to store array vaiables.
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: ExecuteProcess - parse string

Post by BariAbdul »

cfm04 wrote:
Wim Gielis wrote:As far as I can tell with the current information, I *think* that you want to make it too generic and too few hardcoded things in the code.
In itself, this is not bad, but first you need to get it working. After that, you can go generic and reduce the maintenance burden of the application.
Unless I don't understand your situation...
That migh be true. But I don't like to recode the cmoplete process afterwards.
I rewrote the code using some IF statements and now it's working. Nevertheless It would be nice if it wold work the other way where I can use a paresd string to start ExecuteProcess(). :)
It is really interesting situation,Appreciate if you could please post the workaround code.Thanks
"You Never Fail Until You Stop Trying......"
tomok
MVP
Posts: 2832
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: ExecuteProcess - parse string

Post by tomok »

cfm04 wrote:Nevertheless It would be nice if it wold work the other way where I can use a paresd string to start ExecuteProcess(). :)
it would work if you actually parsed the string. Based on your previous posts it appears you used the term "parse" to mean you sourced a string value from a TM1 cube. That is not parsing. Parsing is the act of separating a string into each of it's components based on the delimiter. In a CSV file that would mean looking for all the commas and separating the strings accordingly. It is possible to parse a string in a TI process but it is not easy because of limited functions for finding strings. You have to create a WHILE loop and work your way through the string using SCAN. It's not worth the effort when the easiest answer is not to combine the parameters in the first place.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
User avatar
Harvey
Community Contributor
Posts: 236
Joined: Mon Aug 04, 2008 4:43 am
OLAP Product: PA, TM1, CX, Palo
Version: TM1 8.3 onwards
Excel Version: 2003 onwards
Contact:

Re: ExecuteProcess - parse string

Post by Harvey »

cfm04 wrote:
Harvey wrote:Nice article right now I also have my processes to write/create temporary dimensions to store array vaiables.
Yeah, I think we all have our various techniques and TIs to do similar things. That's why I'm trying to get my tools and methods out there, to save developers the hassle of reinventing the wheel.
Take your TM1 experience to the next level - TM1Innovators.net
Post Reply