cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down by index in webdynpro

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

xxxxxxxx->set_lead_selection_index( index = ).

Former Member
0 Kudos

and if i don't know which index holds the value i want, i just know the value that i wish to display??

regards,

Priyank

Former Member
0 Kudos

Hi.

Then loop the elements of the node and compare the values.

If the value match set lead selection the current loop index.

You can get all elements with node->get_elements. This method returns a set of context elements.

Cheers,

Sascha

Former Member
0 Kudos

hi Sascha,

I am having slight trouble doing this. Can you give me a sample code please.

regards,

Priyank

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Priyank,

data: node type ref to if_wd_context_node.

loop at <internal table> into <workarea>

if workarea-currencyfield = 'USD'.

node = wd_context->get_child_node( 'Your context node' ).

node->set_lead_selection_index( sy-index ).

endif.

endloop.

Regards

Abhimanyu L

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi.

Another version:

data:
 lt_element_set          TYPE wdr_context_element_set,
lr_elem  TYPE REF TO if_wd_context_element,
ls_elem_struc     type kna1.

lt_element_set = <your_context_node>->get_elemente( ).

LOOP AT lt_element_set INTO lr_elem.
    lr_elem->get_static_attributes(
      IMPORTING
        static_attributes = ls_elem_struc
    ).
    if ls_elem_struc-kunnr eq '100000'.
        context_node->set_lead_selection( lr_elem ).
    endif.
endloop.

Cheers,

Sascha