Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
Thank you,
The SAP Community team.
The SAP Community wiki will be closed to new content submissions from December 7 6:00 p.m. CET to December 11 6:00 p.m. CET.
All content created during this period will not be available/restorable after December 11.
We apologize for the inconvenience, but we need to take this action to improve and maintain the SAP Community wiki performance.
Please plan your tasks accordingly.
Skip to end of metadata
Go to start of metadata


I was facing issues in creating a table with Cell Variant at runtime, after some trial and errors I was able to add cell variants in the table dynamically. The table contains a column, cell of this column can have a dropdown or a TextView depending on the variant key passed in code. Hope this code will help you also.

Step 1: Create a table by using “NEW_TABLE” method of class CL_WD_TABLE. This table has 5 rows and is bound to context node “CN_TABLE”.

Step 2: You can give the table header using SET_HEADER method of class CL_WD_TABLE.

Step 3: Add the table into the root UI element container.

Step 4: Once the table is added into the container, it is time to add the column into this table. Below is the code for creating new table column:

Step 5: You can set the header of the column using SET_HEADER method of class CL_WD_TABLE_COLUMN.

Step 6: Now we will have to create two standard cell, first standard cell will contain a TextView, while the other standard cell will contain a dropdown. Variant key for first cell will be ‘NAPPL’ and for other cell variant key will be ‘SELECT’.

Step 7: Once both standard cells are created, these needs to be assigned to the table column. Method “ADD_CELL_VARIANT” is used for the same.

Step 8: Once cell variants are added to the column, it’s time to create cell editors and bind them to standard table cells.

Step 9: Bind the Cell Variant property of the column to context node, so that it can select the variant according to the data passed.