Skip to Content
avatar image
Former Member

CRM ABAP How to upload an Excel file into an internal table?

How to upload an Excel file using GUI_UPLOAD?? what should be the values of the parameters? The function modules ALSM_EXCEL_TO_INTERNAL_TABLE and KCD_EXCEL_OLE_TO_INT are not present in CRM. Please suggest me a way out!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    May 31, 2006 at 06:15 AM

    Hi Saurabh,

    You can use TEXT_CONVERT_XLS_TO_SAP FM to upload an excel file. I am also attaching sample code for ur reference.

    data: begin of itab occurs 0,

    matnr type mara-matnr,

    end of itab.

    data: dummy type TRUXS_T_TEXT_DATA.

    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

    EXPORTING

    i_tab_raw_data = dummy

    i_filename = 'D:\matnr.xls'

    tables

    i_tab_converted_data = itab

    Alternatively you can use GUI_UPLOAD.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = 'D:\matnr'

    filetype = 'ASC'

    has_field_separator = 'X'

    TABLES

    data_tab = itab

    Please award points if you find it useful.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 31, 2006 at 03:59 AM

    Hi

    Use the GUI_UPLOAD with the parameters

    HAS_FIELD_SEPARATOR = 'X'

    DAT_MODE = 'X'

    Regards,

    Ravi

    Note : Please mark the helpful answers

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 31, 2006 at 04:15 AM

    Hi saurabh,

    you can try the folowing sample..

    and make modifications according to your requirement..

    TYPE-POOLS: truxs.
    
    DATA: i_text_data TYPE truxs_t_text_data,
    v_filename_string TYPE string.
    
    DATA: BEGIN OF itab OCCURS 0,
    Name(30),
    Phone(15),
    Fax(500).
    DATA: END OF itab.
    
    PARAMETERS: p_file LIKE rlgrap-filename.
    
    START-OF-SELECTION.
    
    v_filename_string = p_file.
    
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_filename_string
    filetype = 'ASC'
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    dat_mode = ''
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_text_data
    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.
    
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    i_field_seperator = 'X'
    * I_LINE_HEADER =
    i_tab_raw_data = i_text_data
    i_filename = p_file
    TABLES
    i_tab_converted_data = itab
    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.
    
    
    

    this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..

    regards

    satesh

    Add comment
    10|10000 characters needed characters exceeded

  • May 31, 2006 at 04:50 AM

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    FILENAME = file_name

    FILETYPE = 'DAT'

    TABLES

    data_tab = itab

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 31, 2006 at 05:09 AM

    Hi Saurabh,

    You can try using the function module GUI_UPLOAD with the following parameters:

    HAS_FIELD_SEPARATOR = 'X'

    Also u can convert the excel into a tab delimited(while saving use option save as and in file type put tab delimited)and use this FM in your program. The fields of excel file should be in same sequence as that of fields in internal table.

    Regards,

    Usha

    PS:Please mark the helpful answers

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 31, 2006 at 05:12 AM

    Check whether this FM works there...

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    filename = 'C:\TEMP.XLS'

    i_begin_col = 1

    i_begin_row = 1

    i_end_col = 255

    i_end_row = 255

    tables

    intern = itab

    EXCEPTIONS

    INCONSISTENT_PARAMETERS = 1

    UPLOAD_OLE = 2

    OTHERS = 3

    .

    Cheers,

    Thomas.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      ALSM_EXCEL_TO_INTERNAL_TABLE doesn't work at all. In fact it's worse: it is limited to 50chars per column!