cancel
Showing results for 
Search instead for 
Did you mean: 

Drop Down list

Former Member
0 Kudos

Hi Expert ,

In my initial screen i want a dropdown list for the Customer.I ve already created the context and bind it to the dropdown field .But there is no value is coming in the drop down list .

Please help me out its urgent .

Regards,

Satya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

iF there is a node INIT with attribute 'ACC_TYPE_DESCR' for which u want dropdown then

write the following code in wddoinit().

..................................Data Declaration......................

DATA: lo_nd_init TYPE REF TO if_wd_context_node,

lo_nd_init_info TYPE REF TO if_wd_context_node_info,

lt_dbtag_set TYPE wdy_key_value_table,

dbtag_key_item TYPE wdy_key_value,

lo_el_context TYPE REF TO if_wd_context_element. "#EC NEEDED

lo_nd_init = wd_context->get_child_node( name = wd_this->wdctx_init ).

*To insert values of dropdown list into internal table

dbtag_key_item-key = 'STD'.

dbtag_key_item-value = 'STANDARD'.

INSERT dbtag_key_item INTO TABLE lt_dbtag_set.

dbtag_key_item-key = 'CMPD'.

dbtag_key_item-value = ''COMPOUND'.

INSERT dbtag_key_item INTO TABLE lt_dbtag_set.

*To get node info and set the drop down list values

lo_nd_init_info = lo_nd_init->get_node_info( ).

lo_nd_init_info->set_attribute_value_set( name = 'ACC_TYPE_DESCR' value_set = lt_dbtag_set ).

If u want to have a deafult value then for the attribute 'ACC_TYPE_DESCR' at context level give the default value as 'STANDARD'.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Satya,

Use the following code to map your internal table entries (in the cdoe snippet below the itab is i_carrid) to the context attribute bound to the dropdown UI element.

NOTE: Context bound to the dropdown element (DROPDOWN in this example) is an attribute of type string.

METHOD WDDOINIT.

DATA i_carrid TYPE TABLE OF sflight.

DATA wa_carrid TYPE sflight.

DATA wd_node_info TYPE REF TO if_wd_context_node_info.

DATA value_set TYPE wdr_context_attr_value_list.

DATA wa_value_set TYPE wdr_context_attr_value.

SELECT * FROM sflight INTO TABLE i_carrid.

LOOP AT i_carrid INTO wa_carrid.

MOVE sy-index TO wa_value_set-value.

MOVE wa_carrid-carrid TO wa_value_set-text.

APPEND wa_value_set TO value_set.

CLEAR wa_value_set.

ENDLOOP.

wd_node_info = wd_context->get_node_info( ).

wd_node_info->set_attribute_value_set( name = 'DROPDOWN' value_set = value_set ).

The attribute value set must have values.

Regards,

Chitrali

Former Member
0 Kudos

Hi Satya

In which method you are passing customer values to the context.

Regards

Naresh

Former Member
0 Kudos

Hi Naresh,

In the Doinit method i have this code

method WDDOINIT .

***Sold_to Help value

DATA lo_nd_sold_to_f4 TYPE REF TO if_wd_context_node.

DATA lo_el_sold_to_f4 TYPE REF TO if_wd_context_element.

DATA ls_sold_to_f4 TYPE wd_this->element_sold_to_f4.

DATA lv_sold_to LIKE ls_sold_to_f4-sold_to.

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

lo_nd_sold_to_f4 = wd_context->get_child_node( name = wd_this->wdctx_sold_to_f4 ).

  • @TODO handle not set lead selection

IF lo_nd_sold_to_f4 IS INITIAL.

ENDIF.

  • get element via lead selection

lo_el_sold_to_f4 = lo_nd_sold_to_f4->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_sold_to_f4 IS INITIAL.

ENDIF.

  • alternative access via index

  • lo_el_sold_to_f4 = lo_nd_sold_to_f4->get_element( index = 1 ).

  • @TODO handle non existant child

  • IF lo_el_sold_to_f4 IS INITIAL.

  • ENDIF.

    • get single attribute

  • lo_el_sold_to_f4->get_attribute(

  • EXPORTING

  • name = `SOLD_TO`

  • IMPORTING

  • value = lv_sold_to ).

DATA :it_partner TYPE TABLE OF ZPARTNER,

wa_partner like line of it_partner.

DATA error(1) TYPE C.

DATA return TYPE BAPIRET2.

DATA lo_nd_inv_search TYPE REF TO if_wd_context_node.

DATA lo_el_inv_search TYPE REF TO if_wd_context_element.

DATA ls_inv_search TYPE wd_this->element_inv_search.

  • DATA lv_sold_to LIKE ls_inv_search-sold_to.

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

lo_nd_inv_search = wd_context->get_child_node( name = wd_this->wdctx_inv_search ).

  • get element via lead selection

lo_el_inv_search = lo_nd_inv_search->get_element( ).

  • get single attribute

lo_el_inv_search->get_attribute(

EXPORTING

name = `SOLD_TO`

IMPORTING

value = lv_sold_to ).

CALL FUNCTION 'ZAMD_GET_SOLDTO_HELP'

EXPORTING

USERNAME = 'DST_BCOWAN'"sy-uname

IMPORTING

ERROR = error

RETURN = return

TABLES

IT_PARTNER = it_partner.

data tab type wd_this->elements_sold_to_F4.

data entry like line of tab.

data value_list type wdr_context_attr_value_list.

data value_entry type wdr_context_attr_value.

loop at it_partner into wa_partner.

entry-sold_to = wa_partner-customer.

insert entry into table tab.

endloop.

lo_nd_sold_to_f4->bind_table( tab ).

endmethod.

Please have a look into it .

Satya

Former Member
0 Kudos

I did dropdown box like this. just check the following code if its useful for you anyway.

data:

nodeinfo type ref to if_wd_context_node_info,

nodecon type ref to if_wd_context_node.

data : it_tcurc type table of tcurt,

wa_desc type string,

wa_tcurc like line of it_tcurc.

select * from tcurt into table it_tcurc where spras = 'E'.

if sy-subrc = 0.

loop at it_tcurc into wa_tcurc.

concatenate wa_tcurc-waers wa_tcurc-ltext into wa_desc separated by '-'.

wa_valueset-value = wa_tcurc-waers.

wa_valueset-text = wa_desc.

append wa_valueset to it_valueset.

clear wa_desc.

endloop.

nodecon = wd_context->get_child_node( name = if_v_venform=>wdctx_vend_det ).

nodeinfo = nodecon->get_node_info( ).

nodeinfo->set_attribute_value_set(

name = 'WAERS'

value_set = it_valueset ).

endif.

former_member189058
Active Contributor
0 Kudos

Hi Satya,

Try out the eample application WDR_TEST_UI_ELEMENTS in the component WDR_TEST_EVENTS.

You will find Views for DropDownByKey and DropDownByIndex.

Regards,

Reema.