Excel_reference

report ZUPLOADEXCELSHEETS.
INCLUDE ole2incl .
tables : vbap, vbak.
data: begin of itab occurs 0,
      posnr like vbap-posnr,
      vbeln like vbak-vbeln,
      end of itab.
select vbeln
       posnr
       from vbap
       up to 20 rows
       into corresponding fields of table itab.
data : V_COL   LIKE SY-TABIX.     " column number of the cell
data : v_row  like sy-tabix.
data : zmeng like vbap-zmeng.
data : posnr1 like vbap-posnr.
data : count(3) type n.
DATA: gs_excel TYPE ole2_object ,
      H_CELL  TYPE OLE2_OBJECT,
gs_wbooklist TYPE ole2_object ,
gs_application TYPE ole2_object ,
gs_wbook TYPE ole2_object ,
gs_activesheet TYPE ole2_object ,
gs_sheets TYPE ole2_object ,
gs_newsheet TYPE ole2_object .
DATA gv_sheet_name(20) TYPE c .
DATA gv_outer_index LIKE sy-index .
DATA gv_intex(2) TYPE c .
DATA gv_line_cntr TYPE i . "line counter
*PARAMETERS: p_sheets TYPE i .
data : p_sheets TYPE i .
START-OF-SELECTION .
sort itab by posnr.
loop at itab to 1.
posnr1 = itab-posnr.
endloop.
count = 1.
loop at itab.
at new posnr.
p_sheets = p_sheets + 1.
endat.
endloop.
DO p_sheets TIMES .
*--Forming sheet name
gv_intex = sy-index .
gv_outer_index = sy-index .
CONCATENATE 'Excel Sheet #' gv_intex INTO gv_sheet_name .
*--For the first loop, Excel is initiated and one new sheet is added
IF sy-index = 1 .
CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF gs_excel 'Visible' = 1 .
GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooklist .
GET PROPERTY OF gs_wbooklist 'Application' = gs_application .
SET PROPERTY OF gs_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF gs_wbooklist 'Add' = gs_wbook .
GET PROPERTY OF gs_application 'ActiveSheet' = gs_activesheet .
SET PROPERTY OF gs_activesheet 'Name' = gv_sheet_name .
*--For the rest of loops, other sheets are added
ELSE .
GET PROPERTY OF gs_wbook 'Sheets' = gs_sheets .
CALL METHOD OF gs_sheets 'Add' = gs_newsheet .
SET PROPERTY OF gs_newsheet 'Name' = gv_sheet_name .
ENDIF .
gv_line_cntr = 1 . "line counter
sort itab by posnr.
  LOOP AT ITAB where posnr = posnr1.
    V_COL = v_col + 1.
    PERFORM FILL_CELL USING v_col 1 ITAB-vbeln.
    PERFORM FILL_CELL USING v_col 2 ITAB-posnr.
    zmeng = zmeng + ITAB-posnr.
    at end of posnr.
      v_col = v_col + 1.
      PERFORM FILL_CELL USING v_col 2 zmeng.
      clear v_row.
      clear zmeng.
    endat.
  ENDLOOP.
  delete itab where posnr = posnr1.
  loop at itab to 1.
    posnr1 = itab-posnr.
  endloop.
clear v_col.
enddo.
*--Deallocating memory
FREE: gs_excel, gs_wbooklist, gs_application, gs_wbook,
gs_activesheet,gs_sheets, gs_newsheet.
FORM FILL_CELL USING  ROW COL VAL.
  CALL METHOD OF gs_EXCEL 'Cells' = H_CELL
                 EXPORTING #1 = ROW #2 = COL.
  PERFORM ERR_HDL.
  SET PROPERTY OF H_CELL 'Value' = VAL .
  PERFORM ERR_HDL.
ENDFORM.                    " FILL_CELL
FORM ERR_HDL.
  IF SY-SUBRC <> 0.
    WRITE: / 'Error in processing Excel File:'.
    STOP.
  ENDIF.
ENDFORM.

You need to change the way you are handling the data out of the range invoke node. I made your vi output the string to the build array and then I build an array of string. Once you get those you can convert them to integer if you please. See below:
Tim
Johnson Controls
Holland Michigan

Similar Messages

Maybe you are looking for