Application Development and Automation 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: 
Read only

Excel file data reading into program's local itab?

former_member202077
Participant
0 Likes
1,553

Hello

Requirement is: User will pick an excel file from local machine and expets data base update as per that excel file

So, i am reading that excel file into program(report prog. user will run it ONLINE/MANUALLY) specific internal table by using the below FM / code,

Note: We are on Windows 7 with dot XLSX format Excel, ECC 60 with  GUI 720

DATA:  it_excel  TYPE STANDARD TABLE OF alsmex_tabline.

  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = p_file
      i_begin_col            =  '1'

      i_begin_row            =  '2'

      i_end_col              = '10'

      i_end_row              = '2000'
    TABLES
      intern                  = it_excel (declared as )
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.

But, when user is runing this report,  user is getting below popup (MS Excel popup, saying that, Do you wan to save the changes you made to 'test_excel_file' with a 3 push buttons, like, SAVE DON'T SAVE CENCEL), pls. see the attached JPEG file

Pls. let me know how can i fix it? or i should use ther function module instaed of the above FM?

Thank you

5 REPLIES 5
Read only

Former Member
0 Likes
1,226

Hi MSR,

What other options have you tried?

TEXT_CONVERT_XLS_TO_SAP

Thanks,

Shambu

Read only

davis_raja
Active Participant
0 Likes
1,226

Dear MSR,

    I dont think ALSM_EXCEL_TO_INTERNAL_TABLE will give error for .xlsx files.

    Check the code. There might be additional code that you have added.

Read only

venkateswaran_k
Active Contributor
0 Likes
1,226

Dear MSR.

Try this code.. 

form UPLOAD_DATA .

  DATA: loc_filename TYPE rlgrap-filename. "string.

  DATA: it_raw TYPE truxs_t_text_data.

  loc_filename = p_file.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

    EXPORTING

 

*     I_FIELD_SEPERATOR    =

      i_line_header        = 'X'
      i_tab_raw_data      = it_raw       " WORK TABLE
      i_filename             = loc_filename
    TABLES
      i_tab_converted_data = it_itab       "gt_upload[]    "ACTUAL DATA
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.

endform. " UPLOAD_DATA

Please post back with your results

Regards,

Venkat

Read only

former_member213851
Active Contributor
0 Likes
1,226

Hi MSR,

FM ALSM_EXCEL_TO_INTERNAL_TABLE should not give any issue for reading Excel files.

It might be the case that  " yvmcon01 bdc template " is the Excel  file already opened in your machine with some changes made in it and then you are using same file for uploading.

Also you can check below link where z_file_upload_download is used for Upload/Download  :

You just need to create Z function module using SE37 as below::

http://wiki.sdn.sap.com/wiki/display/ABAP/Function+Module+to+Upload+and+Download+files+from+and+to+A...

Read only

Kartik2
Contributor
0 Likes
1,226

Hi,

Have a look at the following document, it will allow you to upload from any format of excel workbook, even xlsm.

Hope it helps, Thank you.

Regards,

kartik