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: 

How to display Logo on ALV Grid Report

Former Member
0 Kudos
3,597

Hi ,

I am displaying data as ALV Grid using

CALL METHOD CL_SALV_TABLE=>FACTORY.

I am having trouble finding how to display Logo on top of page event.

Can anyone please guide me how to do that.

Thanks

Raghu

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
1,398

Hi, here is a sample program which will illistrate how to do it. You want to use the class cl_salv_form_picture when writing your headers. Implement the following and pay attension to the FORM create_header_and_footer .



report zrich_0001 no standard page heading.

data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.


start-of-selection.

  select * into table ispfli from spfli.


  try.
      cl_salv_table=>factory(
        importing
          r_salv_table = gr_table
        changing
          t_table      = ispfli ).
    catch cx_salv_msg.
  endtry.



  gr_functions = gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

*... TOP_OF_LIST
  data: lr_header type ref to cl_salv_form_header_info.
  create object lr_header
    exporting
      text    = 'This is my Header'.
  gr_table->set_top_of_list( lr_header ).

*... END_OF_LIST
  create object lr_header
    exporting
      text    = 'This is my Footer'.
  gr_table->set_end_of_list( lr_header ).



  perform create_header_and_footer.


  gr_table->display( ).



*&---------------------------------------------------------------------*
*&      Form  create_header_and_footer
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form create_header_and_footer .
  data: lr_top_element type ref to cl_salv_form_layout_grid,
        lr_end_element type ref to cl_salv_form_layout_flow,
        lr_grid type ref to cl_salv_form_layout_grid,
        lr_header type ref to cl_salv_form_header_info,
        lr_action type ref to cl_salv_form_action_info,
        lr_textview1 type ref to cl_salv_form_text,
        lr_picture type ref to cl_salv_form_picture.

  create object lr_top_element
    exporting
      columns = 2.

  lr_header = lr_top_element->create_header_information(
    row = 1
    column = 1
    text     = 'Flugdaten'                                  "#EC NOTEXT
    tooltip  = 'Flugdaten' ).                               "#EC NOTEXT

  lr_grid = lr_top_element->create_grid( row = 3
                                         column = 1 ).


  lr_textview1 = lr_grid->create_text(
      row     = 1
      column  = 1
      text    = 'C11'
      tooltip = 'Tooltip' ).


  create object lr_picture
    exporting
      picture_id   = 'ENJOYSAP_LOGO'.

  call method lr_grid->set_element
    exporting
      row       = 4
      column    = 1
      r_element = lr_picture.


  gr_table->set_top_of_list( lr_top_element ).

  data: lr_eol type ref to cl_salv_form_header_info.
  create object lr_eol
    exporting
      text    = 'This is my Footer'.

  gr_table->set_end_of_list( lr_eol ).

endform.                    " create_header_and_footer

Welcome to SDN!

Regards,

Rich Heilman

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
1,399

Hi, here is a sample program which will illistrate how to do it. You want to use the class cl_salv_form_picture when writing your headers. Implement the following and pay attension to the FORM create_header_and_footer .



report zrich_0001 no standard page heading.

data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.


start-of-selection.

  select * into table ispfli from spfli.


  try.
      cl_salv_table=>factory(
        importing
          r_salv_table = gr_table
        changing
          t_table      = ispfli ).
    catch cx_salv_msg.
  endtry.



  gr_functions = gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

*... TOP_OF_LIST
  data: lr_header type ref to cl_salv_form_header_info.
  create object lr_header
    exporting
      text    = 'This is my Header'.
  gr_table->set_top_of_list( lr_header ).

*... END_OF_LIST
  create object lr_header
    exporting
      text    = 'This is my Footer'.
  gr_table->set_end_of_list( lr_header ).



  perform create_header_and_footer.


  gr_table->display( ).



*&---------------------------------------------------------------------*
*&      Form  create_header_and_footer
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form create_header_and_footer .
  data: lr_top_element type ref to cl_salv_form_layout_grid,
        lr_end_element type ref to cl_salv_form_layout_flow,
        lr_grid type ref to cl_salv_form_layout_grid,
        lr_header type ref to cl_salv_form_header_info,
        lr_action type ref to cl_salv_form_action_info,
        lr_textview1 type ref to cl_salv_form_text,
        lr_picture type ref to cl_salv_form_picture.

  create object lr_top_element
    exporting
      columns = 2.

  lr_header = lr_top_element->create_header_information(
    row = 1
    column = 1
    text     = 'Flugdaten'                                  "#EC NOTEXT
    tooltip  = 'Flugdaten' ).                               "#EC NOTEXT

  lr_grid = lr_top_element->create_grid( row = 3
                                         column = 1 ).


  lr_textview1 = lr_grid->create_text(
      row     = 1
      column  = 1
      text    = 'C11'
      tooltip = 'Tooltip' ).


  create object lr_picture
    exporting
      picture_id   = 'ENJOYSAP_LOGO'.

  call method lr_grid->set_element
    exporting
      row       = 4
      column    = 1
      r_element = lr_picture.


  gr_table->set_top_of_list( lr_top_element ).

  data: lr_eol type ref to cl_salv_form_header_info.
  create object lr_eol
    exporting
      text    = 'This is my Footer'.

  gr_table->set_end_of_list( lr_eol ).

endform.                    " create_header_and_footer

Welcome to SDN!

Regards,

Rich Heilman

0 Kudos
1,398

Hi Rich,

Thanks for the quick reply.

Your example works great.

Thanks

Raghu

0 Kudos
1,398

Hi Rich,

How doe we display the top of page if there is a conditional page break by setting the control break using GROUP.

This is required Using CL_SALV_TABLE.

Is there any difference of top_of_list and a separate event to display data in header for every new page.

Regards

Prashanth