Page 1 of 1
Determining the character length in txt using asciioutput
Posted: Tue Mar 11, 2014 7:18 pm
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
Re: Determining the character length in txt using asciioutpu
Posted: Tue Mar 11, 2014 7:49 pm
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.
Re: Determining the character length in txt using asciioutpu
Posted: Tue Mar 11, 2014 8:39 pm
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.
Re: Determining the character length in txt using asciioutpu
Posted: Tue Mar 11, 2014 8:43 pm
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 
Re: Determining the character length in txt using asciioutpu
Posted: Tue Mar 11, 2014 9:59 pm
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.

Re: Determining the character length in txt using asciioutpu
Posted: Tue Mar 11, 2014 10:59 pm
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 );
Re: Determining the character length in txt using asciioutpu
Posted: Thu Mar 13, 2014 12:27 pm
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.
Re: Determining the character length in txt using asciioutpu
Posted: Fri Mar 14, 2014 4:32 pm
by guru1988fortm1
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