Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

dynamic drop down list

Hi all,

I have a alv table with 2 fields. the 1st column is non editable and the 2nd column is a drop down. The value for the 1st column is already being displayed at the time of execution itself. I want a drop down in the 2 nd column which should hold values matching its corresponding row. I used a ONCLICK event and wrote the below code. But my drop down is still empty. When i debugged i found my ONCLICK event is not called.Can any one guide me what correct event i should use or if any changes i need to do in my code to solve this issue please.

DATA: LR_NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO,

LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_ND_ASSESSTMENT TYPE REF TO IF_WD_CONTEXT_NODE.

DATA: LT1_VALUESET TYPE TABLE OF WDR_CONTEXT_ATTR_VALUE,

LS1_VALUESET TYPE WDR_CONTEXT_ATTR_VALUE.

data : lt_weight type STANDARD TABLE OF zest_weight,

ls_weight like LINE OF lt_weight.

Data: context_node type ref to if_wd_context_node.

data: ld_element type ref to if_wd_context_element.

context_node = wd_context->get_child_node( name = 'ASSESSTMENT').

ld_element = context_node->get_lead_selection( ).

if not ld_element is INITIAL.

ld_element->get_static_attributes( IMPORTING

static_attributes = ls_weight ).

endif.

select * from zest_weight into table lt_weight where levels = ls_weight-activity.

LOOP AT LT_WEIGHT INTO LS_WEIGHT.

LS1_VALUESET-VALUE = LS_WEIGHT-ACTIVITY.

LS1_VALUESET-TEXT = LS_WEIGHT-ACTIVITY.

APPEND LS1_VALUESET TO LT1_VALUESET.

ENDLOOP.

LR_NODE = WD_CONTEXT->GET_CHILD_NODE( 'ASSESSTMENT' ).

LR_NODE_INFO = LR_NODE->GET_NODE_INFO( ).

LR_NODE_INFO->SET_ATTRIBUTE_VALUE_SET(

EXPORTING

NAME = 'ASSESSMENT'

VALUE_SET = LT1_VALUESET ).

Thanks in advance,

vadivu.

Former Member
replied

Hi

For creating a dropdown having different entries for each row.

you need to create one extra attribute in you node with type "WDR_CONTEXT_ATTR_VALUE_LIST"

and then in the init method itself where you are filling the node for the first column.

there it self fill this attribute with the valueset having values specific to that particular element/row.

here is a sample code for the same.

which is having this functionality



    DATA lo_nd_dealer TYPE REF TO if_wd_context_node.
    DATA lo_el_dealer TYPE REF TO if_wd_context_element.
    DATA ls_dealer TYPE wd_this->element_Zdealer.
    DATA lv_name LIKE ls_dealer-name.
*   navigate from <CONTEXT> to <DEALER> via lead selection
    lo_nd_dealer = wd_context->get_child_node( name = wd_this->wdctx_Zdealer ).



DATA LS_DT TYPE WD_THIS->ELEMENT_ZDEALER.
DATA LT_DT TYPE WD_THIS->ELEMENTS_ZDEALER.
data ls_value_set TYPE wdr_context_attr_value.
data lt_value_set type  wdr_context_attr_value_list.

" here you fill the table with required values
SELECT * FROM ZDEALER INTO CORRESPONDING FIELDS OF TABLE LT_DT.


DATA INDX TYPE I.

"now loop on the filled values and check the condition and fill the valueset for each row.

LOOP AT LT_DT INTO LS_DT.
INDX = SY-TABIX.
CLEAR LS_DT-LOCATION.
LV_NAME = LS_DT-NAME.
if( "have your condition here  ).
CONDENSE lv_name.
ls_value_set-value = lv_name.
ls_value_set-text = lv_name.
append ls_value_set to LS_DT-VALUESET.
concatenate lv_name '- ' ' 1 ' into lv_name.
CONDENSE lv_name.
ls_value_set-value = lv_name.
ls_value_set-text = lv_name.
append ls_value_set to LS_DT-VALUESET.

"" like this fill the enteries

endif.

MODIFY LT_DT FROM LS_DT INDEX INDX TRANSPORTING LOCATION VALUESET.
" pass the valueset to table


endLOOP.

"bind the table to the node
lo_nd_dealer->BIND_TABLE( LT_DT ).

 data lo_cmp_usage type ref to if_wd_component_usage.
"then the logic for making the field cell editor

lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
  lo_cmp_usage->create_component( ).
endif.


DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
lo_INTERFACECONTROLLER =   wd_this->wd_cpifc_alv( ).
*lo_interfacecontroller->SET_DATA( lo_nd_dealer ).
  DATA lo_value TYPE ref to cl_salv_wd_config_table.
  lo_value = lo_interfacecontroller->get_model(
  ).

  data col type ref to CL_SALV_WD_COLUMN.
  col = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'LOCATION' ).
  DATA DDB TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_IDX.
  CREATE OBJECT DDB
  EXPORTING SELECTED_KEY_FIELDNAME = 'LOCATION'.
DDB->SET_VALUESET_FIELDNAME( 'VALUESET' ).
DDB->SET_TYPE( IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>TYPE_KEY_CONVERT_TO_VALUE ) .
  DATA CELEDI TYPE REF TO IF_SALV_WD_TABLE_CELL_EDITOR.
  CELEDI ?= DDB.
*
  COL->SET_CELL_EDITOR( CELEDI ).
  LO_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( ABAP_FALSE ).


thanks

sarbjeet singh

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question