‎2007 May 08 7:50 AM
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
‎2007 May 08 7:55 AM
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.
‎2007 May 08 7:53 AM
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
‎2007 May 08 7:54 AM
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
‎2007 May 08 7:55 AM
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.
‎2007 May 08 8:17 AM
‎2007 May 08 8:30 AM
'ABCD' is just a string he is using to show concatenation with last 2 characters of w_string
‎2007 May 08 8:46 AM
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
‎2007 May 08 8:51 AM
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.
‎2007 May 08 8:58 AM
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
‎2007 May 08 9:11 AM
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
‎2007 May 08 9:54 AM
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?
‎2007 May 08 7:57 AM
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