Hi All,
I am using Cognos TM1 9.5.2
i have an requirement to generate a .txt file from TM1 with fixed character space for the fields
(guess asciioutput is the only way to do this)
For eg.,
This is the format of the file specifications and their character length
Business unit - 5 character length and starting position 1
LOB- 7 character length and starting position 6
Year - 4 character length and starting position 14
While exporting to an .csv file using asciioutput, this is the part of my output
"31090","Fire","2014"
"31090","CAR\EAR","2014"
"31090","Marine","2014"
Desired or required output
31090 Fire 2014
31090 CAR\EAR 2014
As you can see, the certain LOB is not fixed to the length of 7 , some are short and longer and we have semi colons and commas
So, is there any possible way to fix these characters within this length in the asciioutput and so that the next field will start from the exact position
or is there any other command inTM1 like ascii output to achieve this
Thanks
Regards
Guru
Determining the character length in txt using asciioutput
-
- Posts: 42
- Joined: Mon Feb 06, 2012 5:52 pm
- OLAP Product: Cognos TM1
- Version: PA 2.0.3
- Excel Version: Micrsoft Excel 2010
- Location: Chennai, India
- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: Determining the character length in txt using asciioutpu
Guru? Really? I think you should ready up on TI variables and commands before declaring one self a guru. I think you'll find that even the reference guide pretty much covers it.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
-
- MVP
- Posts: 1828
- 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: Determining the character length in txt using asciioutpu
Code: Select all
Asciioutput ( filepath, v1 | ' ' | Subst ( v2 | ' ', 1, 7 ) | ' ' v3 );
You could also play with the fill formula.
Declan Rodger
-
- Posts: 42
- Joined: Mon Feb 06, 2012 5:52 pm
- OLAP Product: Cognos TM1
- Version: PA 2.0.3
- Excel Version: Micrsoft Excel 2010
- Location: Chennai, India
Re: Determining the character length in txt using asciioutpu
Hi Jim,jim wood wrote:Guru? Really? I think you should ready up on TI variables and commands before declaring one self a guru. I think you'll find that even the reference guide pretty much covers it.
Guru Madhesh is my real name, 1988 is my date of birth and thats why i created an userid like guru1988 for TM1

I read in the reference guide like textoutput and outputcharacterset can be used other than asciioutput
But i need to define a particular characterset for every field and every field should start from a particular position and the additonal space in the field need to be left blank
so, is there a way to do this
Thanks
Regards
Guru Madhesh

- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: Determining the character length in txt using asciioutpu
Guru that's just brilliant. If I were you I would put your full name in your sig so it appears on all your posts. 

Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
-
- Posts: 10
- Joined: Tue Oct 04, 2011 12:06 pm
- OLAP Product: tm1
- Version: 9.5.1
- Excel Version: 2007
Re: Determining the character length in txt using asciioutpu
Hi Guru,
You can use Fill function in conjunction with Long Function within it to achieve the desired result.
See if below works.
#-- Business unit
cLen = 5;
cChar = ' ';
dBU = Trim( vBusinessUnit ); (assuming this is sourced from datasource)
sBU = dBU | Fill( cChar, cLen - Long( dBU ));
#-- LOB
cLen = 7;
cChar = ' ';
dLOB = Trim( vLOB );
sLOB = dLOB | Fill( cChar, cLen - Long( dLOB ));
#-- Do the same for sYear
#-- Output to file
cDelim = ' ';
AsciiOutPut( cFile, sBU | cDelim | sLOB | cDelim | sYear );
You can use Fill function in conjunction with Long Function within it to achieve the desired result.
See if below works.
#-- Business unit
cLen = 5;
cChar = ' ';
dBU = Trim( vBusinessUnit ); (assuming this is sourced from datasource)
sBU = dBU | Fill( cChar, cLen - Long( dBU ));
#-- LOB
cLen = 7;
cChar = ' ';
dLOB = Trim( vLOB );
sLOB = dLOB | Fill( cChar, cLen - Long( dLOB ));
#-- Do the same for sYear
#-- Output to file
cDelim = ' ';
AsciiOutPut( cFile, sBU | cDelim | sLOB | cDelim | sYear );
-
- MVP
- Posts: 600
- Joined: Wed Aug 17, 2011 1:19 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2
- Excel Version: 2003 2007
- Location: York, UK
Re: Determining the character length in txt using asciioutpu
The particular variables to which Jim was obliquely referring are DatasourceASCIIDelimiter and DatasourceASCIIQuoteCharacter which will enable you to clean out the commas and double-quote characters from your output. The name prefix "Datasource" seems to indicate that they are only relevant to sources. However they apply equally well to ASCIIOutput and TextOutput.
-
- Posts: 42
- Joined: Mon Feb 06, 2012 5:52 pm
- OLAP Product: Cognos TM1
- Version: PA 2.0.3
- Excel Version: Micrsoft Excel 2010
- Location: Chennai, India
Re: Determining the character length in txt using asciioutpu
Hi All,
Thanks for all your replies!!!
The trim and fill functions had worked
Thanks Duncan, i had the issue in removing the string codes and i had this variable in my prolog tab
DataSourceASCIIQuoteCharacter = '';
And it did worked now!
This forum has always helped me in fixing issues and exploring new things , cheers and happy weekend!!
Thanks
Regards
Guru Madhesh
Thanks for all your replies!!!

The trim and fill functions had worked

Thanks Duncan, i had the issue in removing the string codes and i had this variable in my prolog tab
DataSourceASCIIQuoteCharacter = '';
And it did worked now!
This forum has always helped me in fixing issues and exploring new things , cheers and happy weekend!!

Thanks
Regards
Guru Madhesh