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 THE STRING INTO FIELDS

Former Member
0 Likes
549

HI EXPERTS,

I AM SASIDHAR, WORKING ON BW SERVER.

I HAD UPLOADED CSV FORMAT FLATFILE INTO INTERNAL TABLE IN STRING FORMAT. NOW I HAVE TO SPLIT THIS STRING AND ALSO NEED TO CONVERT INTO NUMERIC TYPE, BUT I DON'T KNOW NUMBER OF FIELDS AND LENGTH OF FIELD. PLEASE ANY ONE SEND THE SAMPLE CODING FOR THIS SCENARIO.

4 REPLIES 4
Read only

athavanraja
Active Contributor
0 Likes
510

since its CSV, the field delimiter will be comma.

split <record> at ',' into <field1> field2> , etc

Raja

Read only

Former Member
0 Likes
510

If your input file is a CSV file and if you are uploading from local machine then you might be using GUI_UPLOAD function module wherein you can set FIELD_SEPERATOR as X. this enables you to get all the detail to the different fields in the internal table.

if you are uploading from server , you might be using OPEN DATA SET, then you should use the seperator (,) and use SPLIT or make you of offset position of the string.

~thomas

null

Read only

Former Member
0 Likes
510

You can use this code.

  loop at it_file into wa_file.
   refresh it_split.
   split wa_file-<field> at ',' into table it_split.
   .....
  endloop.

it_split will contain each of the fields in a record in the CSV file as a separate record.

Read only

Former Member
0 Likes
510

say u have 10 fields...as it is CSV file and u have uploaded using GUI_UPLOAD, there is an option HAS_SEPERATOR which u need to put as 'X' and all fields get into internal table .... or else use Split file into <field1>.......<field10> at ','.