Skip to Content
avatar image
Former Member

Drop Down in webDynpro.

Hi experts ,

I wana get help on drop down. I have got an internal table which has all the company code related to the user who has loged in UI. I want to display that internal table as drop down. Please provide me a solution .

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Jan 02, 2009 at 09:06 AM

    Hi Madhvi,

    I hope you are using dropdown by key. Create a value set first and then refer the following code:

      DATA: itab_t005t TYPE TABLE OF t005t,
     DATA: wa_value TYPE wdy_key_value.
    FIELD-SYMBOLS: <fs_t005t> TYPE t005t.
    
    CALL METHOD cl_wd_dynamic_tool=>get_table_data
        EXPORTING
          tab_name  = 'T005T'
          row_count = 0
        IMPORTING
          data      = itab_t005t.
    
    LOOP AT itab_t005t ASSIGNING <fs_t005t> WHERE spras EQ sy-langu.
        wa_value-key = <fs_t005t>-land1.
        wa_value-value = <fs_t005t>-landx.
    insert wa_value into table value_set.
      endloop.
    
    node_info = wd_context->get_node_info( ).
      node_info = node_info->get_child_node( 'CN_COUNTRYCODE' ).
     node_info->set_attribute_value_set(
                  name = 'CA_COUNTRYCODE' value_set = value_set ).
    

    I hope it helps.

    Regards

    Arjun

    Edited by: Arjun on Jan 2, 2009 2:45 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2009 at 09:24 AM

    Hi madhavi,

    First let me tell you there are two procudures that you can follow for drop down filling.

    1. Drop by by index

    2.Drop down by Key

    You can follow any of the procedure for the first case you need to create a different node with cardinality 0:n. and bind that drop down to that node, The values which you get from internal table just bind that internal table to that particular node.

    eg: bind_table( lt_data).

    The values will be populated into that drop down.

    Hope you got it .

    Regards,

    Sana

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2009 at 09:54 AM

    hi madhvi,

    There are lots of solution to this requirement.

    Here instead of fetching from database table i am inserting details in table from code only.So u can change that logic.

    If u have any doubt feel free to ask.

    Also write this code in WDDOINIT method.

    data:

    lr_node_info type ref to if_wd_context_node_info,

    lt_value_set TYPE wdy_key_value_table,

    value_set_item TYPE wdy_key_value.

    get object referent of root node metadata

    lr_node_info = wd_context->get_node_info( ).

    fill values into table of type wdy_key_value_table

    value_set_item-key = 'X'.

    value_set_item-value = 'Charter'.

    insert value_set_item into table lt_value_set.

    value_set_item-key = 'P'.

    value_set_item-value = 'Private'.

    insert value_set_item into table lt_value_set.

    set values (table) to context attribute

    lr_node_info->set_attribute_value_set( NAME = 'FLIGHT_TYPE_DYN'

    VALUE_SET = lt_value_set ).

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 06, 2009 at 05:07 AM

    Hi Madhvi,

    DropDownByIndex is achieved for one field of the internal table at a time...However you can implement in the code in such a way that if the corresponding is selected, its respective another is updated in the table..

    The corresponding field is binded to the texts property of the DropDownByIndex UI.

    Regards,

    Narendra.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 06, 2009 at 05:40 AM

    Hi Madhvi,

    I understand that you have an internal table which has the company codes. There are two scenarios here.

    Scenario 1

    You have only one field in the internal table, i.e., company code.

    Here you can make use of the WebDynpro UI element DropDownByIndex. Here you will have to define a node in the context of cardinality 0:n, and an attribute of the type similar to the company code.

    Once you have done that, insert the DropDownByIndex element in the Layout, then bind the texts property of the same to the attribute (company code).

    Now the coding.

    Declare a supply function for the node. Write the code for binding the value in the internal table into the node.

    Here, you will get the company codes as a drop down.

    Scenario 2

    You have only two fields in the internal table, i.e., company code and company code description

    And you want to display the description in the dropdown but use the code for processing in the background.

    In this particular scenario, you can make use of the DropDownByKey UI element. The dropdown node will have two attributes, one for the company code and the other for the description.

    The company code attribute will be bound to the key property of the UI element. Here again, its advisable to use a supply funciton.

    Coding:

    Declare a workarea of type wdy_key_value, say, wa_key_value and an internal table of type wdy_key_value_table, say, lt_key_value_table.

    Assuming the internal table of the company code is lt_company_code, <fs_compay_code> the workarea and the fields are comp_code and comp_desc, comp_code being the company code and comp_desc being the company code description.

    node is the reference of the drop down node.

    DATA: lt_key_value_table TYPE wdy_key_value_table,
              lt_company_code TYPE (table_type of comany code with the above mentioned fields).
    
    DATA: wa_key_value TYPE wdy_key_value.
    
    FIELD-SYMBOLS: <fs_compay_code> TYPE (structure of company code with the above mentioned fields).
    
    
    LOOP AT lt_company_code ASSIGNING <fs_compay_code>.
             wa_key_value-key = <fs_compay_code>-comp_code.
             wa_key_value = <fs_compay_code>-comp_desc.
             APPEND wa_key_value to lt_key_value_table .
             CLEAR wa_key_value.
    ENDLOOP.
    
    node->set_attribute_value_set( name = 'KEY' 
                                                  value_set = lt_key_value_table ).
    

    Add comment
    10|10000 characters needed characters exceeded