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

Concatenating a string to a integer variable..

Former Member
0 Likes
3,212

Hi All,

Could anyone of you clarrify whether 'concatenate' could be used to append a string to a integer (int4) variable..?

If not which keyword should be used to add a string variable to integer variable?

7 REPLIES 7
Read only

Former Member
0 Likes
1,601

Why would you need to that? Just use a STRING variable...Integer variables are not supposed to hold char values...

Greetings,

Blag.

Read only

former_member156446
Active Contributor
0 Likes
1,601

data: lv_int type i value '04',

lv_char type char4 value 'Abap',

lv_string type string.

u can use it as

concatenate lv_int lv_char into lv_string.

Read only

Clemenss
Active Contributor
0 Likes
1,601

Hi SINDHURI,

one of the ABAP features is implicit type conversion.


  DATA:
    lv_string type string,
    lv_int type i.

lv_string = '575'.
lv_int = 5.
lv_int = lv_int + lv_string.
lv_string = lv_string + lv_int.

works good. Did you even try?

If you really want to concatenate, you should first put the values into string or character variables and then concatenate them. There is no type conversion within concatenate. Concatenate is for strings and characters.

Regards,

Clemens

Read only

0 Likes
1,601

DATA : n_val TYPE N,

s_val TYPE STRING VALUE 'PO',

i_val TYPE INTEGER VALUE 40,

result TYPE STRING.

n_val = ival.

CONCATENATE n_val s_val INTO result.

Cheers,

Naveen

Read only

Former Member
0 Likes
1,601

Hi,

You will Not Concatenate String or Character type with Integer type.

You can conatenate by moving integer type to character type . because cocatenate only work with character type variables.

You can Directly add string variable to a integer variable but provide that alphabets and special character should not appeae in that if appeared it goes to dump.

I hope this clarifies you doubt.

Regards,

Raghava Channooru.

Read only

Former Member
0 Likes
1,601

Before anyone else answers, look at the date of the original post.

Rob

Read only

0 Likes
1,601

Hi

Its not permitted to concatenate the integer value directly with string. Instead you can move the integer value to a string and use concatenate of string

eg:

Data v_count type i,

v_string type string,

v_value type string value 'abap',

v_final type string.

v_count = 68.

v_string = v_count.

concatenate v_value v_string into v_final.

Output

-


abap68