problems in string formating.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
dsedi
Participant
Posts: 220
Joined: Wed Jun 02, 2004 12:38 am

problems in string formating.

Post 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
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post by richdhan »

Hi dsedi,

The following syntax should get you through

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

HTH
--Rich
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post 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
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

Edi,

What datatype and length are your stage variables (col1 and col2) declared as?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Also possible by

Code: Select all

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

regards
kumar
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Use left function

Post 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
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Re: Use left function

Post 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
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post 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.
dsedi
Participant
Posts: 220
Joined: Wed Jun 02, 2004 12:38 am

**Intresting updates**

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You don't get a second line. DataStage is processing rows. It's not a printer driver!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

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