Skip to Content
avatar image
Former Member

UDF for Removing Single Space

Hi Experts,

The Source field SourceField1 is mapped to TargetField1 and the length of TargetField1 is of 20 characters only. Lets Suppose If I'm getting one space in the begining then it is causing the problem while generating value in Target.

Lets suppose the value in <SourceField1>00007633574593990389</SourceField1> then the exact value will go in target field, but if there a single space than I may not get the exact value (<SourceField1> 00007633574593990389</SourceField1> then <TargetField1> 0000763357459399038</TargetField1>) . Can anybody provide me UDF wherein I should check if first character is space then it should ignore it and pass correct value.

Regards

Faisal.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Nov 08, 2011 at 08:38 PM

    use standard text function trim() to remove leading (in the beginning empty space) and trailing (ending) space. You dont need UDF for this.

    Source field --> trim -> target field

    If you want udf still same, create simple udf function pass source value as string parameter (ex str) and return value as string

    Example:

    public String trimString(str a){

    return str.trim();

    }

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 08, 2011 at 09:30 PM

    Hello,

    You can use this logic:

                      SourceField1 -> substring: 1..20 -> \
    SourceField1 -> substring:0..1 -> equalsS -> ifThenElse -> Target
                         Constant: -> /   SourceField1 -> /
    

    note: value of Constant is a space

    Hope this helps,

    Mark

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 09, 2011 at 06:14 AM

    Hi Fisal,

    U no need to use any UDF for this.

    As Basker Gopal mentioned you can use the Trim function.

    Regard's

    Preethi.

    Add comment
    10|10000 characters needed characters exceeded