Page 1 of 1

instr in datastage

Posted: Thu Oct 04, 2012 11:34 pm
by deeplind07
Hi,

Can some one tell me how can i search a substring from behind,(i want to search for the 1st space from the end of a string)
E.g. i want to split a note of more than 100 characters into 40 chars each. While doing so i want logically split the note, that means instead of truncating at the 40th Char i want to trunacte till the last space in the 40 cars

input String = 'Can someone tell me how can i search a substring from behind'
i want the first 40 chars until the last space
Expected output= 'Can someone tell me how can i search a '
I dont want 'Can someone tell me how can i search a s'

Posted: Thu Oct 04, 2012 11:52 pm
by ray.wurlod
By far the easiest way to accomplish this task is to use "text formatting", to do which you need to use the Fmt() function in a BASIC Transformer stage (or in a server job).
The derivation expression is

Code: Select all

Field(Fmt(InLink.TheString,"40T"),@TM,1,1)
The Fmt() function with "T" in its second argument produces a dynamic array delimited by text marks (@TM) containing substrings of not more than the specified length, broken on word boundaries. So if you need the other 40-character-or-less substrings, simply change the third argument of the encapsulating Field() function.

Posted: Fri Oct 05, 2012 12:45 am
by deeplind07
i cannot find the FMT() function in my designer

Posted: Fri Oct 05, 2012 1:36 am
by ssreeni3
Hi deeplind,

That function is available in BasicTransformer stage.

---------------------------------------------------------------------------------
Sreeni

instr in datastage

Posted: Fri Oct 05, 2012 4:19 am
by rohitagarwal15
BASIC transformer is not visible in the Proccesing palette in Parallel job. Hence we would need to bring in the BASIC transformer to our design canvas following the steps stated below:
Go to Repository tree -> Stages Types -> Parallel -> Processing -> BASIC Transformer.
Drag and drop the BASIC transformer stage to our design canvas.

Posted: Fri Oct 05, 2012 5:06 am
by PhilHibbs
I wrote a Parallel Routine tro do a similar task - search for pxStrFirstCharList for the version that finds the first occurrence of a character in a set of characters, it should be easy to create a version that finds the last, I did make one but I don't have the source for that to hand.