How to upload an excel file into SAP internal tables


Excel file

 1

Selection-Screen

 

Parameter to get excel file destination.

 2

Result:

 3

 

Codes:

 

** Job: Upload from excel into internal table..

report  zfile_upload_from_excel.

type-pools truxs.

parameter p_excel type rlgrapfilename

               default ‘C:EXCEL_EXAMPLE.xls’

            obligatory.

* Excel Structure

typesbegin of itab,

       val1 type string,

       val2 type string,

       val3 type string,

       end of itab.

data lt_itab type standard table of itab,

       ls_itab type itab,

       it_type type truxs_t_text_data.

* Getting Excel File Destination

at selection-screen 

   on value-request for p_excel.

call function ‘F4_FILENAME’

 exporting

  field_name    ‘P_EXCEL’

 importing

  file_name     p_excel.

start-of-selection.

* Converting Excel File

call function ‘TEXT_CONVERT_XLS_TO_SAP’

 exporting

  i_tab_raw_data       it_type

  i_filename           p_excel

 tables

  i_tab_converted_data lt_itab[].

end-of-selection.

loop at lt_itab into ls_itab.

  write:/ ls_itabval1.

  write space.

  write ls_itabval2.

  write space.

  write ls_itabval3.

endloop.

Leave a comment

Your email address will not be published. Required fields are marked *