Skip to Content

Converting Icons when sending data to excel

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

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • Posted on Jun 22, 2004 at 10:24 AM

    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...

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Jun 22, 2004 at 01:16 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 22, 2004 at 02:34 PM

    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

    Add comment
    10|10000 characters needed characters exceeded