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

String operation in ABAP

Former Member
0 Likes
1,972

String1 = ABC/12222ASDF

String2 = EF/1234W3RSDFASDF

String3 = ABCD/22343DFGADG

.......

I want to get each string's chars before the symbol '/' . Use which ABAP char operation,Please help me.

Thanks,Have a nice day.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
915

Hi Bean,

Use SPLIT statement.

Thanks

Edited by: Nitesh Kumar on Nov 21, 2008 10:38 AM

7 REPLIES 7
Read only

Former Member
0 Likes
916

Hi Bean,

Use SPLIT statement.

Thanks

Edited by: Nitesh Kumar on Nov 21, 2008 10:38 AM

Read only

Former Member
0 Likes
915

Hi Bean,

Refer this code snippet.

DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

P.S. Replace Space by '/' to split your string.

Thanks

Read only

0 Likes
915

Thanks , It's ok

Read only

Former Member
0 Likes
915

hello bean,

greetings of the day,

split is the command used for this solution.

try using this code :

data : string1(15),string2(15),string3(15).

data: str1(5),str2(15).

String1 = 'ABC/12222ASDF'.

String2 = 'EF/1234W3RSDFASDF'.

String3 = 'ABCD/22343DFGADG'.

.......

split string1 at '/' into str1 str2.

write:/ 'characters before / in string1 are :' , str1.

split string2 at '/' into str1 str2.

write : /'characters before / in string2 are :' , str1.

split string3 at '/' into str1 str2.

write 😕 'characters before / in string3 are :' , str1.

thanks

geeta

Read only

Former Member
0 Likes
915

Hi,

Check the below code I have written it according to your requirement.

REPORT  ZRET_CHAR_F_STG.

data: string1 type string,
      string2 type string,
      string3 type string,
      string4 type string,
      string5 type string,
      string6 type string,
      string7 type string,
      string8 type string,
      string9 type string,
      sep type c.

data: l1 type i,
      l2 type i,
      l3 type i.

data: c1 type c,
      c2 type c,
      c3 type c.

String1 = 'ABC/12222ASDF'.
String2 = 'EF/1234W3RSDFASDF'.
String3 = 'ABCD/22343DFGADG'.
sep = '/'.

split string1 at sep into string4 string5.
split string2 at sep into string6 string7.
split string3 at sep into string8 string9.

l1 = strlen( string4 ).
l1 = l1 - 1.
c1 = string4+l1(1).

l2 = strlen( string6 ).
l2 = l2 - 1.
c2 = string6+l2(1).

l3 = strlen( string8 ).
l3 = l3 - 1.
c3 = string8+l3(1).

Write:/ c1, c2, c3.

Write:/ string4, string5.
Write:/ string6, string7.
Write:/ string8, string9.

Cheers,

Murthy.

Read only

Former Member
0 Likes
915

Ok

Edited by: pr murthy on Nov 21, 2008 6:31 AM

Read only

Former Member
0 Likes
915

Hi,

check the following sample:

data: string1 type string,
      string2 type string,
      string3 type string,
      str1_1 type string,
      str1_2 type string.

String1 = 'ABC/12222ASDF'.
String2 = 'EF/1234W3RSDFASDF'.
String3 = 'ABCD/22343DFGADG'.

SPLIT string1 AT '/' INTO: str1_1 str1_2 .
write: str1_1, str1_2.

Regards,

Chris Gu