2013 Sep 19 9:31 AM
Hi,
Im new in ABAP developmet.
Please help.
I need to CONCATENATE integer and a char.
EXAMPLE:
data: v_num1 type i value 11,
v_num2 type i value 14,
v_res type i,
v_percent type c value '%',
v_concat type string.
v_res = (v_num1 / v_num2) * 100. " to get the percentage.
CONCATENATE v_res v_percent into v_concat. "<===== is this POSSIBLE. if not HOW?
I need to output, v_res%
thanks..
2013 Sep 19 9:37 AM
You can only concatenate character fields.
Move the integer field to a character or string field and do the concatenation.
data v_res_c type string.
move v_res to v_res_c.
concatenate v_res_c v_percent into v_concat.
Hi,
Im new in ABAP developmet.
Please help.
I need to CONCATENATE integer and a char.
EXAMPLE:
data: v_num1 type i value 11,
v_num2 type i value 14,
v_res type i,
v_percent type c value '%',
v_concat type string.
v_res = (v_num1 / v_num2) * 100. " to get the percentage.
CONCATENATE v_res v_percent into v_concat. "<===== is this POSSIBLE. if not HOW?
I need to output, v_res%
thanks..
2013 Sep 19 9:37 AM
You can only concatenate character fields.
Move the integer field to a character or string field and do the concatenation.
data v_res_c type string.
move v_res to v_res_c.
concatenate v_res_c v_percent into v_concat.
2013 Sep 19 9:42 AM
Define another field type stirng and place v_res in there after the calculation. Use that field in stead in your concatenate statement. . In your case with v_res being integer you will get 100 %.
If you define v_res with decimals you will get a better result I think e.g:
DATA: v_num1 TYPE i VALUE 11,
v_num2 TYPE i VALUE 14,
v_res TYPE p DECIMALS 3,
v_percent TYPE c VALUE '%',
v_concat TYPE string,
v_string_res TYPE string.
v_res = ( v_num1 / v_num2 ) * 100. " to get the percentage.
v_string_res = v_res.
CONCATENATE v_string_res v_percent INTO v_concat.
2013 Sep 19 9:44 AM
In addition of Susmitha,
You can CONCATENATE Numc(Numeric text). So do the same thing use numc as place of I(interger).
demo code:
data lv_str TYPE numc2.
data lv_str1 TYPE string.
CONCATENATE lv_str lv_str1 INTO lv_str1.
2013 Sep 19 9:51 AM
As everybody said above, You need to copy integer variable to another character variable and then concatenate both the fields.
This will resolve your problem.
Thanks
Siddarth
2013 Sep 19 9:59 AM
Hello Reiner,
CONCATENATE statement will not allow any integer variable to be part of its argument.
Try using a temporary variable to store v_res after the calculation and do concatenation with that variable.
Like..
DATA: v_temp(3) TYPE c.
v_res = (v_num1 / v_num2) * 100. " to get the percentage.
v_temp = v_res.
CONCATENATE v_temp v_percent into v_concat.
2013 Sep 19 10:35 AM
Hi,
CONCATENATE wont work with integer ,You can do the following
Change the type of the variable v_res to string or character type OR Assign the v_res to a string or char variable then concatenate.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |