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: 

regarding function module GUI_DOWNLOAD

Former Member
0 Kudos

Hi all,

I need to add a header to the file which i am going to download.

So can any body say me how can i add header to a table which i am passing to the FM GUI_UPLOAD.

Tell me ASAP.

Regards,

Sagar.

6 REPLIES 6

Former Member
0 Kudos

Sorry not Upload,it is download.

Regards,

Sagar.

0 Kudos

make all itab fields as character.. of desired length...

enter headings in the columns.. and add data to it...then download

0 Kudos

Hi,

try like dis............

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = p_file

filetype = 'ASC'

write_field_separator = ' '

TABLES

data_tab = i_attachment

fieldnames = con_tab.

IF sy-subrc = 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Regards,

Padmasri.

Former Member
0 Kudos

Hi,

pls check this program yaar

TYPES:
     BEGIN OF t_emp_dat,
       pernr TYPE pa0001-pernr,
       persg TYPE pa0001-persg,
       persk TYPE pa0001-persk,
       plans TYPE pa0001-plans,
       stell TYPE pa0001-stell,
     END OF t_emp_dat,
     t_attachment TYPE  solisti1.
DATA:
     w_emp_data TYPE t_emp_dat,
     w_attachment     TYPE  t_attachment.
DATA:
     i_emp_data TYPE STANDARD TABLE OF t_emp_dat,
     i_attachment     TYPE STANDARD TABLE OF t_attachment.

PARAMETERS: p_file TYPE string DEFAULT 'c:\tmp\test.xls'.
*--------------------------------------------------------*
"Start-of-selection.
*--------------------------------------------------------*
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM build_xls_data_and_download.

*&--------------------------------------------------------*
  "Form  get_data from PA0001
*&--------------------------------------------------------*
FORM get_data.

  SELECT pernr
         persg
         persk
         plans
         stell
   FROM pa0001
   INTO CORRESPONDING FIELDS OF TABLE i_emp_data
   UP TO 4 ROWS.

ENDFORM.                    " get_data
*&---------------------------------------------------------*
"Form  build_xls_data_and_download
*&---------------------------------------------------------*
FORM build_xls_data_and_download.
  "If you have Unicode check active in program attributes then
  "you will need to declare constants as follows.
  CLASS cl_abap_char_utilities DEFINITION LOAD.
  CONSTANTS:
      con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
      con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
  DATA :l_lines TYPE char10.

  DESCRIBE TABLE i_emp_data LINES l_lines.
  CONCATENATE 'Total no of records:' l_lines
         INTO  w_attachment
 SEPARATED BY  con_tab.

  CONCATENATE con_cret
              w_attachment
         INTO w_attachment.

  APPEND w_attachment TO i_attachment.
  CLEAR  w_attachment.

  CONCATENATE 'PERNR' 'PERSG' 'PERSK' 'PLANS' 'STELL'
         INTO  w_attachment
 SEPARATED BY  con_tab.

  CONCATENATE con_cret
              w_attachment
         INTO w_attachment.

  APPEND w_attachment TO i_attachment.
  CLEAR  w_attachment.

  LOOP AT i_emp_data INTO w_emp_data.

    CONCATENATE w_emp_data-pernr
                w_emp_data-persg
                w_emp_data-persk
                w_emp_data-plans
                w_emp_data-stell
           INTO w_attachment
   SEPARATED BY con_tab.

    CONCATENATE con_cret w_attachment
           INTO w_attachment.

    APPEND w_attachment TO i_attachment.
    CLEAR  w_attachment.
  ENDLOOP.


  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename              = p_file
      write_field_separator = con_tab
    TABLES
      data_tab              = i_attachment.
  IF sy-subrc = 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

reward if helpful

raam

0 Kudos

Hi,

try like dis............

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = p_file

filetype = 'ASC'

write_field_separator = ' '

TABLES

data_tab = i_attachment

fieldnames = con_tab.

IF sy-subrc = 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Regards,

Padmasri.

0 Kudos

Hi Raam,

thanks for ur response.

I still didn't get clear picture of that. But i will try. You please tell me that even the values which we are getting in to the table should also be concatenated ?

Regards,

Sagar