CSV upload using GUI_UPLOAD

Hi,
  i have a requirement to upload a CSV file. I used the fm GUI_UPLOAD for this. the internal table will be one with a single field and all the field values seperated by ',' right? is there any way to get this fields populated into the corresponding fields while uploading using the FM itself and how?
i tried to use split at ',' to achieve this after uploading. but since some fields are with data type quantity its not working. how i can proceed to achieve my requirement?
Regards,
Anoop R.S

Hi anoop,
1. simple
2. just copy paste.
3. the file name is d:\myfile.txt
the contents are - 2 records:
amit;mittal
mr;xyz
4.
report abc.
type-pools : TRUXS.
data : rawdata type TRUXS_T_TEXT_DATA.
data : begin of itab occurs 0,
       f1(10) type c,
       f2(10) type c,
       end of itab.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = 'd:\myfile.txt'
  TABLES
    DATA_TAB                      = rawdata
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
CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
  EXPORTING
   I_FIELD_SEPERATOR          = ';'
  I_LINE_HEADER              =
    I_TAB_RAW_DATA             = rawdata
  I_FILENAME                 = 'd:\myfile1.txt'
  TABLES
    I_TAB_CONVERTED_DATA       = itab
EXCEPTIONS
   CONVERSION_FAILED          = 1
   OTHERS                     = 2
break-point.
regards,
amit m.

Similar Messages

  • How to upload a .CSV file using GUI_UPLOAD

    Hi Experts,
          In my report, I need to upload .CSV file using GUI_upload..So how to do ....Plz provide solution...

    Hi prashanthishetty,
    this is already answered many times in this forum!
    use forum search or wiki search
    [http://wiki.sdn.sap.com/wiki/display/Snippets/uploadcsvfilesintointernal+table]
    regards
    rea

  • Flat file(Binary file) upload using GUI_UPLOAD

    I had uploaded a Binary file Using GUI_UPLOAD , File type was 'BIN'.
    but the data i got in Internal Table was in 0's and 1's.
    whereas i tried the same thing on a different server but  the same Version it gave me the data as text in Internal Table.
    what could be reason..or wat could be done to resolve this.

    Did you declare the internal table used to upload the binary file as TYPE X ?
    begin of itab,
      raw(255) type x,
    end of itab occurs 0.
    CALL FUNCTION 'GUI_UPLOAD'
       exporting
          filetype =  'BIN'
          filename = 'C:DOWNLOAD.BIN'
       tables
          data_tab = itab.
    Always remember to reward snippets you find useful!

  • How to use GUI_upload for Uploading a CSV file in Microsoft Excel.

    Hi Guys,
                  can anybody tell me how to Upload the CSV format file in Microsoft excel sheet?
    Thanks,
    Gopi.

    Hi Gopi,
    u can use GUI_UPLOAD, TEXT_CONVERT_XLS_TO_SAP.
    Please check these codes.
    Uploading data from CSV file format into internal table using GUI_UPLOAD
    REPORT zupload MESSAGE-ID bd.
    DATA: w_tab TYPE ZTEST.
    DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
    DATA: v_subrc(2),
    v_recswritten(6).
    PARAMETERS: p_file(80)
    DEFAULT 'C:\Temp\ZTEST.TXT'.
    DATA: filename TYPE string,
    w_ans(1) TYPE c.
    filename = p_file.
    CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
    titlebar = 'Upload Confirmation'
    * DIAGNOSE_OBJECT = ' '
    text_question = p_file
    text_button_1 = 'Yes'(001)
    * ICON_BUTTON_1 = ' '
    text_button_2 = 'No'(002)
    * ICON_BUTTON_2 = ' '
    default_button = '2'
    * DISPLAY_CANCEL_BUTTON = 'X'
    * USERDEFINED_F1_HELP = ' '
    * START_COLUMN = 25
    * START_ROW = 6
    * POPUP_TYPE =
    * IV_QUICKINFO_BUTTON_1 = ' '
    * IV_QUICKINFO_BUTTON_2 = ' '
    IMPORTING
    answer = w_ans
    * TABLES
    * PARAMETER =
    * EXCEPTIONS
    * TEXT_NOT_FOUND = 1
    * OTHERS = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CHECK w_ans = 1.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = filename
    * FILETYPE = 'ASC
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_tab
    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.
    * SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
    IF sy-subrc <> 0.
    v_subrc = sy-subrc.
    MESSAGE e899 WITH 'File Open Error' v_subrc.
    ENDIF.
    INSERT ZTEST FROM TABLE i_tab.
    COMMIT WORK AND WAIT.
    MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
    Uploading data from Excel file format into internal table using TEXT_CONVERT_XLS_TO_SAP
    REPORT  zupload_excel_to_itab.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
          col1(30)    TYPE c,
          col2(30)    TYPE c,
          col3(30)    TYPE c,
          END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
          wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    * At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FILE'
        IMPORTING
          file_name  = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
    *     I_FIELD_SEPERATOR        =
          i_line_header            =  'X'
          i_tab_raw_data           =  it_raw       " WORK TABLE
          i_filename               =  p_file
        TABLES
          i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
       EXCEPTIONS
          conversion_failed        = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3.
      ENDLOOP.
    reward if helpful
    raam

  • Upload tab delimted file without using GUI_UPLOAD

    hi gurus,
    my requirement is I have to upload a Tab - delimited text file into a internal table. this should happen as a background job due to which, I cannot use GUI_UPLOAD.
    please provide me with code snippets using open dataset and close dataset.
    points will be awarded for best code!

    Hello,
    Check this sample.
    CONSTANTS: CON_TAB TYPE X VALUE '09'.
      OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
      IF SY-SUBRC = 0.
    loop at g_T_outtab.
            CONCATENATE G_T_OUTTAB-VBELN
                        G_T_OUTTAB-POSNR
                        G_T_OUTTAB-VKBUR
                        L_F_POSID
                        G_T_OUTTAB-BSTKD
                        L_F_NETWR
                        L_F_ERDAT_OR
                        L_F_ERDAT_IN
                        G_T_OUTTAB-VBELN_IN
                        L_F_ERDAT_DE
                        G_T_OUTTAB-VBELN_DE
                        INTO OUTPUT
                        SEPARATED BY CON_TAB.
          TRANSFER OUTPUT TO P_FILE.
    endloop.
    endif.
      CLOSE DATASET P_FILE.
    Cheers,
    Vasanth

  • Can TXT file with separater ',' be upload to internal TBL using GUI_UPLOAD?

    hello, experts,
    I have a problem with data transfer. I need to upload TXT file to SAP internal table, data in TXT file are separated by ',' and more than one line records are contained in the file. I tried to use FM GUI_UPLOAD as below to upload the file and transfer the data to internal table, however it comes out error. SY-SUBRC is UNKNOW ERROR, error message shows: Cannot interpret date in file.
          CALL FUNCTION 'GUI_UPLOAD'
               EXPORTING
                    FILENAME                = FILEPATH
                    FILETYPE                = 'DAT'
                    HAS_FIELD_SEPARATOR     = ','
                    READ_BY_LINE            = 'X'
               TABLES
                    DATA_TAB                = TAB_X3
               EXCEPTIONS
                    CONVERSION_ERROR        = 1
                    FILE_OPEN_ERROR         = 2
                    FILE_READ_ERROR         = 3
                    INVALID_TYPE            = 4
                    NO_BATCH                = 5
                    UNKNOWN_ERROR           = 6
                    INVALID_TABLE_WIDTH     = 7
                    GUI_REFUSE_FILETRANSFER = 8
                    CUSTOMER_ERROR          = 9
                    OTHERS                  = 10.
    Thank you.

    HAS_field_separator can have only SPACE or X.
    upload the file using GUI_UPLOAD and then in the program you split the lines by comma.
    Data: begin of itab occurs 0,
          rec(1000) type c,
          end of itab.
    DATA: begin of itab1 occurs 0, 
              matnr type mara-matnr
          werks type marc-werks
          lgort type marc-lgort,
          end of itab1.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = FILEPATH
    FILETYPE = 'DAT'
    HAS_FIELD_SEPARATOR = 'X'
    READ_BY_LINE = 'X'
    TABLES
    DATA_TAB = TAB_X3
    EXCEPTIONS
    CONVERSION_ERROR = 1
    FILE_OPEN_ERROR = 2
    FILE_READ_ERROR = 3
    INVALID_TYPE = 4
    NO_BATCH = 5
    UNKNOWN_ERROR = 6
    INVALID_TABLE_WIDTH = 7
    GUI_REFUSE_FILETRANSFER = 8
    CUSTOMER_ERROR = 9
    OTHERS = 10.
    loop at itab.
    split itab-rec at ',' into itab1-matnr itab1-werks itab1-lgort.
    append itab1.
    endloop.

  • To upload an excel file from front end using GUI_UPLOAD

    Hi All,
    Please give me the code to upload data from front end to internal table only using GUI_UPLOAD.
    Thanks,
    Kumar

    Check this program , reward points if helpful
    *& Report  ZEXCEL_UPLOAD                                               *
    report  ZEXCEL_UPLOAD    message-id ZMSG.
    tables :T001.
    data : begin of ITAB occurs 0,
          BUKRS like T001-BUKRS,
          BUTXT like T001-BUTXT,
          ORT01 like T001-ORT01,
          LAND1 like T001-LAND1,
          WAERS like T001-WAERS,
          end of ITAB.
    data : WA_T001_EXCEL like ITAB.
    data : IT_T001_EXCEL like standard table of WA_T001_EXCEL.
    data IT_TEXT like ITAB occurs 0 with header line.
    data : IT_RETURN  like standard table of ALSMEX_TABLINE,
           WA_RETURN like ALSMEX_TABLINE,
            WA_RETURNS like ALSMEX_TABLINE.
    data : V_FILE type STRING,V_MASK(10) type C.
    selection-screen  begin of block B1 with frame title TEXT-001.
    parameters P_FILE like RLGRAP-FILENAME .
    selection-screen end of block B1.
    selection-screen  begin of block B2 with frame title TEXT-002.
    parameter : R_TXT  radiobutton group G1 default 'X' user-command C1,
                R_EXCEL radiobutton group G1.
    selection-screen end of block B2.
    at selection-screen on value-request for P_FILE.
      if R_TXT = 'X'.
        V_MASK = '*TXT'.
      elseif R_EXCEL = 'X'.
        V_MASK = '*XLS'.
      endif.
      call function 'KD_GET_FILENAME_ON_F4'
        exporting
          PROGRAM_NAME  = SYST-REPID
          DYNPRO_NUMBER = SYST-DYNNR
          MASK          = V_MASK
        changing
          FILE_NAME     = P_FILE.
    at selection-screen.
      translate P_FILE to upper case.
      if R_TXT = 'X'.
        search P_FILE for '*TXT'.
        if SY-SUBRC <> 0.
          message E011.
        endif.
      endif.
      if R_EXCEL = 'X'.
        search P_FILE for '*XLS'.
        if SY-SUBRC <> 0.
          message E012.
        endif.
      endif.
    start-of-selection.
      V_FILE = P_FILE.
      if R_TXT = 'X'.
        call function 'GUI_UPLOAD'
          exporting
            FILENAME            = V_FILE
            FILETYPE            = 'ASC'
            HAS_FIELD_SEPARATOR = 'X'
          tables
            DATA_TAB            = IT_TEXT.
        if SY-SUBRC eq 0.
          message I013 with V_FILE.
          loop at IT_TEXT .
        write :/ IT_TEXT-BUKRS color 4, IT_TEXT-BUTXT color 3,IT_TEXT-ORT01
        color 5,
        IT_TEXT-LAND1 color 2,IT_TEXT-WAERS color 1.
          endloop.
        endif.
      elseif R_EXCEL = 'X'.
        call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
          exporting
            FILENAME    = P_FILE
            I_BEGIN_COL = 1
            I_BEGIN_ROW = 1
            I_END_COL   = 4
            I_END_ROW   = 2
          tables
            INTERN      = IT_RETURN.
        if SY-SUBRC eq 0.
          message I014 with P_FILE.
          sort IT_RETURN by ROW COL.
          loop at IT_RETURN into WA_RETURNS.
            WA_RETURN = WA_RETURNS.
            case WA_RETURN-COL.
              when 1.
                WA_T001_EXCEL-BUKRS = WA_RETURN-VALUE.
              when 2.
                WA_T001_EXCEL-BUTXT = WA_RETURN-VALUE.
              when 3.
                WA_T001_EXCEL-ORT01 = WA_RETURN-VALUE.
              when 4.
                WA_T001_EXCEL-LAND1 = WA_RETURN-VALUE.
            endcase.
            at end of ROW.
              append WA_T001_EXCEL to IT_T001_EXCEL.
              clear : WA_RETURN, WA_T001_EXCEL.
            endat.
          endloop.
        endif.
        loop at IT_T001_EXCEL into WA_T001_EXCEL.
          write :/ WA_T001_EXCEL-BUKRS color 1, WA_T001_EXCEL-BUTXT color 2,
                   WA_T001_EXCEL-ORT01 color 3,WA_T001_EXCEL-LAND1 color 4.
        endloop.
      endif.

  • Getting #while using gui_upload

    im using gui_upload to upload data into internal table itab
    this itab has field of type string
    my input text file has values ++;100;0101+;
    but when i m using gui_upload i m getting extra value # in my internal table.
    plz tell me why this # value is coming Extra.
    My internal table is of folllowing type
    begin of itab occurs 0,
    line type string,
    end of itab.
    regards

    hi,
    use this code.
    parameters: p_fname like rlgrap-filename.
    at selection-screen on value-request for p_fname.
    call function 'F4_FILENAME'
    exporting
       program_name        = syst-cprog
       dynpro_number       = syst-dynnr
    importing
       file_name           = p_fname.
    start-of-selection.
    data:v_fname type string.
         move p_fname to v_fname.
    *reading the input file
    call function 'GUI_UPLOAD'
      exporting
       filename                      = v_fname
       filetype                      = 'ASC'
       has_field_separator           = 'X'
      tables
        data_tab                     = itab.

  • File Upload Using WebDynpro

    Hi All,
    I want to upload single or multiple CSV files using a user interface written in WebDynpros. The files will then be parsed and converted to XML.
    I did something similar with jsps earlier but am not sure how to go about it with WebDynpros.
    If anyone has already done something similar then please share your views.
    Thanks in advance.
    Noaman

    Hi,
    check this link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/web dynpro sample applications and tutorials.htm#ui
    File Upload/Download 23/30
    Tutorials will help you.
    Regards,
    RK

  • How to have concurrent CSV upload and manual edit in APEX on the same table

    Hi there,
    my users want to have csv upload and manual edit on apex pages functions together...
    it means they want to insert the data by csv upload and also have interactive report and form on the same table...
    so if user A changes something in csv file...then user B update or delete another record from apex fronted (manually in the apex form)...then after that user A wants to upload the csv file,the record was changed by user B would be overwritten ...
    So how can I prevent it?????

    Hi Huzaifa,
    Thanks for the reply...
    I'm going to use File Browser so that end users can upload the files themselves...
    after editing data by users...a manger going to review it and in case of approval , i need to insert the data to one final table....
    so it needs much effort to check two source tables and in case of difference between table of csv and other one...what to do...

  • What is ws_upload, upload and gui_upload?

    while i am doing recording sing fk01   in bdc when i am trying to upload .prn file one message is coming i.e. ws_upload is obsolete use gui_upload? then i used gui_upload but .prn file not uploading?why?

    Hi
    GUI_UPLOAD is the new fm has replaced the WS_UPLOAD, when u uses it u make sure the file is beeing loaded has to be closed in your pc.
    Anyway it's better u post the code where u call that fm.
    Max

  • Can't we use GUI_UPLOAD and scshedule in background

    Hi,
    I have a program which uploads a comma delimted text file and updates custom table.
    .It works fine in when I run online but when I schedule it background it fails.
    I used GUI_UPLOAD to upload the text file.
    FORM file_upload.
      CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
      filename = file
    * FILETYPE = 'ASC
    * has_field_separator = ','   <-- Comment this
    * HEADER_LENGTH = 1
    * READ_BY_LINE = 'X'
    * IMPORTING
    * FILELENGTH =
    * HEADER = 'X'
      TABLES
      data_tab = i_datatab
      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.
      LOOP AT i_datatab INTO x_datatab .
        IF sy-tabix GT '1'.
          SPLIT x_datatab-line AT ',' INTO wa_tab-zdate
        wa_tab-empid wa_tab-lname wa_tab-fname wa_tab-cycle wa_tab-branch
        wa_tab-job wa_tab-phase wa_tab-pdept wa_tab-ptype wa_tab-zhour .
          APPEND wa_tab TO i_tab.
        ENDIF.
      ENDLOOP.

    fm GUI_UPLOAD will not work in background
    you need to use
    lv_filename = <input file path> " app server path
    open dataset lv_filename for input in text mode encoding default.
        if sy-subrc = 0.
          do.
            read dataset lv_filename into gs_input-wa_string.
            if sy-subrc eq 0.
              append gs_input to gt_input.
            else.
              exit.
            endif.
          enddo.
          close dataset lv_filename.
        endif.

  • Change from UPLOAD to GUI_UPLOAD  function module

    pls  let me know that  wat are  the  changes that should be made if  the report  currently using UPLOAD function module and it should be  replaced with GUI_UPLOAD  function module ..
    wat should be the TYPE of  file name and File type ????????  with the respect to changes ....
    thanks . in advance..

    Check out this thread to find the answer
    UPLOAD and GUI_UPLOAD
    Regards,
    Santosh

  • How to schedule BDC program in background when we use GUI_UPLOAD

    Hi,
    I need to run the BDC program in the back ground. But my flat file is in presentation server and i am using GUI_UPLOAD F.M to upload data into I.T. How to schedule BDC program in background.
    Will anybody help me in this regards.
    Thanks in advance,
    Mythily

    You will either have to put your data file on the application server or make the directory of the presentation server available as part of the file system so that the background job will have access to it via OPEN DATASET... TRANSFER... CLOSE DATASET.

  • CSV upload for end user

    I've searched all over the web and this forum and haven't found exactly what I'm looking for. I see this referenced a lot (http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/), but it's still a little too technical for me to figure out.
    Is there a packaged app or a dumbed down "how to" for creating a csv upload? I want the end user to be able to upload a csv file (same columns/headings, but the number of rows will vary) and display the table they just uploaded in a report.
    Thank you!!

    Hi Bob,
    Where exactly are you stuck? In the example that Tony linked, all you have to do is modify ~line 53 to the number of columns that will go into your table (and the name of the file browse item).
    i.e.
    APEX_COLLECTION.ADD_MEMBER(
                                p_collection_name => c_collection_name,
                                p_c001 => v_curr_row(1),
                                p_c002 => v_curr_row(2) -- add more of these for the number of columns that will be in your csv file);Or does the example not meet your requirements? If I interpret correctly, you want the user to be able to upload a file where they have specified the column names at the top of the csv file? I have created an example using this technique, although I am not entirely happy with it yet (for the lack of confirming the data that is to be inserted).
    Ta,
    Trent

Maybe you are looking for

  • Error deploying Tutorial to Weblogic Integration 9.2

    Hi all, I am having problems in deploying EAR for tutorial provided by BEA for WLI 9.2 I followed the instructions for "Build your First Business Process" tutorial using Work shop but whenever I tried to deploy it to WL server it always failed due to

  • How create value in segment4 of gl account in batch script ?

    Hi Here is a problem in relation to value creation in a key flexfield (more exactly value in segment4 and segment7 of my accounts combinaison). In one batch, I would like to automatically create values (10 or 50 per day) in segment4 and segment7 of k

  • Lock box project

    Hi all! I was asked to prepare a project scope document as a part of my project of 1 month duration in lockbox configuration for two company codes which daily perform a manual posting of 250 cash payments So, could someone please help me with the det

  • Is there a 2GB file size limit on saving a custom format plugin for a custom file type?

    I have resolved issues on reading files > 2GB. Now when I save files >2GB, I get a popup that states there is a 2GB limit for plugins. I an using photoshop CS6 on a MAC OSX 10.9 with 16 GB RAM. The custom file type is what should be selected when the

  • Asking for receipt of read mail

    Can anyone tell me whether it is possible to ask for a receipt indicating that the person to whom u have sent mail has read it? I cannot seem to find this feature in the Mail program. Thank you