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 a string row at comma and put in a internal table columns

former_member203480
Participant
0 Likes
6,192

Hi I the file records are read into string table .

loop at stringtable into <fs_wa>.

Here when sytabix is '10'

the record in field symbol is like below

Publish Date,22-jul-2020,24-jul-2020,21-jul-2020,22-jul-2020,22-jul-2020...etc(dynamic)

Here when sytabix is '12'

he record in field symbol is like below

places,USA,CAN,MAL,IND,SRIL,UKR,BRT...etc(dynamic)

endloop

i want to move these 2 rows to columns of an internal table like below

final-internal-table.png

any suggestions

Kind Regards

1 ACCEPTED SOLUTION
Read only

Abinathsiva
Active Contributor
4,779

Hi,

Try below with below code...

DATA: BEGIN OF it_table OCCURS 0,
        string1(15),
        string2(15),
        string3(15),
      END OF it_table.


data: date1 type table of string with header line.
data: country type table of string with header line.

DATA string11(100) VALUE '*********,****,****'. "* Represents
DATA string12(100) VALUE '*********,****,****'. "* Represents

SPLIT string11 AT ',' INTO TABLE date1 .
SPLIT string12 AT ',' INTO TABLE country .

 loop date1,
   Read country with tab index..
     assign fields and append it_table.
 endloop.


Hi I the file records are read into string table .

loop at stringtable into <fs_wa>.

Here when sytabix is '10'

the record in field symbol is like below

Publish Date,22-jul-2020,24-jul-2020,21-jul-2020,22-jul-2020,22-jul-2020...etc(dynamic)

Here when sytabix is '12'

he record in field symbol is like below

places,USA,CAN,MAL,IND,SRIL,UKR,BRT...etc(dynamic)

endloop

i want to move these 2 rows to columns of an internal table like below

final-internal-table.png

any suggestions

Kind Regards

5 REPLIES 5
Read only

Abinathsiva
Active Contributor
4,780

Hi,

Try below with below code...

DATA: BEGIN OF it_table OCCURS 0,
        string1(15),
        string2(15),
        string3(15),
      END OF it_table.


data: date1 type table of string with header line.
data: country type table of string with header line.

DATA string11(100) VALUE '*********,****,****'. "* Represents
DATA string12(100) VALUE '*********,****,****'. "* Represents

SPLIT string11 AT ',' INTO TABLE date1 .
SPLIT string12 AT ',' INTO TABLE country .

 loop date1,
   Read country with tab index..
     assign fields and append it_table.
 endloop.


Read only

0 Likes
4,779
OCCURS 0

and

WITH HEADER LINE

Really? SAP made them both obsolete 15 years ago for a very good reason.

Read only

matt
Active Contributor
0 Likes
4,779

The 1990s called. They'd like their ABAP syntax back.

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,779

Your question will be more attractive if you embed the image, not the hyperlink:

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,779

As suggested by abishankar, did you use SPLIT to get the values between commas? (into an internal table, each line is one of these values)

SPLIT <fs_wa> AT ',' INTO TABLE @DATA(segments).