Text manipulation

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Dsnew
Participant
Posts: 90
Joined: Tue Apr 19, 2005 2:08 pm

Text manipulation

Post by Dsnew »

Hi all,

I have a requirement where in I need to convert some values in a tables below.


From------------------------->To
===================================
111,22,3245,44 ------------> ##111,###22,#3245,###44
32,434-----------------------> ###32,##434
1232,3432,54,54334-------> #1232,#3432,###54,54334
.
.
.
===================================

Rule
- To pad the input data to a make it a total of 5 characters(left Pad the remaining with '#')
- The number of values in a coulmn is not fixed.
- The number of rows is not known.

I can convert the first value by using FMT and Field

FMT(Field(In.Value,',',1),"5'#'R")

How can I change it for all the values in the input?

Any inputs appreciated?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Build a routine. Count the number of fields and then loop through them, concatenating together the result.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You will need to use a routine to do this, as Craig has already suggested. The reason is that loops are not supported in transform stages, and you will need to loop the conversion statement for each column.
Dsnew
Participant
Posts: 90
Joined: Tue Apr 19, 2005 2:08 pm

Post by Dsnew »

Thanks Craig and ArndW for pointing in the correct direction.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can be done without a routine.

Code: Select all

Convert(@FM,",",Fmts(Convert(",",@FM,InLink.TheString),"5'#'R"))
This converted the comma-delimited string to a dynamic array, applied the Fmts() function to the dynamic array element-by-element, then converted the dynamic array back to a comma-delimited string.
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 »

Cool, hadn't stumbled over that particular function before this. And no wonder, it's nowhere to be found in the online help. I guess it's time for you to once again advise that I read and commit to memory the entire DataStage BASIC Guide. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply