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: 

upload of csv file

Former Member
0 Kudos

hello,

i want to upload the a csv file is there any function that i can use for that. i know "ws_upload" function is used only for dat and asci files. can anybody help me asap.

thanx,

Ravi.

6 REPLIES 6

Former Member
0 Kudos

Hi,

How to Upload csv file to SAP?

Use function module GUI_UPLOAD

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\test.csv'

FILETYPE = 'ASC'

TABLES

DATA_TAB = itab

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

Hope it helps u.

Thanks&Regards,

Ruthra

former_member221770
Contributor
0 Kudos

Ravi,

Use FM 'GUI_UPLOAD'. This will load your csv file into an internal table. Then use the "SPLIT" command to split the record into it's required fields.

eg.


data: begin of tbl_upload occurs 0,
        rec(1000) type c,
      end of tbl+upload.

data: begin of tbl_data occurs 0,
        vbeln  like vbak-vbeln,
        posnr  like vbap-posnr,
        matnr  like vbap-matnr,
      end of tbl_data.

call function 'GUI_UPLOAD'
  exporting
     filename = 'C:file.csv'
     filetype = 'ASC'
  tables
     data_tab = tbl_upload.

loop at tbl_upload.
  split tbl_upload-rec at ',' into
    tbl_upload-vbeln
    tbl_upload-posnr
    tbl_upload-matnr.
 append tbl_upload.
endloop.

Hope this helps.

Cheers,

Pat.

0 Kudos

HI,

I STILL GET A ERROR LIKE FUNTION MODULE CONFLICT CAN U PLEASE HELP ME.

THANX

RAVI.

0 Kudos

Hi,

Check out these threads and pages:

http://www.sapdevelopment.co.uk/file/file_uptabpc.htm

Regards,

Ville

0 Kudos

try this ..i generally use the ws_upload even for .csv file, it works fine.

PARAMETER: FNAME LIKE RLGRAP-FILENAME OBLIGATORY

default 'c:\test111.csv'.

DATA:BEGIN OF FILEDATA OCCURS 10,

LINE(80),

END OF FILEDATA.

start-of-selection.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = FNAME

FILETYPE = 'ASC'

TABLES

data_tab = FILEDATA "your internal table

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

OTHERS = 11.

if sy-subrc <> 0.

write:/ sy-subrc.

endif.

loop at filedata.

write:/ filedata-line.

endloop.

former_member221770
Contributor
0 Kudos

Ravi,

The GUI_UPLOAD FM requires the parameter FILENAME to be passed in as a string.

Cheers,

Pat.

Message was edited by: Patrick Yee