cancel
Showing results for 
Search instead for 
Did you mean: 

Sum Row in standard Table

Former Member
0 Kudos

hi all,

I want to add a sum row (it's marks in yellow color) in a standard table. I ve tried to adjust the source code in the standard application WDR_TEST_TABLE in my case but still doesn't work. I dont know if i miss something.

IN THE MODIFY VIEW methode

DATA wd_table TYPE REF TO cl_wd_table.
  DATA wd_abstr_columns TYPE cl_wd_abstr_table_column=>tt_abstr_table_column.
  DATA wd_abstr_column TYPE REF TO cl_wd_abstr_table_column.

  DATA wd_column TYPE REF TO cl_wd_table_column.
  DATA wd_cell TYPE REF TO cl_wd_abstr_table_cell_var.

  DATA wd_text_view TYPE REF TO cl_wd_text_view.
  DATA wd_sum_hier_cell TYPE REF TO cl_wd_table_sum_hier_cell.
  DATA wd_summary_cell TYPE REF TO cl_wd_table_summary_cell.

  DATA binding TYPE string.
  DATA editor TYPE REF TO cl_wd_view_element.

  DATA design TYPE wdui_table_sum_cell_design.

" TABLE is the ID of the UI table in my case 
  wd_table ?= view->get_element( 'TABLE' ).
  wd_abstr_columns = wd_table->get_grouped_columns( ).

  design = cl_wd_table_summary_cell=>e_cell_design-total.


  LOOP AT wd_abstr_columns INTO wd_abstr_column.
    wd_column ?= wd_abstr_column.
    CLEAR wd_cell.

    wd_cell = wd_summary_cell = cl_wd_table_summary_cell=>new_table_summary_cell(
          cell_design = design
          view = view ).

    wd_text_view = cl_wd_text_view=>new_text_view(
          view = view
          design = cl_wd_text_view=>e_design-emphasized ).


    wd_summary_cell->set_editor( wd_text_view ).
    wd_column->add_cell_variant( wd_cell ).

  ENDLOOP.

Any help is welcome

Best regards

Accepted Solutions (0)

Answers (1)

Answers (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

you have to specify the variant_key when you create the summary cell and also post your table filling logic are you filling the cell variant column correctly?

Abhi

Former Member
0 Kudos

Hi Abhi,

Thank you for replying !

I just update my source code by specifying the variant_key with SUM_TOTAL but still not working. and i'm filling my table. Here is the part of code modified, must i specify something else in the variant_key ?


    wd_cell = wd_summary_cell = cl_wd_table_summary_cell=>new_table_summary_cell(
          variant_key = 'SUM_TOTAL'
          cell_design = design
          view = view ).

Best regards

abhimanyu_lagishetti7
Active Contributor
0 Kudos

is the cell variant attribute populated in the internal table and binded to the SelectedCellVariant property of the table column in view?

Former Member
0 Kudos

HI Abhi,

Im trying to populate the cell variant like it's done in WDR_TEST_TABLE, but my program doesn't know the

if_summary=>element_NODE

Can you post an exemple or a tuto please

Best regards

abhimanyu_lagishetti7
Active Contributor
0 Kudos

if_<View_name>=>Element_<Node_name>

it is used to declare a structure/table of the node type in your view.

Former Member
0 Kudos

Hi Abhi,

I thought it was a total interface, but still dont know by what i can fill my variant_key.

1) I m filling data to a node (NODE that have 3 attributes Att_1 Att_2 Att_variant ) in the WDOINIT method.

(Att_variant with 'SUM_TOTAL' is this a significant value ?)

2) I m binding NODE to a table which have two Colomns CL1 -> Att_1 , CL2 -> Att_2 (the SelectedCellvariant of CL2 binded to the Att_variant).

3) In the MODIFYVIEW the code posted.

I wonder if i miss something ..

Best regards

abhimanyu_lagishetti7
Active Contributor
0 Kudos

>

> I thought it was a total interface, but still dont know by what i can fill my variant_key.

>

> 1) I m filling data to a node (NODE that have 3 attributes Att_1 Att_2 Att_variant ) in the WDOINIT method.

> (Att_variant with 'SUM_TOTAL' is this a significant value ?)

yes you have to fill att_variant value for the last row with SUM_TOTAL, 2 and 3 looks Ok

Abhi

Former Member
0 Kudos

Hi Abhi,

Thank you for your replies.

Now i get a table like that :

__C1_____

____ C2 _______________

EUR_______|_(empty with yellow color)|

EUR_______|_(empty with yellow color )|

This code hides data from table and display empty row in yellow color.

i want to get the additionnal row like proposed with ALV:

__C1______

____ C2_______________

EUR_______|_120__________________|

EUR_______|_150__________________|

EUR(yellow) |_270(yellow)____________|

i m bloked on this.

Best regards

gill367
Active Contributor
0 Kudos

1) I m filling data to a node (NODE that have 3 attributes Att_1 Att_2 Att_variant ) in the WDOINIT method.

(Att_variant with 'SUM_TOTAL' is this a significant value ?)

you need to insert a row in the end with

cell variant i.e att_vairant = 'SUM_total'

and and att_2 = sum total of all the values.

so in the place where you are filling the internal table for the node

there do it like as

data tl type wd_this->elements_<nodename>.
data ws type wd_this->element_<nodename>.

"here you write the logic to fill theTABLE TL with the values form backend tables 

"then you insert one last line in the end with the values required for sum as follows

ws-Att_2 = <total value>.
ws-Att_variant = 'SUM_TOTAL'.
APPEND WS TO TL.

"NOW BIND THE TABLE TO THE NODE.

this will make the last line in the table as sum row.

thanks

sarbjeet singh

abhimanyu_lagishetti7
Active Contributor
0 Kudos

wd_text_view = cl_wd_text_view=>new_text_view(

view = view

design = cl_wd_text_view=>e_design-emphasized

BIND_TEXT = 'NODE.C2' ).

Bind_text parameter is missing hence you are not getting the value in C2 column

also SUM_TOTAL value to CELL_VARIANT field to be passed only to the last row of the internal table, let the value for this field be initial for all the other rows.

Abhi