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: 

Reg Header and Footer details in XL download

Former Member
0 Kudos

Hi All,

I have a requirement that I have to display the Header and Footer in the XL file download usig the FM : XXL_FULL_API.

I have tried by seeing the some of the threads posted in the SDN.

But I am not getting the Header and Footer detials .

I could download the dat intot the XL file but I am unable to get the Header and Footer information.

If anyone has the solution could you please send it across?

Thanks in advance.

Abhilash.

4 REPLIES 4

Former Member
0 Kudos

Use OLE objects .

Here you have an example

Mohamed_Mukhtar
Active Contributor
0 Kudos

hi abhilash ,

try like this
PARAMETERS : p_dload TYPE rlgrap-filename.
DATA : w_dload TYPE string.

TYPES : BEGIN OF ty_kna1,      "record structure
        kunnr TYPE kna1-kunnr,
        name1 TYPE kna1-name1,
        ort01 TYPE kna1-ort01,
        land1 TYPE kna1-land1,
        END OF ty_kna1.

TYPES : BEGIN OF ty_head,      " header structure
        kunnr(20),
        name1(20),
        ort01(20),
        land1(20),
        END OF ty_head.
TYPES : BEGIN OF ty_footer, " footer structure
        abc(30),
        END OF ty_footer.
DATA :  it_kna1 TYPE TABLE OF ty_kna1.  "table to download records
DATA : wa_hedtab TYPE ty_head,
       wa_footer TYPE ty_footer,
       it_footer TYPE TABLE OF ty_footer,
       it_hedtab TYPE TABLE OF ty_head. " table for heading

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dload.
  PERFORM f_dload.

START-OF-SELECTION.
  PERFORM f_header. " preparing header internal table
  PERFORM f_extract.
  PERFORM f_footer.  " preparing footer internal table

  PERFORM f_download.  " download file to presentation server
*&---------------------------------------------------------------------*
*&      Form  f_dload
*&---------------------------------------------------------------------*
FORM f_dload .
  CALL FUNCTION 'F4_FILENAME'
* EXPORTING
*   PROGRAM_NAME        = SYST-CPROG
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
    IMPORTING
      file_name           = p_dload
             .

ENDFORM.                    " f_dload
*&---------------------------------------------------------------------*
*&      Form  f_extract
*&---------------------------------------------------------------------*
FORM f_extract .
  SELECT kunnr
          name1
          ort01
          land1 FROM kna1 INTO TABLE it_kna1 UP TO 100 ROWS.
ENDFORM.                    " f_extract

*&---------------------------------------------------------------------*
*&      Form  f_download
*&---------------------------------------------------------------------*
FORM f_download .
  w_dload = p_dload.

  CALL FUNCTION 'GUI_DOWNLOAD'           " downloading header here
      EXPORTING
*   BIN_FILESIZE                    =
        filename                        = w_dload
     filetype                        = 'ASC'
     write_field_separator           = 'X'
      TABLES
        data_tab                        = it_hedtab
   EXCEPTIONS
     file_write_error                = 1
     no_batch                        = 2
     gui_refuse_filetransfer         = 3
     invalid_type                    = 4
     no_authority                    = 5
     unknown_error                   = 6
     header_not_allowed              = 7
     separator_not_allowed           = 8
     filesize_not_allowed            = 9
     header_too_long                 = 10
     dp_error_create                 = 11
     dp_error_send                   = 12
     dp_error_write                  = 13
     unknown_dp_error                = 14
     access_denied                   = 15
     dp_out_of_memory                = 16
     disk_full                       = 17
     dp_timeout                      = 18
     file_not_found                  = 19
     dataprovider_exception          = 20
     control_flush_error             = 21
     OTHERS                          = 22
              .
  IF sy-subrc  NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'GUI_DOWNLOAD'     "-----> downloading data here
    EXPORTING
      filename                        = w_dload
   filetype                        = 'ASC'
   append                          = 'X'
   write_field_separator           = 'X'
    TABLES
      data_tab                        = it_kna1
 EXCEPTIONS
   file_write_error                = 1
   no_batch                        = 2
   gui_refuse_filetransfer         = 3
   invalid_type                    = 4
   no_authority                    = 5
   unknown_error                   = 6
   header_not_allowed              = 7
   separator_not_allowed           = 8
   filesize_not_allowed            = 9
   header_too_long                 = 10
   dp_error_create                 = 11
   dp_error_send                   = 12
   dp_error_write                  = 13
   unknown_dp_error                = 14
   access_denied                   = 15
   dp_out_of_memory                = 16
   disk_full                       = 17
   dp_timeout                      = 18
   file_not_found                  = 19
   dataprovider_exception          = 20
   control_flush_error             = 21
   OTHERS                          = 22
            .
  IF sy-subrc  NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'GUI_DOWNLOAD'     "-----> appendind footer here
      EXPORTING
        filename                        = w_dload
     filetype                        = 'ASC'
     append                          = 'X'
     write_field_separator           = 'X'
      TABLES
        data_tab                        = it_footer
   EXCEPTIONS
     file_write_error                = 1
     no_batch                        = 2
     gui_refuse_filetransfer         = 3
     invalid_type                    = 4
     no_authority                    = 5
     unknown_error                   = 6
     header_not_allowed              = 7
     separator_not_allowed           = 8
     filesize_not_allowed            = 9
     header_too_long                 = 10
     dp_error_create                 = 11
     dp_error_send                   = 12
     dp_error_write                  = 13
     unknown_dp_error                = 14
     access_denied                   = 15
     dp_out_of_memory                = 16
     disk_full                       = 17
     dp_timeout                      = 18
     file_not_found                  = 19
     dataprovider_exception          = 20
     control_flush_error             = 21
     OTHERS                          = 22
              .
  IF sy-subrc  NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


ENDFORM.                    " f_download


*&---------------------------------------------------------------------*
*&      Form  f_header
*&---------------------------------------------------------------------*
FORM f_header .
  wa_hedtab-kunnr = 'Customer No'.
  wa_hedtab-name1 = 'Name'.
  wa_hedtab-ort01 = 'city'.
  wa_hedtab-land1 = 'Country'.
  APPEND wa_hedtab TO it_hedtab.
ENDFORM.                    " f_header
*&---------------------------------------------------------------------*
*&      Form  f_footer
*&---------------------------------------------------------------------*
FORM f_footer .
  wa_footer-abc = 'Footer for excel file'.
  APPEND wa_footer TO it_footer.
ENDFORM.                    " f_footer

Thanks & Regards

Former Member
0 Kudos

Hi Always Learner,

Anyways thanks for the update given.

With GUI_DOWNLOAD function moule , I have tried it and working fine.

In my program I am using the FM:XXL_FULL_API.

I have read that using this function module also I think we can get the header and footer details aswell.

If you have any solution kindly suggets me .

Thanks in Advance.

Regards

Abhilash.

Former Member
0 Kudos

Answered