cancel
Showing results for 
Search instead for 
Did you mean: 

row wise total in editable ALV

Former Member
0 Kudos

hello all,

I am workin on editable alv, the user need to enter the values in the editable fields and in the last column(non-editable) i need to populate the total row wise,as soon as user enters a value and goes to next editable cell or on entering a vale and press enter.how to accomplish this task...

with regards,

sandeep akella.

Edited by: sandeep akella on Aug 20, 2009 1:58 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

can you explin me in detail..

Former Member
0 Kudos

You need to Implement the OnCellAction event.follow these steps;

1. Goto WDDOMODIFYVIEW and place the following code

IF first_time IS INITIAL.

    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

    lo_cmp_usage =   wd_this->wd_cpuse_usg_alv( ).
    IF lo_cmp_usage->has_active_component( ) IS INITIAL.
      lo_cmp_usage->create_component( ).
    ENDIF.

    DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
    lo_interfacecontroller =   wd_this->wd_cpifc_usg_alv( ).

    DATA lo_value TYPE REF TO cl_salv_wd_config_table.
    lo_value = lo_interfacecontroller->get_model(
    ).

    CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
     EXPORTING
        value = abap_true.

  ENDIF.

2. Implement the onCellAction event as follows;

Goto Methods tab, create a new method. Method Type- Event Handler , Event - ON_CELL_ACTION

3. Now in this method retrive the contents of the row and calculate the value as follows.

DATA: l_element TYPE REF TO if_wd_context_element.
  DATA:ls_stru TYPE wd_this->element_cn_alv.
 
  DATA: l_node TYPE REF TO if_wd_context_node.
  l_node  = wd_context->get_child_node( 'CN_ALV' ).

  l_element = l_node->get_element(  r_param->index ).
  l_element->get_static_attributes( IMPORTING static_attributes = ls_stru ).

  ls_stru-last_col = ls_stru-col1+ls_stru-col2....+ ls_stru-col5. " add all the cells data
  l_element->set_static_attributes( exporting static_attributes = ls_stru ).

Former Member
0 Kudos

Hi,

In the OnCellAction for that ALV, there is a paramter R_PARAM that has Id and also the content.

Using the Id, get the element at that ID.

*Use code wizard to get thr proper code. this is an example

lo_nd_node->get_element   "Get elemnet at that index
exporting
index = r_param-id
importing
elmenet = lr_element.

if lr_element is not intiial.
lr_element->get_statitc_attributes
importing
new_items = ls_table.
endif.

lr_node->get_static_attributes_table
importing
new_items = lt_table.
lv_total = ls_table-cell1 + ls_table-cell2 + ls_table-cell3.

loop at lt_table into ls_table1.
if sy-tabix = r_param->id.
ls_table1-total = lv_total.
endif.
modify table lt_table from ls_table1 index r_param->id.
endloop.

Regards,

Lekha.

Answers (3)

Answers (3)

Former Member
0 Kudos

hello all,

yes i have implemented the aggregate total method. the column total was working fine before adding the cell action event.After adding it i am not able to get the change in the value of total when i changea value in the editable field.

I have commented all the code for enabling cell action and checked , then the column totals are changing normally as before with change in the value.

with regards,

sandeep akella.

Edited by: sandeep akella on Aug 21, 2009 5:28 AM

Former Member
0 Kudos

Hi,

Can you write the code in the ONDATACHECK event for that ALV instead of ONCELLACTION.

I think then you will get the columns totals.

Please cehck it.

Regards,

Lekha.

Former Member
0 Kudos

i have resolved the column total issue..it is not related to oncellaction.If i put the code in ondata check event then i will be unable to get the change in data, so that i can add them up n display in my last column....is there any method so that i can catch tab event in the alv grid

Former Member
0 Kudos

Hi,

ONDATACHECK event can alos be used But the USER needs to hit ENTER key explictily to trigger this.

Implement the event for tabselection, In the TABSTRIP UIelement, then you willget to know the selected tab and

move it to any global variable that can be used inside the ALV.

Regards,

Lekha.

Former Member
0 Kudos

ondata check is not getting triggered when i am pressing enter , the only the oncell action is getting triggered.how to catch the ondata chek on pressing enter.

Former Member
0 Kudos

Hi,

CALL METHOD lo_value->if_salv_wd_table_settings~set_data_check

EXPORTING

value = if_salv_wd_c_table_settings=>DATA_CHECK.

When you have achived your task using oncellactio what exaclty you want. getting of Tab ID is also done using tab selection event.

What exactly you want to perform.

Regards,

Lekha.

Former Member
0 Kudos

my doubt is i am able to catch the change in data oncellaction on entering value and pressing enter...can we do it after moving from one editable cell to another on pressing tab etc...

Former Member
0 Kudos

Hi,

There are no tab events registered with the ALV.

Regards,

Lekha.

Former Member
0 Kudos

ok.

Former Member
0 Kudos

Hello all,

i am able to capture data and add them on change of cell.I have also implemented the colunm wise total (before adding the event for editable cells) for editable cells and the non-editable total cell.Now with this change of getting the cell event I am unable to get the column totals automatically..what to do about this...

Edited by: sandeep akella on Aug 20, 2009 3:30 PM

Former Member
0 Kudos

HI,

Have you applied stanadard aggregation functions for totals. Have you bound the table to node in ONCELLACTION event.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Implement the onCellAction event for the Inputfield of the cell. In that method get the contents of the row and populate the total in the last cell.

Regards,

Radhika.