cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate a dynamically created dropdown box (index)

Former Member
0 Kudos

I have created a dropdown box dynamically(index). Now i want to know how to populate it.

I have created a dropdown dynamically of type SFLIGHT.CARRID.

Now when i press the dropdown button i want to display the carrids available for the user to select from.

That is when i create an input button dynamically of type SFLIGHT.CARRID it automatically gives the F4 help.

What should be done in dropdown button to get all the possible values for CARRID in dropdown.

Please explain how to proceed.

Edited by: Mohamed Aslam on Feb 16, 2010 7:08 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi ,

u proceed like this :

1 get instance of new node


  DATA: dyn_node TYPE REF TO if_wd_context_node.
   dyn_node = wd_context->get_child_node( name = lv_node ).
// where lv_node is my dynamic node

2 internal table declarations


  DATA : itab TYPE STANDARD TABLE OF ztable ,
           wa TYPE TABLE OF ztable.

3 APPENDING INITIAL LINE TO INTERNAL TABLE


   APPEND INITIAL LINE TO itab .

4 populating internal table and binding it with the context node generated dynamically


  SELECT * FROM ztable
    APPENDING TABLE itab.
  dyn_node->bind_table( itab) .

I hope it will help u ..

regards,

amit

Former Member
0 Kudos

Hi Amit,

I have used the following code in ModifyView to create the DD.

CALL METHOD CL_WD_DROPDOWN_BY_IDX=>NEW_DROPDOWN_BY_IDX

EXPORTING

BIND_TEXTS = 'SFLIGHT.CARRID'

ID = 'DROP1'

RECEIVING

CONTROL = LR_DROPDOWN.

LR_MATRIX = CL_WD_MATRIX_HEAD_DATA=>NEW_MATRIX_HEAD_DATA( LR_DROPDOWN ).

LR_DROPDOWN->SET_LAYOUT_DATA( LR_MATRIX ).

CALL METHOD LR_CONTAINER->ADD_CHILD

EXPORTING

INDEX = 2

THE_CHILD = LR_DROPDOWN.

Now when i click on the dropdown icon, i want all the CARRID (which comes in F4 help ) to be displayed.

Will your approach help to achieve this?

If so should i write this code in Modify itself. Should it be written in some action method?

Pleas explain.

Thanks in advance.

Former Member
0 Kudos

Hi All,

I tried the above solution and my drop down get populated.

But in this case we are fetching all the CARRID for all the records and displaying them.

For example Dropdown shows

AA

AA

AA

AA

AA

AA

AZ

AZ

AZ

JL

JL

LH

LH

But actually i want to be as in F4 help as we get when i bind the SFILGHT.CARRID to an input field.

For example

AA

AZ

JL

LH

How to bring F4 help here.

Please explain. Thanks in advance.

Former Member
0 Kudos

hi ,

u can use the delete SQL statement , before u bind the internal table to the context node


*  populating internal tables
  SELECT * FROM ztable APPENDING TABLE itab.
  
*sort internal tables
   SORT itab BY role_desc .

*  delete duplicate entries
  DELETE ADJACENT DUPLICATES FROM itab COMPARING role_desc.
  

regards,

amit

Former Member
0 Kudos

Hi Amit,

Thanks for the quick response. Yes this is possible.

But i just want to know how to use F4 help. The F4 help for SFLIGHT.CARRID is S_CARRIER_ID. Is there a way to bind this with the field so that the query will not be needed.