Application Development and Automation 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: 
Read only

adding header to ALV

Former Member
0 Likes
8,351

Hi Friends

I need to add header to ALV grid, pls tell me how to do it.

Thanx in advance,

Regards,

Venu.

4 REPLIES 4
Read only

dani_mn
Active Contributor
0 Likes
2,262

HI,

check the following program doing the same.

REPORT ZWA_ALV_EDITABLE_FM .

type-pools: slis.

data it_fieldcat type slis_fieldcat_alv occurs 0 with header line.

data: gs_layout type slis_layout_alv.

data v_repid like sy-repid.


DATA: BEGIN OF itab OCCURS 0.
        INCLUDE STRUCTURE CSKT.
DATA: end of itab.


START-OF-SELECTION.

  v_repid = sy-repid.

*--- selection form cost center master table

  SELECT * FROM CSKT
  INTO TABLE itab.

  PERFORM field_catalog.



   call function 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program     = v_repid
            it_fieldcat            = it_fieldcat[]
            is_layout              = gs_layout
            i_callback_top_of_page = 'TOP-OF-PAGE1'
            i_grid_title           = 'xyz'
            i_default              = 'X'
            i_save                 = 'U'
       TABLES
            t_outtab               = itab.


*&---------------------------------------------------------------------*
*&      Form  field_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM field_catalog.

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name     = v_repid
            i_internal_tabname = 'ITAB'
            i_inclname         = v_repid
       CHANGING
            ct_fieldcat        = it_fieldcat[].


ENDFORM.                    


*---------------------------------------------------------------------*
*       FORM top-of-page1                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
<b>form top-of-page1.
  data: header type slis_t_listheader,
  wa type slis_listheader. 

  wa-typ = 'S'.
  wa-info = 'dd'.
  append wa to header.

  wa-typ = 'S'.
  write sy-datum to wa-info mm/dd/yyyy.
  concatenate 'abc' wa-info into wa-info separated by space.
  append wa to header.

  wa-typ = 'S'.
  concatenate 'cd' sy-uname into wa-info separated by space.
  append wa to header.

  wa-typ = 'S'.
  concatenate 'ee' sy-repid into wa-info separated by space.
  append wa to header.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
            it_list_commentary = header.</b>



ENDFORM.

Regards,

Read only

Former Member
0 Likes
2,262

function <b>REUSE_ALV_COMMENTARY_WRITE</b>, for writing the header.

Read only

Former Member
0 Likes
2,262

U have to use the following function module

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

i_logo = 'Z_LOGO'.

endform.

See this link also:

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_enhanced.htm

U have to uplaod the logo into the server

Upload Logo for REUSE_ALV_COMMENTARY_WRITE

For those who wish to upload and use a picture in your ALV abap reports.

Steps for uploading Logo :-:

1. Goto the transaction OAER

2. Enter the class name as 'PICTURES'

3. Enter the class type as 'OT'

4. Enter the object key as the name of the logo you wish to give

5. Execute

6. Then in the new screen select Standard doc. types in bottom window

Click on the Screen icon

Now, it will ask for the file path where you have to upload the logo

7. Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE

or

Import Logo and Background Picture for Reporting

In this step, you can import a customer-specific logo and a background picture into the R/3 System. These will be displayed in the header area of reports in HR Funds and Position Management.

From the SPRO:

HR Funds and Position Management --> Dialog Control --> Customize Reporting Interface --> Import Logo and Background Picture for Reporting.

Activities

1. Enter the Name of your logo/background picture as an object key in the initial screen.

2. Make sure that the class name is PICTURES, and the class type is OT.

3. Choose Execute.

4. Double-click the document type Picture on the Create tab page. A dialog box will appear in which you can enter the path in which the logo/background picture can be found.

5. Enter the path and choose Open. The logo will be uploaded into the current R/3 System. If the logo/background picture is to be transported into other systems as well, choose Transport.

6. Return to the initial screen and repeat the procedure after having entered the Name of your background picture as an object key.

Please note that the logo/background picture can only be displayed in ALV-based reports with an HTML header. Manually programmed reports such as business distribution plans are not based on the ALV.

If you have selected several initial objects, ALV-based reports in HR Funds and Position Management will automatically use a hiearchical-sequential display. A logo is not displayed here either. Note also that the logo cannot be printed (see print preview in program).

Make sure that the logo does not exceed a height of 100 pixels because it would mean that the header of the report will be scrollable.

Regards

Read only

Former Member
0 Likes
2,262
*&---------------------------------------------------------------------*
*& Report  Y_TOP_PAGE                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  y_top_page                              .

TABLES : mara.
TYPE-POOLS: slis.

DATA : w_repid LIKE sy-repid.
  w_repid = sy-repid.

DATA : BEGIN OF it_mara OCCURS 0,
       matnr LIKE mara-matnr,
       END OF it_mara.

*layout
DATA: wa_layout           TYPE SLIS_LAYOUT_ALV.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
      wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.

START-OF-SELECTION.

  SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.

END-OF-SELECTION.


  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     i_program_name               = w_repid
   I_INTERNAL_TABNAME           = 'IT_MARA'
*     i_structure_name             = 'IT_MARA'
*   I_CLIENT_NEVER_DISPLAY       = 'X'
   I_INCLNAME                   = w_repid
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  = it_fieldcat_wrt_off[]
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program     = w_repid
      i_callback_top_of_page = 'TOP-OF-PAGE'
      is_layout              = wa_layout
      it_fieldcat            = it_fieldcat_wrt_off
    TABLES
      t_outtab               = it_mara
    EXCEPTIONS
      program_error          = 1
      OTHERS                 = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
  DATA: t_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE i,
        ld_linesc(10) TYPE c.

* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'CHANDU REPORT'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  APPEND wa_header TO t_header.
  CLEAR: wa_header.

* Total No. of Records Selected
*  describe table it_ekko lines ld_lines.
*  ld_linesc = ld_lines.
*  concatenate 'Total No. of Records Selected: ' ld_linesc
*                    into t_line separated by space.
*  wa_header-typ  = 'A'.
*  wa_header-info = t_line.
*  append wa_header to t_header.
*  clear: wa_header, t_line.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
ENDFORM.                    "top-of-page