Determining the character length in txt using asciioutput

Post Reply
guru1988fortm1
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

Determining the character length in txt using asciioutput

Post by guru1988fortm1 »

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
User avatar
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

Post by jim wood »

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
declanr
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

Post by declanr »

Code: Select all

Asciioutput ( filepath, v1 | ' ' | Subst ( v2 | '       ', 1, 7 ) | ' ' v3 );
Edit - written on my phone that seems to have removed extra spaces; I'd stick 7 in after v2 to guarantee its at least 7 in length after the subnm. Also I only answered after the now deleted reply to Jim's comment provided me with great amusement.

You could also play with the fill formula.
Declan Rodger
guru1988fortm1
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

Post by guru1988fortm1 »

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.
Hi Jim,

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 ;)
User avatar
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

Post by jim wood »

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
amin
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

Post by amin »

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 );
Duncan P
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

Post by Duncan P »

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.
guru1988fortm1
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

Post by guru1988fortm1 »

Hi All,

Thanks for all your replies!!! :D

The trim and fill functions had worked :D

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!! 8-)

Thanks
Regards
Guru Madhesh
Post Reply