cancel
Showing results for 
Search instead for 
Did you mean: 

Sy-UCOMM

Former Member
0 Kudos

Hi,

I am new to WD-ABAP. Is there anything like system fields (like SY-UCOMM in ABAP) in WD? For eg I have several buttons on my view. Based on the click of a particular button, I would like to perform certain validations in WDDOBEFOREACTION.

Is there anyway to know which button has the user clisked to perform the validation in WDDOBEFOREACTION?

Thanks,

Mick

Accepted Solutions (1)

Accepted Solutions (1)

yesrajkumar
Active Participant
0 Kudos

Hi James,

Try to bind the button poperty say button1 to the attribute of type wdy_boolean in you controller(View or controller) try as below.

data lo_nd_button1 type ref to if_wd_context_node.

data lo_el_button1 type ref to if_wd_context_element.

data lv_value type boolean.

lo_nd_button1= wd_context->get_child_node( name = wd_this->wdctx_button1 ).

  • get element via lead selection

lo_el_button1 = lo_nd_button1->get_element( ).

lo_el_button1->get_attribute(

exporting

name = `BUTTON1`

importing

value = lv_value ).

if lv_value is not initial.

  • lv_value holds the value . If its clicked it has 'X' else space

endif.

Thanks,

Rajkumar.S

Former Member
0 Kudos

Thanks Rajkumar. Its a very helpful answer.

Is there any easier way, because if there are multiple buttons, then I will have to check for each and every button.

Mick

yesrajkumar
Active Participant
0 Kudos

Hi,

Once you define the button UI element in the View, you need to map some action to the same button. In your case map the actions for the corresponding buttons say save and cancel.

Then use the following code. Here method map_on_action is used to map the action to the button.

Data: ls_action_param TYPE wdr_name_value,

lt_action_parameters TYPE wdr_name_value_list,

lo_ui_button TYPE REF TO cl_wd_button.

"Cancel navigation

CLEAR lt_action_parameters.

lo_ui_button ?= io_view->get_element( 'CANCEL' ).

ls_action_param-value = 'CANCEL'.

APPEND ls_action_param TO lt_action_parameters.

lo_ui_button->map_on_action( EXPORTING parameters = lt_action_parameters ).

"Save navigation

CLEAR lt_action_parameters.

lo_ui_button ?= io_view->get_element( 'SAVE' ).

ls_action_param-value = 'SAVE'.

APPEND ls_action_param TO lt_action_parameters.

lo_ui_button->map_on_action( EXPORTING parameters = lt_action_parameters ).

**************************************************************************************************

In order to retrieve the action parameters for the button SAVE during the runtime, use the following

Here method mapped_on_action is used to map the action to the button.

lo_ui_button TYPE REF TO cl_wd_button.

lo_ui_button ?= io_view->get_element( 'SAVE' ).

lo_ui_button->mapped_on_action( importing parameters = lt_action_parameters ).

Thanks,

Rajkumar.S

Former Member
0 Kudos

Thanks Rajkumar. Its a very helpful answer.

I have tried pasting your following code as it is in the event handler and the WDDOBEFOREACTION methods.

data lo_nd_button1 type ref to if_wd_context_node.

data lo_el_button1 type ref to if_wd_context_element.

data lv_value type boolean.

lo_nd_button1= wd_context->get_child_node( name = wd_this->wdctx_button1 ).

get element via lead selection

lo_el_button1 = lo_nd_button1->get_element( ).

lo_el_button1->get_attribute(

exporting

name = `BUTTON1`

importing

value = lv_value ).

But I am getting the following error:

Statement lo_nd_button1 is not defined. Check your spelling......

In wd_this (IF_SELECTION) I do not see any constant or any object defined as wdctx_button1.

Please help.

Reg,

Mick

Mick

arjun_thakur
Active Contributor
0 Kudos

Hi Mick,

Use code given below in the WDDOBEFOREACTION method. You said that your view has many buttons and you need to do validation according to each button. When we create a button, we create some ONACTION event as well. This code catches that event name. Suppose i have a button "SUBMIT" which has 'ONSUBMIT' as ONACTION event. So just use 'ONSUBMIT' in the case statement and then you can write validation code according to that button.

data lo_api_controller type ref to if_wd_view_controller.
  data lo_action         type ref to if_wd_action.

  lo_api_controller = wd_this->wd_get_api( ).
  lo_action = lo_api_controller->get_current_action( ).

  if lo_action is bound.
    case lo_action->name.
      when 'ONSUBMIT'.

endcase.
  endif.
endmethod. 

I hope it helps.

Regards

Arjun

Former Member
0 Kudos

Thanks Arjun. This works

Answers (0)