cancel
Showing results for 
Search instead for 
Did you mean: 

How to truncate the extra spaces coming in a field

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member229310
Active Participant

Hello,

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

Regards,

Hari

Former Member
0 Kudos

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

former_member190293
Active Contributor
0 Kudos

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.

anand_sagarsethi
Contributor
0 Kudos

Use condense statement.

Example:

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

Thanks

Anand

Former Member
0 Kudos

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

Expected Output: ABCDEFGHIJKLMNBBBBBBSSJJ