cancel
Showing results for 
Search instead for 
Did you mean: 

SRM 71: Making checkbox checked dynamically and triggering the actions

darren_brown3
Explorer
0 Kudos

Hello please can you help,

Within the "Create Contact Person" screen in SRM 713 on netweaver 740 I need to make the checkboxes "Create User for Contact Person" and "Existing SU01 User" checked on entry into the screen, I also need to fire any actions associated to these checkboxes and then make them read only.

I have managed to be able to check the checkboxes by implementing an enhancement into the web dynpro component /SAPSRM/WDC_MODC_CPD_UD within a post-exit of method WDDOMODIFYVIEW using the code below, however, the actions associated to these checkboxes are not being fired. I have tried to call the on action method for the checkbox actions but this is not updating the screen.

I have also tried with no success to change the values with the controller but have not included that code... to be honest I seem to be able to update the screen in various ways but not trigger the actions. What is the correct way to update elements dynamically?

"This code does check the checkbox and does display it to the screen, however it does not trigger the actions

data lo_nd_cp_user_data type ref to if_wd_context_node.

data lo_el_cp_user_data type ref to if_wd_context_element.

data lor_element type ref to cl_wd_checkbox.

if first_time eq abap_true.

     lo_nd_cp_user_data = wd_context->get_child_node( name = wd_this->wdctx_cp_user_data )

     lo_el_cp_user_data = lo_nd_cp_user_data->get_element( ).

     lor_element ?= view->get_element('C_EXISTING').

     if lor_element is bound.

          lor_element->set_checked( abap_true ).

     endif.

endif.

I did find some articles that suggested that you call the onaction method for the action rather than trigger the event, so I have tried to do that but the context_element parameter within the event parameters of the event has a value with a data type defined as being "REF TO \TYPE=%T00004S00000102O0000001584" and an absolute type defined as "\TYPE=%_T00004S00000423O0000001344". I have no idea what types these are and cannot create an object containing these. If there is a way to trigger the event rather than calling the event handler method with a dummy event?

This code does not error, it calls the onaction method but does not hide the elements that would be hidden had the user checked the box for themselves. It could simply be that the types are incorrect for the CONTEXT_ELEMENT value or is there a better to trigger an action.

constants:

     lc_element_name_c_existing(10) type c value 'C_EXISTING'.

data:

     lor_dummy_event type ref to cl_wd_custom_event,

     lit_event_params type wdr_event_parameter_list,

     lwa_event_param type wdr_event_parameter,

     lv_wdr_value_id type wdr_value,

     lor_dummy_data type ref to data.

lv_wdr_value_id = lc_element_name_c_existing.

lwa_event_param-name = 'ID'.

insert lwa_event_param into table lit_event_params assigning <lfs_parameter>.

get reference of lv_wdr_value_id into <lfs_parameter>-value.

lwa_event_param-name = 'CONTEXT_ELEMENT'.

insert lwa_event_param into table lit_event_params assigning <lfs_parameter>.

get reference of lor_dummy_data into <lfs_parameter>-value.

lwa_event_param-name = 'CHECKED'.

lv_wdr_value_checked = 'X'.

insert lwa_event_param into table lit_event_params assigning <lfs_parameter>.

get reference of lv_wdr_value_checked into <lfs_parameter>-value.

create object lor_dummy_event

     exporting

          name = 'ON_TOGGLE'

          parameters = lit_event_params.

wd_this->onactionexist_user( lor_dummy_event ).

regards,

Darren.

Accepted Solutions (1)

Accepted Solutions (1)

darren_brown3
Explorer
0 Kudos

After a lot more debugging I found the solution, see snippet in attachment.

Answers (0)