Skip to Content

Step1:Creation of WDA component

Transaction used SE80

Capture.PNG

Step 2: Create a view and an ALV in the viewcontainer UI element by using View UI element.

Now decide the column in which you want to display the drop down as per the requirement given to

you.

In the example here I have taken the column name as ‘TYPES’

Now add an attribute say VALUESET in the node of the ALV

Capture.PNG

The Type of Value set must be WDR_CONTEXT_ATTR_VALUE_LIST

Capture.PNG

Step3: Paste the below code in the DO Init hook method of  the view

Method DOINIT

DATA: LT_VALUESET TYPE TABLE OF WDR_CONTEXT_ATTR_VALUE,

LS_VALUESET TYPE WDR_CONTEXT_ATTR_VALUE.

DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_DATA_CHECK

( IF_SALV_WD_C_TABLE_SETTINGS=>DATA_CHECK_ON_CELL_EVENT ).

DATA: LR_COL TYPE REF TO CL_SALV_WD_COLUMN,

LR_DROPDOWN TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.

LO_VALUE = LO_INTERFACECONTROLLER->GET_MODEL( ).

LO_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( ABAP_FALSE ).

LR_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ID = ‘TYPES’ ).

CREATE OBJECT LR_DROPDOWN EXPORTING SELECTED_KEY_FIELDNAME = ‘TYPES’.

LR_COLUMN->SET_CELL_EDITOR( LR_DROPDOWN ).

DATA: LT_VALUESET TYPE TABLE OF WDR_CONTEXT_ATTR_VALUE,

LS_VALUESET TYPE WDR_CONTEXT_ATTR_VALUE,

LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE,

LR_NODEINFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO.

LR_NODE = WD_CONTEXT->GET_CHILD_NODE( ‘CTX_VN_ALV_TABLE’ ).

LR_NODEINFO = LR_NODE->GET_NODE_INFO( ).

* navigate from <CONTEXT> to <CTX_VN_ALV_TABLE> via lead selection

LO_ND_CTX_VN_ALV_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS-

>WDCTX_CTX_VN_ALV_TABLE ).

* get element via lead selection

LO_EL_CTX_VN_ALV_TABLE = LO_ND_CTX_VN_ALV_TABLE->GET_ELEMENT( ).

* @TODO handle not set lead selection

IF LO_EL_CTX_VN_ALV_TABLE IS INITIAL.

ENDIF.

CALL METHOD LO_ND_CTX_VN_ALV_TABLE->GET_STATIC_ATTRIBUTES_TABLE

IMPORTING

TABLE = LT_ALV.

*append ls_valueset to lt_valueset.

LS_VALUESET-VALUE = ‘FIRST’.

LS_VALUESET-TEXT = ‘FIRST’.

APPEND LS_VALUESET TO LT_VALUESET.

LS_VALUESET-VALUE = ‘SECOND’.

LS_VALUESET-TEXT = ‘SECOND’.

APPEND LS_VALUESET TO LT_VALUESET.

LR_NODEINFO->SET_ATTRIBUTE_VALUE_SET(

EXPORTING

NAME = ‘TYPES’

VALUE_SET = LT_VALUESET

ENDMETHOD.

Step 4: Execute the application now to get the below displayed alv with dropdown.

Capture.PNG

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply