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

SPLIT function

Former Member
0 Likes
611

Hello, i need separate a string, example, 1,95,02,55, by ',' into a internal table. if i use "SPLIT p_frase AT ',' INTO TABLE t_frase" but it create a registry for string. Is it posible in only one registry?

Excuse for my bad english.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
570

thats ok, but my internal table has 26 fields and i want to know if there are one fast way ;-).

Thanks.

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
570

Not sure what you mean by registry. By using the statement that you have provided, it will break the string into the specific parts into each line of the internal table. So if there are 4 fields in your string delimited by ',' you will have 4 records in your internal table. You can also break it out into individual fields.

split field_string at ',' into field1 field2 field3 field4.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
571

thats ok, but my internal table has 26 fields and i want to know if there are one fast way ;-).

Thanks.

Read only

0 Likes
570

I am not sure, but try this.

Have a work area of the table

SPLIT STRING_vAR AT ',' INTO WA_TABLE.

I am not sure but this might get the values into individual tables.

Regards,

Ravi

Note : Please mark the helpful answers

Read only

0 Likes
570

it´s no good.

Read only

0 Likes
570

You may want to try something like this.



report  zrich_0001.


data: str type string.
data: istr type table of str with header line.

data: begin of xstructure,
      field1(10) type c,
      field2(10) type c,
      field3(10) type c,
      field4(10) type c,
      end of xstructure.

field-symbols: <fs>.

str = '12,345,678,901'.

split str at ',' into table istr.

do.

  read table istr index sy-index.
  if sy-subrc <> 0.
    exit.
  endif.

  assign component sy-index of structure xstructure to <fs>.

  <fs> = istr.


enddo.

write:/ xstructure-field1,
        xstructure-field2,
        xstructure-field3,
        xstructure-field4.

Regards,

Rich Heilman

Read only

0 Likes
570

ok thank you very much.