Creation of Drop Down in ALV in Web Dynpro ABAP

8
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2010 SAP AG 1 Creation of Drop Down in ALV in Web Dynpro ABAP Applies to: Web Dynpro ABAP. For more information, visit the Web Dynpro ABAP homepage . Summary The Paper here tells how to get a drop down in ALV in web Dynpro ABAP. By following the steps given here one will be able to understand getting drop down in Web Dynpro ALV and also how to populate the values in the drop down displayed. It is assumed that the reader knows how to display an editable ALV before hand. Author: Shitanshu Sahai Company: L&T Infotech Created on: 28 December 2010 Author Bio Shitanshu Sahai is a development consultant at L&T Infotech. He has worked on projects and gained practical experience in Web Dynpro ABAP development, in the creation of concepts code reviews. Shitanshu is very interested in new technologies. Currently he is dealing with Web Dynpro ABAP.

description

Creation of Drop Down in ALV in Web Dynpro ABAP

Transcript of Creation of Drop Down in ALV in Web Dynpro ABAP

Page 1: Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 1

Creation of Drop Down in ALV in

Web Dynpro ABAP

Applies to:

Web Dynpro ABAP. For more information, visit the Web Dynpro ABAP homepage.

Summary

The Paper here tells how to get a drop down in ALV in web Dynpro ABAP. By following the steps given here one will be able to understand getting drop down in Web Dynpro ALV and also how to populate the values in the drop down displayed. It is assumed that the reader knows how to display an editable ALV before hand.

Author: Shitanshu Sahai

Company: L&T Infotech

Created on: 28 December 2010

Author Bio

Shitanshu Sahai is a development consultant at L&T Infotech. He has worked on projects and gained practical experience in Web Dynpro ABAP development, in the creation of concepts code reviews. Shitanshu is very interested in new technologies. Currently he is dealing with Web Dynpro ABAP.

Page 2: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 2

Table of Contents

Creation of web Dynpro component ................................................................................................................... 3

Creation of Attribute Valueset for Dropdown In ALV .......................................................................................... 4

Method DOINIT ................................................................................................................................................... 5

Result……….. ..................................................................................................................................................... 6

Related Content .................................................................................................................................................. 7

Disclaimer and Liability Notice ............................................................................................................................ 8

Page 3: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 3

Creation of web Dynpro component

Transaction used : SE80

Create a view for ALV and check whether alv is getting displayed or not. If the alv is not displayed kindly check and correct it to get the alv displayed.

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

Page 4: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 4

Creation of Attribute Valueset for Dropdown In ALV

The Type of Value set must be WDR_CONTEXT_ATTR_VALUE_LIST

Page 5: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 5

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

Page 6: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 6

Result

If the steps are correctly followed you will see the following result when you execute the code.

Page 7: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 7

Related Content

SAP Community Network Forums » Application Server » Web Dynpro ABAP

SAP List Viewer in Web Dynpro - Editing ALV

Using Dynamic ALV with Web Dynpro ABAP with Editable Fields

For more information, visit the Web Dynpro ABAP homepage

Page 8: Creation of Drop Down in ALV in Web Dynpro ABAP

Creation of Drop Down in ALV in Web Dynpro ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 8

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.