Page 1 of 1
split the long line into multiple lines
Posted: Sun Mar 20, 2011 8:23 pm
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
Posted: Sun Mar 20, 2011 8:32 pm
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.
Posted: Mon Mar 21, 2011 12:48 pm
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
Posted: Mon Mar 21, 2011 4:58 pm
by ray.wurlod
You tried to do too much. Try:
Code: Select all
Convert(@TM,@FM,Fmt(InvcReconMsg.BLRT_RECON_TXT, "70T"))
Posted: Mon Mar 21, 2011 8:12 pm
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
Posted: Mon Mar 21, 2011 8:28 pm
by sri75
do i need to use any convert function or something like that to get unix line character in string
Posted: Mon Mar 21, 2011 8:37 pm
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.
Posted: Mon Mar 21, 2011 8:58 pm
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
Posted: Mon Mar 21, 2011 11:58 pm
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.
Posted: Tue Mar 22, 2011 12:56 pm
by sri75
Thanks Ray.it worked