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: 

How can i get a file header using this method cl_gui_frontend_services=>gui

Former Member
0 Kudos

Hi Experts,

How can i get a file header using this method cl_gui_frontend_services=>gui_download

Thanks

Basu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Kari,

For having the header in the internal table, all the fields must have type C. So, just fill the fields with the header text and insert at index 1.

CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
      filename = <Your file name>
      filetype = 'TXT'
CHANGING
     data_tab = i_data
EXCEPTIONS
     file_write_error = 1
     no_batch = 2

Regards,

Swapna.

3 REPLIES 3

Former Member
0 Kudos

Hi,

Try this.

Append the file header as the first line in the internal table(the table contents which u use in the download). If you want to give column headings, you can give it through "FIELDNAMES" in the tables section of the "GUI_DOWNLOAD".

Hope this may be helpful.

Regards,

Sharin.

Former Member
0 Kudos

Hi Kari,

For having the header in the internal table, all the fields must have type C. So, just fill the fields with the header text and insert at index 1.

CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
      filename = <Your file name>
      filetype = 'TXT'
CHANGING
     data_tab = i_data
EXCEPTIONS
     file_write_error = 1
     no_batch = 2

Regards,

Swapna.

Former Member
0 Kudos

Hi,

You can use the FM - GUI_DOWNLOAD to specify the headers. It can be done in the following manner -

TYPES: BEGIN OF ty_head, "Structure for header
             h(10) TYPE c,
             END OF ty_head.
DATA: it_head  TYPE TABLE OF ty_head WITH HEADER LINE.
 
"Adding header details
it_head-h = 'Field1'.
APPEND it_head.
 
it_head-h = 'Field2'.
APPEND it_head.
 
it_head-h = 'Field3'.
APPEND it_head.
 
it_head-h = 'Field4'.
APPEND it_head.
 
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename                        = p_file
   filetype                        = 'ASC'
   write_field_separator           = 'X'
   header                          = '00'  "<= note this
  TABLES
    data_tab                        = it_tab
   fieldnames                      = it_head[] "<= Pass your header table here
 EXCEPTIONS
   OTHERS                          = 1.

Hope this helps.

Regards,

Himanshu