split the long line into multiple lines

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
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

split the long line into multiple lines

Post by sri75 »

Hi,

I need to be able to split large string variables into multiple lines, each line can be no longer than 70 chars.

The string variables are text, so I would additionally like the lines
to end at the end of a word

Now, with a limit of 70 chars per line (and lines *must* end with a
completed word)

ex-
Keying variance message to see what looks like on invoice.Keying really long first line

if I split exactly at 70 charcaters the word "Really" is goingto split into 2 lines.What I need hereis

Keying variance message to see what looks like on invoice.Keying

really long first line

can you please help me ow to do this

Thank you in advance in
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a BASIC Transformer stage (or a server job) and, within that, use the Fmt() function - which you can read about in the DataStage BASIC manual or the on-line help - with a "70T" format as the second argument. This will do precisely what you ask. Convert any text marks into field marks or newline characters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

HI Ray, Thanks for your reply.
I need to split the long line into multiple lines and write these to table records

Based on your input my idea is write this to sequential file adding some delimiter between these and read the input file by delimiter

I did like this. I added new line feed after every 70 characters and loaded into sequential file. and then read this with new line character

It is not writing to the file

field(Fmt(InvcReconMsg.BLRT_RECON_TXT, "70T"),@TM,1,1) :char(10):field(Fmt(InvcReconMsg.BLRT_RECON_TXT, "70T"),@TM,2,1)

Where did i do wrong

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

Post by ray.wurlod »

You tried to do too much. Try:

Code: Select all

Convert(@TM,@FM,Fmt(InvcReconMsg.BLRT_RECON_TXT, "70T"))
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

Thank s ray.

I am using basic transformer in paralle job

Now i can write to the seq file
KEYING VARIANCE MESSAGE TO SEE WHAT LOOKS LIKE ON INVOICE. KEYING ?REALLY LONG FIRST LINE. PLEASE PAY THE FOLLOWING ADJUSTMENTS:
now i need to read this into multiple lines and write to the table. i tried with UNIXnew line delimiter when I read the file.but it is not reading.

'?' is this the record delimiter

Thank
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

do i need to use any convert function or something like that to get unix line character in string
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No, the @FM character is automatically converted to UNIX linefeed by the DataStage internals. Check the file with a non-DataStage text viewer. Also make sure that your metadata contain just a single VarChar field when writing.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

I did check the file in UNIX.
KEYING VARIANCE MESSAGE TO SEE WHAT LOOKS LIKE ON INVOICE. KEYING ^Z REALLY LONG FIRST LINE. PLEASE PAY THE FOLLOWING ADJUSTMENTS:

there is ^Z character instead of ^M.what is ^Z

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

Post by ray.wurlod »

^Z is the DOS end-of-file marker - it has no particular meaning in UNIX.
Although you should not need to, Convert(@TM,Char(10),TheString) will do the trick.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

Thanks Ray.it worked
Post Reply