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

how to upload an excel sheet to an internal table

hi all,

i have to transfer an excel sheet(tab separated) into an internal table.i am doing this by calling function ws_upload bt its giving error during uploading.

regards,

shweta upadhyay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 06:14 AM

    check the file name variable. It should be of the type of import parameter of function module you are using. Any difference will cause a dump.

    open the FM and see the import type and give the same in the selection screen of yours

    regards,

    Sandeep Josyula

    • Mark helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 26, 2006 at 06:14 AM

    Hi,

    USE function module <b>GUI_UPLOAD</b> to upload the excel file and save the excel as a tab delimited file.

    and pas through the f.m .

    U can able to upload it..

    Cheers,

    Simha.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 06:19 AM

    hi shweta,

    Refer this thread for more info..

    upload-the-xl-sheet-to-an-it

    Hope this helps !!!

    Cheers

    Alfred

    Reward with points for helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

    • ALSM_EXCEL_TO_INTERNAL_TABLE

      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

      exporting

      FILENAME = P_FILE

      I_BEGIN_COL = 1

      I_BEGIN_ROW = 1

      I_END_COL = 256

      I_END_ROW = 65356

      tables

      INTERN = IT_DATA

      exceptions

      INCONSISTENT_PARAMETERS = 1

      UPLOAD_OLE = 2

      others = 3.

      if SY-SUBRC <> 0.

      message E024(PC).

      endif.

      loop at IT_DATA into IS_DATA.

      if IS_DATA-COL eq '001'.

      move IS_DATA-VALUE to IS_TAB-WERKS.

      endif.

      if IS_DATA-COL eq '002'.

      move IS_DATA-VALUE to IS_TAB-MATNR.

      endif.

      if IS_DATA-COL eq '003'.

      move IS_DATA-VALUE to IS_TAB-ZLL_CONFMODE.

      endif.

      if IS_DATA-COL eq '004'.

      move IS_DATA-VALUE to IS_TAB-ZLL_LOW.

      endif.

      if IS_DATA-COL eq '005'.

      move IS_DATA-VALUE to IS_TAB-ZLL_HIGH.

      endif.

      clear IS_DATA.

      endloop.

      Regards

      - Gopi

  • Posted on Oct 26, 2006 at 06:22 AM

    hi,

    check this code.

    DATA: IT_XLFILD LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

    ===[SELECTION SCREEN]=================================================

    PARAMETERS: fname LIKE rlgrap-filename LOWER CASE OBLIGATORY.

    ===[AT SELECTION-SCREEN]==============================================

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname.

    PERFORM f4_file_name CHANGING fname.

    (for select the excel file ).

    FORM f4_file_name CHANGING p_fname.

    CALL METHOD cl_gui_frontend_services=>file_open_dialog

    EXPORTING

    window_title = 'Select File'

    default_extension = 'Excel Files (*.XLS)'

    file_filter = cl_gui_frontend_services=>filetype_excel

    initial_directory = 'C:\'

    CHANGING

    file_table = lt_files

    rc = lv_return

    EXCEPTIONS

    file_open_dialog_failed = 1

    cntl_error = 2

    error_no_gui = 3

    not_supported_by_gui = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    READ TABLE lt_files INTO ls_files INDEX 1.

    fname = ls_files-filename.

    CLEAR lt_files[].

    ENDIF.

    ENDFORM. " f4_file_name

    ( for uploading excel file )

    FORM upload_file .

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    filename = fname

    i_begin_col = '1'

    i_begin_row = '2'

    i_end_col = '19'

    i_end_row = '9999'

    TABLES

    intern = it_xlfild

    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.

    • Sort table by rows and colums

    SORT it_xlfild BY row col.

    • Get first row retrieved

    READ TABLE it_xlfild INDEX 1.

    • Set first row retrieved to current row

    lv_gd_currentrow = it_xlfild-row.

    LOOP AT it_xlfild.

    • Reset values for next row

    IF it_xlfild-row NE lv_gd_currentrow.

    • append wa_record to it_record.

    APPEND it_file_up.

    • append IT_FILE_STR to it_record. IT_FILE_UP

    CLEAR it_file_up.

    • clear IT_FILE_STR.

    lv_gd_currentrow = it_xlfild-row.

    ENDIF.

    CASE it_xlfild-col.

    WHEN '0001'.

    it_file_up-hdr = it_xlfild-value.

    WHEN '0002'.

    it_file_up-bukrs = it_xlfild-value.

    WHEN '0003'.

    it_file_up-bldat = it_xlfild-value.

    WHEN '0004'.

    it_file_up-blart = it_xlfild-value.

    WHEN '0005'.

    it_file_up-budat = it_xlfild-value.

    WHEN '0006'.

    it_file_up-xblnr = it_xlfild-value.

    WHEN '0007'.

    it_file_up-waers = it_xlfild-value.

    WHEN '0008'.

    it_file_up-bktxt = it_xlfild-value.

    WHEN '0009'.

    it_file_up-bschl = it_xlfild-value.

    WHEN '0010'.

    it_file_up-hkont = it_xlfild-value.

    WHEN '0011'.

    it_file_up-kostl = it_xlfild-value.

    WHEN '0012'.

    it_file_up-prctr = it_xlfild-value.

    WHEN '0013'.

    it_file_up-wrbtr = it_xlfild-value.

    WHEN '0014'.

    it_file_up-wrbtr1 = it_xlfild-value.

    WHEN '0015'.

    it_file_up-mwskz = it_xlfild-value.

    WHEN '0016'.

    it_file_up-valut = it_xlfild-value.

    • WHEN '0016'.

    • it_file_up-geber = it_xlfild-value.

    • WHEN '0017'.

    • it_file_up-fistl = it_xlfild-value.

    WHEN '0017'.

    it_file_up-zuonr = it_xlfild-value.

    WHEN '0018'.

    it_file_up-sgtxt = it_xlfild-value.

    ENDCASE.

    ENDLOOP.

    APPEND it_file_up.

    CLEAR it_file_up.

    • append wa_record to it_record.

    ENDFORM. " upload_file

    reward points if its helpfull.

    praveen.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 06:22 AM

    begin of itab,

    field1(50) type c,

    field2(50) type c,

    end of itab occurs 0.

    CALL FUNCTION 'GUI_UPLOAD'

    exporting

    filetype = 'ASC'

    filename = 'C:\DOWNLOAD.XLS'

    tables

    data_tab = itab.

    This function module treats the data in tab delimated format, which actually is in the XLS file format.

    So, field1 resembles to column1 and field2 resembles to column2 of excel file.

    Let me know if you have any further queries.

    Don't forget to mark helpful answers!

    Gaurav Parmar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 06:25 AM

    Hi,

    can use the following code,

    data : begin of head occurs 0,

    fie(20) type c,

    end of head.

    data : l_tmp_fl(40).

    selection-screen begin of block ysr.

    parameters: p_fname like rlgrap-filename,

    p_oname like rlgrap-filename modif id act.

    selection-screen end of block ysr.

    *----


    *

    at selection-screen.

    *----


    *

    *----- Existenz Datei

    clear l_tmp_fl.

    call function 'WS_QUERY'

    exporting

    query = 'FE' "Filename exist

    filename = p_fname

    importing

    return = l_tmp_fl.

    if l_tmp_fl(1) = space or l_tmp_fl(1) = '0'.

    message e718(01) with p_fname.

    • Datei & nicht vorhanden

    endif.

    at selection-screen on value-request for p_fname.

    perform f_file_dialog using p_fname.

    start-of-selection.

    perform f_get_data.

    form f_file_dialog using p_file.

    data: i_file like draw-filep,

    o_file like draw-filep.

    call function 'F4_FILENAME'

    exporting

    dynpro_number = syst-dynnr

    field_name = 'PATH'

    importing

    file_name = p_file

    exceptions

    others = 1.

    i_file = p_file.

    call function 'CV120_SPLIT_FILE'

    exporting

    pf_file = i_file

    importing

    pfx_file = o_file.

    concatenate o_file '_RESULT.XLS' into p_oname.

    endform. " f_file_dialog

    form f_get_data .

    data: lt_intern type kcde_cells occurs 0 with header line.

    data: ld_index type i.

    field-symbols: <fs>.

    call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'

    exporting

    filename = p_fname

    i_begin_col = 1

    i_begin_row = 1

    i_end_col = 256

    i_end_row = 65536

    tables

    intern = lt_intern

    exceptions

    inconsistent_parameters = 1

    upload_ole = 2

    others = 3.

    if sy-subrc eq 0.

    • Move data from LT_INTERN into T_ITAB

    sort lt_intern by row col.

    sort lt_intern by row col.

    loop at lt_intern.

    move lt_intern-col to ld_index.

    assign component ld_index of structure itab to <fs>.

    move lt_intern-value to <fs>.

    at end of row.

    append itab. clear itab.

    endat.

    endloop.

    endif.

    endform. " f_get_data

    regards,

    Rajesh.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 06:32 AM

    i am giving the code which i am using for uploading the file.

    DATA : BEGIN OF itab OCCURS 0,

    lastname(15) TYPE c,

    firstname(60) TYPE c,

    unique_id(15) TYPE c,

    org_unit(10) TYPE c,

    personnel_type(15) TYPE c,

    level1_description(20) TYPE c,

    level2_description(80) TYPE c,

    date1 TYPE n,

    date2 TYPE n,

    date3 TYPE n,

    date4 TYPE n,

    date5 TYPE n,

    date6 TYPE n,

    date7 TYPE n,

    date8 TYPE n,

    date9 TYPE n,

    date10 TYPE n,

    date11 TYPE n,

    date12 TYPE n,

    date13 TYPE n,

    date14 TYPE n,

    date15 TYPE n,

    date16 TYPE n,

    date17 TYPE n,

    date18 TYPE n,

    date19 TYPE n,

    date20 TYPE n,

    date21 TYPE n,

    date22 TYPE n,

    date23 TYPE n,

    date24 TYPE n,

    date25 TYPE n,

    date26 TYPE n,

    date27 TYPE n,

    date28 TYPE n,

    date29 TYPE n,

    date30 TYPE n,

    date31 TYPE n,

    END OF itab.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    filename = 'C:\PEP_Report4'

    filetype = 'ASC'

    TABLES

    data_tab = itab.

    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.