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: 

Split function

former_member215107
Active Participant
0 Kudos

How can i use Split function when i receive one of them:

Pim/Pam/Poum

Pim;Pam;Poum

Pim Pam Poum

To separate Pim, Pam and Poum i can have a different special character ...

Thanks for your help

Rodolphe.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use CA

DATA : W_STRING TYPE STRING.

W_STRING = 'Pim/Pam/Poum'.

IF W_STRING CA '/: ( Place all the special characters here )' .

WRITE SY-FDPOS.

using sy-fdpos write the letter then split by it.

ENDIF.

6 REPLIES 6

Former Member
0 Kudos

HI,

You can Use This code.

If var_String CA '/'.

split var_string AT '/' into var1 var2 var3.

Elseif Var_string CA ','.

Elseif var_string CA space.

Endif.

Regards

Sumit Agarwal

Former Member
0 Kudos

Can the string have all of ' ;/' in the same string?

Rob

Former Member
0 Kudos

Use CA

DATA : W_STRING TYPE STRING.

W_STRING = 'Pim/Pam/Poum'.

IF W_STRING CA '/: ( Place all the special characters here )' .

WRITE SY-FDPOS.

using sy-fdpos write the letter then split by it.

ENDIF.

Former Member
0 Kudos

SPLIT string AT DELIMITER INTO ONE TWO THREE.

Former Member
0 Kudos

DATA : W_STRING TYPE STRING,

split_char type c,

var1 type string,

var2 type string,

var3 type string.

W_STRING = 'Pim:Pam:Poum'. ( Try replcaing the special character )

IF W_STRING CA '/:;$%@!' ( If the special character is not included in the quotes pls include ) .

split_char = w_string+sy-fdpos(1).

split w_string at split_char into var1 var2 var3.

write : var1, var2 , var3.

ENDIF.

output :

Pim Pam Poum

valter_oliveira
Active Contributor
0 Kudos

In each record you don't know what is the separator, but in the entire record it's the same, right? So you can try something like this:


DATA: char TYPE char1.
IF <your_string> CA '/'.
  char = '/'.
ELSEIF <your_string> CA ';'.
  char = ';'.
ELSE.
  char = ' '.
ENDIF.
SPLIT <your_string> AT char INTO <var1> <var2> <var3>.

Regards.

Valter Oliveira.