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: 

Not able to display Header Details using cl_salv_table class

idrisahmed
Participant
0 Kudos
3,860

Hi Experts,

I have used cl_salv_table to display data for two tables in two containers for containers i have use two cl_gui_docking_container class object.

I have provided Caption and setcaption method in instance still no Header displayed as well tried following method still no Header. please Suggest on this.

DATA: r_dock_container TYPE REF TO cl_gui_docking_container,
        r_salv_table     TYPE REF TO cl_salv_table,
        gv_count TYPE i,
        lr_action TYPE REF TO cl_salv_form_action_info.
  DATA: lo_header          TYPE REF TO  cl_salv_form_layout_grid,
        lo_h_label         TYPE REF TO  cl_salv_form_label.

  SET PF-STATUS 'STATUS'.
  SET TITLEBAR 'TITLEBAR'.
  CREATE OBJECT r_dock_container
    EXPORTING
      side    = cl_gui_docking_container=>dock_at_top   

     EXCEPTIONS
      others  = 1.

  CALL METHOD r_dock_container->set_height
    EXPORTING
      height = 200.
  CALL METHOD cl_salv_table=>factory
    EXPORTING
      r_container  = r_dock_container
    IMPORTING
      r_salv_table = r_salv_table
    CHANGING
      t_table      = gt_headtab.
*******************Header Details
  CREATE OBJECT lo_header
    EXPORTING
      columns = 1.
  lo_h_label = lo_header->create_label( row =  1  column =  1  ).
  lo_h_label->set_text( 'Heaer Details' ).

  r_salv_table->set_top_of_list( lo_header ).
*  ALV Display
  r_salv_table->display( ).**
  CREATE OBJECT r_dock_container
    EXPORTING
      side    = cl_gui_docking_container=>dock_at_bottom
      caption = 'Header Details'
      name    = 'Header Details'
    EXCEPTIONS
      others  = 1.

  CALL METHOD r_dock_container->set_height
    EXPORTING
      height = 250.


  CALL METHOD cl_salv_table=>factory
    EXPORTING
      r_container  = r_dock_container
    IMPORTING
      r_salv_table = r_salv_table
    CHANGING
      t_table      = gt_itemtab.

      r_salv_table->display( ).

19 REPLIES 19

Sidhant-Acharya
Participant
0 Kudos
674

Hi,

Check this

DATA:
lo_grid   TYPE REF TO cl_salv_form_layout_grid,
lo_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lo_label  TYPE REF TO cl_salv_form_label ##NEEDED,
lo_text   TYPE REF TO cl_salv_form_text ##NEEDED,
lv_text   TYPE        string.

CREATE OBJECT lo_grid.
 

*   Header Information
lo_grid->create_header_information(
row = 1
column = 1
text    = lv_text
tooltip = lv_text ).

* Add row
lo_grid->add_row( ).
lo_grid_1 = lo_grid->create_grid(
row    = 3
column = 1 ).

CLEAR:lv_text.
lv_text = text-050.
lo_label = lo_grid_1->create_label(
row     = 1
column  = 1
text    = lv_text
tooltip = lv_text ).

lo_text = lo_grid_1->create_text(
row     = 1
column  = 2
text    = ls_count-tot_dis
tooltip = ls_count-tot_dis ).

0 Kudos
674

Hi Sidhant,

Thank you for code. i tried it but still no luck. please correct if i am doing something wrong.

   REPORT ztestidris NO STANDARD PAGE HEADING.

DATA:
lo_grid   TYPE REF TO cl_salv_form_layout_grid,
lo_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lo_label  TYPE REF TO cl_salv_form_label ##needed,
lo_text   TYPE REF TO cl_salv_form_text ##needed,
lv_text   TYPE        string.

DATA: r_dock_container TYPE REF TO cl_gui_docking_container,
      r_salv_table     TYPE REF TO cl_salv_table,
      gv_count         TYPE i,
      lr_action        TYPE REF TO cl_salv_form_action_info.
DATA: lo_header        TYPE REF TO  cl_salv_form_layout_grid,
      lo_h_label       TYPE REF TO  cl_salv_form_label.
TYPES: BEGIN OF ts,
       header TYPE string,
       item   TYPE string,
END OF ts.
DATA: gt_header TYPE STANDARD TABLE OF ts,
      gs_header TYPE ts,
      gt_item   TYPE   STANDARD TABLE OF ts,
      gs_item   TYPE ts.


gs_header-header = 'Header Details'.
APPEND gs_header TO gt_header.
gs_item-item = 'Item Details'.
APPEND gs_item TO gt_item.

*  *************************************** Header Details
CREATE OBJECT lo_grid.

*   Header Information
lo_grid->create_header_information(
row = 1
column = 1
text    = lv_text
tooltip = lv_text ).

* Add row
lo_grid->add_row( ).
lo_grid_1 = lo_grid->create_grid(
row    = 3
column = 1 ).

CLEAR:lv_text.
lv_text = text-001.
lo_label = lo_grid_1->create_label(
row     = 1
column  = 1
text    = lv_text
tooltip = lv_text ).

lo_text = lo_grid_1->create_text(
row     = 1
column  = 2
text    = text-004
tooltip = text-004 ).
***********************************************

CREATE OBJECT r_dock_container
  EXPORTING
    side   = cl_gui_docking_container=>dock_at_top
  EXCEPTIONS
    others = 1.

CALL METHOD r_dock_container->set_height
  EXPORTING
    height = 200.

CALL METHOD cl_salv_table=>factory
  EXPORTING
    r_container  = r_dock_container
  IMPORTING
    r_salv_table = r_salv_table
  CHANGING
    t_table      = gt_header.

*******************Header Details

r_salv_table->set_top_of_list( lo_grid ).

*  ALV Display
r_salv_table->display( ).


CREATE OBJECT r_dock_container
  EXPORTING
    side    = cl_gui_docking_container=>dock_at_bottom
    caption = 'Header Details'
    name    = 'Header Details'
  EXCEPTIONS
    others  = 1.

CALL METHOD r_dock_container->set_height
  EXPORTING
    height = 250.
*  *************************************** Header Details
CREATE OBJECT lo_grid_1.

*   Header Information
lo_grid_1->create_header_information(
row = 1
column = 1
text    = lv_text
tooltip = lv_text ).

* Add row
lo_grid_1->add_row( ).
lo_grid_1 = lo_grid_1->create_grid(
row    = 3
column = 1 ).

CLEAR:lv_text.
lv_text = text-001.
lo_label = lo_grid_1->create_label(
row     = 1
column  = 1
text    = lv_text
tooltip = lv_text ).

lo_text = lo_grid_1->create_text(
row     = 1
column  = 2
text    = text-004
tooltip = text-004 ).
***********************************************


CALL METHOD cl_salv_table=>factory
  EXPORTING
    r_container  = r_dock_container
  IMPORTING
    r_salv_table = r_salv_table
  CHANGING
    t_table      = gt_item.

r_salv_table->set_top_of_list( lo_grid_1 ).

r_salv_table->display( ).

rosenberg_eitan
Active Contributor
0 Kudos
674

Hi,

It will be very helpful if you can post some code that can be compiled

Regards.

rosenberg_eitan
Active Contributor
0 Kudos
674

Is this is what you want ?

Screen

See program....

Regards.

0 Kudos
674


Hi Eitan,

Thank you for reply. I am looking Header line to be display at header area.

0 Kudos
674

Please check this code. this is for one table i am trying for two tables with header.

   REPORT ztestidris.

DATA: gr_salv_table      TYPE REF TO  cl_salv_table,

         lv_header          TYPE REF TO  cl_salv_form_layout_grid,

         lv_h_label         TYPE REF TO  cl_salv_form_label,
         lt_output          type  STANDARD TABLE OF mara.

select * from mara into table lt_output UP TO 10 rows.

  CALL METHOD cl_salv_table=>factory
    IMPORTING
      r_salv_table = gr_salv_table
    CHANGING
      t_table      lt_output.                           " o/p alv table


*?set top of page

  create object lv_header.

lv_h_label = lv_header->create_label( row column ).
lv_h_label->set_text( 'Header Details' ).
lv_h_label = lv_header->create_label( row column ).
lv_h_label->set_text( 'Item Details' ).


*•  set the top of list using the header for online.

gr_salv_table->set_top_of_list( lv_header ).

*•  set the top of list using the header for print.

gr_salv_table->set_top_of_list_print( lv_header ).

  gr_salv_table->display( ).

0 Kudos
674

It would be great help if you give sample code to show two table with headers.

0 Kudos
674

Hi,

I have also no success

when using 

cl_salv_table=>factory

r_container parameter .

Regards.

0 Kudos
674

Hi,

Found this

rosenberg_eitan
Active Contributor
0 Kudos
674

Hi,

A work around (I did not try this)

Create cl_gui_splitter_container with 4 rows.

in row 1 and 3 use cl_gui_textedit

in row 2 and 4 use cl_salv_table


Regards.

PeterJonker
Active Contributor
0 Kudos
674

Did you try:

DATA:  lr_top_element TYPE REF TO cl_salv_form_layout_grid,     

           lr_action TYPE REF TO cl_salv_form_action_info,     

           lr_header TYPE REF TO cl_salv_form_header_info.

CALL METHOD cl_salv_table=>factory

*         EXPORTING

*           list_display   = IF_SALV_C_BOOL_SAP=>FALSE

*           r_container    =

*           container_name =       

          IMPORTING         

             r_salv_table   = gr_table       

          CHANGING         

             t_table        = lt_table.

CREATE OBJECT lr_top_element

EXPORTING  

columns = 2.

lr_header = lr_top_element->create_header_information(

row = 1

column = 1

text     = 'Your text'                       "#EC NOTEXT

tooltip  = 'Your text' ).                    "#EC NOTEXT

lr_action = lr_top_element->create_action_information(

row = 2

column = 1

text     = 'More text' "#EC NOTEXT

tooltip  = 'More text' ). "#EC NOTEXT

gr_table->set_top_of_list( lr_top_element ).

0 Kudos
674

Hi,

Please try to use parameter r_container .

Regards.

0 Kudos
674


Thank you Eitan for your reply. I tried this code and it worked.

   DATA: splitter_1     TYPE REF TO cl_gui_splitter_container,
             splitter_2     TYPE REF TO cl_gui_splitter_container,
             container     TYPE REF TO cl_gui_custom_container,
             container_1 TYPE REF TO cl_gui_container,
             container_2 TYPE REF TO cl_gui_container,
             container_3 TYPE REF TO cl_gui_container,
             grid1            TYPE REF TO cl_gui_alv_grid,
             grid2            TYPE REF TO cl_gui_alv_grid,
             grid3            TYPE REF TO cl_gui_alv_grid.

data: gs_layout TYPE lvc_s_layo.
data: gs_layout1 TYPE lvc_s_layo.

DATA:        gt_sflight_1 TYPE TABLE OF sflight,
             gt_sflight_2 TYPE TABLE OF sflight,
             gt_sflight_3 TYPE TABLE OF sflight,
             g_container TYPE scrfname VALUE 'CCONTAINER'.

  

  gs_layout-GRID_TITLE = 'Header details'. "header.
gs_layout1-GRID_TITLE = 'Item details'.

CALL SCREEN 100.


*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
   CREATE OBJECT container
    EXPORTING
      container_name = 'CCONTAINER'.

   CREATE OBJECT splitter_1
    EXPORTING
      parent  = container
      rows    = 1
      columns = 2.


*getting the reference for the splited container (row 1 & col 1 container)
  CALL METHOD splitter_1->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = container_1.


*getting the reference for the splited container (row 1 & col 2 container)
  CALL METHOD splitter_1->get_container
    EXPORTING
      row       = 1
      column    = 2
    RECEIVING
      container = container_2.
*splitting the 2nd coloum container in to 2 rows & 1 coloum
  CREATE OBJECT splitter_2
    EXPORTING
      parent  = container_2
      rows    = 2
      columns = 1.
*getting the reference for the splited container2 (row 1 & col 2 container)
  CALL METHOD splitter_2->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = container_2.


*************************************************
*populating first internal table to the container
  CREATE OBJECT container
    EXPORTING
      container_name = g_container.
  CREATE OBJECT grid1
    EXPORTING
      i_parent = container_1.
  CALL METHOD grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SFLIGHT'
      is_layout = gs_layout
    CHANGING
      it_outtab        = gt_sflight_1.


*populating second internal table
  CREATE OBJECT container
    EXPORTING
      container_name = g_container.
  CREATE OBJECT grid2
    EXPORTING
      i_parent = container_2.


  CALL METHOD grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SFLIGHT'
      is_layout = gs_layout1
    CHANGING
      it_outtab        = gt_sflight_2.

EndModule.

0 Kudos
674

Hi,

I know that there is no problem to present more then one grid on the screen .

The program that I ul do that .

But what about the cl_salv_form_layout_grid ? Try to use it .

I am testing a new idea it looks like this:

Regards.

0 Kudos
674

could you please share this code i would like to try this.

Thanks,

Idris.

0 Kudos
674

Hi,

Creating a blog about it .(The code will be there)

Any luck with cl_salv_form_layout_grid ?

Regards.

0 Kudos
674

Hi Eitan,

tried few method with  cl_salv_form_layout_grid but no luck yet.

and not getting ouput like you shown in screen shot.if you share code or blog link i will try it.

Thanks,

Idris.

0 Kudos
674

Hi,

See

Regards.

Former Member
0 Kudos
674

Hi,

Try this code.

data: gr_display type ref to cl_salv_display_settings.

gr_display = r_salv_table->get_display_settings( ).

gr_display->set_striped_pattern( cl_salv_display_settings=>true ).

gr_display->set_list_header( 'This is the heading' ).

r_salv_table->display( ).

Thanks,

Ashok.