Page 1 of 1

Avoid copying code á la Wim Gielis

Posted: Mon Sep 06, 2010 8:36 am
by bskalli
I use very much the method Wim Gielis, Avoid copying code.
But I still have not found any possibility that the n-fund on the shows of the n-variable inputs,
it would be an art activation.
I do not want to know how the variable is called but its content
I speak about a text input in a ti Process

Any idee ?

if you write +Param01+ in MDX, you mean the value of your Param01.
Is there anything comparable in TI ?

Re: Avoid copying code á la Wim Gielis

Posted: Thu Sep 09, 2010 12:02 pm
by bskalli
where are our Gurus?

On vacation?

Re: Avoid copying code á la Wim Gielis

Posted: Thu Sep 09, 2010 12:54 pm
by David Usherwood
I wish :)
I can't speak for others but I am afraid I don't have the faintest idea of what your posting was about - hence the lack of response.

Re: Avoid copying code á la Wim Gielis

Posted: Thu Sep 09, 2010 2:52 pm
by drbot
Do you want to place parameters or variables inside an mdx-expression in a ti process?
It works with string concatenation. If your parameter name is pCountry and you want to check if it is an element of your [countries] dimension, then use
TM1FILTERBYPATTERN({TM1SUBSETALL( [countries] )},'|'"'|pCountry|'"'|')}
Watch out for single and double apostrophes - the double apostrophes are only necessary because i used TM1FILTERBYPATTERN. Otherwise '|pCountry|' should be ok.

Hope that helps

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 6:09 am
by bskalli
Thanks Drbot und David.
Short question:
how can I read data within a three loop from an input ?

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 6:20 am
by Alan Kirk
bskalli wrote:Thanks Drbot und David.
Short question:
how can I read data within a three loop from an input ?
Short answer: that question isn't any clearer than your first one.

- What input, exactly? From what source? Are we talking about a process parameter? A cube view as a data source? A Text file as a data source? A CellGetN/CellGetS statement somewhere in your code?
- What do you mean by a "three loop"? Are you talking about three nested While loops? A While loop that iterates three times? Something else? Is this loop within the Prolog? Or is it on the Data tab? Or is it on the Metadata Tab? Or is it something in an obscure corner of The Discovery Channel?
- What do you mean by "read" it given that if it's an "input" it is, by definition, already "read".

As the Request for Assistance Guidelines say,
Try to make the question as specific as possible.

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 7:13 am
by bskalli
Hello Alan,
I have a text-file as Data-Source with three variables.
I want to transfer the value of this variable within a loop.

I know that the last line is wrong:

MyDims='Column01§Column13§Column27§';
WHILE(LONG(MyDims)>0);
Column=SUBST(MyDims,1,SCAN('§',MyDims)-1);
x=+Column+;


the only solution I know is the following:
If (Colum@='Column01'); x=Column01;
ElseIf (Column@='Column13'); x=Column13;
ElseIf (Column@='Column27'); x=Colum27;
EndIf;

Hopful

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 8:00 am
by Michel Zijlema
Posting this code fragment doesn't make it much clearer what you're trying to establish...

I assume that the WHILE statement is followed somewhere in your code by an END statement.
I see that in the WHILE statement you check for the length of the MyDims string value - is this length reduced anywhere in the WHILE loop before the END statement? Otherwise the loop will never end.
The last statement you posted contains an invalid construct - what value exactly do yo want to assign to the x variable? If this needs to be the value of the Column variable (as per your first post in this thread) than x = Column; would be sufficient (where the variable Column will contain the value 'Column01' in the first iteration of your WHILE loop).

Michel

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 11:20 am
by Wim Gielis
Hello

Michel is right, at the bottom of the code, the string should become smaller:

MyDims=DELET(MyDims,1,SCAN('§',MyDims));

And the WHILE loop should be closed with an END;

For those interested, check out the article on my website with the same name: "Avoid copying code".

bskalli,

I more or less understand what you are trying to do. Unfortunately, in TI you cannot "create" variables out of a text string. My method, however, can be used for many other loops, cases where statements are executed for a number of similar objects. There is no better workaround than what you were proposing in your (pseudo-)code.

Wim

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 12:04 pm
by bskalli
Hello Wim, I know your code and I use it too.
You're the first who told me that there is no activation in TI.
I have my answer.
Hello Michel,
Of course there are a lot of code inside the loop,
Read attributes, arithmetic, writing in a cube ...
Thank you for your patience

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 12:30 pm
by bskalli
Hello Wim, here is an example of your method without loop,
rather than one dimension to be defined with attributes.

CompanyCode='00301';

T_I='&00011&00013&00301&00338&';
T_O='&58012&58043&56002&56061&';
Firma=Subst(T_O,Scan(CompanyCode,T_I),5);


bskalli

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 12:36 pm
by Wim Gielis
You are right with the example.

Drawback is that maintenance is more difficult (changing an attribute is easier than going in the TI code - also permissions wise). Also, attributes cubes can be filled by rules for instance, here in the TI code it's hardcoded.

The loop idea can be used for fixed, rather random, enumerations, with which we will not do much in the TM1 model itself (as opposed to an alias for instance).

Thanks for reflecting on the hint I gave.

Wim

Re: Avoid copying code á la Wim Gielis

Posted: Fri Sep 10, 2010 1:16 pm
by bskalli
Hi Wim,
in order to avoid defining a dimension for every TI_Process , I have implemented a single dimension ,
which elements are as follows: PGMnn.Elemnn.Valuenn and some attributes.

And my former Request deals with : Valuenn.

bskalli