UPLOAD FILE FROM EXCEL

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
VONKAJAY

UPLOAD FILE FROM EXCEL

Post by VONKAJAY » Mon Oct 21, 2002 10:28 am

HI ALL ABAP EXPERTS:
IS THERE A WAY TO DIRECTLY UPLOAD FILE FROM AN EXCEL SHEET DIRECTLY AND NOT CONVERTING INTO TEXT FILES. IS THERE A DIRECT UPLOAD FUNCTION.
ANY HELP IS APPRECIATED
AJAY
SAP PROJECT MANAGER
BOSCH INC.

Guest

Post by Guest » Mon Oct 21, 2002 10:46 am

FUNCTION MODULE 'ALSM_EXCEL_TO_INTERNAL_TABLE'

TwoABAPers
Posts: 990
Joined: Sun Oct 20, 2002 9:16 pm
Location: web
Contact:

Post by TwoABAPers » Tue Oct 22, 2002 1:17 am

Hi ,
You can use following routine

Code: Select all

*======================================================================*
* Subroutine to upload data from excel file from local PC              *
*----------------------------------------------------------------------*
*  --->  P_TAB        Internal table for data to be uploaded           *
*  --->  P_FILENAME   File to be uploaded                              *
*  <---  P_RC         Return Code                                      *
*======================================================================*
form f_excel_upload  tables   p_tab
                     using    p_filename  like rlgrap-filename
                              p_rc        like sy-subrc.
  data : $i_intern type  kcde_cells occurs 0 with header line.
  data : $v_index type i.
  data : $v_start_col type i value '1',
         $v_start_row type i value '1',
         $v_end_col   type i value '256',
         $v_end_row   type i value '65536'.
  field-symbols : <$fs>.
  call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
       exporting
            filename                = p_filename
            i_begin_col             = $v_start_col
            i_begin_row             = $v_start_row
            i_end_col               = $v_end_col
            i_end_row               = $v_end_row
       tables
            intern                  = $i_intern
       exceptions
            inconsistent_parameters = 1
            upload_ole              = 2.
  move : sy-subrc to p_rc.
  check not $i_intern[] is initial.
  sort $i_intern by row col.
  loop at $i_intern.
    move : $i_intern-col to $v_index.
    assign component $v_index of structure p_tab to <$fs>.
    move : $i_intern-value to <$fs>.
    at end of row.
      append p_tab.
      clear p_tab.
    endat.
  endloop.
endform.
Regards,
Sudhir/Mohit

Post Reply