2008 Jan 25 8:39 AM
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.
2008 Jan 25 8:45 AM
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
2008 Jan 25 8:45 AM
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
2008 Jan 25 9:39 AM
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
2008 Jan 25 9:50 AM
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
2008 Jan 25 10:02 AM
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
2008 Jan 25 10:38 AM
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
2008 Jan 25 10:50 AM
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
2008 Jan 25 8:46 AM
Hi,
Try this
Constants: c_space(10) type c value '10 spaces'.
Concatenate str1 str2 c_space into string.
Regards,
Satish
2008 Jan 25 9:11 AM
concatenate v1 v2 into v3 separated by space.
regards.
santhosh reddy
Reward if useful
2008 Jan 25 9:15 AM
try like this...
DATA : l_space(10) value space.
CONCATENATE string1 string2 l_space INTO combined.
2008 Jan 25 9:20 AM
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