Search code examples
datastage

trim Leading and trailing spaces without using transform stage in datastage


I am trying to remove leading and trailing spaces in datastage. In Transform stage we can use TrimLeadingTrailing(ID) to achieve this. But without using transform stage , i am trying to use Modify stage . Below is the code

id = string_trim[" ",begin,end](id)

In any of the case by using String_Trim function , only leading or trailing spaces are getting removed. I am unable to achieve both the things.

Please help if there is any way.

Sample Input :

"    Abc  Yyyy    "

Sample Output:

"Abc  Yyyy"

Solution

  • Well look at the function definition this is obvious

    string_trim[NULL, begin](name)
    

    will remove all leading ASCII NULL characters from the beginning of name

    string_trim['X', end, begin](text)
    

    will remove all trailing X chars from text

    Becasue of this "direction" you cannot do both at the same time