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

OLE Excel file upload method

Former Member
0 Likes
3,082

hi

we have the requirement to download data in excel file in unicode format for which the OLE FM EXCEL_OLE_STANDARD_DAT in used for the download.

We now want to upload the same file after modification. GUI_DOWNLOAD uplaods the file wsith gibberish characters. We tried using the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' but it gives the dump UPLOAD_OLE exception.

What else are the methods to upload the excel file.

Your ideas appreciated.

Rgds,

Stck

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,017

Hi,

Try this code to upload the data from EXCEL sheet.

DATA l_count TYPE sy-tabix.

   CONSTANTS: lc_begin_col TYPE i VALUE '1',

              lc_begin_row TYPE i VALUE '2',

              lc_end_col   TYPE i VALUE '2',

              lc_end_row   TYPE i VALUE '3000'.

* Begin of CALK912848 - Carlos Werberich - 16Sep08

  CLEAR p_i_excel_data. REFRESH p_i_excel_data.

* End   of CALK912848 - Carlos Werberich - 16Sep08

* Function module to read excel file and convert it into internal table

   CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

     EXPORTING

       filename                = p_p_file

       i_begin_col             = lc_begin_col

       i_begin_row             = lc_begin_row

       i_end_col               = lc_end_col

       i_end_row               = lc_end_row

     TABLES

       intern                  = i_data

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

* Error in file upload

   IF sy-subrc NE 0 .

     MESSAGE text-006 TYPE 'E'.

     EXIT.

   ENDIF.

   IF i_data[] IS INITIAL .

     MESSAGE text-007 TYPE 'E'.

     EXIT.

   ELSE.

     SORT i_data BY row col .

* Loop to fill data in Internal Table

     LOOP AT i_data .

       MOVE i_data-col TO l_count .

       ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO  .

       AT END OF row .

* Append data into internal table

         APPEND p_i_excel_data.

         CLEAR p_i_excel_data.

       ENDAT .

     ENDLOOP .

   ENDIF 

2 REPLIES 2
Read only

Former Member
0 Likes
1,018

Hi,

Try this code to upload the data from EXCEL sheet.

DATA l_count TYPE sy-tabix.

   CONSTANTS: lc_begin_col TYPE i VALUE '1',

              lc_begin_row TYPE i VALUE '2',

              lc_end_col   TYPE i VALUE '2',

              lc_end_row   TYPE i VALUE '3000'.

* Begin of CALK912848 - Carlos Werberich - 16Sep08

  CLEAR p_i_excel_data. REFRESH p_i_excel_data.

* End   of CALK912848 - Carlos Werberich - 16Sep08

* Function module to read excel file and convert it into internal table

   CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

     EXPORTING

       filename                = p_p_file

       i_begin_col             = lc_begin_col

       i_begin_row             = lc_begin_row

       i_end_col               = lc_end_col

       i_end_row               = lc_end_row

     TABLES

       intern                  = i_data

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

* Error in file upload

   IF sy-subrc NE 0 .

     MESSAGE text-006 TYPE 'E'.

     EXIT.

   ENDIF.

   IF i_data[] IS INITIAL .

     MESSAGE text-007 TYPE 'E'.

     EXIT.

   ELSE.

     SORT i_data BY row col .

* Loop to fill data in Internal Table

     LOOP AT i_data .

       MOVE i_data-col TO l_count .

       ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO  .

       AT END OF row .

* Append data into internal table

         APPEND p_i_excel_data.

         CLEAR p_i_excel_data.

       ENDAT .

     ENDLOOP .

   ENDIF 

Read only

Former Member
0 Likes
1,017

hi

try using the following fm's

TEXT_CONVERT_XLS_TO_SAP'

SAP_CONVERT_TO_CSV_FORMAT

KCD_EXCEL_OLE_TO_INT_CONVERT

if the above fm's are not able to solve your problem then you need to save the excel sheet as "tab delimited text file" and then Upload using the GUI_UPLOAD FM.

hope it helps

regards

Aakash Banga