Skip to Content
avatar image
Former Member

Reg: TEXT_CONVERT_XLS_TO_SAP; Problem opens a new empty excel file

Hi All,

The Function Module 'TEXT_CONVERT_XLS_TO_SAP' opens a new empty excel sheet while uploading the file.

Please give me a solution for this. I do not want the empty excel file to be opened.

Thanks,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 17, 2011 at 04:30 AM

    DATA:t_raw TYPE truxs_t_text_data.

    PARAMETERS: p_file TYPE rlgrap-filename.

    "Upload the file

    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

    EXPORTING

    i_line_header = 'X'

    i_tab_raw_data = t_raw

    i_filename = p_file

    TABLES

    i_tab_converted_data = t_tab[]

    EXCEPTIONS

    conversion_failed = 1

    OTHERS = 2.

    IF sy-subrc 0.

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

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

    ENDIF.

    Please specify the path of the file p_file, contains the excel file which you want to upload contains data, or the active sheet contains the data.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 17, 2011 at 03:55 PM

    Hi,

    Do like below. This will solve your problem.

    *--Uploading xls sheet
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = p_locin     "Path of file
          has_field_separator     = c_x
        TABLES
          data_tab                = li_text_data
        EXCEPTIONS
          file_open_error         = 1.
    
      lv_file  = p_locin.
    *--Converting the xls to readable format
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator    = c_x
          i_tab_raw_data       = li_text_data
          i_filename           = lv_file
        TABLES
          i_tab_converted_data = i_locfile
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Please try this out

      DATA: t_file TYPE STANDARD TABLE OF alsmex_tabline.

      constants :c_begin_col TYPE i VALUE '1',

      c_begin_row TYPE i VALUE '1',

      c_end_col TYPE i VALUE '38',

      c_end_row TYPE i VALUE '65535'.

      DATA: lt_filetable TYPE filetable,

      lx_filetable TYPE file_table,

      lv_rc TYPE i.

      CALL METHOD cl_gui_frontend_services=>file_open_dialog

      EXPORTING

      window_title = c_sel_text

      default_extension = c_ext_exl

      CHANGING

      file_table = lt_filetable

      rc = lv_rc

      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.

      ENDIF.

      READ TABLE lt_filetable INTO lx_filetable INDEX 1.

      CHECK sy-subrc EQ 0.

      p_file = lx_filetable-filename.

      CLEAR t_file[].

      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

      EXPORTING

      filename = p_file

      i_begin_col = c_begin_col

      i_begin_row = c_begin_row

      i_end_col = c_end_col

      i_end_row = c_end_row

      TABLES

      intern = t_file[]

      EXCEPTIONS

      inconsistent_parameters = 1

      upload_ole = 2

      OTHERS = 3.

      IF sy-subrc <> 0.

      MESSAGE s000 WITH text-002.

      ENDIF.

      Edited by: Rahul Babukuttan on Mar 18, 2011 9:03 AM