How t o appl y Cel l var i ant f or

c ol umns of ALV i n Web Dynpr o f or
ABAP
Applies to:
SAP NetWeaver 2004S.Web Dynpro for ABAP
Summary
Cell variant is used to change the cell properties dynamically.
In the Table UI element we have a provision that we can add the cell variant directly to the column, where
as in ALV it is not possible. So we will create cell variant and will assign this to the column.
Author: Suman Kumar Chinnam
Company: YASH Technologies
Created on: 17 September 2008
Author Bio
Suman Kumar is a Consultant for YASH Technologies, Pvt., and Ltd. Based in India. He has 2 years of IT
experience. He has good knowledge of ABAP, BSP and Web Dynpro for ABAP.
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 1
How to apply Cell variant for columns of ALV in Web Dynpro for ABAP
Table of Contents
How to add cell variant to the column in ALV.....................................................................................................3
Result..................................................................................................................................................................6
Related Content..................................................................................................................................................6
Disclaimer and Liability Notice............................................................................................................................7
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 2
How to apply Cell variant for columns of ALV in Web Dynpro for ABAP
How to add cell variant to the column in ALV
In this Application I am trying to show the Flights details using ALV.I Will make some cells are Checkbox and
some are Text Views of one of the column using Cell variant. To do this we have to add one attribute like
CELL_VARIANT of type STRING to the Context node.

Now populate the data to the internal table.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 3
How to apply Cell variant for columns of ALV in Web Dynpro for ABAP
Populate the Cell_Variant attribute of context node FLIGHTS to make some cells Text Views and some are
Checkboxes.
Here I am assigning TextViews in alternative cells.

Bind the table to the Context node.

Initialize the ALV and call the method GET_MODEL to get the reference of table.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 4
How to apply Cell variant for columns of ALV in Web Dynpro for ABAP
To make alternative cells with Checkboxes and Text Views. We have to follow the following steps.
Get Column to which one you want to add Cell Variant and make alternative cells Checkboxes and Text
views.
Get the column Flight Number and add Checkbox to the column. Now the entire column contains the
checkboxes.

Now create a Textview and assign this to Cell variant and set the key value ‘TEXT_VIEW’. We then tell the
column where it can get its cell variant value from.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 5
How to apply Cell variant for columns of ALV in Web Dynpro for ABAP
Result
In the below output see the column Flight no column cells is alternatively checkboxes and Textviews.

Related Content
For more information, visit the User Interface Technology homepage.
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 6
How to apply Cell variant for columns of ALV in Web Dynpro for ABAP
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
©2008 SAP AG 7
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.