Application Development 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: 

Need a split logic.

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

10 REPLIES 10

former_member184657
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

former_member156446
Active Contributor
0 Kudos

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.

vinod_vemuru2
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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 ....

Former Member
0 Kudos

Hi,

data:

str1(10),

str2(10).

str1 = '6V_EGD'.

str2 = '107V_EGDH'.

str1(1) . "To get 6

str2(3). " To get 107

Former Member
0 Kudos

Thanx Sriram Ponna

Former Member
0 Kudos

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