Exercise 4: Display R/3 Data 

Procedure

  1. To format the output table, define the following FORM routine fill_cell:
  2. *

    * Form routine --> fills lines on EXCEL sheet with output values

    *

    form fill_cell using i j werte.

       call method of excel 'CELLS' = cell exporting #1 = i #2 = j.

       set property of cell 'VALUE' =   werte.

    endform.

     

  3. Use the above FORM routine to format the active EXCEL worksheet:
  4. *

    * Fill the second line on EXCEL worksheet with header line info

    *

    perform fill_cell using  2  1  'Number'.

    perform fill_cell using  2  2  'Form'.

    perform fill_cell using  2  3  'Name'.

    perform fill_cell using  2  4  'POBox'.

    perform fill_cell using  2  5  'Street'.

    perform fill_cell using  2  6  'ZIP'.

    perform fill_cell using  2  7  'City'.

    perform fill_cell using  2  8  'Tel.No'.

    perform fill_cell using  2  9  'Tel.Fax'.

     

  5. Fill the table with output values from the internal table of the ABAP program:
  6. *

    * Loop on table customer_data

    *

    loop at customer_data.

    perform fill_cell using  I  1  customer_data-kunnr.

    perform fill_cell using  i  2  customer_data-anred.

    perform fill_cell using  i  3  customer_data-name1.

    perform fill_cell using  i  4  customer_data-pfach.

    perform fill_cell using  I  5  customer_data-stras.

    perform fill_cell using  i  6  customer_data-pstlz.

    perform fill_cell using  i  7  customer_data-ort01.

    perform fill_cell using  i  8  customer_data-telf1.

    perform fill_cell using  i  9  customer_data-telfx.

    i  =  i  +  1.

    endloop.

     

  7. Make the EXCEL worksheet visible on the desktop. Use the ABAP keyword SET PROPERTY:

set  property  of  excel  'VISIBLE'  =  1.

 

How to Continue

Exercise 5: Release OLE Objects