Skip to Content

Introduction

This document helps how to make selected row of table editable in Web Dynpro ABAP.

Step by Step Process

Step 1: Create a Web Dynpro Component.

Go to the SE80 transaction and create a Web Dynpro Component.

/wp-content/uploads/2012/04/1_94587.jpg

/wp-content/uploads/2012/04/2_94588.jpg

Enter Description and click on OK.

Step 2: Data Binding

Go to the Context tab of Main View and create a node FLIGHT..

/wp-content/uploads/2012/04/3_94589.jpg

Enter dictionary structure SFLIGHT, cardinality 0..n and click on Add attributes from structure.

/wp-content/uploads/2012/04/4_94591.jpg

Select the required fields and click on OK.

/wp-content/uploads/2012/04/5_94592.jpg

Step 3: Layout Design.

   Now Go to Layout tab, and click on Web Dynpro Code Wizard( magic symbol button).


/wp-content/uploads/2012/04/6_94593.jpg

Double click on Table to create and bind Table UI.

/wp-content/uploads/2012/04/7_94594.jpg

Click on context and select the Flight Node.

/wp-content/uploads/2012/04/8_94595.jpg

Change the Standard cell editor to ‘Input Filed’ .and click on OK.

/wp-content/uploads/2012/04/9_94596.jpg

Now we can see the Table UI in the layout.

/wp-content/uploads/2012/04/10_94597.jpg

  Now select the carrid input field, under properties click on bind button for readOnly property.

/wp-content/uploads/2012/04/11_94598.jpg

Select the required attribute( by default it will be selected, here carrid ), And slect the radio button ‘Bind to the property of selected Attribute’ and select ‘Read Only’ property. click on OK.

/wp-content/uploads/2012/04/12_94599.jpg

Now click on table UI, under properties, click on create button for onLeadSelect Event to create an action for Lead Selection.

/wp-content/uploads/2012/04/13_94600.jpg

Enter Action Name, description and click on OK.

/wp-content/uploads/2012/04/14_94601.jpg

Now goto Methods tab, and enter below code in WDDOINIT method.

WDDOINIT

method WDDOINIT .

   DATA lo_nd_flight TYPE REF TO if_wd_context_node.

   DATA lt_flight TYPE wd_this->Elements_flight.

   DATA ls_flight TYPE wd_this->Element_flight.

   DATA lo_el_flight TYPE REF TO if_wd_context_element.

*   navigate from <CONTEXT> to <FLIGHT> via lead selection

   lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight ).

   SELECT * FROM sflight into TABLE lt_flight UP TO 10 rows.

   lo_nd_flight->bind_table( new_items = lt_flight set_initial_elements = abap_true ).

* To disable all rows initially

   LOOP AT lt_flight INTO ls_flight.

     lo_el_flight = lo_nd_flight->get_element( index = sytabix ).

*  set single attribute

     lo_el_flight->set_attribute_property(

       attribute_name `CARRID`

       property = 3  ” Property 3 – Read Only

       value = ‘X’ ). ” Disable the rows for carrid

   ENDLOOP.

endmethod.

Enter below code in ONACTIONMODIFY_ROW method.

ONACTIONMODIFY_ROW

method ONACTIONMODIFY_ROW .

   DATA lo_nd_flight TYPE REF TO if_wd_context_node.

   DATA lo_el_flight TYPE REF TO if_wd_context_element.

   DATA lt_flight TYPE wd_this->Elements_flight.

   DATA ls_flight TYPE wd_this->Element_flight.

   DATA lv_index TYPE i.

*   navigate from <CONTEXT> to <FLIGHT> via lead selection

   lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight ).

   lv_index = lo_nd_flight->get_lead_selection_index).

   lo_nd_flight->get_static_attributes_table( importing table = lt_flight ).

*  Enable selected row

   LOOP AT lt_flight INTO ls_flight.

     IF sytabix = lv_index.

       lo_el_flight = lo_nd_flight->get_element( index = sytabix ).

       lo_el_flight->set_attribute_property(

        attribute_name `CARRID`

        property = 3    ” Property 3 – Read Only

        value = ).  ” Enable

     ELSE.

       lo_el_flight = lo_nd_flight->get_element( index = sytabix ).

       lo_el_flight->set_attribute_property(

        attribute_name `CARRID`

        property = 3   ” Property 3 – Read Only

        value = ‘X’ ).       ” Disable

     ENDIF.

   ENDLOOP.

endmethod.

Now Save and Activate the Web Dynpro Component.

Create Application.

Create Web Dynpro Application and save it.

/wp-content/uploads/2012/04/15_94602.jpg

Now right click on web dynpro application and click on Test.

/wp-content/uploads/2012/04/16_94603.jpg

Result:

Now you can see, initially all the rows are disable.

/wp-content/uploads/2012/04/17_94606.jpg

Now select any row and the corresponding row will be enabled.

/wp-content/uploads/2012/04/18_94607.jpg

Conclusion

Here I demonstrated only for one column, we can disable all columns initially and make the entire row enable onLead Selection of the row.

Reference

I saw this thread http://scn.sap.com/thread/3163682 and tried for the solution, the above doc is one such experiment .

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply