cancel
Showing results for 
Search instead for 
Did you mean: 

dropdownbykey code for default value

Former Member
0 Kudos

Hi,

I have a dropdownbykey element where input is taken from the table PTRV_RELATION. (In this table there are two values External and Internal). The deafult valuse that shows in dropdownbykey element is external probably because it is the first valuse in the table.

I want default value to be Internal. How can i acheive this bt doing Enhancemnet and not modifying the Sap provided table.

Example- writing a code in postexit WDDOINIT.

Please advise.

Thank You!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Just set he attribute binded to Dropdownby key UI with the value you want to set using :

set_Attribute method of if_wd_context_node.

It will show as default value.

Former Member
0 Kudos

Hi Saurav,

I have added the following code in the post exit of WDDOINIT. Due to this there is no default value.....in the drop down the values "Internal" and "External" appear in order. But I also want that "Internal" be in drop down by default without user having to click and slecet it.

Please advise what else i need to add to this code.

Thank You!

method PSTD7KT4DSILCRO2M063ZKZM7LG8 . "Exit of WDDOINIT (in Z_FITE_UI_RECEIPT_DETAILSV2 )

DATA lr_node_info TYPE REF TO if_wd_context_node_info.

DATA ls_value TYPE wdy_key_value.

DATA lt_value_set TYPE wdy_key_value_table.

ls_value-key = '0'.

ls_value-value = 'Internal'.

APPEND ls_value TO lt_value_set.

ls_value-key = '1'.

ls_value-value = 'External'.

APPEND ls_value TO lt_value_set.

*----- Retrieve node

lr_node_info = wd_context->get_node_info( ).

lr_node_info = lr_node_info->get_child_node( 'ENTERTMNT_DETAILS' ).

*----- Set attribute info

lr_node_info->set_attribute_value_set( name = 'RELATION'

value_set = lt_value_set ).

endmethod.

Answers (2)

Answers (2)

P1029777
Explorer
0 Kudos

write this code on INIT method of either view or component controller

-


DATA lo_nd_month_yr TYPE REF TO if_wd_context_node.

DATA lo_el_month_yr TYPE REF TO if_wd_context_element.

DATA ls_month_yr TYPE wd_this->element_month_yr.

DATA lv_month TYPE wd_this->element_month_yr-month.

  • navigate from <CONTEXT> to <MONTH_YR> via lead selection

lo_nd_month_yr = wd_context->get_child_node( name = wd_this->wdctx_month_yr ).

  • @TODO handle non existant child

  • IF lo_nd_month_yr IS INITIAL.

  • ENDIF.

  • get element via lead selection

lo_el_month_yr = lo_nd_month_yr->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_month_yr IS INITIAL.

ENDIF.

  • @TODO fill attribute

lv_month = p_month. "here you can set whatever value you want to set at first time in dropdown

  • set single attribute

lo_el_month_yr->set_attribute(

name = `MONTH`

I hope this will solve ur problem.

Regards.

Gyanendra.

Former Member
0 Kudos

I solved this issue by dynamically setting the value for RELATION in:

FITE_UI_RECEIPT_DETAILS->ENTERTAINMENT_VIEW - POST_EXIT to SET_FOCUS_AND_FIRST_ROW:

DATA lo_nd_entertmnt_details TYPE REF TO if_wd_context_node.

DATA lo_el_entertmnt_details TYPE REF TO if_wd_context_element.

DATA ls_entertmnt_details TYPE wd_this->element_entertmnt_details.

DATA lv_relation TYPE wd_this->element_entertmnt_details-relation.

  • navigate from <CONTEXT> to <ENTERTMNT_DETAILS> via lead selection

lo_nd_entertmnt_details = wd_context->get_child_node( name = wd_this->wdctx_entertmnt_details ).

  • handle non existant child

IF lo_nd_entertmnt_details IS INITIAL.

RETURN.

ENDIF.

  • get element via lead selection

lo_el_entertmnt_details = lo_nd_entertmnt_details->get_element( ).

  • handle not set lead selection

IF lo_el_entertmnt_details IS INITIAL.

RETURN.

ENDIF.

  • set relation to 1 = Internal participant as default

lv_relation = 1.

  • set single attribute

lo_el_entertmnt_details->set_attribute(

name = `RELATION`

value = lv_relation ).