Intelligent word wrapping

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

Shah_h
Participant
Posts: 21
Joined: Fri Sep 11, 2009 6:06 am

Intelligent word wrapping

Post by Shah_h »

I have a requirement to read a field with Datatype Varchar2(800) from oracle table and split it into 20 columns of 40 characters each. However, if the word being read is not complete at the end of 40 characters for a particular line, then i need to wrap the line at a previous word and put this word on a new line .

For eg. the input field is like :
"I have a requirement to read a field with Datatype Varchar2(800) from oracle table and split it into 20 columns of 40 characters each."

I want to read the first 40 characters from this line but say the 40th character ends at "Ora" of the word "oracle", i need to end the line on the previous word "from" and put oracle on the next line.

I understand from other posts that such a thing can be done using Column Import but do not know how to use it.
Can anyone please help on how do i achieve this ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... I seem to recall Ray mentioning the Fold() function for this but can't check at the moment.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

There's nothing out of the "natively parallel" box that will do this for you, but you could write your own routine.

That said, you can use a server job, a server shared container or a BASIC Transformer stage and make use of the Fmt() function. For example load a stage variable, let's call it svChoppedString, with

Code: Select all

Fmt(InLink.LongString, "20T")
Define column1 as Field(svChoppedString,@TM,1,1).
Define column2 as Field(svChoppedString,@TM,2,1).
And so on.

The "20T" in the Fmt() function specifies 20 character maximum width, "text formatting" (= break on whole word boundaries).
Note that you may need more than 40 fields, perhaps 41 or 42.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... no Folding? What the heck am I misremembering? :(
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Fold() breaks on length boundaries, not word boundaries.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Shah_h
Participant
Posts: 21
Joined: Fri Sep 11, 2009 6:06 am

Post by Shah_h »

Ray, Could you please explain what is this "@TM" in the function :

Field(svChoppedString,@TM,1,1)

And thanks for the info. I will try this out.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

When the Fmt() function breaks the string, it inserts a special delimiter called a "text mark" in at each break point. This special character is available through the system variable @TM. Internally it is represented by the single byte whose decimal value is 251 (or 0xFB if you prefer).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ray.wurlod wrote:Fold() breaks on length boundaries, not word boundaries.
Phooey.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Shah_h
Participant
Posts: 21
Joined: Fri Sep 11, 2009 6:06 am

Post by Shah_h »

Hi Ray, i tried using the Fmt() function you suggested, however the problem is we are using DataStage 7.5 which does not have a BASIC transformer and the Transformer doesnt support Fmt() Function.

Any possible alternative to this ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Shah_h wrote:the problem is we are using DataStage 7.5 which does not have a BASIC transformer
It does.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Shah_h
Participant
Posts: 21
Joined: Fri Sep 11, 2009 6:06 am

Post by Shah_h »

Under Processing tab in Palette, i am able to see only Transformer stage and not a BASIC Transformer ?
Shah_h
Participant
Posts: 21
Joined: Fri Sep 11, 2009 6:06 am

Post by Shah_h »

I even tried customizing the Palette but could not find the a BASIC transformer stage in Processing(Parallel) nor in Processing(Server).
antonyraj.deva
Premium Member
Premium Member
Posts: 138
Joined: Wed Jul 16, 2008 9:51 pm
Location: Kolkata

Post by antonyraj.deva »

I even tried customizing the Palette but could not find the a BASIC transformer stage in Processing(Parallel) nor in Processing(Server).


The transformer available under the processing tab of server job is conventionally referred to as "Basic" Transformer. :wink:

-Tony
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's not on the Palette. The BASIC Transformer stage is to be found in the Stage Types branch of the Repository. It is NOT the same as the server Transformer stage - for example the BASIC Transformer stage does not support reference inputs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

If you wish to fold the text, what will happen to the key fields ?

Do you expect all other columns to be left blank for non-first lines ?
Post Reply