Page 1 of 1

problems in string formating.

Posted: Wed Sep 14, 2005 5:20 pm
by dsedi
Hi All,

In one of Our PX job,we need to cancatenate several stage variables to form a line of text which will be used for Email.

we are using a transformer to do this cancatenation and populating
a .TXT file which will be used by Dsmail.

we are facing issues while doing the cancatenation.
Irrespective of length of the first variable, we need to print the second in a particular position.

for example
if i have col1 and col2, we want to print col2 in 20th position..no matter about the string length of col1.


for this, currently we are using the space function in the transformer.

col1 : space(20-len(col1)) : col2

which is not at all working where as if we use space() separately or len() separately it's working.

any valuable idea's to achive this.

Thanks in advance
Edi

Posted: Thu Sep 15, 2005 1:01 am
by richdhan
Hi dsedi,

The following syntax should get you through

col1 : Str(" ", 20 - Len(col1)): col2

HTH
--Rich

Posted: Thu Sep 15, 2005 5:43 am
by chulett
Rich, curious how that's different from what they already tried and asserted "is not at all working"? They seem highly equivalent to me. :?

Posted: Thu Sep 15, 2005 6:07 am
by richdhan
Hi Craig,

I have used the following syntax in my ETL jobs and it works fine. Thats why I suggested it eventhough it seems equivalent. Lets wait for dsedi's response.

--Rich

Posted: Thu Sep 15, 2005 6:29 am
by thompsonp
Edi,

What datatype and length are your stage variables (col1 and col2) declared as?

Posted: Thu Sep 15, 2005 6:49 am
by chulett
Unless this is another one of those things that are different in PX, stage variables are not declared as any particular datatype or length.

Posted: Thu Sep 15, 2005 8:07 am
by kumar_s
Also possible by

Code: Select all

PadString(col1," ", (20-Len(col1))) 

regards
kumar

Use left function

Posted: Thu Sep 15, 2005 8:40 am
by Nageshsunkoji
Hi,

I think left function in transformer stage will resolve your problem, the syntax is as follows

Left(col1,19):col2

now the col2 will start from 20 th opsition.


Thanks&Regards
Nagesh

Re: Use left function

Posted: Thu Sep 15, 2005 8:49 am
by kumar_s
Nageshsunkoji wrote:Hi,

I think left function in transformer stage will resolve your problem, the syntax is as follows

Left(col1,19):col2

now the col2 will start from 20 th opsition.


Thanks&Regards
Nagesh
No nagesh,
Left() function gives 'n' character from left of the specific set.
But the requirment is different.

regards
kumar

Posted: Thu Sep 15, 2005 9:06 am
by thompsonp
Nobody can give a solution that is certain to work until we know how long these two stage variables are (and presumably therefore the datatypes of the columns that populated them).

One of the earlier solutions works if col1 is less than 20 characters and one works if it is 20 or more characters.

Tell us a bit more about the problem and we can give you a proper answer.

**Intresting updates**

Posted: Thu Sep 15, 2005 1:48 pm
by dsedi
Helo Rich,Craig,thom,kumar,Nagesh

Thanks Very much Everyone for the valuable inputs.

ok...Here are the updates.

Rich : Your Idea of using str() function is working fine..

here is my exact code in the transformer.

Code: Select all

AssetDesc1 : STR(" ",38- LEN(AssetDesc1) ) : AssetDesc2
Result :

Code: Select all

 HITACHI CAPITAL(UK)                   ORD GBP0.25
Thanks Very Much Rich.. :D


Kumar : I tried your Idea of using padstring but I got Fatel error.

Code: Select all

PadString(AssetDesc1," ", (20-Len(AssetDesc1))) : AssetDesc2
Fatel Error

Code: Select all

FormatTextLine,0: Failure during execution of operator logic
Nagesh : while i was using your idea, nothing Happened...

Code: Select all

Left(AssetDesc1,19): AssetDesc2
Result :

Code: Select all

HITACHI CAPITAL(UK)ORD GBP0.25
Tom :

Code: Select all

 What datatype and length are your stage variables 
I am able to assign datatype like any other properties for stage variables and it is varchar of 100 for both.
Kindly advise me reagrding this.

so, Thanks again everyone.

Now the Next move... :D

If The string length of "AssetDesc1" is going to be more then expected then i want that should be Printed in the second line (I.e without moving the "AssetDesc2" printing position)

It would be great if..

Code: Select all

xxxxxxxx               yyyyy
xxx                   
Expecting all you again here.

Thanks again,
Edi

Please note that totally i am using 5 stage variables like this.for easier look i have mentioned only 2 of them.

Posted: Thu Sep 15, 2005 4:11 pm
by ray.wurlod
You don't get a second line. DataStage is processing rows. It's not a printer driver!

Posted: Thu Sep 15, 2005 11:08 pm
by kumar_s
Hi
you can try using another variable which holds the excess value untill next row comes in and it can be concatinated

regards
kumar