cancel
Showing results for 
Search instead for 
Did you mean: 

Table Cell Variant

kanthimathikris
Employee
Employee
0 Kudos

Dear Friends,

I have a table with 3 columns, one of them is a textview while other two are input fields. On the click of a button, it should create an element (record) with the first column's cell as an Input Field (which was a textview at design). How can I achieve this?

Thanks,

Kanthimathi

Accepted Solutions (1)

Accepted Solutions (1)

kanthimathikris
Employee
Employee
0 Kudos

I have done that too; I have created a variant with variant key INP and below is my piece of code

IF lo_nd_goals IS NOT INITIAL.

LS_GOALS-CELL_VARIANT = 'INP'.

CALL METHOD lo_nd_goals->BIND_STRUCTURE

EXPORTING

NEW_ITEM = ls_goals

SET_INITIAL_ELEMENTS = ABAP_FALSE

  • INDEX =

  • RECEIVING

  • ELEMENT =

.

ENDIF.

I am getting the dump "No access possible via the 'NULL' data reference"

Former Member
0 Kudos

Hi,

Can you debug and check that which statement is the exact cause of this dump?

-Neha

Answers (8)

Answers (8)

kanthimathikris
Employee
Employee
0 Kudos

The reason for the dump is - I have not bound the value property of the input field of my cell variant. Neha, Thank you so much for resolving the issue.

Former Member
0 Kudos

Welcome

kanthimathikris
Employee
Employee
0 Kudos

The assignment statement which assigns the variant key to the attribute - it seems it expects an object to be created prior to it

kanthimathikris
Employee
Employee
0 Kudos

The info for the dump is as follows

1 method <b>get_attribute_external</b>.

2

3 data data_container type ref to cl_wdr_data_container.

4 data attribute type wdr_attribute_pointer.

5 data client_component type ref to cl_wdr_client_component.

6

<b>>>>> attribute-attribute_name = i_binding->attribute_name.</b>

8 attribute-element ?= get_bound_element( i_binding ).

9

10 client_component ?= attribute-element->node->controller->component->data_container_superio

11 data_container = client_component->data_container.

12

13 e_value = data_container->get_and_format( attribute = attribute ).

14

15 endmethod.

Former Member
0 Kudos

Hi,

You need to define a VariantKey for each of the cell variants. This is what will be assigned to your selectedCellVariant property. For e.g. I have two variants in a column with IDs VAR1 and VAR2 respectively. In my context node i have an attribute (string) CELLVAR. Now, I bind the table's appropriate property to this one.

In the concerned event handler, I have to code so that depending on a condition, my CELLVAR is set to 'VAR1' or 'VAR2'. This can be achieved simply by the set_attribute method.

Regards,

Neha

kanthimathikris
Employee
Employee
0 Kudos

Hi Neha,

I have done the following and getting a dump after the click of the button (The method gets processed successfully)

I created a table in dictionary with four columns one of which is the Cell Variant.

Created a node in the view pointing to the above structure

Created a table in the view; bound it to the above context node

In the first column of the table I created a cell variant (table standard cell) and added an Editor (Input View) - This variant doesn't have a variant key.

Then I bounded the standardcellvariant property of the first column to the attribute for cell variant.

Then in the click of the button

I got the node instance, populated the structure with the value of the cell variant,

then bind the structure to the node.

During the runtime, after the method (for the click) has been processed I am getting a dump- No access possible via the 'NULL' data reference

P.S : I have set the cell variant column's visible property has none. I have not assigned any value for the variant key for the cell variant.

Where am I going wrong?

kanthimathikris
Employee
Employee
0 Kudos

Hi Neha,

Thanks for the information; will try the same and reply you.

Will also award points then.

Regards,

Kanthi

Former Member
0 Kudos

Hello Kanthimathi!!

First of all you need an attribute in your context node bound to the table which will store the cell variant id. Bind the selectedCellVariant property of your table to this attribute. Next, in your column, define a cell variant with an input field as the cell editor.

Now, whenever you create a new element, just set the attribute in your node corresponding to the cell variant id to the respective ID.

Hope this helps!

Regards,

Neha

PS: for more types of editors, create as many cell variants with different IDs.

Message was edited by:

Neha Agrawal

kanthimathikris
Employee
Employee
0 Kudos

This is really helpful; but what if I need other elements like button for a specific cell? So would like to use the cell variant concept; can you help me in achieving it.

Former Member
0 Kudos

Hi Kanthimathi,

You can simply have all the columns as input fields and manipulate the "read only" attribute alone. For the existing rows, set read only as true for the 1st column. When you add a new empty row, set read only as false. For this you need to introduce another attribute in your context and bind it to the read_only property of the input field that is bound to the first column.

Regards

Nithya