‎2008 Nov 26 8:01 AM
Hi All,
KIndly let me know if you have an example using class cl_salv_hierseq_table and having total (better total in different color).
Thanks.
‎2008 Nov 26 8:09 AM
check this program SALV_DEMO_HIERSEQ_SELECTIONS
search some more demo programs starting with SALV_DEMO_HIERSEQ*
‎2008 Nov 26 8:38 AM
Thanks, but this demo program "SALV_DEMO_HIERSEQ_SELECTIONS" doesn't shows the total values which I'm looking for.
‎2009 Jan 13 5:56 AM
‎2009 Jan 13 6:21 AM
try this
REPORT ztest.
DATA: ispfli TYPE TABLE OF spfli.
DATA: gr_table TYPE REF TO cl_salv_table.
data: gr_funct type ref to cl_salv_functions.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to CL_SALV_COLUMN_table.
START-OF-SELECTION.
SELECT * INTO TABLE ispfli FROM spfli.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = ispfli.
CATCH cx_salv_msg .
ENDTRY.
gr_funct = gr_table->get_functions( ).
gr_funct->set_all( Abap_True ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->Get_Column( 'DISTANCE' ).
gr_column->SET_VISIBLE( abap_false ).
gr_table->display( ).
‎2009 Jan 13 7:59 AM
Hi Akash,
Thanks, but I need example using class cl_salv_hierseq_table and which shows "Total" in output also.
‎2009 Jan 13 8:06 AM
use the code below to get the total...
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_agg TYPE REF TO cl_salv_aggregations.
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
‎2009 Jan 13 11:11 AM
Hi TT,
Thanks, do you have full code of a report using the class cl_salv_hierseq_table ?
‎2009 Jan 13 11:45 AM
ok.... i have used the SAP std program SALV_DEMO_HIERSEQ_SIMPLE and added aggregation to field SEATSMAX ...
*&----
*
*& Report SALV_DEMO_HIERSEQ_SIMPLE
*&
*&----
*
*&
*&
*&----
*
report z94_hier_salv no standard page heading.
*----
-
*... This report demonstrates the simplest call of new ALV API
- cl_salv_hierseq_table (hierseq. lists)
*
If the table ALV_T_T2 is empty, please create data for the demo
by running report BCALV_GENERATE_ALV_T_T2
*
§1 select data into global output table
*
§2 create ALV hierseq Table
§2.1 create the binding information between master and slave
§2.2 create instance of cl_salv_hierseq_table for displaying a
hierseq list of your output tables
*
§3 Functions
§3.1 activate default ALV generic Functions
*
§4 Display
display the configurated ALV hierseq Table by calling the method
display of cl_salv_hierseq_table.
*----
-
include .
types: begin of g_type_s_master.
include type alv_chck.
types: expand type char01,
end of g_type_s_master,
begin of g_type_s_slave.
include type alv_t_t2.
types: end of g_type_s_slave.
types: begin of g_type_s_test,
amount type i,
repid type syrepid,
end of g_type_s_test.
constants: con_master type lvc_fname value 'ALV_CHCK',
con_slave type lvc_fname value 'ALV_T_T2'.
data: gs_test type g_type_s_test.
data: gt_master type standard table of g_type_s_master,
gt_slave type standard table of alv_t_t2.
data: gr_hierseq type ref to cl_salv_hierseq_table,
gr_agg TYPE REF TO cl_salv_aggregations..
*----
*
SELECTION-SCREEN *
*----
*
selection-screen begin of block gen with frame.
parameters:
p_amount type i default 30.
selection-screen end of block gen.
*----
*
START-OF-SELECTION *
*----
*
start-of-selection.
gs_test-amount = p_amount.
gs_test-repid = sy-repid.
perform select_data.
*----
*
END-OF-SELECTION *
*----
*
end-of-selection.
perform display_hierseq.
*&----
*
*& Form select_data
*&----
*
§1 select data into your global output table
*----
*
form select_data .
field-symbols:
-connid. "#EC *
append lines of lt_slave to gt_slave.
endloop.
endform. " select_data
*&----
*
*& Form display_hierseq
*&----
*
text
*----
*
form display_hierseq.
data:
lt_binding type salv_t_hierseq_binding,
ls_binding type salv_s_hierseq_binding.
data:
lr_functions type ref to cl_salv_functions_list.
data:
lr_columns type ref to cl_salv_columns_hierseq,
lr_column type ref to cl_salv_column.
data:
lr_level type ref to cl_salv_hierseq_level.
*... §2.1 create the binding information between master and slave
ls_binding-master = 'MANDT'.
ls_binding-slave = 'MANDT'.
append ls_binding to lt_binding.
ls_binding-master = 'CARRID'.
ls_binding-slave = 'CARRID'.
append ls_binding to lt_binding.
ls_binding-master = 'CONNID'.
ls_binding-slave = 'CONNID'.
append ls_binding to lt_binding.
*... §2.2 create an ALV hierseq table
try.
cl_salv_hierseq_table=>factory(
exporting
t_binding_level1_level2 = lt_binding
importing
r_hierseq = gr_hierseq
changing
t_table_level1 = gt_master
t_table_level2 = gt_slave ).
catch cx_salv_data_error cx_salv_not_found.
endtry.
*... §3 Functions
*... §3.1 activate ALV generic Functions
lr_functions = gr_hierseq->get_functions( ).
lr_functions->set_all( abap_true ).
*... *** MASTER Settings ***
*... set the columns technical
try.
lr_columns = gr_hierseq->get_columns( 1 ).
catch cx_salv_not_found.
endtry.
try.
lr_column = lr_columns->get_column( 'MANDT' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
*... set expand column
try.
lr_columns->set_expand_column( 'EXPAND' ).
catch cx_salv_data_error. "#EC NO_HANDLER
endtry.
*... set items expanded
try.
lr_level = gr_hierseq->get_level( 1 ).
lr_level->set_items_expanded( ).
catch cx_salv_not_found.
endtry.
*... *** SLAVE Settings ***
*... set the columns technical
try.
lr_columns = gr_hierseq->get_columns( 2 ).
catch cx_salv_not_found.
endtry.
try.
gr_agg = gr_hierseq->get_aggregations( 2 ).
CATCH cx_salv_data_error
.
ENDTRY.
gr_agg->add_aggregation( 'SEATSMAX' ).
perform set_columns_technical using lr_columns.
*... §4 display the table
gr_hierseq->display( ).
endform. "display_hierseq
*&----
*
*& Form set_columns_technical
*&----
*
text
*----
*
form set_columns_technical using ir_columns type ref to cl_salv_columns_hierseq.
data:
lr_column type ref to cl_salv_column.
try.
lr_column = ir_columns->get_column( 'MANDT' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'FLOAT_FI' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'STRING_F' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'XSTRING' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'INT_FIEL' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'HEX_FIEL' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'DROPDOWN' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
try.
lr_column = ir_columns->get_column( 'TAB_INDEX' ).
lr_column->set_technical( if_salv_c_bool_sap=>true ).
catch cx_salv_not_found. "#EC NO_HANDLER
endtry.
endform. " set_columns_technical
‎2009 Jan 14 8:53 AM
Hi TT,
Thanks for the code.
In the same example which you given the Total (or aggregate) comes at the bottom, do you have code for the intermediate totals coming after every flight number..
‎2009 Jan 15 10:40 AM
Done it anyway using following codes :
DATA: g_level_total TYPE REF TO cl_salv_sorts.
g_level_total = gr_hierseq->get_sorts( 1 ).
g_level_total->add_sort( columnname = 'CARRID' subtotal = abap_true ).
Thanks everyone.
‎2009 Aug 04 2:23 PM