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: 

upload data to internal table without fixing the excel column width

former_member185116
Active Participant
0 Kudos

hello all,

i am uploading the data to internal table using TEXT_CONVERT_XLS_TO_SAP.

here the column width of excel is equivalent to column width of internal table field otherwise it is giving an error,

my question is there any other way to upload data to internal table with out fixing the excel column width ....

thankq....

4 REPLIES 4

Former Member
0 Kudos

Hi Vinay,

Try this Function Module 'ALSM_EXCEL_TO_INTERNAL_TABLE'.

Former Member
0 Kudos

Hi Vinay,

you may use "ALSM_EXCEL_TO_INTERNAL_TABLE" or "KCD_EXCEL_OLE_TO_INT_CONVERT" 

function modules for upload excel file into an internal table. Please find the below code for your reference.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

       exporting

            filename                = p_infile

            i_begin_col             = '1'

            i_begin_row             = '2'  "Do not require headings

            i_end_col               = '14'

            i_end_row               = '31'

       tables

            intern                  = itab

       exceptions

            inconsistent_parameters = 1

            upload_ole              = 2

            others                  = 3.

  if sy-subrc <> 0.

    message e010(zz) with text-001. "Problem uploading Excel Spreadsheet

  endif.

* Sort table by rows and colums

  sort itab by row col.

* Get first row retrieved

  read table itab index 1.

* Set first row retrieved to current row

  gd_currentrow = itab-row.

  loop at itab.

*   Reset values for next row

    if itab-row ne gd_currentrow.

      append wa_record to it_record.

      clear wa_record.

      gd_currentrow = itab-row.

    endif.

    case itab-col.

      when '0001'.                              "First name

        wa_record-name1 = itab-value.

      when '0002'.                              "Surname

        wa_record-name2 = itab-value.

      when '0003'.                              "Age

        wa_record-age   = itab-value.

    endcase.

  endloop.

  append wa_record to it_record.

* Display report data for illustration purposes

  loop at it_record into wa_record.

    write:/     sy-vline,

           (10) wa_record-name1, sy-vline,

           (10) wa_record-name2, sy-vline,

           (10) wa_record-age, sy-vline.

  endloop.

Regards,

Krishna.

former_member206650
Active Participant
0 Kudos

hi,

you can use the above mentioned FM or through OOPS by cl_gui_frontend_services class

ABAP code snippet to upload Excel file into an internal table and display it in alv format - ABAP De...

CALL METHOD cl_gui_frontend_services=>gui_upload.

former_member200434
Participant
0 Kudos

can u show code of calling FM text_convert_xls_to_sap