GUI_UPLOAD+HAS_FIELD_SEPARATOR

Hi everybody .
In my program, I use the fm GUI_UPLOAD to upload the flat file which separator is the pipe(|).
Exemple of line :  AAA|BBB|CCC|DDD
HAS_FIELD_SEPARATOR='|' not working, so how can i use this fm and define SEPARATOR  as pipe .
thank  in advance

Hi ,
   I believe the field separator parameter will work for Excel files..You have to get the internal table in a string format..and then use split statement..
     Use the below code it work for me..
DATA: BEGIN OF it_tab OCCURS 0,
       object_id TYPE string,
       version_series_id TYPE string,
       version_number TYPE string,
       revision TYPE string,
       doc_number TYPE string,
       doctitle TYPE string,
       filesize TYPE string,
       mime_type TYPE string,
       plantunit TYPE string,
     END OF it_tab.
DATA: t_tab   TYPE TABLE OF string,
      v_string TYPE string.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                = 'C:\TEST.TXT'
   has_field_separator     = '|'          "Actually not required.*
  TABLES
    data_tab                = t_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.
IF sy-subrc  0.
ENDIF.
LOOP AT t_tab INTO v_string.
  SPLIT v_string AT '|'
        INTO
        it_tab-object_id
        it_tab-version_series_id
        it_tab-version_number
        it_tab-revision
        it_tab-doc_number
        it_tab-doctitle
        it_tab-filesize
        it_tab-mime_type
        it_tab-plantunit.
  APPEND it_tab.
  CLEAR: it_tab.
ENDLOOP.
Regards,
DHina..
Edited by: Dhina DMD on May 13, 2011 1:41 PM
Edited by: Dhina DMD on May 13, 2011 1:47 PM

Similar Messages

  • Upload , dilimited file

    Hi,
      I am tring to upload , dilimited file into internal table using GUIUPLOAD function module. its not reading only first field only. Please help me out.
    Thanks.
    file has
    name,value
    GUI Function
    call function 'GUI_UPLOAD'
        exporting
          filename                = l_name
          has_field_separator     = ','
        tables
          data_tab                = it_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.

    Check this FM documentation:
    FU GUI_UPLOAD                     HAS_FIELD_SEPARATOR
    Short Text
    Columns Separated by Tabs in Case of ASCII Upload
    Description
    Specifies if the fields in the file are separated by a tab. This is necessary if the structure passed contains several components. CR/LF occurs instead of a tab after the last field of a row.
    Value range
    'X': Fields are separated by tabs.
    SPACE: Fields are not separated by tabs. In this case, the table must
    contain either only one single column or all columns must be contained
    in the file in their full length.
    Default
    SPACE
    Function Module
    GUI_UPLOAD
    This is the rich's reply in one of the posts:
    Here is an example program.
    code
    report zrich_0001.
    types: begin of ttab,
    rec(1000) type c,
    end of ttab.
    types: begin of tdat,
    fld1(10) type c,
    fld2(10) type c,
    fld3(10) type c,
    end of tdat.
    data: itab type table of ttab with header line.
    data: idat type table of tdat with header line.
    data: file_str type string.
    parameters: p_file type localfile.
    at selection-screen on value-request for p_file.
    call function 'KD_GET_FILENAME_ON_F4'
    exporting
    static = 'X'
    changing
    file_name = p_file.
    start-of-selection.
    file_str = p_file.
    call function 'GUI_UPLOAD'
    exporting
    filename = file_str
    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.
    loop at itab.
    clear idat.
    split itab-rec at ',' into idat-fld1
    idat-fld2
    idat-fld3.
    append idat.
    endloop.
    loop at idat.
    write:/ idat-fld1, idat-fld2, idat-fld3.
    endloop.
    [/code]
    Regards,
    Rich Heilman
    Edited by: Aparna Shekhar on Jun 2, 2008 2:33 PM

  • In BDC GUI_UPLOAD what is the use of  'HAS_FIELD_SEPARATOR    = ' X'

    Hi Friends
    In BDC Pogram i am uploadig the flat file from presentation server by GUI_UPLOAD fm.
    what is the difference if i use parameters in this fm f  'HAS_FIELD_SEPARATOR           = ' X' AND
    If i didnot mention this parameters i'HAS_FIELD_SEPARATOR           = ' X'

    HAS_FIELD_SEPARATOR = 'X 'is used as tabs in the tab delimited file.
    Regards,
    Sri

  • "Cannot interpret data in file" error while using GUI_UPLOAD for .xls file

    Hi,
         I have made a program using FM GUI_UPLOAD to upload an .xls file to an internal table. But upon executing ,it gives error "Cannot Interpret data in file". I have seen in other posts people talking about GUI_UPLOAD FM to upload data from excel directly into internal table. Kindly help.
    Here is my code. I had tried using different combination for HAS_FIELD_SEPARATOR but still its not working.
    In my emp1.xls file , the data in each column is present in the same order as in the internal table. Although the first column in my internal table is NUMC. I dont know if that is causing the problem.
    REPORT  ZUPLOAD_1.
    data: itab TYPE TABLE OF zempl_master WITH HEADER LINE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'C:\empl1.xls'
        FILETYPE                      = 'ASC'
        HAS_FIELD_SEPARATOR           = 'X'
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   CHECK_BOM                     = ' '
    *   VIRUS_SCAN_PROFILE            =
    *   NO_AUTH_CHECK                 = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      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
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP at itab.
      write:/ itab-emp_no,itab-name.
    endloop.

    hi amber22 you need to use the below fm to upload an xls file
    FORM EXCEL_UPLOAD .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = FILENAM
          I_BEGIN_COL = 1
          I_BEGIN_ROW = 1
          I_END_COL   = 6
          I_END_ROW   = 100
        TABLES
          INTERN      = xl_itab.
    * EXCEPTIONS
    * INCONSISTENT_PARAMETERS = 1
    * UPLOAD_OLE = 2
    * OTHERS = 3 .
      IF SY-SUBRC = 0.
    MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " EXCEL_UPLOAD

  • Getting error while uploading data  using the EXCEL( GUI_upload)

    Dear Freinds,
    I am uploading data from my excel sheet to my Custom table . I am using the below code
    call function 'GUI_UPLOAD'
    exporting
    filename = l_fn
    filetype = 'BIN' "'ASC'
    has_field_separator = 'X'
    tables
    data_tab = p_i_ins_db
    exceptions
    others = 17.
    i can see in my internal P_i_ins_db ...all the data is coming in encrypted format.
    The flat given to me is the .CSV file .
    Could any one please let me know how i can upload the data which is there in .csv file.
    regards
    syamala

    Hi Syamala,
    Before using the GUI_UPLOAD to upload the data from the excel file to the internal table,you can try usng the Function Module 'SAP_CONVERT_TO_TEX_FORMAT' or 'SAP_CONVERT_TO_CSV_FORMAT' as it helps n formatting the data.
    In case you have any further clarifications,do let me know.
    Regards,
    Puneet Jhari.

  • Error while using the function module GUI_UPLOAD

    Hi,
    My requirement is to upload the data from .txt file into internal table.
    I have given my code like this
    PARAMETERS: p_fname LIKE rlgrap-filename.
    data: begin of gt_string occurs 0,
           record type char255,
          end of gt_string.
    AT SELECTION-SCREEN ON VALUE-REQUEST for p_fname.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
       EXPORTING
        PROGRAM_NAME        = SYST-REPID
        DYNPRO_NUMBER       = SYST-DYNNR
        FIELD_NAME          = ' '
         STATIC              = 'X'
        MASK                = ' '
        CHANGING
          file_name           = p_fname
       EXCEPTIONS
         MASK_TOO_LONG       = 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.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = p_fname
         FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
         HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
        DAT_MODE                      = ' '
        CODEPAGE                      = ' '
        IGNORE_CERR                   = ABAP_TRUE
        REPLACEMENT                   = '#'
        CHECK_BOM                     = ' '
        NO_AUTH_CHECK                 = ' '
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        tables
          data_tab                      = gt_string
       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
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Here I am getting dump error as 'Type conflict when calling a function module.
    The function module interface allows you to specify only fields
    of a particular type under "FILENAME". The field "P_FNAME" specified here has a different field type'.
    What would be the reason for this error?
    Can anyone help me?
    Regards,
    Hema

    see this sample program for F4 help
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 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.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 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.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • 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.

  • Problem with GUI_UPLOAD using excel sheet

    Hi,
      I am trying to upload excel sheet thru GUI_UPLOAD ... this excel sheet has a header line and 3 line of data. Even if I remove the header line then also the internal while debugging is showing 28 lines of entries with "#" "squares" in some columns ... while in others where data should be there shows all Zeros....
    The excel sheet has the following info
    Rate Type Valid From Date     From Currency     To Currency      Indirect Quote     Direct Quote
    M       29.09.2006             SGD             USD             1.6932     
    M       29.09.2006             USD             SGD                          1.6932
    M       29.09.2006             SGD             MYR                          2.19653
    KURST GDATU    FCURR TCURR INUKURS     DUKURS
    ###&#2161; |########|#####|### #|   0.00000 |0.00000 |
    ##29 |00000000|     |     |   0.00000 |0.00000 |
    o#d# |00000000|     |     |   0.00000 |0.00000 |
    The code that I am writing is as follows:-
    *& INTERNAL TABLES
    DATA : BEGIN OF T_INPUT occurs 0,
             KURST   LIKE TCURV-KURST,  " Exchange rate type
             GDATU   LIKE SY-DATUM,     " Date from which rate is effective
             FCURR   LIKE TCURC-WAERS,  " From currency
             TCURR   LIKE TCURC-WAERS,  " To currency
             INUKURS LIKE TCURR-UKURS,  " Indirect Quote
             DUKURS  LIKE TCURR-UKURS,  " Direct Quote
           END OF T_INPUT.
                S T A R T - O F - S E L E C T I O N                      *
    START-OF-SELECTION.
    Perform to upload the excel file.
      PERFORM UPLOAD_EXCEL_FILE.
    FORM UPLOAD_EXCEL_FILE .
      DATA: L_FILENM TYPE STRING.
      L_FILENM = P_FILENM.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      = L_FILENM
          FILETYPE                      = 'ASC'
          HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
        TABLES
          DATA_TAB                      = T_INPUT
       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 .
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

    Hi SB,
    pls change the data type declared for 'valid from date'
    from
    DATA : BEGIN OF T_INPUT occurs 0,
    KURST LIKE TCURV-KURST, " Exchange rate type
    <b>GDATU LIKE SY-DATUM,</b> " Date from which rate is effective
    FCURR LIKE TCURC-WAERS, " From currency
    TCURR LIKE TCURC-WAERS, " To currency
    INUKURS LIKE TCURR-UKURS, " Indirect Quote
    DUKURS LIKE TCURR-UKURS, " Direct Quote
    END OF T_INPUT.
    to
    DATA : BEGIN OF T_INPUT occurs 0,
    KURST LIKE TCURV-KURST, " Exchange rate type
    GDATU(10) type c, " Date from which rate is effective
    FCURR LIKE TCURC-WAERS, " From currency
    TCURR LIKE TCURC-WAERS, " To currency
    INUKURS LIKE TCURR-UKURS, " Indirect Quote
    DUKURS LIKE TCURR-UKURS, " Direct Quote
    END OF T_INPUT.
    Cheers,
    Vikram
    Please reward for helpful replies!!

  • Runtime error while using GUI_UPLOAD

    Hi All,
    I have a text file which contains few records delimited by tab.
    I am trying to upload the contents of the file into an internal table using the FM GUI_UPLOAD
    But, I am getting run time error 'Type conflict when calling a function module'.
    The code that I had written is shown below.
    Please let me know where I went wrong.
    REPORT  Z84364BDC                               .
    TYPES : BEGIN OF ITAB_TP,
            MATNR TYPE MARA-MATNR,
            EAN11 TYPE MARA-EAN11,
            END OF ITAB_TP.
    DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
    DATA : ITAB_WA TYPE ITAB_TP.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
    PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
    SELECTION-SCREEN END OF BLOCK B1.
    ***FILLING THE INTERNAL TABLE****
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = P_FILE
        FILETYPE                      = 'ASC'
        has_field_separator           = ','
        tables
        data_tab                      = FILE_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
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    The file is delimited by Comma field as mentioned above.
    Below is the code that I had written. But, I face the same problem
    REPORT  Z84364BDC                               .
    TYPES : BEGIN OF ITAB_TP,
            MATNR TYPE MARA-MATNR,
            EAN11 TYPE MARA-EAN11,
            END OF ITAB_TP.
    DATA : FILE_ITAB TYPE STANDARD TABLE OF ITAB_TP.
    DATA : ITAB_WA TYPE ITAB_TP.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
    PARAMETERS : P_PATH TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.
    SELECTION-SCREEN END OF BLOCK B1.
    DATA : P_FILE TYPE STRING.
    P_FILE = P_PATH.
    ****FILLING THE INTERNAL TABLE*****
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = P_FILE
        FILETYPE                      = 'ASC'
        has_field_separator           = 'X'
        tables
        data_tab                      = FILE_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
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ***Displaying the Material*****
    LOOP AT FILE_ITAB INTO ITAB_WA.
    WRITE:/ ITAB_WA-MATNR.
    ENDLOOP.

  • Error in gui_upload

    hi guru,
    iam doing some bdc program.. but ity will going to dump on gui_upload.. so plz help me.
    An exception occurred that is explained in detail
    The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
    not caught in.
    procedure "F_UPLOAD_FILE" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    The call to the function module "GUI_UPLOAD" is incorrect:
    The function module interface allows you to specify only
    fields of a particular type under "FILENAME".
    The field "P_P_FILE" specified here is a different
    field type
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-h01.                         
    PARAMETERS: p_file LIKE rlgra-filename                                                                               
    SELECTION-SCREEN : END OF BLOCK b1.                                                                                .----
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.                                                                               
    PERFORM f_get_file USING p_file.                                                                               
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'       
    *EXPORTING-                                                                               
    CHANGING                                                                               
    FILE_NAME           = p_p_file                                                                               
    endform.               
    form f_upload_file  using    p_p_file.                                                                               
    CALL FUNCTION 'GUI_UPLOAD'                                                                               
    EXPORTING                                                                               
    FILENAME                      = p_p_file                                                                               
    FILETYPE                      = 'DAT'                                                                               
    endform.

    Hi,
    Refer the program given below. it is working fine for me.
    make the paramerter as:
    pa_dfile TYPE rcgfiletr-ftfront.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_dfile.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static        = 'X'
          mask          = '(Text file|*.TXT'
        CHANGING
          file_name     = pa_dfile
        EXCEPTIONS
          mask_too_long = 1
          OTHERS        = 2.
      IF sy-subrc <> 0.
        MESSAGE ID 'PG' TYPE 'E' NUMBER '016'
              WITH 'Error in F4 help'(005).
        "The provided file is not an excel sheet.
        RETURN.
      ENDIF.
    DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'ASC'.
      lv_gui_sep = 'X'.
      lv_file_name = pa_dfile.
    FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep 
        TABLES
          data_tab                = gi_table
        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.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Hope it helps.
    Regards
    Rajesh Kumar
    Edited by: Rajesh Kumar on Jul 24, 2009 7:11 AM

  • Issue with field separator in GUI_UPLOAD

    Hello Gurus
    I am facing issue with gui_upload. I have a text file in which the fields are eparated by single Pipe  i.e |. Now when I try to read the data from file in internal table even with using field separator it does not insert data in proper fields.
    DATA: BEGIN OF IT_TAB OCCURS 0,
          OBJECT_ID type string,
          VERSION_SERIES_ID TYPE string,
          VERSION_NUMBER TYPE string,
          REVISION TYPE string,
          DOC_NUMBER TYPE string,
          DOCTITLE TYPE string,
          FILESIZE TYPE string,
          MIME_TYPE TYPE string,
          PLANTUNIT TYPE string,
          END OF IT_TAB.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = w_mpath
        FILETYPE                      = 'ASC'
        HAS_FIELD_SEPARATOR           = '|'
      HEADER_LENGTH                 = 0
       READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = it_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
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I want the data to get appended in internal table based on | separator.
    Please help.
    Regards,
    Rajesh.

    Hi,
    I believe the field separator parameter will work for Excel files..You have to get the internal table in a string format..and then use split statement..
    check this example..
    DATA: BEGIN OF it_tab OCCURS 0,
           object_id TYPE string,
           version_series_id TYPE string,
           version_number TYPE string,
           revision TYPE string,
           doc_number TYPE string,
           doctitle TYPE string,
           filesize TYPE string,
           mime_type TYPE string,
           plantunit TYPE string,
         END OF it_tab.
    DATA: t_tab   TYPE TABLE OF string,
          v_string TYPE string.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                = 'C:\TEST.TXT'
    *    has_field_separator     = '|'          "Actually not required.
      TABLES
        data_tab                = t_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.
    IF sy-subrc <> 0.
    ENDIF.
    LOOP AT t_tab INTO v_string.
      SPLIT v_string AT ','
            INTO
            it_tab-object_id
            it_tab-version_series_id
            it_tab-version_number
            it_tab-revision
            it_tab-doc_number
            it_tab-doctitle
            it_tab-filesize
            it_tab-mime_type
            it_tab-plantunit.
      APPEND it_tab.
      CLEAR: it_tab.
    ENDLOOP.
    Thanks
    Naren
    Edited by: Narendran Muthukumaran on Oct 15, 2008 4:58 PM

  • GUI_Upload & GUI_Download for excel files

    Hi experts,
    I want to upload excel file into sap. i am trying with GUI_Upload function module. when i see the data it is filled with # and other special char. When i save the excel file as .txt file and then read the txt file. Now i am getting correct data. Is it possible to read Excel data using GUI_UPLOAD directly without changing .xls to .txt.
    Also, how to change data in  second or  third tab of excel file using GUI_Download.
    -RK

    Hi
    Actually ur file selection s wrong.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          PROGRAM_NAME  = SYST-REPID
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = 'P_FNAME'
          STATIC        = 'X'
         MASK          = '*.txt'
        CHANGING
          FILE_NAME     = P_FNAME
        EXCEPTIONS
          MASK_TOO_LONG = 1
          OTHERS        = 2.
    Upload:
    CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                = LV_FNAME
          FILETYPE                = 'ASC'
          HAS_FIELD_SEPARATOR     = 'X'
        TABLES
          DATA_TAB                = IT_UEXBANK01
        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.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

  • GUI_UPLOAD Function Module in 4.6C does not split into lines

    Dear All,
    I'm about to upload text file into SAP using the FM 'GUI_UPLOAD'.
    Previously I've developed a test program to upload the same file in SAP v4.7
    and it returns correctly into several lines as expected.
    Snippet:
    CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = l_filename
          filetype                        = 'ASC'
          has_field_separator       = ' '
          header_length               = 0
          read_by_line                  = 'X'
        TABLES
          data_tab                      = gt_tabfile
    As we can see, the 'read_by_line' parameter is already 'X'. gt_tabfile only consist of 1 string column.
    But as I run the same code using the same parameter and file in SAP v4.6C
    it returned only 1 line of very long string instead of the correct lines resulted in 4.7.
    Is there anything to do with codepage (4.6 is English 1100, I forgot the codepage in 4.7 but i believe it's the same due to language selection is EN). Or anything to do with OSS Note?
    Kindly help me to resolve the issue.
    Appreciate it very much

    Thank you for trying to help.
    Please be noted I've done all the possible value on these parameter
    -   filetype 'ASC' OR 'BIN'
    -  has_field_separator ' ' or 'X'
    -  header_length 0 or 1 which is dont make sense since my file dont have header so must be 0
    -  read_by_line ' ' of 'X' doesnt work my expectation.
    Any other good questions please? How 4.6C and 4.7 above make a different result?

  • Problem in GUI_Upload only first field is appending into table

    Hi all,
      I m using code :-
    DATA : BEGIN OF RAWDATA OCCURS 0,
            RECORD type string,
           END OF RAWDATA.
      CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            FILENAME                      = g_file
            FILETYPE                      = 'DAT'
            HAS_FIELD_SEPARATOR           = 'X'
          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
    structure of g_file is like ---
    TEST1     MAT1     2     EA     15.00     1
    TEST2     MAT2     2     EA     20.00     1
    TEST3     MAT1     2     EA     15.00     1
    TEST4     MAT2     2     EA     25.00     1
    TEST5     MAT2     2     EA     30.00     1
    now my problem is in rawdata table record is coming as
    test1
    test2
    but i need it as
    test1mat12EA.......
    Thanks & Regards,
    Ruchi Tiwari

    Hi Ruchi,
    Are you using excel sheet to upload or text file?
    If you are using excel sheet for uplaoding then you can refer to the below code:
    P_FILE                 TYPE FILE_NAME OBLIGATORY.
    lv_FILE = P_FILE.
    ****************** CALL FUNCTION MODULE GUI_UPLOAD******************
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME = lv_FILE
          FILETYPE = 'ASC'
        TABLES
          DATA_TAB = it_string.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    I hope this helps.
    Thanks,
    Archana

  • Doubt in GUI_UPLOAD function

    Hi friends,
    CALL FUNCTION 'GUI_UPLOAD '
    EXPORTING
    FILENAME = FILE
    FILETYPE = 'ASC'
    *HAS_FIELD_SEPARATOR = 'X'
    TABLES
    DATA_TAB = ITAB.
    In the GUI_UPLOAD function what the filetype should be and has_field_separator should be given what value? What does it mean.How should i prepare the file for example for VA01 transaction if i have a file like this it is not working. What is the problem. I am new to BDC so i need your help on this.
    Thanks in Advance.

    try the following.
    DATA: begin of ITAB occurs 0,
          field1 type char10,
          field2 type char10,
          end of itab.
    data: filename type string value 'C:\TMP.TXT'.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
       FILENAME                      = filename
       FILETYPE                      = 'ASC'
      TABLES
        DATA_TAB                      = itab.
    loop at itab.
      write:/ itab-field1, 20 itab-field2.
    endloop.
    create a file with tab-delimitations.

Maybe you are looking for

  • Need help connecting to my digital receiver

    I bought an airport express to play itunes from my computer to my stereo. I have a digital receiver that's fairly old but still digital with optical inputs. I don't want to just connect RCA cables from airport express to receiver-i want to take advan

  • External microphone

    I can't get an external microphone to work on my HP Pavillion dv7 laptop.  I have read through most of the posts and nothing has helped.  However, I haven't seen anyone who has had my exact experience.  When I plug in either of two external microphon

  • Photo upload pop up window

    When I try to upload a new album to Facebook or pictures to printerpix the photo upload window where I choose which photos to add does not come up, until I click on another screen. But then when it does come up everything is frozen and I have to forc

  • Can anyone guide me to ideas on basics of parallel processing in SQL

    Hi all, Can anyone guide me to ideas on basics of parallel processing in SQL and its usage in the the performance tuning of the query. If so what's the syntax to be followed and how to arrive at the optimized query after tuning

  • System problems after installing iphone & itunes

    I'm wondering if anyone else has noticed a weird problem with their computers after installing the iphone & itunes. Up untill i got the iphone, my computer was working fine. Now about every 15 - 30 mins, i get a few seconds of static sound from my sp