Page 1 of 1

ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 9:42 am
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?

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 10:30 am
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 10:34 am
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 10:51 am
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 10:59 am
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 1:09 pm
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?

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 1:41 pm
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 1:56 pm
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...

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 2:33 pm
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 2:35 pm
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(). :)

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 2:40 pm
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.

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 3:48 pm
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

Re: ExecuteProcess - parse string

Posted: Tue Feb 11, 2014 4:43 pm
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.

Re: ExecuteProcess - parse string

Posted: Wed Feb 12, 2014 3:23 am
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.