Application Development 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: 

CSV File

Former Member
0 Kudos

Hi,

Am trying to upload the CSV file into internal table using 'GUI_UPLOAD' initially and then splitting the record at ',' into different fields. But the issue is, my data contains numbers (currency) and they have ',' in the data and hence the data is uploaded into the internal table with 'GUI_UPLOAD' inbetween " ", for example, "41,500".

So when we use Split at ',' it splits the entire number to "41 and 500" etc..

How can I resolve this?

Thanks in advance.

Tony.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Instead of using GUI_UPLOAD try to use ALSM_EXCEL_TO_INTERNAL_TABLE which will help u..This FM automatically splits fields into internal table...

5 REPLIES 5

Former Member
0 Kudos

You can use tab delimited file instead of CSV file.

or you can try out these function modules.

TEXT_CONVERT_CSV_TO_SAP

KCD_CSV_FILE_TO_INTERN_CONVERT

hope this helps.

Reward points if its useful

Former Member
0 Kudos

Instead of using GUI_UPLOAD try to use ALSM_EXCEL_TO_INTERNAL_TABLE which will help u..This FM automatically splits fields into internal table...

0 Kudos

Hi Ramesh,

ALSM_EXCEL_TO_INTERNAL_TABLE With this function module, we can populate the internal table. For this we need to write some amount of logic to populate the records in the internal table. I am searching for a function module which will directly give the record which excludes ',' and give us a proper record.

Anyway thanks for the help.

Thanks,

Tony.

former_member181962
Active Contributor
0 Kudos

YOu have to build an internal table of exactly the same structure as the file, including a separate field for holding the ',' as well.

Once you upload those fields into the internal table, you can move them to another internal table which has no separator.

data: begin of itab1 occurs 0,

field1(10),

dummy(1),

field2(20),

end of itab1.

data: begin of itab2 occurs 0,

field1(10),

field2(20),

end of itab2.

call function gui_upload into itab1.

loop at itab1.

move-corresponding itab1 to itab2.

append itab2.

endloop.

Regards,

ravi

Former Member
0 Kudos

Hi,

type-pools: KCDE.

parameters: p_file like rlgrap-filename default 'C:\STOCK.csv'.

data: it_data type KCDE_INTERN .

CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'

EXPORTING

I_FILENAME = p_file

I_SEPARATOR = ','

TABLES

E_INTERN = it_data

EXCEPTIONS

UPLOAD_CSV = 1

UPLOAD_FILETYPE = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

regards,

keerthi