Skip to Content
0
Jul 26, 2016 at 01:04 PM

Set Default values in DropDownByKey in Webdynpro ABAP

902 Views

Hi,

I have set list of values for Drop Down By Key using the below code in WDDOINIT method.

I need EMP value to set as default in the drop down when the page is opened initially.

Node Name: OPERATION

Attribute Name: OPERATION_TYPE

DATA value_set_op_type TYPE wdr_context_attr_value_list.
DATA ls_value_set_op_type LIKE LINE OF value_set.

DATA wd_node_info TYPE REF TO if_wd_context_node_info.

DATA lo_child_node TYPE REF TO if_wd_context_node_info.

ls_value_set_op_type-value = 'E'.
ls_value_set_op_type-text = 'Emp'.
APPEND ls_value_set_op_type TO value_set_op_type.
ls_value_set_op_type-value = 'P'.
ls_value_set_op_type-text = 'Pat'.
APPEND ls_value_set_op_type TO value_set_op_type.
ls_value_set_op_type-value = 'Q'.
ls_value_set_op_type-text = 'Eqp'.
APPEND ls_value_set_op_type TO value_set_op_type.
CLEAR ls_value_set_op_type.
APPEND ls_value_set_op_type TO value_set_op_type.

*Set the Operation Type in Operation Info Tab.
wd_node_info = wd_context->get_node_info( ).
lo_child_node = wd_node_info->get_child_node( name = 'OPERATION_INFO' ).
lo_child_node->set_attribute_value_set( name = 'OPERATION_TYPE' value_set = value_set_op_type ).



I reffered to but not much helpful. By following this link when made changes which is as below it shows error saying NULL OBJECT REFERENCE

DATA lo_nd_operation_info TYPE REF TO if_wd_context_node.
DATA lo_el_operation_info TYPE REF TO if_wd_context_element.
DATA ls_operation_info TYPE wd_this->element_operation_info.
DATA lv_operation_type TYPE wd_this->element_operation_info-operation_type.

* navigate from <CONTEXT> to <OPERATION_INFO> via lead selection
lo_nd_operation_info = wd_context->get_child_node( name = wd_this->wdctx_operation_info ).


*
** get element via lead selection
lo_el_operation_info = lo_nd_operation_info->get_element( ).


** set single attribute
lo_el_operation_info->set_attribute(
name = `OPERATION_TYPE`
value = 'E' ).

Please provide if any input on this.


Regards,

Rafi