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

Offsetting a String, Removing SPACEs in a string, CONDENSE??

Former Member
0 Likes
2,035

Hi Experts,

I hv a string and its value is= 'ABCDEF space1 space 2 space3 space4 GHIJKL'.......I mean, there r 4 spaces, I need to hv only 1 space between these..........these number of spaces are varies and the lenghth of string also varies........so, how can I get it? like 'ABCDEF space1 GHIJKL'

thanq

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
900

Hi,

Please try the method below.

data: s1 type string,

str1 type string,

str2 type string,

. str3 type string.

s1 = 'ABCD EFGHIJ'.

split s1 at space into str1 str2.

condense str2 no-gaps.

concatenate str1 space str2 into str3.

This way, the output will always be 'ABCD EFGHIJ' irrespective of the number of spaces between the two.

Thanks!

Sandeep

PS: please mark all helpful answers

7 REPLIES 7
Read only

Former Member
0 Likes
900

i got it by splitting

Read only

Former Member
0 Likes
900

Either way:

REPORT.
data:text TYPE string VALUE 'abcd    efgh'.
CONDENSE text NO-GAPS.
CONCATENATE text+0(4) ' ' text+4(4) INTO text RESPECTING BLANKS.
WRITE text.

Read only

0 Likes
900

thanq

but, as i mentioned in my posting that, the SPACES are variable, they may b start from 3 CHAR or 4th or 5th!!

anyways thaq

Read only

0 Likes
900

hi,

i hv issue to see the complete page of SDN webpage.........I mean, am getting a width of 25.5 CM only, so, if i want to write reply, i need to go all the bottom to get scroll extreme right and then, move top, then, clicking the REPLY button..........but, in this course, am loosing my response/reply box!!

So, all u guys r gettign the same width(if so, why SAP did it like incomfortable, I guess this is a application of a net weaver) or some thing wrong with my laptop/browser-explorer(if so, How to correct myself) ??

thanq

Read only

0 Likes
900

This is the problem with every one.

Read only

0 Likes
900

ok, thanq.

Read only

Former Member
0 Likes
901

Hi,

Please try the method below.

data: s1 type string,

str1 type string,

str2 type string,

. str3 type string.

s1 = 'ABCD EFGHIJ'.

split s1 at space into str1 str2.

condense str2 no-gaps.

concatenate str1 space str2 into str3.

This way, the output will always be 'ABCD EFGHIJ' irrespective of the number of spaces between the two.

Thanks!

Sandeep

PS: please mark all helpful answers