cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Data to opeed Excel

michael_fallenbchel
Active Participant
0 Kudos

Hi experts,

I'm new to Web Dynpro.

With the help of the different threads I now got a Web Dynpro where I can open a Excel Template (from MIME). In this, I defined a few fileds (for example Cell A1 is called "TEST1").

Now I want to fill this cell with data. But I absolutly don't knwo how to do this?!?! Have I to use an XML-file? Or is there a method I can pass a table with the fields I want to fill with the wanted content?

Could anybody tell me a little bit more about this?

Thanks in advance

Michael

Accepted Solutions (0)

Answers (3)

Answers (3)

michael_fallenbchel
Active Participant
0 Kudos

Using Excel 2007 (XLSX-Files - XML) - I can "built" my own Excel

Former Member
0 Kudos

Hi Michael ,

if u want to transfer the data to excel file follow these steps :

1 obtain data from the table into internal table.

If u r having table UI , and u want the values in the internal table , use get_static_attributes_table

Read the node which is binded to the table and apply this method .

2 Convert the internal table contents to STRING format.

3 Convert it into tab deleimeted format using CL_ABAP_CHAR_UTILITIES

4 Convert this STRING format to XSTRING format using FM SCMS_STRING_TO_XSTRING

5 Make use of the attach_file_to_response method.

following code snippet can help u :



data LO_ND_SFLIGHT type ref to IF_WD_CONTEXT_NODE.
  data LO_EL_SFLIGHT type ref to IF_WD_CONTEXT_ELEMENT.
  data LT_SFLIGHT type WD_THIS->ELEMENTS_SFLIGHT.
  data LS_SFLIGHT type WD_THIS->ELEMENT_SFLIGHT.  data TEXT   type STRING.
  data XTEXT  type XSTRING.
* navigate from <CONTEXT> to <SFLIGHT> via lead selection
  LO_ND_SFLIGHT = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_SFLIGHT ).
* get all declared attributes
  LO_ND_SFLIGHT->GET_STATIC_ATTRIBUTES_TABLE(
    importing
      TABLE = LT_SFLIGHT ).
  loop at LT_SFLIGHT into LS_SFLIGHT.    
  concatenate TEXT LS_SFLIGHT-CARRID
                LS_SFLIGHT-CONNID
                LS_SFLIGHT-FLDATE
                LS_SFLIGHT-CURRENCY
                LS_SFLIGHT-PLANETYPE
                CL_ABAP_CHAR_UTILITIES=>NEWLINE into TEXT separated by
                CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.  
     endloop.  
call function 'SCMS_STRING_TO_XSTRING'
    exporting
      TEXT   = TEXT
    importing
      BUFFER = XTEXT.  WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
**path to the word file
    I_FILENAME = 'WDP.xls'
* String Variable
    I_CONTENT =  XTEXT
* File Type
    I_MIME_TYPE = 'EXCEL' ).   

rgds,

amit

michael_fallenbchel
Active Participant
0 Kudos

Hi amit.

I checked your method with the "WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE" method.

Seems to be nice - but not what I want to have.

I have an Excel-template with a view fields (not in one line - one field is in cell A1, the other in D17 and so on...).

I need to open the Excel and fill these fields. Maybe not online (Excel-inplace), maybe just in the background (SAP fills the fields in an saved Excel in MIME) and give me the possibility to download this file?

Any ideas?

michael_fallenbchel
Active Participant
0 Kudos
  • double post *

michael_fallenbchel
Active Participant
0 Kudos

Hi experts,

after searching in so much threads and the internet itself, I now think that there's no way to fill certain fields in an Excel template:

I can read my excel-file from MIME this way

mime_repository = cl_mime_repository_api=>get_api( ).
  CALL METHOD mime_repository->get
    EXPORTING
      i_url     = url
    IMPORTING
      e_content = content.

But what can I do with this XSTRING (content)? Is there a way to get a field and pass data?

I found this:

https://wiki.sdn.sap.com/wiki/display/WDABAP/ModifyingexistingexcelsheetusingWDABAP

But unfortunately point 6 is missing (maybe the step I need...)

Any help is welcome

Edited by: Michael Fallenbüchel on Nov 17, 2009 7:25 AM

Former Member
0 Kudos

Hi Micheal,

Just to clarify few things on your requirement. Do u like to export the data from the web dynpro application to the Excel sheet?

Ranganathan

michael_fallenbchel
Active Participant
0 Kudos

Hi Ranganathan,

I've got the following situation:

On my first view I can enter the material I want.

The second view is the "detail-view" which shows me different details of the material.

On this detail-view I've got a button that brings me to the third view - the Excel-view. On this, I've got an Office Control showing me my Excel-file directly in the Web Dynpro.

When clicking the Excel-Button on the Detail-View, it openes the Excel-View and also opens an Excel-File from MIME. Everything OK - now comes the part I don't know how to code:

The Excel is opned in hte View, now I want to fill some fileds there with data from the second view - so I have to do "something" in the WDDOMODIFYVIEW method of my Excel.

Hope everything is clear now

Former Member
0 Kudos

hi ,

create context attributes in component controller and map it to ur second view and excel view .

nw u hav to to get the data from ur component controller .

converting it into tab delemeted using CL_ABAP_CHAR_UTILITIES , and thn send it to excel .. isnt it wrkng ?