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

Former Member
0 Likes
1,145

Hi Friends,

I need to concatenate the last two characters of the string can any one tell me how to do it.

Y94701000000000<b>LS</b>

With Regards,

Line

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,114

Hi..

to which field u want to concatenate??

any how..

data:

w_string type string,

len type i.

w_string = 'Y94701000000000LS'.

len = strlen( w_string ).

len = len - 2.

concatenate w_string+len(2) 'ABCD' into new_string.

11 REPLIES 11
Read only

Former Member
0 Likes
1,114

Using Offset operator you can do that.

First get the string length and get the last characters of the variable

length = length of string.

length = length -2.

concatenate v1+length(2) -


I hope this will help you.

Warm Regards,

Vijay

Read only

Former Member
0 Likes
1,114

Hi,

Data : v1(2),

v2(2),

v3(4).

v1 = 'AB'.

v2 = 'CD'.

Concatenate v1 v2 into v3.

Reward points if it is helpful.

Regards,

Sangeetha.A

Read only

Former Member
0 Likes
1,115

Hi..

to which field u want to concatenate??

any how..

data:

w_string type string,

len type i.

w_string = 'Y94701000000000LS'.

len = strlen( w_string ).

len = len - 2.

concatenate w_string+len(2) 'ABCD' into new_string.

Read only

0 Likes
1,114

Hi Ram,

What is 'ABCD'.

Line

Read only

0 Likes
1,114

'ABCD' is just a string he is using to show concatenation with last 2 characters of w_string

Read only

0 Likes
1,114

Hi there,

pls check my code i am getting error message 'Char like field expected after v_tempstr+len(2).

Code :

v_tempstr = i_prpx-posid4.

len = strlen( v_tempstr ).

if len > 14.

len = v_chrg - 2.

concatenate v_tempstr+len(2) into v_chrg.

i_bseg-posid5 = v_chrg.

endif.

Regards,

Line

Read only

0 Likes
1,114

Hi,

Line , you have not put anything after v_tempstr+len(2) field, thats y it says char like field expected!

concatenate v_tempstr+len(2) <b>put something here</b> into v_chrg.

Read only

0 Likes
1,114

Hi,

This error occurs because when You're using CONCATENATE' command

You have to give it anleast 2 arguments (2 strings or chars).

In Your code:

concatenate <b>v_tempstr+len(2)</b> into v_chrg.

You have only 1 argument.

Solution:

1) v_chrg = v_tempstr+len(2).

2) use CONCATENATE but give more arguments f.e.

concatenate v_tempstr+len(2) <b>second argument</b> into v_chrg.

Message was edited by:

Artur Cywinski

Read only

0 Likes
1,114

Hi there,

But When I am keeping something after that statement it is also adding.

like i want to concatenate this string 'Y94701000000000LS'

I used the following code:

v_tempstr = i_prpx-posid4.

len = strlen( v_tempstr ).

if len > 14.

len = len - 2.

concatenate v_tempstr+len(2) 'XYZ' into v_chrg.

i_bseg-posid5 = v_chrg.

endif.

I am getting LSXYZ in the field v_chrg.

Pls tell me what to do.

Regards,

Line

Read only

0 Likes
1,114

Hi Line,

What is the value stored in the v_tempstr?

If it is 'Y94701000000000LS', then you will get '15' for len so v_tempstr+15(2) will extract 'LS' from v_tempstr.

After that, concatenate 'LS' 'XYZ' will become 'LSXYZ' which is same as the result that you got. Is this the result you want?

What are you exepected result that will store in the v_chrg?

Read only

Former Member
0 Likes
1,114

Hi,

Constants: c_l type c value 'L',

c_s type c value 'S'.

data: s_target(17) type c value 'Y94701000000000'.

concatenate c_l c_s into s_target.

or you can define it as single constant

constants: c_ls(2) type c value 'LS'.

concatenate c_ls s_target into s_string.

where s_string is a new variable.

Asha