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: 

Add Header to file downloaded from alv, but header should not be displayed when alv is displayed.

Former Member
0 Kudos

Hi,

I have a probelm,

the thing is i need to display a header with some information in file that is downloaded from the alv,

but i do not want this header to be displayed in the alv output, that is when the alv is displayed.

how do i achieve this?

Thanks,

chetan

11 REPLIES 11

Former Member
0 Kudos

Hii Chetan,

You can achieve this by displaying alv without header but while downloading into Excel use OLE concept to display Header.

Regards,

Ashwath.

0 Kudos

Hi ashwath,

Can you please elaborate and i am trying to do this in a report.

Thanks,

chetan

0 Kudos

Hi Chetan,

Just display ALV grid.In ALV ouput at Function toolbar use PUSH BUTTON (Download).

After clicking Push Button,write code to download excel using OLE concepts.

For eg: Final internal Table is itab you are displaying without header.

just provide me ur email id i will forward u OLE concept documents.

Regards,

Ashwath.

kesavadas_thekkillath
Active Contributor
0 Kudos

There is an option in the "layout" parameter to hide the header while display. Please check.

0 Kudos

Hi kesavadas,

I did search for such field in layout but i could not find any.

Thanks,

chetan

0 Kudos

Use below code to get the header in ALV

perform add_header using:

  'H' '' 'Maximum Account Balances For International Accounts'(h01).

form add_header using value(ip_type) type slis_listheader-typ

                      value(ip_key)                         "#EC *

                      value(ip_info).                       "#EC *



  data: lwa_top_header type char255.



  perform add_alv_header using: ip_type   ip_key   ip_info.



  concatenate ip_key ip_info into lwa_top_header

       separated by space.

  shift lwa_top_header left deleting leading space.

  append  lwa_top_header to t_top_header.



endform.                    " ADD_ALV_header

0 Kudos

Hi Hamsitha,

I do not want to add header in alv, and i could not understand your code.

Thanks,

chetan

0 Kudos

Is it TOP_OF_PAGE header or ALV field headings ???

0 Kudos

Hi Kesavadas,

its not ALV field heading. but the heading that comes up when we use reuse_alv_commentary_write function.

bharat_rathod2
Active Participant
0 Kudos

Dear,

You want to download your ALV output in Excel with your header.

if yes then you to work with OLE try following code.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

     EXPORTING

       WINDOW_TITLE         = 'Select File Location'

       DEFAULT_EXTENSION    = 'XLS'

       DEFAULT_FILE_NAME    = ' yur file name'

*      WITH_ENCODING        =

*      FILE_FILTER          =

       INITIAL_DIRECTORY    = 'C:\Documents and Settings\'

*      PROMPT_ON_OVERWRITE  = 'X'

     CHANGING

       FILENAME             = P_FILENAME

       PATH                 = P_PATH

       FULLPATH             = P_FULLPATH

       USER_ACTION          = P_RESULT.

   CHECK P_RESULT = 0.

   P_FILE = P_FULLPATH.

   CREATE OBJECT WA_EXCEL 'EXCEL.APPLICATION'. "Create object for Excel

*  SET PROPERTY OF WA_EXCEL  'VISIBLE' = 1. "In background Mode

   CALL METHOD OF WA_EXCEL 'WORKBOOKS' = WA_WORKBOOK.

   CALL METHOD OF WA_WORKBOOK 'ADD'. "Create a new Workbook

   SET PROPERTY OF WA_EXCEL 'SheetsInNewWorkbook' = 7. "No of sheets

   PERFORM FILL_DATA. " Fill the internal tables with the req. data

* Downloading Manufacture Month Wise details to first sheet

   PERFORM DOWNLOAD_SHEET TABLES IT_TAB USING 1 'Excel name'.

in fill_data.

CONCATENATE 'YEAR' 'MONTH' 'QTY' 'PROD. VEH.' 'PER(%)'

               INTO WA_TAB SEPARATED BY WA_DELI.

   APPEND WA_TAB TO IT_TAB.

   LOOP AT IT_MNFCTR INTO WA_MNFCTR.

     WRITE WA_MNFCTR-PRCT TO PRCT.

     CONCATENATE WA_MNFCTR-YEAR WA_MNFCTR-MONTH1 WA_MNFCTR-QTY WA_MNFCTR-PRDV PRCT

                 INTO WA_TAB SEPARATED BY WA_DELI.

     APPEND WA_TAB TO IT_TAB.

     CLEAR PRCT.

   ENDLOOP.

   CLEAR  : WA_TAB,IT_TAB1.

   REFRESH IT_TAB1.

in download.

CALL METHOD OF WA_EXCEL 'WORKSHEETS' = WA_WORKSHEET

     EXPORTING

     #1 = P_SHEET.

   CALL METHOD OF WA_WORKSHEET 'ACTIVATE'.

   SET PROPERTY OF WA_WORKSHEET 'NAME' = P_NAME.

   CALL METHOD OF WA_EXCEL 'Range' = WA_RANGE

     EXPORTING

     #1 = 'A1'

     #2 = 'G1'.

   CALL METHOD OF WA_RANGE 'INTERIOR' = WA_INT.

*  SET PROPERTY OF WA_INT 'ColorIndex' = 6.

   SET PROPERTY OF WA_INT 'Pattern' = 1.

* Initially unlock all the columns( by default all the columns are locked )

   CALL METHOD OF WA_EXCEL 'Columns' = WA_COLUMNS.

   SET PROPERTY OF WA_COLUMNS 'Locked' = 0.

* Locking and formatting first column

   CALL METHOD OF WA_EXCEL 'Columns' = WA_COLUMNS

     EXPORTING

     #1 = 1.

   SET PROPERTY OF WA_COLUMNS  'Locked' = 1.

   CALL METHOD OF WA_EXCEL 'Columns' = WA_COLUMNS

     EXPORTING

     #1 = 2.

former_member821147
Participant
0 Kudos

Hi,

Use this parameter I_CALLBACK_HTML_TOP_OF_PAGE .