Skip to Content
avatar image
Former Member

control / sort / default values in a drop down box by index

Hey guys,

I have a drop down box by index which i populated using a select statement.

my requirement is that i want to be able set the first value to be any value i want to,

but every time i try to insert my own value after the select statement i always get that value

AT THE END OF THE drop down list.

please let me know if you have any thoughts or you know how to solve that problem ???

or

how can I control the data within my table itab any way i want to ( moving values up and down)??

Here is an example of what i am talking about

data : it_table type STANDARD TABLE OF sflight.

DATA lo_nd_cn_drpindex TYPE REF TO if_wd_context_node.

DATA lo_el_cn_drpindex TYPE REF TO if_wd_context_element.

DATA ls_cn_drpindex TYPE wd_this->element_cn_drpindex.

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

lo_nd_cn_drpindex = wd_context->get_child_node( name = wd_this->wdctx_cn_drpindex ).

select carrid from sflight into CORRESPONDING FIELDS OF TABLE it_table.

ls_test-carrid = 'default'.

append ls_test to it_table.

lo_nd_cn_drpindex->bind_table( it_table ).

Regards,

Abdul.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jun 25, 2009 at 10:15 AM

    Hello Abdul,

    I suggest to use your context node and add a context element at first place utilizing method IF_WD_CONTEXT_NODE->BIND_ELEMENT or in your case (working with structured type) IF_WD_CONTEXT_NODE->BIND_STRUCTURE (performance reason according to SAP Library documentation cited below). You can transmit the index of the new entry as a parameter of the mentioned methods.

    Interface F_WD_CONTEXT_NODE :

    Link: [http://help.sap.com/saphelp_nw2004s/helpdata/en/fd/be5b4150b38147e10000000a1550b0/content.htm]

    Hope that helps,

    Peter

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2009 at 11:57 AM

    hi,

    Set the attribute binded to Dropdown by key with the value you want to apppear at first.

    It will be the first value coming in the Dropdown.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2009 at 12:12 PM

    Hi,

    I am just trying to understand your requirement clearly. Is it that you want to control the complete order of the value set for dropdown or just looking to change the selected value by default.

    If you are looking to change the default selected value then you can do as below.

    Since you are using DROPDOWNBYINDEX, you can achive this by setting the lead selection of the context node. The lead selected one, will be shown as default in the dropdown.

    I am using your example code.

    lo_nd_cn_drpindex->SET_LEAD_SELECTION_INDEX( index = n )
    "where n is the index of the row that you want to appear default in dropdown. This could be lastly added 
    " one, middle one or any thing from the value list

    If you are adding new value to valuelist of dropdown, add it and then set the lead selection to this index sothat this willl be the first displayed one

    Regards,

    Manne.

    Edited by: Raja Sekhar Manne on Jun 25, 2009 2:26 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 25, 2009 at 08:34 PM

    Hi,

    Thanks for the reply guys, what I did is that I looped around my tmp table work area,

    inserted the values and sorted into my attributes.

    Regards,

    Abdul

    Add comment
    10|10000 characters needed characters exceeded