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

read a CSV structure

Former Member
0 Likes
602

Hi,

I have my data in internal table which has one filed, say fielda(2000) type c.

Now in this field i have data in CSV format.

e.g

abc, 101022, xyz, USA, 36598, etc

I have one final internal table in which I want to transfer this CSV values. Lets suppose final internal table name is final_itab.

Now i want to pass the values like this,

final_itab-f1 = abc

final_itab-f2 = 101022

final_itab-f3 = xyz

like this.

So in short i want to transfer CSV values to my final_itab. How can i do that.(each comma is one field).

Is there any function module for this.

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
564

Hello, <li>Try this way.


LOOP AT it_csv_data.
  SPLIT it_csv_data-fielda AT ',' INTO it_final_tab-f1
                                       it_final_tab-f2
                                       it_final_tab-f3
                                       it_final_tab-f4.
  APPEND it_final_tab.
  CLEAR  it_final_tab.
ENDLOOP.
Thanks Venkat.O

4 REPLIES 4
Read only

Former Member
0 Likes
564

use FM, KCD_CSV_FILE_TO_INTERN_CONVERT to get the CSV data to Intenal table.

Read only

venkat_o
Active Contributor
0 Likes
565

Hello, <li>Try this way.


LOOP AT it_csv_data.
  SPLIT it_csv_data-fielda AT ',' INTO it_final_tab-f1
                                       it_final_tab-f2
                                       it_final_tab-f3
                                       it_final_tab-f4.
  APPEND it_final_tab.
  CLEAR  it_final_tab.
ENDLOOP.
Thanks Venkat.O

Read only

Former Member
0 Likes
564

You can use Split statement if you know how many commas will be present in one particular line of CSV Format.

Hope this helps!!

Kanchan

Read only

Former Member
0 Likes
564

Hi,

Replace all commas with space using the comand REPLACE ALL OCCURANCES.

Then read the file as usual with GUI_UPLOAD.

Thanks,

Sudheer