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: 

Converting Icons when sending data to excel

zsolt_szuromi
Discoverer
0 Kudos

Hi,

I need some help. I have an ALV list created with REUSE_ALV_GRID_DISPLAY. There is a column of this list which contains icons. When a user presses the 'Spreadsheet' button and selects 'Excel display' these icons will appear with their SAP code (that is @0A@, @08@, etc.) in Excel. How can I convert these codes to some user friendly text like 'OK', 'FAILED', etc.? Anyway, is it possible? Thank you in advance.

Regards, Zsolt

4 REPLIES 4

zsolt_szuromi
Discoverer
0 Kudos

Hi All,

I already have a solution which is mentioned in OSS note 365472. Unfortunately it is not the best solution, because it suggests writing an excel macro. If you know anything better, please don't hesitate...

0 Kudos

Hi Zsolt,

IMHO you must write your own download routine. The Icon text you'll find in the table ICON and you must replace the ICON column with the ICON text. But I think this is not the solution that you are looking for.

Regards,

Dirk

Former Member
0 Kudos

Hi,

I don't know if you will like it, but the simplest solution would be to add a text column to you ALV report in which you would store the text of the icon (using table ICON as suggested by Dirk Altman) .

Up to the user who downloads the report either to have a display variant with the icon texts or to download everything to excel and just suppress the column containing the icon ids...

Hope this will help you...

Regards

Julien

zsolt_szuromi
Discoverer
0 Kudos

Hi,

Thak you for your suggestions. Client, unfortunately, don't want to do extra actions...you know.

But I have found a solution:

An instance of the class CL_GUI_ALV_GRID works behind REUSE_ALV_GRID_DISPLAY function element. It has two events: BEFORE_USER_COMMAND and AFTER_USER_COMMAND which are raised by the object in every case when an interface with the outside world of SAP is activated in ALV (I mean when the user presses the 'Send', 'Word processing', or ' Spreadsheet buttons'). These Events has no event handler by default. If you write your own, you can catch processing before and after data transportation. In the event handler methods you can modify the content of the output table. CL_GUI_ALV_GRID uses it referenced by a pointer.

For example:


* int_out_tab -> the output table
* int_out_tab_excel and int_out_tab_buffer have the same type as
*       int_out_tab

*---Class declarations
class lcl_event_handler definition.
  public section.
    class-methods: before_user_command
                   for event before_user_command of cl_gui_alv_grid,
                   after_user_command
                   for event after_user_command of cl_gui_alv_grid.
endclass.

*---Class definitions
class lcl_event_handler implementation.

  method before_user_command.    "changing to excel content"
    int_out_tab[] = int_out_tab_excel[].
  endmethod.

  method after_user_command.       "restoring the original state"
    int_out_tab[] = int_out_tab_buffer[].
  endmethod.
endclass.

You have to insert into your program the followings before calling REUSE_ALV_GRID_DISPLAY:


*Registering event handlers
  set handler lcl_event_handler=>before_user_command for all instances.
  set handler lcl_event_handler=>after_user_command for all instances.

*Saving the original output list
  int_out_tab_buffer[] = int_out_tab[].

*Generating the user-friendly Excel list
  loop at int_out_tab into int_out_tab_excel.
    case int_out_tab_excel-status.
      when '@0A@'.
        int_out_tab_excel-status = 'FAIL'.   "or whatelse you want"
        append int_out_tab_excel.
      when '@08@'.
        int_out_tab_excel-status = 'OK'.     "or whatelse you want"
        append int_out_tab_excel.
      "..."
    endcase.
  endloop.

Regards,

Zsolt

Message was edited by: Zsolt Szuromi