Application Development 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: 

space after text

Former Member
0 Kudos

hi guys,

i have a string,

i want to display it with spaces at the end.

how do i do it?

say i have the following:

string1 type c.

string2 type c.

combined type c.

i want to combine string1 and string2 into combined with 10 spaces at the end of combined.

how?

tnx.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Laure

Please check if the below code helps...

-


data : len type i.

concatenate string1 string into combined.

len = strlen( combined ).

combined+len(10) = CL_ABAP_CHAR_UTILITIES=>SPACE_STR.

-


Kind Regards

Ranganath

PS : Reward points for all useful answers.

Edited by: Ranganath Ramesh on Jan 25, 2008 9:45 AM

Edited by: Ranganath Ramesh on Jan 25, 2008 9:48 AM

10 REPLIES 10

Former Member
0 Kudos

Hi Laure

Please check if the below code helps...

-


data : len type i.

concatenate string1 string into combined.

len = strlen( combined ).

combined+len(10) = CL_ABAP_CHAR_UTILITIES=>SPACE_STR.

-


Kind Regards

Ranganath

PS : Reward points for all useful answers.

Edited by: Ranganath Ramesh on Jan 25, 2008 9:45 AM

Edited by: Ranganath Ramesh on Jan 25, 2008 9:48 AM

0 Kudos

hi Ranganath,

your help looks promising but when i tried to activate the program, i get an error

at line combined+len(10) = CL_ABAP_CHAR_UTILITIES=>SPACE_STR.:

"BACKSPACE-" expected, not "SPACE_".

can you check?

tnx,

laure

0 Kudos

Hi Laure

Please check whether you have the class CL_ABAP_CHAR_UTILITIES in SE24 and in that Attributes as SPACE_STR. Also try with the option CL_ABAP_CHAR_UTILITIES -> SPACE_STR.

Regards

Ranganath

0 Kudos

hi Ranganath,

yes i have that space_str attribute but i get the same error.

how should i declare the combined variable?

i had it declared as string.

regards,

laure

0 Kudos

Hi Laure

Apologies for wrong suggestion. Just forgot to check that attribute is a Private member in the class, you cannot access it directly. One option would be inherit that class and later use that attribute in your program, which need lots of efforts.

Else other approach would be to declare a constant of 10 characters and for the value part between the quotes - Hold the ALT key and press the number 0160 from numpad in your kepboard i.e. the ascii value for space. This will give you 1 space, you can copy paste this value for subsequent 9 chars.

Hope this helps.

Regards

Ranganath

0 Kudos

hi Ranganath,

the ascii technique works fine for me.

all i have to do now is to figure out how to make the number of spaces dynamic (coz it's not always 10 as my sample indicates).

thanks for the effort.

10 points for you.

tnx,

laure

Former Member
0 Kudos

Hi,

Try this

Constants: c_space(10) type c value '10 spaces'.

Concatenate str1 str2 c_space into string.

Regards,

Satish

SantoshKallem
Active Contributor
0 Kudos

concatenate v1 v2 into v3 separated by space.

regards.

santhosh reddy

Reward if useful

Former Member
0 Kudos

try like this...


DATA : l_space(10) value space.
CONCATENATE string1 string2 l_space INTO combined.

Former Member
0 Kudos

Hi,

Let suppose your string1 has length 5 char and string2 has length 3 char now you want 10 spaces in combined_string with these 2 strings, then you can do this

data:string1(5) type c,

string2(3) type c,

combined_string(20) type c.

CONCATENATE string1 string2 into combined_string separated by space.

This will meet your requirement.

Rgds,

Bujji