Page 1 of 1

Can use variable in TI Variable Name?

Posted: Tue Aug 01, 2017 10:22 am
by wendyWang
Hi guys,
I'm import a .csv file to TM1 cube with TI. The file format is attached.
From column F to column Q which highlighted with yellow are product list. I don't want to hardcode each product code in TI, and want to set a loop in the TI code.

vColumnIndex =6;
while(vColumnIndex<=17);
vtypeclass = 'vColumn'|NumbertoString(vColumnIndex);

if(DIMIX('product','vColumn'|NumbertoString(vColumnIndex)) = 0);
ASCIIOutPut('c:\test.txt', vtypeclass );
ENDIF;
vColumnIndex = vColumnIndex + 1;
end;

But the output file only show "vColumn6",ideally I hope it can output column6 value 'A111'. TI consider variable vtypeclass as string,
vtypeclass = 'vColumn6'.


How can I change the vtypeclass value, and use it as variableName? Many thanks.

wendywang

Re: Can use variable in TI Variable Name?

Posted: Tue Aug 01, 2017 10:40 am
by gtonkin
Have a look on the forum for 'expand' -you should fine some posts dealing with this requirement.

Re: Can use variable in TI Variable Name?

Posted: Tue Aug 01, 2017 12:07 pm
by Drg
pStart=6
pEnd=17
vColumnIndex =pStart;

while(vColumnIndex<=pEnd);
vtypeclass = 'vColumn'|NumbertoString(vColumnIndex);

if(DIMIX('product','vColumn'|NumbertoString(vColumnIndex)) = 0);
#create variable name %VARâ„–%
vtypeclass=EXPAND( ('%vColumn'|NUMBERTOSTRING(vColumnIndex) | '%' ) )
ASCIIOutPut('c:\test.txt', vtypeclass );
ENDIF;
vColumnIndex = vColumnIndex + 1;
end;

Re: Can use variable in TI Variable Name?

Posted: Wed Aug 02, 2017 1:47 am
by wendyWang
Dear Drg & gtonkin,
The Expand() function works, the output file prints what I want. Thank you very much.


wendywang