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

how to split a table fields and create a new record for each split

Former Member
0 Likes
1,249

Hi,

Could any one let me know how to split a table with strucutre and create a new record for each split. structure is as follow:

Filed1

Filed2

Filed3 more than one value seperated wtih commas

I need to split Filed3 values and create a new record for each split. Split is on comma operator.

Thanks

Rajeev.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
962

Hi Rajeev,

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 ',' INTO: str1 str2 str3,

TABLE itab.

Edited by: jagadeesh tirumalasetti on May 10, 2008 12:09 PM

6 REPLIES 6
Read only

Former Member
0 Likes
962

Are the new records going to be in the same table? here is an example with a second table.


data: itab2 type table of string,
        itabaux like itab2.

loop at itab.
split itab-field3 at ',' into table itabaux.
append lines of itabaux to itab2.
endloop.

itab2 should have all the records

Read only

0 Likes
962

No It has to update in another table.

Read only

0 Likes
962

example by ramiro is for another table only

Read only

0 Likes
962

I have the webserice commming in in the following strucutre:

- <COUNTRIES>

<F_COUNTRY_CODE>ABW</F_COUNTRY_CODE>

<F_COUNTRY_NAME>ARUBA</F_COUNTRY_NAME>

- <F_LANGUAGE>

<F_LANGUAGE_CODE>DUT, ENG, FRE, SPA</F_LANGUAGE_CODE>

<F_LANGUAGE_NAME>DUTCH; FLEMISH, ENGLISH, FRENCH, SPANISH; CASTILIAN</F_LANGUAGE_NAME>

</F_LANGUAGE>

- <F_REGION>

<F_REGION_CODE>LA</F_REGION_CODE>

</F_REGION>

</COUNTRIES>

I need to split the data coming in at "," and create new records for each split value (country code+name). Could any one guide me on this.

Thanks

Rajeev

Read only

Former Member
0 Likes
962

hi check this..

this can be done through the command split in additon with table

syntax : SPLIT f AT g INTO TABLE itab.

Stores the components of f in the internal table itab . For each part of f , a "special" table line is created.

f is considered without trailing blanks.

Example

DATA: BEGIN OF ITAB OCCURS 10,

WORD(20),

END OF ITAB.

SPLIT 'STOP Two STOP Three STOP ' AT 'STOP' INTO TABLE ITAB.

Now, ITAB has three lines. The first line is blank, the second contains 'Two' and the third contains 'Three' .

regards,

venkat .

Read only

Former Member
0 Likes
963

Hi Rajeev,

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 ',' INTO: str1 str2 str3,

TABLE itab.

Edited by: jagadeesh tirumalasetti on May 10, 2008 12:09 PM