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: 

REUSe_ALV_GRID_DISPLAY export to excel

soumya_jose3
Active Contributor
0 Kudos

Hi,

When the ALV output is export to excel the order of the columns changes in excel.

The columns with same header comes adjacently.

For eg: ALV output has the below columns in the order

"NAME1", "NAME2", "NAME3", "NAME2" .

When I export it to excel, the order becomes

"NAME1", "NAME2" , "NAME2", "NAME3".

How can I get the excel also in the same order as the ALV ouptut?

Regards,

Soumya.

3 REPLIES 3

Former Member
0 Kudos

hi,

you ca do it by using function module: 'GUI_DOWNLOAD'

DATA: l_file TYPE string.

  l_file = p_file.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = l_file
      filetype                = 'ASC'
    TABLES
      data_tab                = t_itab1
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " download

regards

rahul

Former Member
0 Kudos

hi!

you can explicitly provide the column positions with each field as:

DATA :

t_cat TYPE lvc_t_fcat,

w_cat TYPE lvc_s_fcat.

w_cat-col_pos = 1 (for a field in your program.)

APPEND w_cat TO t_cat.

Let the rest of the program be as it is.

0 Kudos

Hi Richa,

I am concerned about the order of the columns in the excel and not in the ALV output.

In excel the order is not the same as that coming in the ALV output.

Regards,

Soumya.