cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Export ALV webdynpro Abap

Former Member
0 Kudos

Hi all,

I want to export my context data with taking into acount he type of data for example DATS DD.MM.YYYY, NUMBERS.. Like they are displayed in the ALV in my web dynpro application.

I do not want to use standars buton from the ALV. we want to export data to excel from an other button. I m using this code from the wiki http://wiki.sdn.sap.com/wiki/display/WDABAP/Downloadafileintoexcel+sheet

but it seems not work for the specific caracters as (é,à,è,$ ....). How can we solve this problem ?

Please any suggestions

Best regards

Accepted Solutions (0)

Answers (2)

Answers (2)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Doing such a concatenation into a string, you will lose formatting. You might be able to save non-Latin 1 characters by converting the the string to Unicode (UTF-8) when going to the binary string.

However the larger question is, why exactly do you not want to use the built in conversion to Excel?

Former Member
0 Kudos

Thank you for the quick replay

It's not my requirement . I m devlopping a web application. This is the requirement of the customer

I dont know if we can reuse the action of the ALV button ...or please can show how it can be done the conversion

Best regards

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>This is the requirement of the customer

What exactly is the requirement - that's my question. Is there some functionality deficiency in the current ALV Excel Export? Is it that the users just want the button moved 100px to the left? Or is it that the customer in fact has no idea tha the requirement they ask for is already there.

Former Member
0 Kudos

There aren't any deficiency in the current ALV Excel Export.

The cutomer know about the standard export but he doesnt want to keep the button embedded with the ALV.They want an other button in the botom of the page that can export the data displayed in the ALV .

Best regards

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

That seems like a lot of work with very little benefit. However I suggest that you look at this Blog:

This approach wouldn't be supported by SAP, but it shows how you can re-use the ALV's Export To Excel functionality.

ChrisPaine
Active Contributor
0 Kudos

It's worth noting that if you are already displaying your data in an ALV table then most of the code in my blog is not required. It is written with the assumption that the table being used for export is not even displayed in a UI element.

That said - when I've used this it is to "mimic" ALV functionality where ALV just cannot be used (because of cell variants etc.) So I've always embedded the export to Excel button on the table toolbar - just like ALV.

Given the number of standard components that are using ALV it would make sense for your users to have the same experience in all situations. This reduces training time and support effort (due to use of standards).

So I would strongly suggest to you to not use the code in my blog, but to go back to the person writing the requirements document and point out the "Standard" approach to the location of the export to excel button and how this appears in many standard applications. Hopefully this will then mean you can use the standard ALV functionality.

Cheers,

Chris

ChrisPaine
Active Contributor
0 Kudos

>This approach wouldn't be supported by SAP

Interesting - this was one of the questions I asked in my blog (in a round about way).

How can we know which classes we can and can't use - which would be supported by SAP and which wouldn't.

When it came to function modules there was a released / not released flag which made it quite easy to see which interfaces would be supported in the case of upgrade. For classes/interfaces there is the Released Internally checkbox, but these ALV interfaces do not have this checkbox ticked - check IF_SALV_WD_COMP_TABLE_IF for example. Does this mean it is released for any kind of use I want? I think not, which is the point I made in blog, but how am I supposed to know - just by the ["vibe of the thing" |http://en.wikiquote.org/wiki/The_Castle]?

I feel another blog coming on,,,

Cheers,

Chris

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

General Rule about support for APIs and reusable class in Web Dynpro:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/64/be5b4150b38147e10000000a1550b0/frameset.htm

Of coures that doesn't exactly cover this situation since you have the ALV objects in question here.

I'm making a bit of an assupmtion here based upon the general rule - if it isn't used how SAP intended then that usage isn't supported. Then again we often talk a big talk but then end up supporting a lot more than intended.

There is one piece of evidence that might indicate the class CL_SALV_BS_TT_UTIL is safe to use: The package interface on SALV_BS_EXPORT does expose this class and interface.

Long term good usage and tools and checks to enforce package interfaces is the answer to the question of what is supported and not. Even now, just becuase this is in the package interface doesn't necessarily mean its intended for customer/partner usage. That could just because it was needed for SAP internal only cross package usage.

Former Member
0 Kudos

Hi community,

Here's the way I solved the problem thanks following SDN page [http://wiki.sdn.sap.com/wiki/display/ABAP/CSVtestsofencodingandcolumnseparator].

The problem is that your file was probably encoded in UTF-8 and not opened with the correct encoding by Excel. If you encode your file like below, then it will be opened correctly by MS Excel.

Regards,

Jacques Duparc


     CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text     = lv_excel_string
          encoding = '4103'
        IMPORTING
          buffer   = lv_excel_xstring
        EXCEPTIONS
          failed   = 1.

      CONCATENATE  cl_abap_char_utilities=>byte_order_mark_little  lv_excel_xstring INTO  lv_excel_xstring IN BYTE MODE.

Former Member
0 Kudos

Hi,

Here is a sample code to download the table context to excel file by clicking on button.


method ONACTIONEXPORT_TO_EXCEL .  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' ).    endmethod. 

In the above code, My Conext nodes are SFLIGHT and AIRLINE.

Hope it helps you to resolve your issue.

Kinldy let me know if you face any problem.

Regards

Amarnath S

Former Member
0 Kudos

Thank you for replying

As i said i use the code from http://wiki.sdn.sap.com/wiki/display/WDABAP/Downloadafileintoexcel+sheet.

It's the same code , what i want is to solve the problem of export in order to taking into account the specific caracters é à è $ .... and displaying the same Type of data in the excel file that are displayed in my ALV.

Any ideas please