Quantcast
Channel: SCN: Message List - ABAP Development
Viewing all articles
Browse latest Browse all 10425

Re: Field Headers not coming in Excel sheet

$
0
0

Hi Priyesh Shah,

 

 

Instead of using GUI_DOWNLOAD function module you can use XXL_FULL_API. In that XXL_FULL_API function module you can give the Header also.

 

Example Code.

 

*** Show Status as an excel file *****

     DATA : header3 LIKE gxxlt_p-text VALUE 'Status',

            header4 LIKE gxxlt_p-text VALUE 'Excel Sheet Format'.

 

* Internal table for holding the horizontal key.

     DATA BEGIN OF  t_hkey1 OCCURS 0.

             INCLUDE STRUCTURE gxxlt_h.

     DATA END   OF t_hkey1 .

 

* Internal table for holding the vertical key.

     DATA BEGIN OF t_vkey1 OCCURS 0.

             INCLUDE STRUCTURE gxxlt_v.

     DATA END   OF t_vkey1 .

 

* Internal table for holding the online text....

     DATA BEGIN OF t_online1 OCCURS 0.

             INCLUDE STRUCTURE gxxlt_o.

     DATA END   OF t_online1.

 

* Internal table to hold print text.............

     DATA BEGIN OF t_print1 OCCURS 0.

             INCLUDE STRUCTURE gxxlt_p.

     DATA END   OF t_print1.

 

* Internal table to hold SEMA data..............

     DATA BEGIN OF t_sema1 OCCURS 0.

             INCLUDE STRUCTURE gxxlt_s.

     DATA END   OF t_sema1.

***** End of show the status as an excel file ********



* Text which will be displayed online is declared here....

       t_online1-line_no    = '1'.

       t_online1-info_name  = 'Created by'.

       t_online1-info_value = sy-uname.

       APPEND t_online1.

 

* Text which will be printed out..........................

       t_print1-hf     = 'H'.

       t_print1-lcr    = 'L'.

       t_print1-line_no = '1'.

       t_print1-text   = 'This is the header'.

       APPEND t_print1.

 

       t_print1-hf     = 'F'.

       t_print1-lcr    = 'C'.

       t_print1-line_no = '1'.

       t_print1-text   = 'This is the footer'.

       APPEND t_print1.

 

* Defining the vertical key columns.......

       t_vkey1-col_no   = '1'.

       t_vkey1-col_name = 'Material'.

       APPEND t_vkey1.

 

       t_vkey1-col_no   = '2'.

       t_vkey1-col_name = 'Plant'.

       APPEND t_vkey1.

 

       t_vkey1-col_no   = '3'.

       t_vkey1-col_name = 'Start Date'.

       APPEND t_vkey1.

 

       t_vkey1-col_no   = '4'.

       t_vkey1-col_name = 'End Date'.

       APPEND t_vkey1.

 

       t_vkey1-col_no   = '5'.

       t_vkey1-col_name = 'Requirement Quantity'.

       APPEND t_vkey1.

 

       t_vkey1-col_no   = '6'.

       t_vkey1-col_name = 'Status'.

       APPEND t_vkey1.

 

* populating the SEMA data..........................

       t_sema1-col_no  = 1.

       t_sema1-col_typ = 'STR'.

       t_sema1-col_ops = 'DFT'.

       APPEND t_sema1.

 

       t_sema1-col_no = 2.

       APPEND t_sema1.

 

       t_sema1-col_no = 3.

       APPEND t_sema1.

 

       t_sema1-col_no = 4.

       APPEND t_sema1.

 

       t_sema1-col_no = 5.

       APPEND t_sema1.

 

       t_sema1-col_no = 6.

       t_sema1-col_typ = 'STR'.

       t_sema1-col_ops = 'ADD'.

       APPEND t_sema1.

 

       CALL FUNCTION 'XXL_FULL_API'

         EXPORTING

*         DATA_ENDING_AT    = 54

*         DATA_STARTING_AT  = 5

           filename          = 'TESTFILE'

           header_1          = header3

           header_2          = header4

           no_dialog         = 'X'

           no_start          = ' '

           n_att_cols        = 0

           n_hrz_keys        = 1

           n_vrt_keys        = 6

           sema_type         = 'X'

*         SO_TITLE          = ' '

         TABLES

           data              = it_zmmstatus " Your internal table name

           hkey              = t_hkey1

           online_text       = t_online1

           print_text        = t_print1

           sema              = t_sema1

           vkey              = t_vkey1

         EXCEPTIONS

           cancelled_by_user = 1

           data_too_big      = 2

           dim_mismatch_data = 3

           dim_mismatch_sema = 4

           dim_mismatch_vkey = 5

           error_in_hkey     = 6

           error_in_sema     = 7

           file_open_error   = 8

           file_write_error  = 9

           inv_data_range    = 10

           inv_winsys        = 11

           inv_xxl           = 12

           OTHERS            = 13.

       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,


Ramesh N


Viewing all articles
Browse latest Browse all 10425

Trending Articles