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 Truncating when passing from string to character

Former Member
0 Kudos

Hi Gurus,

When i pass data from string variable to character varaible, space available in the string is missing.

lv_string contains 'Hello '. when i pass this to lv_char, iam getting 'Hello'.

is there any way by which we can pass the space as well?

Regards,

Lijo Joseph

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos

Hi,

check this..

REPORT  ZTEST_sring message-id zz.

data: lv_char(10).
data: str type string.

str = 'Hello   '.

lv_char+0(10) = str.

write lv_char.

regards

vijay

0 Kudos

Hi,

Blank characters at the end of strings are not taken into account so you get space traucated when you pass string to character field.

0 Kudos

Hi Vijay,

In the code which you mention is giving length of the lv_char as 5.

it is not considering spaces...

below is the code.

***********************

data: lv_char(10).

data: str type string.

str = 'Hello '.

lv_char+0(10) = str.

lv_len = strlen( lv_char ).

write:/ 'Character Length',lv_len.

Is there any other way by which we can do this?

Regards,

Lijo Joseph

0 Kudos

Hi Lijo,

if u consider the length of the string 'Hello ', even that will be returned as 5. so the char variable picks up the 5 characters..

but if u consider ' Hello'. this returns 6 characters n hence will be passed to the char variable as such with the leading space.