2008 Jan 03 8:12 AM
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>
2008 Jan 03 8:14 AM
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>
2008 Jan 03 8:14 AM
string will automatically truncate the extra spaces.
declare l_string as like below...
data: l_string(15) type c.
you can see the difference....
2008 Jan 03 8:19 AM
hi.
u can use like
CONCATENATE '{' <fs> '}' INTO l_string separated by space.
regards,
Arpit
2008 Jan 03 8:22 AM
actually, i want to eliminate the blank after it. i need instead of , and input is integer rather than string. how could i do?
2008 Jan 03 8:25 AM
Hi,
I assigned <fs> = '5'. 5 within inverted commas. Then the result is .
Regards
Vadi
2008 Jan 03 8:28 AM
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
2008 Jan 03 8:32 AM
Friend,
Try this...
CONCATENATE '{' <fs> '}' INTO l_string.
CONDENSE l_string no-GAPS.
WRITE: / l_string. " result =
2008 Jan 03 8:36 AM
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
2008 Jan 03 8:42 AM
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.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |