Application Development 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: 

EXCEL Integration

Former Member
0 Kudos

Greetings, The requirement needs an excel file to be populated with data and then be presented to the user for simulation of an installment plan, I am doing this using OLE and then calling the FM SAP_STARTS_EXCEL to present the information. However, all changes made to the file while open inside the GUI are ignored and when the file is re-opened for data retrieval the correct data is not there.

Does anyone know how can I implement this kind of interaction for data presentation and retrieval using Excel.

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The user would have to "SAVE" the excel sheet after making changes. Then when in re-import it, it would have the updated changes.

Regards,

Rich Heilman

Former Member
0 Kudos

Thanks Rich for the prompt reply, however I don't see the changes reflected in the original file after saving it, is there anything else I should do to see the changes reflected?

0 Kudos

Is it important that the excel sheet is embedded into the dynpro? Can you please post your code.

Regards,

Rich Heilman

Former Member
0 Kudos

Here it is:

* Initialize
DATA:
    EXCELAPP TYPE OLE2_OBJECT, "Aplicación Excel
    EXCELWBK TYPE OLE2_OBJECT. "Hoja de trabajo

  CREATE OBJECT EXCELAPP 'EXCEL.Application'.
  SET PROPERTY OF EXCELAPP 'Visible' = 0.

  CALL METHOD OF EXCELAPP 'Workbooks' = EXCELWBK.

  CALL METHOD OF EXCELWBK 'Open'
    EXPORTING
      #1 = FNAME.

  CALL METHOD OF EXCELAPP 'Run'
    EXPORTING
      #1 = 'SelectWBK'
      #2 = 'Parametros'.

  CALL METHOD OF EXCELAPP 'Run'
    EXPORTING
      #1 = 'EscribirCelda'
      #2 = 'C5'
      #3 = PARTNERDATA-CONT_ACCT.

.....
* This call saves the file
  CALL METHOD OF EXCELAPP 'Run'
    EXPORTING
      #1 = 'SaveWBK'
      #2 = ''.

* Everything OK so far

CALL METHOD OF EXCELAPP 'Quit'.

  FREE OBJECT EXCELWBK.
  FREE OBJECT EXCELAPP.

* Present file in the dynpro

  CALL FUNCTION 'SAP_STARTS_EXCEL'
    EXPORTING
      I_FILENAME        = FNAME
    EXCEPTIONS
      EXCECUTION_FAILED = 1
      OTHERS            = 2.

* retrieve data

  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                = FNAME
      I_BEGIN_COL             = 1
      I_BEGIN_ROW             = 14
      I_END_COL               = 11
      I_END_ROW               = 74
    TABLES
      INTERN                  = DATA_TAB
    EXCEPTIONS
      INCONSISTENT_PARAMETERS = 1
      UPLOAD_OLE              = 2
      OTHERS                  = 3.