DROP Down By Index in Webdynpro ABAP

Hi,
I 've a small doubt in Drop down by Index in ABAP-Webdynpro
I have two Dropdown, In first dropdown i have few Departmnet name for EX:- Dept1 , dept2 etc..
based upon DEPT from first drop down i need to get  the employee deails in second dropdown.
scenario:-
                      if i will chosse dept1 in first dropdown in second dropdown dept1 employee should populate
                     iif i will chosse dept2  in first dropdown in second dropdown dept2 employee should populate
Thanks...
Edited by: Rakshar on Sep 12, 2011 7:30 AM

Hi Rakshar,
1.  Add an onSelect event to the Dropdown 1.
2.  In the event handler get the the selected value of Dropdown 1 from the context of the same. Based on the selected value, retrieve the data to be displayed in Dropdown 2 ( for example data from a table)
3.  Invalidate the context for Dropdown 2
4.  Bind the data retrieved from table to the context for Dropdown 2 by using method BIND_TABLE
Let me know if you face any difficulty.
Regards,
Arpan

Similar Messages

  • OnSelect event for a Drop down UI Element in Webdynpro ABAP Select Options

    Hi Experts
    We have built our UI based on the webdynpro ABAP Select Options. We have a requirement that, when we change the value of a drop down box in the UI, I need to hide some fields. Can anybody help me out in handling of OnSelect event of a drop down box built using webdynpro ABAP Select Options. We are on SAP Netweaver 7.0 EHP1.
    Rrgards,
    Srikanth.
    Edited by: Srikanth Kancherla on Apr 29, 2010 10:43 PM

    Hi Srikanth,
    as you seem to be already aware, the component is dynamically built.
    so you would have to enhance the code that builds the element and insert a reference to a new action (enhancement) that could handle the onSelect event.
    What is it about this that you particularly want help with?
    Cheers,
    Chris

  • Drop down by index in webdynpro

    I am using a drop down by index element in my webdynpro ABAP screen.
    I populate this drop down by fetching values through a remote-enabled function module. How do i set one particular value as default after fetching these values. ?
    I am getting the currency keys as the list of values and want to show a particular value when the view is first shown. How is this possible?
    regards,
    Priyank

    Hi Priyank,
        I have the sample code where index is used.
        This code is used for radiobutton group by index.
        You can use same logic in your requirement.
    data:
        text    type string,
        element type ref to if_wd_context_element,
        index   type string.
      DATA:
        node_check                          TYPE REF TO if_wd_context_node,
        elem_check                          TYPE REF TO if_wd_context_element,
        stru_check                          TYPE if_start_ior=>element_check ,
        item_check_attribute                LIKE stru_check-check_attribute.
      element = wd_context->get_lead_selection( ).
      index = wdevent->get_string( 'INDEX' ).
    Case when Overhead option is selected
    navigate from <CONTEXT> to <CHECK> via lead selection
      node_check = wd_context->get_child_node( name = if_start_ior=>wdctx_check ).
    get element via lead selection
      elem_check = node_check->get_element(  ).
    get single attribute
      elem_check->get_attribute(
        EXPORTING
          name =  `CHECK_ATTRIBUTE`
        IMPORTING
          value = item_check_attribute ).
    if index EQ 2.
    elem_check->set_attribute( name = 'CHECK_ATTRIBUTE' value = Abap_true ).
    endif.
    if index EQ 1.
    elem_check->set_attribute( name = 'CHECK_ATTRIBUTE' value = Abap_false ).
    endif.
    Hope this answer will help you.
    Cheers,
    Darshna.

  • Drop down in ALV for Webdynpro ABAP

    Hi Experts,
    I was trying to implement one Web dynpro ABAP application that will show one ALV and ALV will content one dropdown so that user can select data from the drop down. Addtion to that, my dropdown should have data based on another column of ALV.
    I have followed one article which is available in Net.
    At the end of development, ALV is displayed with dropdown. Also dropdown has data binded. However, no data is visible in dropdown.
    I have created one context node having four dictionary element and one elemt for dispplaying the dropdown.
    In the DoInit method of view, i have written below code:
    Data Declaration
      DATA:
            lo_node_cskt  TYPE REF TO if_wd_context_node,
            lo_el_cskt    TYPE REF TO if_wd_context_element,
            ls_cskt       TYPE wd_this->element_cskt,
            lt_cskt       TYPE wd_this->elements_cskt,
            lo_cmp_usage  TYPE REF TO if_wd_component_usage,
            lv_value      TYPE REF TO cl_salv_wd_config_table,
            lr_column     TYPE REF TO cl_salv_wd_column,
            lr_drdn       TYPE REF TO cl_salv_wd_uie_dropdown_by_idx,
            ls_value_set  TYPE wdr_context_attr_value,
            lv_tabix      TYPE sy-tabix,
            lv_count(2)  TYPE c,
            lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.
    Navigate from <CONTEXT> to <CSKT> via lead selection:
      lo_node_cskt = wd_context->get_child_node( name = wd_this->wdctx_cskt ).
    get element via lead selection
      lo_el_cskt = lo_node_cskt->get_element( ).
    Get Data:
      SELECT kokrs kostl datbi ktext FROM cskt  INTO CORRESPONDING FIELDS OF TABLE lt_cskt.
      lv_count = 0.
    Populate value set
      LOOP AT lt_cskt INTO ls_cskt.
        lv_tabix = sy-tabix.
        CLEAR ls_cskt-ktext.
        DO 3 TIMES.
          lv_count = lv_count + 1.
          CONCATENATE 'TEST' lv_count INTO ls_value_set-text.
          CONCATENATE 'TEST' lv_count INTO ls_value_set-value.
          if lv_tabix = 2.
           if sy-index = 2.
             EXIT.
           endif.
          endif.
          APPEND ls_value_set TO ls_cskt-valueset.
        ENDDO.
        MODIFY lt_cskt FROM ls_cskt INDEX lv_tabix TRANSPORTING ktext valueset.
      ENDLOOP.
    Bind data
      lo_node_cskt->bind_table( lt_cskt ).
    Instantiate ALV
      lo_cmp_usage = wd_this->wd_cpuse_alv( ).
      IF lo_cmp_usage->has_active_component( ) IS INITIAL.
        lo_cmp_usage->create_component( ).
      ENDIF.
      lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
    Bind Data to Interface Controller Node
       lo_interfacecontroller->set_data(
            r_node_data = lo_node_cskt
    Get ALV reference table
       lv_value = lo_interfacecontroller->get_model( ).
    Make KTEXT column as drop down
       CALL METHOD lv_value->if_salv_wd_column_settings~get_column
       EXPORTING
         id = 'KTEXT'
       RECEIVING
         value = lr_column.
    Create Object for Drop down
      CREATE OBJECT lr_drdn
       EXPORTING
         selected_key_fieldname = 'KTEXT'.
      CALL METHOD lr_drdn->set_valueset_fieldname
      EXPORTING
        value = 'VALUESET'.
      CALL METHOD lr_drdn->set_type
      EXPORTING
        value = IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>TYPE_KEY_CONVERT_TO_VALUE.
      CALL METHOD lr_column->set_cell_editor
      EXPORTING
        value = lr_drdn.
      CALL METHOD  lv_value->if_salv_wd_table_settings~set_read_only
      EXPORTING
        value = abap_false.
    I am still finding the answer why data in drop down is not visible. However, I can select by clicking dropdown and blank elements (since data is not visible) can be selected.

    Hey
    i am using  the same code except i have just modified little bit the select statement to restrict the number of entries.
    and also besides writing the code in wddoinit i have added the compenent usage of alv component and added the node
    having the structure ckst and after that deleting the dictionary reference to add the attribute valueset in both places
    component controller and view controller and mapped them and mapped the data node of interface controller of comp
    usage to this node in comp contrlr.
    and adding the view container and embeding table view of alv comp there.
    that's it
    and here is the code which is almost same as yours except small change in select statement.
    method WDDOINIT .
      DATA:
    lo_node_cskt TYPE REF TO if_wd_context_node,
    lo_el_cskt TYPE REF TO if_wd_context_element,
    ls_cskt TYPE wd_this->element_cskt,
    lt_cskt TYPE wd_this->elements_cskt,
    lo_cmp_usage TYPE REF TO if_wd_component_usage,
    lv_value TYPE REF TO cl_salv_wd_config_table,
    lr_column TYPE REF TO cl_salv_wd_column,
    lr_drdn TYPE REF TO cl_salv_wd_uie_dropdown_by_idx,
    ls_value_set TYPE wdr_context_attr_value,
    lv_tabix TYPE sy-tabix,
    lv_count(2) TYPE c,
    lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.
    * Navigate from <CONTEXT> to <CSKT> via lead selection:
    lo_node_cskt = wd_context->get_child_node( name = wd_this->wdctx_cskt ).
    * get element via lead selection
    lo_el_cskt = lo_node_cskt->get_element( ).
    * Get Data:
    SELECT kokrs kostl datbi ktext FROM cskt INTO CORRESPONDING FIELDS OF TABLE lt_cskt up to 10 rows .
    lv_count = 0.
    * Populate value set
    LOOP AT lt_cskt INTO ls_cskt.
    lv_tabix = sy-tabix.
    CLEAR ls_cskt-ktext.
    DO 3 TIMES.
    lv_count = lv_count + 1.
    CONCATENATE 'TEST' lv_count INTO ls_value_set-text.
    CONCATENATE 'TEST' lv_count INTO ls_value_set-value.
    if lv_tabix = 2.
    if sy-index = 2.
    EXIT.
    endif.
    endif.
    APPEND ls_value_set TO ls_cskt-valueset.
    ENDDO.
    MODIFY lt_cskt FROM ls_cskt INDEX lv_tabix TRANSPORTING ktext valueset.
    ENDLOOP.
    * Bind data
    lo_node_cskt->bind_table( lt_cskt ).
    * Instantiate ALV
    lo_cmp_usage = wd_this->wd_cpuse_alv( ).
    IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
    ENDIF.
    lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
    * Bind Data to Interface Controller Node
    lo_interfacecontroller->set_data(
    r_node_data = lo_node_cskt
    * Get ALV reference table
    lv_value = lo_interfacecontroller->get_model( ).
    * Make KTEXT column as drop down
    CALL METHOD lv_value->if_salv_wd_column_settings~get_column
    EXPORTING
    id = 'KTEXT'
    RECEIVING
    value = lr_column.
    * Create Object for Drop down
    CREATE OBJECT lr_drdn
    EXPORTING
    selected_key_fieldname = 'KTEXT'.
    CALL METHOD lr_drdn->set_valueset_fieldname
    EXPORTING
    value = 'VALUESET'.
    CALL METHOD lr_drdn->set_type
    EXPORTING
    value = IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>TYPE_KEY_CONVERT_TO_VALUE.
    CALL METHOD lr_column->set_cell_editor
    EXPORTING
    value = lr_drdn.
    CALL METHOD lv_value->if_salv_wd_table_settings~set_read_only
    EXPORTING
    value = abap_false.
    endmethod.
    thanks
    sarbjeet

  • How can I add values on a Drop Down by Index Webdynpro Element?

    Hi every body
    Can anybody help me?
    How can I add values on a Drop Down by Index Webdynpro Element?
    How can I invoque my element on the Implementation Webdynpro?

    Hi Jesus,
    You can add elements to your DDbyIndex like this:
    //Example: Popular un Dropdown by Index usando Nodos de contexto  
    // NODE[Card: 1..n, Sele:1..1]  Si es obligatorio;            ||    NODE[Card: 0..n, Sele:0..1]  Si no es obligatorio y se puede dejar en blanco
    //Assuming we created a node called "Source", with a string attribute called "Texto" binded to the dropdownbyindex
    for (int i = 1; i <= 101; i++)
         ISourceElement sourceElement = wdContext.createSourceElement();
           sourceElement.setTexto("Text number "+i);
           wdContext.nodeSource().addElement(sourceElement);
    Regards.
    Julio Herrera

  • How can I add values on a Drop Down by Index Webdynpro Element by a Model?

    How can I add values on a Drop Down by Index Webdynpro Element with a Model RFC?

    Hi Jesus,
    Please use the below code for DropDownByIndex Elements :-
    Suppose you have model node ABC and attribute xyz. Now you have created custom node CustNode and attribute CustAtt.
    ICustNodeElement  ele = null;
    if(wdContext.nodeABC().size > 0)
                  for(int i=0; i< CustNode< wdContext.nodeABC().size; i++
         ele = wdContext. createCustNode();
                          ele.setCustAtt(wdContext.nodeABC().getABCElementAt(i).getXYZ)
         wdContext.nodeCustNode.add(ele);
    Refer to http://help.sap.com/saphelp_nw70/helpdata/en/3b/f1754276e4c153e10000000a1550b0/frameset.htm
    Best Regards
    Arun Jaiswal

  • Subject: Drop Down By index Vs Key

    Question: I have domain with Fixed value and i want the drop down in webdynpro screen to pick  the domain value automatically
    what type of drop down should be used and can you differentiate the two types
    kindly reply

    Hi,
    You should use drop down by key in order to select the domain value automatically.
    Map your contxt attribute as a selected key property of the UI element property.
    Diff. b/w the two avalable types:
    For drop Down by index, You need to build the value table to the node intially and an intial value will be space by default.
    For drop Down by key: you have val-nam pair i.e if you can decide to display domain value or description.
    Hope this  may be helpful.
    Thank you
    Depeshl

  • Drop Down By Index

    Hi Gurus,
    I've one problem with the Drop Down By Index in the WEBDYNPRO JAVA.
    I'm filling the Drop Down By Index from the node based on some condition.
    Based upon the condition the node has only one record.
    After adding the node data to my drop down by index i'm getting the data but the problem is i'm getting two rows in the drop down by index.
    First one is Empty string and the second is the actual value.
    I've written some logic on the "onselectionchange" of the Drop Down By Index.
    There if i select the empty string i'm getting the following error
    "java.lang.NullPointerException "
    How to resolve this issue.
    Thanks in advance.
    Regards,
    Adi.

    Hi Guru's,
    One more problem...
    The solution is working fine for removing the Empty row from the drop down by index, but when i select some thing in the dropdown box it is always pointing to the First row only???
    Why it is behaving like that??/
    Thanks in adavance.
    Regards,
    Adi

  • Drop down by Index label

    Hi all,
    I have a "drop down by index" UI element in my webdynpro which is bound to a value node which intern gets values from a model node. Values are visible in the drop down and also are going to the BAPI proprely.
    But, I want to show an entry simillar to "Please Select" as the first entry which is visible by default and nothing should happen if user selects this entry. how can this be acheived?
    Also, I want to make the selection of the drop down mandatory. I tried chaning the "state" property of the drop down to "required". It did not work.
    Any pointers on these?
    Thanks,
    Hari

    Hi Hari,
    See this thread for "Please Select":
    How to add "please select " Stirng to dropdownbyindex
    On action button write code for dropdown validation whether value is selected or not.
    Search in SDN for sample validation code.
    Regards, Suresh KB

  • Unable to expand drop down by index UI element

    Hi,
    I have got one Drop down by index in my webdynpro form and I want to bind this to backend data. For this purpose, I created one adaptive rfc model  and also did all this model binding, context mapping etc.
    Now my context in view  looks like this :- GetDropDown_Mn (parent node) , this has got child Output_DropDown which again has two value attributes Name and Text.
    This is component controller code where you bind and invalidate
    __Shell__Ca_Read_Cr_Drbox_Val_Input dropdown = new __Shell__Ca_Read_Cr_Drbox_Val_Input();
            wdContext.nodeGetDropDown_Mn().bind(dropdown);
            wdContext.currentGetDropDown_MnElement().modelObject().execute();
            wdContext.nodeOutput_DropDown().invalidate();
    I then tried to bind my UI element in view with Name attribute , but when I try to run my application , the field appears as read only, kind of non editable (blocked) and I am unable to expand my dropdown.
    The readonly property of UI element is false. I have hard coded one value like " Please select from drop down list " and I want the backend values to come below this. For this, I have written code to append the backend values with the hardcoded value. Now the problem is my dropdown is blocked  and not able to expand ( unable to click the arrow button), and I cannot see the other values in dropdown except the hard coded value.
    Can someone please help me on this. 
    The cardinality of context node is 1..n, selection = 0..1 and I have set Leadselection = -1.
    Thanks and regards,
    Sai

    Hi Sai,
    You can use the below code to add the please select in ur drop down in wdInit() method
    wdContext.nodeVn_Node().currentVn_NodeElement().setVa_Attribute("-Please Select-");
    please use the name of node as u have created in the context.
    and after that please check if yoy are getting values from RFC call or not.
    if you are getting the values then try to change the selection property of that node to 1..n and comment the lead selection line that you have written.
    hope this will help.
    Regards
    Narendra

  • Drop Down BY Index Vs Drop Down By Key

    What is the difference between Drop Down By Index & Drop Down By Key.
    How Do we retrive What value is selected in a drop down
    regards
    Nilesh

    Hello Nilesh,
    //Create ISimpleTypeModifiable to fill the dropdownbox
    //XXX is your Desc field
                    IWDAttributeInfo soAttribInfo= wdContext.getNodeInfo().getAttribute("XXX");
                    ISimpleTypeModifiable soType = soAttribInfo.getModifiableSimpleType();
                    soType.setFieldLabel("XXXX");
                    IModifiableSimpleValueSet soSet= soType.getSVServices().getModifiableSimpleValueSet();
                    soSet.clear();
                    //To Get desc and key from web services you pass some information to the run the given Webservice do it here
                    wdContext.currentRequest_XXXViDocument_getDescnKeyArrayElement().setInfo(infonr);
                    wdThis.wdGetXXXController().getDescObjects();
                    int size = wdContext.nodeResult_getDescObjectsArray().size();
                    if (size != 0)
                         //Filling the desc in the dropdownbykey field
                         for (int i=0; i<wdContext.nodeResult_getDescObjectsArray().size(); i++ )
                              IPrivateXXView.IResult_getDescObjectsArrayElement soElement =
                                  wdContext.nodeResult_getDescObjectsArray().getResult_getDescObjectsArrayElementAt(i);
                               soSet.put(soElement.getkey(),
                              soElement.getDesc().trim() + " " + soElement.getkey().trim() );
    Implement this code for populating the drowdown when that works I can tell you the next step.
    Good Luck,
    Dharmi

  • In Drop Down by Index how can i pass default value Dynamically

    Hi Friends,
    In Drop Down by Index how can i pass default value Dynamically.Please help me.
    Thanks in advance.
    Regards,
    Kumar.

    hi,
    if you want the value to be defaulted only the first time you execute the program then write the code which suman has mentioned in the views method
    wddoinit.
    Regards
    Sajid

  • Default value in the drop down by index

    Hi Experts,
    I have a drop down by index to which i binded one internal table,but m not able to get the default value
    i want the first value to be selected in the drop down by default,Pls give me suggestion for solving this problem

    Hi Shan,
    As per your requirement,When ur binding the internal table to the  drop down by index ,but your are not able to get the default value.
    For this please check this code.
    In this I hv taken a node - dropdown1 and within this attribute of type Land1 and I hv set the cardinality to 0..n.
    Then I hv bind the text property of the dropdownbyidx ui element to the node attribute.
    then i hv call this code in the init method of view.
    DATA lo_nd_dropdown1 TYPE REF TO if_wd_context_node.
      DATA lo_el_dropdown1 TYPE REF TO if_wd_context_element.
      DATA lt_dropdown1 TYPE wd_this->elements_dropdown1.
      DATA ls_dropdown1 LIKE LINE OF lt_dropdown1.
      navigate from <CONTEXT> to <DROPDOWN1> via lead selection
      lo_nd_dropdown1 = wd_context->get_child_node( name = wd_this->wdctx_dropdown1 ).
      @TODO handle not set lead selection
      IF lo_nd_dropdown1 IS INITIAL.
      ENDIF.
      get all declared attributes
      lo_nd_dropdown1->get_static_attributes_table(
        IMPORTING
          table = lt_dropdown1 ).
      SELECT land1 FROM t005 INTO CORRESPONDING FIELDS OF TABLE lt_dropdown1.
      CALL METHOD lo_nd_dropdown1->bind_table
        EXPORTING
          new_items            = lt_dropdown1
          set_initial_elements = abap_true .
    Regards
    Manoj Kumar

  • How to hard code values in drop down by index

    Hi everyone
    I hav a node containing 2 attributes ie value n key. I am using drop down by index.  Value attribute is bound to my drop dwn box. In key I am providing key value for the value.  I need to hard code 3 value..Can anyone help me how to do so.
    Thanks
    Jaspreet Kaur

    Hi,
    Example for Data Binding of the DropDownByIndex UI Element:
    Procedure at design time:
           1.      Create a view with the name TestView.
           2.      Insert the DropDownByIndex UI element as a container child of the TestView view. (Step 1)
           3.      Create the context structure, as described in step 2.
    Create the context node X with the cardinality 0..n. Insert the value attribute y of the type String into this node. Then perform the data binding of the DropDownByIndex UI element in the Properties window of the View Designer. The texts property must be bound to the value attribute y with the context path description TestView.X.y (step 3).
    The context path TestView.X.y describes the attribute y in the context node X of the view context of the TestView view.
    You can fill the context with test data using the following controller implementation.
    public void wdDoInit()
        //@@begin wdDoInit()
       String[] letters = new String []
       {"A", "B", "C", "D"};
    //Create context elements for the node "X"
       List nodeElements = new ArrayList();
       for (int i =  0; i <letters.length; ++i)
          IPrivateTestView.IXElement xElement = wdContext.createXElement();
          xElement.setY(letters<i>);
          nodeElements.add(xElement);
    //Bind node element list to the node
       wdContext.nodeX().bind(nodeElements);
    //Set node’s lead selection which determines the selected item
       wdContext.nodeX().setLeadSelection(1);
        //@@end
    Regards
    Ayyapparaj

  • How to capture selected value from drop down by index

    Dear friends,
    i want to capture the value of select value from drop down by index, for eg if  select air france, how to capture , could any one please let me know
    Thanks
    Vijaya

    Hi Vijaya,
    You can get the value of selected from drop down as below
    Check out the event handler method attached to Onselect event of the ui element drop down by index , if no event is associated, then create an event and attach to the drop down list
    Now you will be having the CONTEXT_ELEMENT in the WDEVENT parameter
                   data lo_element type ref to if_wd_context_element.
                   lo_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT').
    Now, you can get the static attribute value of selected  drop down value & let us say your drop down list values are populated from context node 'ND_DRP_DOWN'
                   data ls_data type wd_this->element_nd_drp_down.
                             lo_element->get_static_attributes(
                                       importing
                                       static_attributes = ls_data ).
    Hope this helps you.
    Regards,
    Rama

Maybe you are looking for