‎2008 Jun 25 5:30 AM
I am having a string, for example : (1) 6V_EGD, i need 6 out of this
(2) 107V_EGDH, i need 107 out of this.
Plz send me the logic for this.
‎2008 Jun 25 5:37 AM
Hi,
Please refer the code below :
data : string(20) type c value'12ABAP',
num(20) type n.
num = string.
SHIFT num left DELETING leading '0'.
write : num.
Thanks,
Sriram POnna.
‎2008 Jun 25 5:32 AM
string+0(1) will give u 6
string+0(3) will give u 107
pk
please ignore this answer provided by me.
i thought u wanted to print values "6' and '107'.
pk
Edited by: prashanth kishan on Jun 25, 2008 7:21 AM
‎2008 Jun 25 5:35 AM
Hi Dilip,
Try the following:
1. string1 = 6V_EGD:
string1(1) gives 6
2. string2 = 107V_EGDH
string2(3) gives 107.
Hope This Helps You.
Regards,
Chandra Sekhar
‎2008 Jun 25 5:37 AM
Hi,
Please refer the code below :
data : string(20) type c value'12ABAP',
num(20) type n.
num = string.
SHIFT num left DELETING leading '0'.
write : num.
Thanks,
Sriram POnna.
‎2008 Jun 25 5:38 AM
Hi there I just made it.. check this might work
(1)vl_type1 = 6V_EGD, i need 6 out of this
(2)vl_type2 = 107V_EGDH, i need 107 out of this.
vl_1 type i, vl_2 type i. catch the string length in these fields..
do vl_1 times.
vl_buff = vl_type1+ sy-index(1).
if not vl_buff CA sy-abcde.
concatenate vl_buff vl_ouput to vl_output.
endif.
else.
skip / exit. " debug and check which is suitable.
endif.
clear: vl_buff,
enddo.
condense vl_output no gaps.
‎2008 Jun 25 5:38 AM
Hi Dilip,
After the number if u always have letter V i.e V_ some thing then do like this.
DATA: l_string TYPE string,
l_string1 TYPE string,
l_string2 TYPE string.
l_string = '6V_EGD'.
SPLIT l_string AT 'V' INTO l_string1, l_string2.
WRITE l_string1. "Here u have 6 now.
Thanks,
Vinod.
‎2008 Jun 25 5:40 AM
hi,
if text1 = (1) 6V_EGD: 6 is in the 5th place..so it is text1+4(1)
(2) 107V_EGDH: text2+4(3).
regards,
madhu
‎2008 Jun 25 5:44 AM
hi,
try this one......
data : st_1 type string value '6sahg'.
data : ch_1 type c.
ch_1 = st_1.
write : ch_1.
o/p : 6
-
data : st_1 type string value '623sahg'.
data : ch_1(3) type c.
ch_1 = st_1.
write : ch_1.
o/p : 623
Mark the post answered once ur problem is solved ....
‎2008 Jun 25 5:49 AM
Hi,
data:
str1(10),
str2(10).
str1 = '6V_EGD'.
str2 = '107V_EGDH'.
str1(1) . "To get 6
str2(3). " To get 107
‎2008 Jun 25 6:05 AM
‎2008 Jun 25 6:05 AM
hi
you can do it in two ways.
if u want to split from the begining use
string1(1) gives u 6.
string2(3) gives u 107.
but if u want split not from first position then use offsets.
string1+0(1) gives u 6.
string2+0(3) gives u 107.
hope this will help.
reward points if useful.
regards
Sumit Agarwal