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

Question on CONCATENATE behavior

Former Member
0 Likes
948

it seems concatenate will add a blank to integer, differs from dealing with string.

is there any rules?

<code>

data l_string type string.

field-SYMBOLS <fs> TYPE any.

ASSIGN l_string to <fs>.

<fs> = 5.

CONCATENATE '{' <fs> '}' INTO l_string.

WRITE: / l_string. " result = l_string = '5 '. CONCATENATE '{' l_string '}' INTO l_string. WRITE: / l_string. " result =

</code>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
927

string will automatically truncate the extra spaces.

declare l_string as like below...

data: l_string(15) type c.

you can see the difference....

it seems concatenate will add a blank to integer, differs from dealing with string.

is there any rules?

<code>

data l_string type string.

field-SYMBOLS <fs> TYPE any.

ASSIGN l_string to <fs>.

<fs> = 5.

CONCATENATE '{' <fs> '}' INTO l_string.

WRITE: / l_string. " result = l_string = '5 '. CONCATENATE '{' l_string '}' INTO l_string. WRITE: / l_string. " result =

</code>

8 REPLIES 8
Read only

Former Member
0 Likes
928

string will automatically truncate the extra spaces.

declare l_string as like below...

data: l_string(15) type c.

you can see the difference....

Read only

arpit_shah
Contributor
0 Likes
927

hi.

u can use like

CONCATENATE '{' <fs> '}' INTO l_string separated by space.

regards,

Arpit

Read only

0 Likes
927

actually, i want to eliminate the blank after it. i need instead of , and input is integer rather than string. how could i do?

Read only

i048168
Product and Topic Expert
Product and Topic Expert
0 Likes
927

Hi,

I assigned <fs> = '5'. 5 within inverted commas. Then the result is .

Regards

Vadi

Read only

Former Member
0 Likes
927

ok, i think my question is "how to convert integer to string without tailing blanks" then.

my general purpose method is following:

if i_right_operand = 5 (type i), then i will get '5 ', not '5'.

declaration

methods wrap_cond_param

importing

!i_left_operand type fieldname optional

!i_operator type uj_string optional

!i_right_operand type data

returning

value(e_wrapped_param) type uj_string

raising

cx_ujc_exception .

implementation

method wrap_cond_param.

e_wrapped_param = i_right_operand.

" deal with Escape-Characters

replace all occurrences of substring '''' in e_wrapped_param with ''''''.

" wrap Single-Quotation-Mark

concatenate '''' e_wrapped_param '''' into e_wrapped_param.

" wrap NAME OP VALUE

if i_left_operand is not initial and i_operator is not initial.

concatenate i_left_operand i_operator e_wrapped_param into e_wrapped_param separated by space.

endif.

endmethod.

Edited by: Davin Wang on Jan 3, 2008 4:30 PM

Read only

Former Member
0 Likes
927

Friend,

Try this...

CONCATENATE '{' <fs> '}' INTO l_string.

CONDENSE l_string no-GAPS.

WRITE: / l_string. " result =

Read only

0 Likes
927

thanks Ramu,

CONDENSE is very helpful for integer, but it doesn't work with string, on the opposite.

is there a ALL-IN-ONE solution?

data l_string type string.

field-SYMBOLS <fs> TYPE any.

ASSIGN l_string to <fs>.

<fs> = 5.

CONCATENATE '{' <fs> '}' INTO l_string SEPARATED BY space.

CONDENSE l_string no-GAPS.

WRITE: / l_string. " result = expected

l_string = '2 6'.

CONCATENATE '{' l_string '}' INTO l_string.

CONDENSE l_string no-GAPS.

WRITE: / l_string. " result = expected {2 6} here

Edited by: Davin Wang on Jan 3, 2008 4:38 PM

Read only

0 Likes
927

Friend,

Try this...

data: len type i.

CONCATENATE '{' <fs> INTO l_string.

len = strlen( l_string ) - 1.

l_string = l_string+0(len).

CONCATENATE l_string '}' INTO l_string.

write:/ l_string.