Skip to Content

Introduction


This document demonstrates how to use table element in web dynpro application in a dynamic fashion.


Let me set a plot by taking an example. Suppose, we want user to have a view in web dynpro application, which will be comprising of one table element for inputting row line items. Let’s say, we don’t know how many lines user would input. Yes, user has dynamic mind set. Thus, table element will be having multiple columns in which one column, say is drop down element (just to increase the complexity), having multiple values. User will be facilitated to add as many line items dynamically and delete line items as and when required, on a click of add button and delete button respectively.


Here we go, doing what I just described.


Goto SE80, give the appropriate name to your web dynpro component and hit the green tick.


/wp-content/uploads/2014/07/image001_501921.png

/wp-content/uploads/2014/07/image002_501922.png

Right click on the web dynpro component, create a view and give appropriate name.


/wp-content/uploads/2014/07/image003_501950.png

/wp-content/uploads/2014/07/image004_502755.png

Embed the view in the existing window. You can either right click to embed the newly created view or you can drag and drop the newly created view to the window.

/wp-content/uploads/2014/07/image005_502756.png

/wp-content/uploads/2014/07/image006_502778.png

/wp-content/uploads/2014/07/image007_502779.png


Now create a service call. Here, I have taken example of creation of sales order. You can choose as per your requirement. Note creation of service call is not mandatory here. I have created it only to demonstrate the piece of functionality.


/wp-content/uploads/2014/07/image008_502784.png

/wp-content/uploads/2014/07/image009_502785.png

/wp-content/uploads/2014/07/image010_502786.png

/wp-content/uploads/2014/07/image011_502790.png

/wp-content/uploads/2014/07/image012_502791.png

/wp-content/uploads/2014/07/image013_502792.png

/wp-content/uploads/2014/07/image014_502793.png

/wp-content/uploads/2014/07/image015_502794.png


After successful creation of service call, you will be having a node in the context of component controller. Map this node in the view we created earlier. Create a layout something like mentioned below. View is having two sections, header data and item data.


Here, item data, which we are managing using a table, is in turn bound with some node. Item data part is dynamic where we don’t really know, how many entries user would prefer to make? So after arranging the UI elements, bind them as per your need.


In every row (line item), there will be drop down control element, thus adding one sub node inside the node (which is bound with table control element).


Also, to achieve the functionality of deleting row (line item) from the table on the click of link button, add one column in our table element with link to action element inside. Generate event  for the same.


Repeating again, I have bound table element with order item details.

/wp-content/uploads/2014/07/image016_502795.png

Now, in method WDDOMODIFYVIEW of view, put code I have shown in screenshots. Inside calling two method in component controller, one to fetch some materials and other one to perform initialization tasks. Screen shots of the same are following immediately.

Only, when WDMODIFYVIEW is being called for very first time, call to method, namely GET_MATERIALS and INITIALIZE, will be made. Otherwise, rest of the code will be executed, which is calculating the element count of the node, bound with table element, and setting the visible row count of table element, every time.

/wp-content/uploads/2014/07/1_502808.png

GET_MATERIALS method in component controller, fetches the material data, material number and description, stores them in node at component controller level. Thus, whenever new order line item will be added, material data will be loaded from the node just mentioned.


/wp-content/uploads/2014/07/2_502809.png

INITIALIZE method in component controller, initializes the node bound to table element, creates new element and binds it to the node.


/wp-content/uploads/2014/07/3_502812.png

/wp-content/uploads/2014/07/4_502813.png

/wp-content/uploads/2014/07/5_502817.png


So here we are done with the code in modify view method.


Now, when user clicks the button to add new item to the list, following code to execute.


/wp-content/uploads/2014/07/6_502819.png


If user wants to delete the existing line from the list, put following code on event link to action table element


/wp-content/uploads/2014/07/7_502824.png

And here we are with the output 

/wp-content/uploads/2014/07/8_502825.png


Regards,

Harsh

To report this post you need to login first.

4 Comments

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

  1. PARIN CHAHWALA

    Actually I was having the very similar kind of requirement. This document proved very helpful in achieving my scenario. Thank you very much Regards, Parin

    (0) 

Leave a Reply