Skip to Content
author's profile photo Former Member
Former Member

upload of csv file

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2005 at 04:06 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2005 at 03:58 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2005 at 04:51 AM

    Ravi,

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

    Cheers,

    Pat.

    Message was edited by: Patrick Yee

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.