cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Table column value dynamically in ABAP WebDynpro

Former Member
0 Kudos

Hello Guys.

My Query is ready Table element in ABAP Webdynpro.

Say I have a context for 6 columns. & I have mapped 5 columns out of it in a table element...Now I have my table control column 5 as open for editing.

So my queries are :

1) How can i calculate the value is column 4 based on value in column 5  * 6th column in context + some constant.

As the column 5 is open for editing , user can edit it value anytime & according the value should be change in column at the same time, say on Enter command. How can we achieve this.

2) Can I display no of columns in table based on certain condition.

Say I have a View which is having many input fields and also a table element with 5 columns.

Now the requirement is same View with value of one of input field (say Flag X) table will display only 4 columns & the same view with( Flag y) should display all the 5 columns.

All you valuable suggestions are Highly appreciated.

Regards,

Fox

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Sample Image:

  1. Add a check box to the table and enable the input field whenever the check box is checked.

This way u can find the entries changed so that later u can do the calculation as u require and modify the node table data.Add the below kind of code in the ON_ENTER method of input enabled field of the table.

METHOD onactionon_enter.

DATA lo_nd_vbak TYPE REF TO if_wd_context_node.
DATA lo_el_vbak TYPE REF TO if_wd_context_element.
DATA ls_vbak TYPE wd_this->element_vbak.
DATA lt_vbak TYPE wd_this->elements_vbak.

FIELD-SYMBOLS <fs_vbak> TYPE wd_this->element_vbak.

*   navigate from <CONTEXT> to <VBAK> via lead selection
lo_nd_vbak = wd_context->get_child_node( name = wd_this->wdctx_vbak ).

CALL METHOD lo_nd_vbak->get_static_attributes_table
IMPORTING
table = lt_vbak.

LOOP AT lt_vbak ASSIGNING <fs_vbak>.
CHECK <fs_vbak>-cb = abap_true.
<fs_vbak>-total = <fs_vbak>-quantity * <fs_vbak>-netwr.
ENDLOOP.

lo_nd_vbak->bind_table( lt_vbak ).
ENDMETHOD.


2.  By default include all the node fields into the table and hide whichever the fields are not required by binding an attribute to the visibility property of table columns.

Same way u can make the column visible by setting the context attribute. Code for this in ON_ENTER method of the input column in same view mentioned by u.

It is easy to get this functionality done in ALV than table UI Element. Check whether it is possible to replace the table with an ALV.

Thanks,

Mahendra K.

Former Member
0 Kudos

Hi Wilson,

1. In on-enter event of 5 or 6th column you have to write code to do your calculations.

2. Yes you can display no of columns based on conditions. To do so create one attribute of type WDUI_VISIBILITY and bind this with your 5th column which you want to display based on condtion.

IF flag = x, set this attribute to invisible and for Y set to visible.

Cheers,

Kris..

Former Member
0 Kudos

Hi Krishna,, thanks for your valuable suggestion , could you please explain I could I  zble to access column values in On-Enter Event, Any sample code will be be much appreciated.

Regards,

Fox

Former Member
0 Kudos

Hi Wilson,

Find below my sample code. This code is written on_enter of one input column in table.

  DATA lo_nd_n_item_details1 TYPE REF TO if_wd_context_node.
  DATA lo_el_n_item_details1 TYPE REF TO if_wd_context_element.
  DATA ls_n_item_details1    TYPE wd_this->Element_n_item_details1.
  DATA ls_item_details1      TYPE wd_this->Element_n_item_details1.

   *   navigate from <CONTEXT> to <N_ITEM_DETAILS1> via lead selection
    lo_nd_n_item_details1 = wd_context->get_child_node( name = wd_this->wdctx_n_item_details1 ).

*   get element via lead selection
    lo_el_n_item_details1 = lo_nd_n_item_details1->get_element( ).

*   get all declared attributes
    context_element->get_static_attributes(
      IMPORTING
        static_attributes = ls_n_item_details1 ).

By executing this code..  ls_n_item_details1  contains values of that row where you pressed enter.

hope it helps.

Cheers,

Kris.