cancel
Showing results for 
Search instead for 
Did you mean: 

Check box in ALV in Webdynpro

Former Member
0 Kudos

Hi Experts,

I have a requirement to display check boxes as the first column of the ALV, now at any point of time if the user selects one check box i have to get all the corresponding data of that row and display it at a different location, Can you let me know how i can identify when the check box is checked and how can i identify the row that is selected?

Also when the standard select all button is pressed all the check boxes should be automatically checked , how do i handle this.

Thanks in Advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

(1) Under the Context node for corresponding ALV,have a attribute called 'check' if type char.

Whem u select the check box,and press the button to display the information,

place th code,

CALL METHOD lo_nd_nd_<nodename>->get_static_attributes_table

IMPORTING

table =lt_nd_<nodename>.

READ TABLE lt_nd_<nodename> INTO <Structurename>

with key check = 'X'.

Now the Structure will give the value of the record u have chosen.

(2) When Select All button is selected,

Similarly get the table value,

loop at the table value and set the 'Check' attribute as 'X' and use Modify statement ,

loop at lt_nd_<nodename> into <structure>.

<structure>-check = 'X'.

MODIFY lt_nd_<nodename> FROM

<structure> TRANSPORTING check

WHERE index = sy-tabix.

endloop.

Then bind the table as,

lo_nd_nd_<nodename>->bind_table( new_items = lt_nd_<nodename> ).

Now all the check box will get selected.

Thanks,

Divya.S

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

You can try go through my postings in this [thread |;where when the user selects a checkbox in the ALV's row I need to fetch the information in that particular row & update it on to the database. You would find the entire coding along with explanation in there. Hope that it would help you get a better understanding as to how you can approach your problem.

Regards,

Uday

Former Member
0 Kudos

Hi Uday,

Thanks a lot for all the information.

I just have one more small clarification, should the user always press some button after the check box is checked, can we directly trigger the even ON_DATA_CHECK immediately the check box is checked and enter is pressed ?

Thanks,

Anvesh

Edited by: anvesh mantena on Jul 6, 2009 5:31 PM

Former Member
0 Kudos

Hi,

No extra button click is required and clicking the CHEKC BOX & enter will create a roundtrip through the application.

Regards,

Manne.

uday_gubbala2
Active Contributor
0 Kudos

Hi Anvesh,

Its not possible to directly trigger the ON_DATA_CHECK by pressing enter after checking the checkbox. I did just play around trying to do the same and it doesn't work. This is unlike the case with the checkbox in table where a server round trip gets triggered automatically when you toggle the checkbox. You just need to associate an action with the onToggle event of the checkbox & the framework would just trigger a server roundtrip as soon as you toggle with the checkbox. But things are different in the case of a checkbox within an ALV. No roundtrip is triggered by toggling with the checkbox. Its why you need to trigger the checks from within another event like pressing a button.

You can try test it out yourself in your component so that you would get a better picture of the same.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos
Coding inside my event handler method for the event ON_DATA_CHECK of the ALV:
-----------------------------------------------------------------------------

method ON_DATA_CHECK .
  DATA: lr_node TYPE REF TO if_wd_context_node,
        lr_element TYPE REF TO if_wd_context_element,
        ls_modified_cells TYPE salv_wd_s_table_mod_cell,
        wa_data type wd_this->element_table,
        wd_node type ref to if_wd_context_node.

  FIELD-SYMBOLS <temp> TYPE data.

  wd_node = wd_context->get_child_node( name = 'TABLE' ).

" get message manager
  DATA lo_api_controller     TYPE REF TO if_wd_controller.
  DATA lo_message_manager    TYPE REF TO if_wd_message_manager.

  lo_api_controller ?= wd_this->wd_get_api( ).

  CALL METHOD lo_api_controller->get_message_manager
    RECEIVING
      message_manager = lo_message_manager.

  lr_node = wd_context->get_child_node( name = 'TABLE' ).

  LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
    lr_element = lr_node->get_element( index = ls_modified_cells-index ).
" The ALV might also have been modified at other places so check if the modification
" has happened in the checkbox column. In my example the column APPROVE is being
" displayed as checkboxes to the user. 
    IF ls_modified_cells-attribute = 'APPROVE'.
" If the modification has happened in the checkbox then fetch the information of that row
      wd_node->get_static_attributes( exporting index             = ls_modified_cells-index
                                      importing static_attributes = wa_data ).
" Do your desired processing with the row information that you have in wa_data
    endif.
  endloop.
endmethod.
uday_gubbala2
Active Contributor
0 Kudos

Hi Anvesh,

At what particular point of time do you want to look out for checked checkboxes? You can say have a button which the user clicks up on to look out for changes in the ALV's data after checking his desired checkboxes.

Say suppose you have a button then within this buttons event handler you should call the DATA_CHECK method of the ALV. This method would scan the ALV for any changes in data. If anything has changed (any checkbox checked) then the system raises the event ON_DATA_CHECK.

Below is the coding inside my buttons action handler ONACTIONCHECK_ALV_DATA

method ONACTIONCHECK_ALV_DATA .

DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .

l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_My_Alv( ).

l_ref_INTERFACECONTROLLER->Data_Check( ).

endmethod.

So if the user has checked any checkboxes then the ALV's data would have changed & so the system would have raised the ON_DATA_CHECK event. So create an event handler method for the event ON_DATA_CHECK. The framework does pass a parameter WDEVENT as input to this particular method. If you check the properties of this WDEVENT parameter in debugging mode, you would see that it has a PARAMETERS table. Now within this table you have another parameter R_PARAM.

Double click on R_PARAM and you can see various attributes present among which you also have:

IF_SALV_WD_TABLE_DATA_CHECK~T_MODIFIED_CELLS

This table would contain the indexes of the rows in which the data has changed. (where the checkbox has been checked) So you can pass this index to read the data from the context node using a normal get_static_attributes call.

Former Member
0 Kudos

Hi uday

I have same problem but mine is not alv. I am using table with check box if the user checks on the check box then the selected records should be saved in one internal table . Please guide me no one posted such kind of queries.

Thanks

Indiranjithn