Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP script of process char string

Former Member
0 Likes
810

Hi ABAP experts,

I would like to write a ABAP script to remove additional spaces present in a string. The additional spaces present in a string will be removed and replaced with one single space character. I am not a ABAPer, so can I have your help?

For example,

String: "abc def ghi"

ABAP Process: remove additional spaces and replace with one single space character.

Expected result: "abc def ghi"

Appreciate your help,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
761

HI,

TRY THIS CODE


DATA CHAR(20) VALUE 'ABC    DEF    GHI'. (Your String)
CONDENSE CHAR.

4 REPLIES 4
Read only

Former Member
0 Likes
762

HI,

TRY THIS CODE


DATA CHAR(20) VALUE 'ABC    DEF    GHI'. (Your String)
CONDENSE CHAR.

Read only

Former Member
0 Likes
761

Hi,

You can try this way.

1.take an Internal table.

2.Split the String at space into internal table.

3.Then condense the Contents of the internal table.

4.Concatenate each row separated by space.

This will solve your problem.

Thanks & Regards,

Vamsi.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
761

Does CONDENSE not solve the problem?

Read only

0 Likes
761

Yes, the problem solved.. Thanks you all.