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: 

String operation

Former Member
0 Kudos

Hi Friends,

I wan to split one word from a character occurring inside the word. For example , I want to split the following word from '_' . 'PROPERT_METH' . i.e, into PROPERTY , METH.

How can i do this.....

Thanks,

Brij...

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Soni

try this


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. 

6 REPLIES 6

Former Member
0 Kudos

Hi

Use STRING_SPLIT function module

Regards

Madhan

Former Member
0 Kudos

Hi Soni

try this


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. 

Former Member
0 Kudos

Hi,

You can use the SPLIT at statement.

Since your delimiter is '_'... you can say

Split w_word at c_under into w_word1 w_word2.

Regards,

Pramod

Former Member
0 Kudos

SPLIT str AT '-' INTO TABLE str1 str2.

where str is input string.

Regards,

Aparna.

Former Member
0 Kudos

Hi,

You can use anyone of the below syntaxes:

1. Split <variable> at '_' into var1 var2 ... var.

2. Split <variable> at '_' into itab.

(where itab is like:

data: begin of wa,

var(255),

end of wa.

data: itab like standard table of wa with header line.)

I consider 2nd option to be best.

ITAB contains all the splitted variables as diff records.

Thanks & Regards,

Navneeth K.

satsrockford
Active Participant
0 Kudos

Hi,

look at this sample code.

data: text(255).

data: v_x.

text = 'AA,17,2/19/2003,"9,999.00",USD,00,10,318,"193,275.31"'.

do.

v_x = ' '.

search text for '"' and mark.

if sy-subrc = 0.

replace first OCCURRENCE OF '"' in section offset sy-fdpos of text with

''.

replace first OCCURRENCE OF ',' in section offset sy-fdpos of text with

''.

replace first OCCURRENCE OF '",' in section offset sy-fdpos of text with

','.

v_x = 'X'.

endif.

if v_x = ' '.

exit.

endif.

enddo.

write:/ text.

regads

satish