Page 1 of 1

Splitting of Values into 2 or more lines

Posted: Fri Apr 24, 2009 3:23 am
by poornima.chandramouli
Hi,

I've a input file which holds a column of length 20 characters.
I've to write it in the target which has the column length as 8 characters.
So the first 8 characters should be written in first line of the column & the next 8 characters should be written to the nest line,.....

But the values of the other columns should remain same.

Code: Select all

Input:

Name    Explanation
Jai         My pet name is Huby
Ram      My Pet name is Tiger

Output:

Name    Explanation
Jai         My pet name
             is Huby
Ram       My Pet name
              is Tiger
How to achieve it in datastage.

Re: Splitting of Values into 2 or more lines

Posted: Fri Apr 24, 2009 3:31 am
by nirdesh2
In Transformer, use 2 output links and write first 8 chacacter is first link and rest character in second link and then use funnel stage to combine both the output.

Posted: Fri Apr 24, 2009 3:38 am
by Sainath.Srinivasan
or easier still, convert the req char to newline.

Re: Splitting of Values into 2 or more lines

Posted: Fri Apr 24, 2009 3:39 am
by poornima.chandramouli
nirdesh2 wrote:In Transformer, use 2 output links and write first 8 chacacter is first link and rest character in second link and then use funnel stage to combine both the output.
Hi Nirdesh,

Thanks for ur reply.
But if in the case of my input having more characteres,which has to be written in more than two lines in the output,then having 2 outputs from a transformer won't workout.

Posted: Fri Apr 24, 2009 3:41 am
by poornima.chandramouli
Sainath.Srinivasan wrote:or easier still, convert the req char to newline.
Hi Sainath,

Could you please elaborate a bit.

Posted: Fri Apr 24, 2009 3:47 am
by Sainath.Srinivasan
In pseudocode.....

If you find that 'n'th char is where you need to break, do it like

Code: Select all

keyField = keyField
nonKeyField = nonKeyField[1, n - 1] : newlineChar : nonKeyField[n + 1, 9999]
I will leave it to you to derive the value of 'n' and 'newlineChar'

Posted: Fri Apr 24, 2009 4:10 am
by ray.wurlod
If you're prepared to use a server job this is a very easy task.

Code: Select all

Convert(@TM,@FM,Fmt(InLink.TheString,"8L"))
and write to a text file.

Posted: Tue Mar 09, 2010 11:02 am
by dganeshm
Sainath.Srinivasan wrote:In pseudocode.....

If you find that 'n'th char is where you need to break, do it like

Code: Select all

keyField = keyField
nonKeyField = nonKeyField[1, n - 1] : newlineChar : nonKeyField[n + 1, 9999]
I will leave it to you to derive the value of 'n' and 'newlineChar'


Need help to define the 'newlineChar' , if I give '\n' it doesnt recognise it and loads it as '\n' , what should be the value of newlingChar so that it is recognised...

Posted: Tue Mar 09, 2010 12:08 pm
by anbu
This gives a new line character
Char(10)

Posted: Tue Mar 09, 2010 12:12 pm
by dganeshm
anbu wrote:This gives a new line character
Char(10)
Thanks Anbu..