Skip to Content
avatar image
Former Member

How to truncate the extra spaces coming in a field

I have created a mapping. There is a source field which contains some data and its coming with spaces between the data. Now i don't want spaces in output. How to remove extra spaces.

Source Field= ABCD EFGHIJKLMNBBBBBBSSJJ

Expected Output: ABCDEFGHIJKLMNBBBBBBSSJJ

Please help on priority

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • May 22, 2017 at 01:44 PM

    Hello,

    You can use Replace function - ' ' with ''.

    Regards,

    Hari

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2017 at 12:35 PM

    Source Field= ABCD*********************************EFGHIJKLMNBBBBBBSSJJ

    Expected Output: ABCDEFGHIJKLMNBBBBBBSSJJ

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2017 at 01:23 PM

    Use condense statement.

    Example:

    https://archive.sap.com/discussions/thread/402285

    Thanks

    Anand

    Add comment
    10|10000 characters needed characters exceeded

  • May 22, 2017 at 01:51 PM

    Hi Ankit!

    This java expression returns the string without extra spaces. You can use it in UDF.

    <code>String myStr = myStr.trim().replaceAll(" +"," ");

    If you need to remove ALL the spaces, not just the EXTRA spaces, you can use suggestion given above.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 01, 2017 at 09:38 AM

    Hi Ankit,

    You can use Standard Mapping function "trim" to remove the spaces. No need to use UDF.

    If you need to remove * then use standard function "ReplaceString" in the mapping. Input1: Your string; Input2: "*"; Input3: "" (Ignore " double quotes)

    Thanks/Lokesh

    Add comment
    10|10000 characters needed characters exceeded