Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Encounter message UPLOAD_OLE in FM ALSM_EXCEL_TO_INTERNAL_TABLE

colin_cheong
Contributor
0 Kudos
2,207

Hi SAP Guru,

I was trying out the function ALSM_EXCEL_TO_INTERNAL_TABLE under SE37.

My intention is to upload an excel workbook with multiple sheets.

I encountered exception, sy-subrc = 2 and it returns UPLOAD_OLE

in here:-

CALL METHOD OF worksheet 'Cells' = h_cell1

EXPORTING #1 = i_end_row #2 = i_end_col.

m_message.

What's is missing?

4 REPLIES 4

gopi_narendra
Active Contributor
0 Kudos
147

Check out the sample example below

parameters       : p_ifname type rlgrap-filename.

data : it_data type table of alsmex_tabline initial size 0,
         is_data type alsmex_tabline.

* Flatfile internal table.
types : begin of ty_tab,
              zuonr type bsid-zuonr,
           end of ty_tab.

data : it_tab type table of ty_tab initial size 0,
         is_tab type ty_tab.

*&--------------------------------------------------------------*
*&      Form  upload_data_excel
*&--------------------------------------------------------------*
*       text
*---------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*---------------------------------------------------------------*
form upload_data_excel.

* If Input file name is not initial.
  if not p_ifname is initial.
* Upload EXCEL data into internal table
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
         exporting
              filename                = p_ifname
              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 id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
  endif.

* Append EXCEL Data into a internal table
  loop at it_data into is_data.
    at new row.
      clear is_tab.
    endat.
    if is_data-col = '001'.
      move is_data-value to is_tab-zuonr.
    endif.
    at end of row.
      append is_tab to it_tab.
    endat.
    clear : is_data.
  endloop.

Regards

Gopi

Former Member
0 Kudos
147

Check the below link

Reward Points if helpful

Thanks

Seshu

former_member189059
Active Contributor
0 Kudos
147

Hi Colin,

1. i do not think that the function module allows uploading of data in sheets other than the first

2. make sure the parameters you specified exist in the excel file

ie: ensure that the end row and column are not past any limit and that they are larger than the start row and col specified

0 Kudos
147

Where can I find an Upload for multiple worksheet within a workbook?