Skip to Content
avatar image
Former Member

dropdown in webdynpro

hi all,

i have a requirement where i need to create a dropdown key, which will display all the values of a feild in a data base table.

Now i need to add a new option 'create new' into the dropdown along with the values populated from the table.

eg: i have AAA,BBB,CCC,DDD as the name of persons in the name feild of the table.

i have used the below code to link these values into my dropdown..

loop at lt_zjjweb_tab into ls_zjjweb_tab .

ls_valueset-value = ls_zjjweb_tab-name

ls_valueset-text = ls_zjjweb_tab-name

append ls_valueset to lt_valueset.

endloop.

now can u please tell me how to add my new option 'create new' into the dropdown so that my dropdown shld have AAA, BB,CCC,DDD, create new..

thanks in advance..

jithin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Oct 24, 2008 at 07:37 AM

    Hi,

    Populate the workarea and then append to the Internal table.

    ls_valueset-value = 'Create New'.

    ls_valueset-text = 'Create New'.

    append ls_valueset into it_valueset index 1.

    Now the "create new" will be the first option of your drop down list.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      I have mapped the dropdown key to the name feild of the table.so when i am selecting the 'create new' in the dropdown list i am getting an error as cardinality violated.

      the basic reqirement is when i click on the 'create new', it should allow me to enter new names.

      can u also tell me how to set an action under this 'create new' element which is included in the dropdown list..

  • Oct 24, 2008 at 08:27 AM

    Hi Jithin,

    Its simple. You will just have to append the new value to the table of values which you are using to bind to your dropdown. Try go through the code snippet below:

    DATA: lv_node TYPE REF TO if_wd_context_node,
                 lt_texts TYPE if_main=>elements_dropdown,
                 wa_texts TYPE if_main=>element_dropdown.
     
    
      lv_node = wd_context->get_child_node( name = 'DROPDOWN' ).
    
      select matnr from mara into table lt_texts.
    
    " So by default you have all the material numbers displayed in the dropdown
    
     wa_texts-application = 'Create New'.
     APPEND wa_texts TO lt_texts.
     insert wa_texts into lt_texts index 1. "  To have your custom entry as the first value in the dropdown write as
    
    append wa_texts TO lt_texts. " If you write like this your custom entry would get displayed as the last value in the dropdown
    
    lv_node->bind_table( new_items = lt_texts ). " Bind the new set of values to be displayed by the dropdown to the corresponding context node

    Regards,

    Uday

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 24, 2008 at 08:47 AM

    hi uday...

    i am getting an error:

    type if_main=>elements_dropdown is unknown..

    can u plz tel me what is this if_main.. (i am new to web dynpro)

    i have mentioned my reqiurement above..

    can anyone suggest a solution for this

    thanks in advance,

    jithin

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jithin,

      For each controller (<ctrl>), an interface is generated having the name IF_<ctrl>. I had written this coding in the view controller so had written the code as if_main.

      For each node <node> of a controller context, a structure type element_<node> is implicitly generated in the interface IF_<ctrl>. So if you want to define a structure in your webdynpro component with the same structure as an context node by name NODE1 then you can write as below:

      data : wa_node1 type if_main=>element_node1. " If the context is created at view level
      
      data : wa_node1 type ig_componentcontroller=>element_node1. " If the context is created at component controller level

      In addition, for each node <node> of a controller context, a standard table type elements_<node> is implicitly generated in the interface IF_<ctrl>. The line type of this table is element_<node>. So if you want to define an internal table in your webdynpro component with the same structure as an context node by name NODE1 then you can write as below:

      data : wa_node1 type if_main=>elements_node1. " If the context is created at view level
      
      data : wa_node1 type ig_componentcontroller=>elements_node1. " If the context is created at component controller level

      So as you can understand you were getting the error coz you would have created a context node with a name other than DROPDOWN. So suppose your context node is MYNODE then you can declare like:

      data : wa_node1 type if_main=>element_mynode. " If the context is created at view level
      
      data : wa_node1 type ig_componentcontroller=>element_mynode. " If the context is created at component controller level
      
      data : wa_node1 type if_main=>elements_mynode. " If the context is created at view level
      
      data : wa_node1 type ig_componentcontroller=>elements_mynode. " If the context is created at component controller level

      Regards,

      Uday

  • Oct 24, 2008 at 09:22 AM

    DATA: NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO.

    NODE_INFO = WD_CONTEXT->GET_NODE_INFO( ).

    NODE_INFO = NODE_INFO->GET_CHILD_NODE( `DROP` ).

    DATA: itab TYPE TABLE OF Ztestk.

    DATA: VALUE TYPE WDY_KEY_VALUE,

    VALUE_SET TYPE WDY_KEY_VALUE_TABLE.

    FIELD-SYMBOLS: <EXT1_F> TYPE Ztable.

    TYPES : BEGIN OF T_create,

    create(50),

    END OF T_create.

    DATA : IT_create TYPE STANDARD TABLE OF T_create.

    DATA : WA_create LIKE LINE OF IT_create.

    FIELD-SYMBOLS: <EXT3_F> TYPE T_create.

    CALL METHOD CL_WD_DYNAMIC_TOOL=>GET_TABLE_DATA

    EXPORTING

    TAB_NAME = 'ZTable'

    ROW_COUNT = 0

    IMPORTING

    DATA = itab.

    LOOP AT itab ASSIGNING <EXT1_F> .

    VALUE-KEY = <EXT1_F>-ID.

    VALUE-VALUE = <EXT1_F>-ID.

    INSERT VALUE INTO TABLE VALUE_SET.

    ENDLOOP.

    WA_create = 'GOVT.SERVICE'.

    APPEND WA_create TO IT_create.

    loop at it_create ASSIGNING <EXT3_F>.

    VALUE-KEY = <EXT3_F>-create.

    VALUE-VALUE = <EXT3_F>-create.

    INSERT VALUE INTO TABLE VALUE_SET.

    endloop.

    NODE_INFO->SET_ATTRIBUTE_VALUE_SET( NAME = `DROP` VALUE_SET = VALUE_SET ).

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 24, 2008 at 09:40 AM

    hi Uday,

    can u please help me out with my requirements...

    to create a new name when i click 'create new'in the dropdown..

    thx in advance,

    jithin

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jithin,

      I would need a better explanation of what you are actually intending to do. This is what I had understood from your description. You have extracted the NAME values from the database table and are displaying them in a dropdown field. Now you say that when you click on the "Create New" value from the dropdown you should be able to enter a new value in the table. So you first select a table row & then when you select "Create New" you want the table to have an input field where you can enter a value for the name. Is this right?

      Regards,

      Uday

  • avatar image
    Former Member
    Oct 24, 2008 at 11:38 AM

    can i give input values through a dropdown.

    say for eg: can i enter a new value through the dropdown and save it in a table.

    Add comment
    10|10000 characters needed characters exceeded