Skip to Content
avatar image
Former Member

How to Change a Default Value from Drop Down Box displayed in Web Dynpro?

Hi,

How to Change a Default Value from 'High' to 'Low' in a Drop Down Box for RANGE field displayed in Standard Web Dynpro Component. I saw a Default Value set for a RANGE field in View Context When I select that field and click on Display. I am seeing Default Value set it to 'HI'. Please let me know how to change from HIgh to Low.

I appreciate your help!

Thanks,

Monica

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 23, 2010 at 03:46 AM

    hi ,

    u can use the method set_lead_selection( ) for this . take the reference of the context node attribute whcih is binded to ur dropdown . press control + f7 to use code wizard and read the context node/attribute . now use the set_lead_selection method

      DATA: dyn_node1 TYPE REF TO if_wd_context_node.
      dyn_node1 = wd_context->get_child_node( name = lv_node1 ).
    
    select  single MOD_ID from z2ts_usermods into
          lv_modid where userid EQ lv_userid.
      DATA : lv_index1 type i .
        clear  wa_mods.
      LOOP AT itab_mods INTO wa_mods.
        IF wa_mods-MOD_ID =  lv_modid.
          lv_index1 = sy-tabix.
        ENDIF.
       clear  wa_mods.
    
      ENDLOOP.
    
      dyn_node1->set_lead_selection_index( lv_index1 ).
    

    regards,

    amit

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi monica,

      Please use the below code in the WDDOMODIFYVIEW POST method.

      DATA lo_nd_node TYPE REF TO if_wd_context_node.
        lo_nd_node = wd_context->get_child_node( name = 'NODE_NAME' ).
        lo_nd_node->set_attribute(
          name =  `RANGE`
          value = `LO` ).

      In above code replace NODE_NAME with the name of your context node and RANGE with the name of the attribute which is

      bind to dropdown UI element.

      Regards,

      Vikrant

  • avatar image
    Former Member
    Feb 26, 2010 at 03:17 AM

    hi,

    use the set_attribute( ) method now to set the attribute with a particular key eg HIGH in ur case

    // u can use the code wizard( control +f7) this code will be auto generated when u select the 
    //radio button to read the context node
    DATA lo_nd_cn_node TYPE REF TO if_wd_context_node.
      DATA lo_el_cn_node TYPE REF TO if_wd_context_element.
      DATA ls_cn_node TYPE wd_this->element_cn_node.
      
    * navigate from <CONTEXT> to <CN_NODE> via lead selection
      lo_nd_cn_node = wd_context->get_child_node( name = wd_this->wdctx_cn_node ).
    * get element via lead selection
      lo_el_cn_node = lo_nd_cn_node->get_element(  ).
    * set single attribute
      lo_el_cn_node->set_attribute(
          name =  `ATTribute name.`
          value = 'LOW' ).
    
    

    it will solve ur query ..

    also refer to this component

    wdr_test_events -> view dropdownbyidx and dropdownbykey ->method name onactionselect.

    regards,

    amit

    Add comment
    10|10000 characters needed characters exceeded