Skip to Content
0

How to truncate the extra spaces coming in a field

May 22, 2017 at 12:34 PM

82

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Hari Joshyam May 22, 2017 at 01:44 PM
1

Hello,

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

Regards,

Hari

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 22, 2017 at 12:35 PM
0

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

Expected Output: ABCDEFGHIJKLMNBBBBBBSSJJ

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 22, 2017 at 01:23 PM
0

Use condense statement.

Example:

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

Thanks

Anand

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov May 22, 2017 at 01:51 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jun 01, 2017 at 09:38 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded