cancel
Showing results for 
Search instead for 
Did you mean: 

Need to add 3 table values and get the total using table in java webdynpro

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Experts,

Can you please help me in adding 3 column values add the result should be displayed in the 4th column.

I have gone through this material https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-tec....

I am able to add 3 columns provided the first column value is already defined and the other 2 column type is integer.

But my requirement is I need to enter 3 columns and the total should be displayed in 4th column of the table. Please guide me through this.

Your help is very much appreciated as I need to complete this in 2 days.. Please let me know your inputs.

Thanks in advance,

Shilpa

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Shilpa,

Since webdynpro doesn't support java script, at runtime its not possible to add 3 entered column values and showing it in a 4th column.

So you have to create a button and write the logic for adding this 3 entered column values in the button action.

I think there is no other way other than this.

Regards,

Saleem

Former Member
0 Kudos

Hi Shilpa,

Do one thing , using supply functions we can achieve this.

Let us have a coloumn a, b and c and total shoul be come in coloumn d.

context structur like

Test

- A

- B

- C

Add a value node "add" under node Test and create a value attribute D. the context look like.

Test

- A

- B

- C

- Add

|

- D

The node ADD cardinality is 1..1 and selection 0..1 singleton = false.

and create a supplyfunctionfoe node ADD "supplyAdd".

Write the code the supplyAdd() method

public void supplyAdd(IPrivateTest.IaddNode node, IPrivateTest.ITestElement parentElement)

{

//@@begin supplySpecialParameters(IWDNode,IWDNodeElement)

IaddElement elem = node.createAddElement();

node.bind(elem);

elem.setD(parentElement.getA()parentElement.getB()parentElement.getC());

//@@end

}

Please let me know if you got any problems.

Regards,

Naga

Former Member
0 Kudos

HI,

Define a fourth attribute locally in the same node which displays the table.

Go to the properties of this attribute and you will see a "Calculated" property. This will be set to false by default. Change this to True.

Once you change the property to true you will find a getter and setter method added for this attribute in the controller code. These methods are always automatically called before the value is set in the element for this attribute.

In your case, you can use the setter method for this attribute and fill in the required addition calculation code.

http://help.sap.com/saphelp_nw70/helpdata/EN/7f/a0384162316532e10000000a1550b0/frameset.htm

Regards

Srini

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Srini,

Thanks for your quick response. I have already followed this process but I am not able to add the value. Let me brief what I have done. I have 3 attributes. 3 attributes type is float. Third attribute calculated property is true. This is the coding what I have written for calculated method:

public float getAdditionThird(IPrivateTableEdit.IAdditionElement element)

{

//@@begin getAdditionThird(IPrivateTableEdit.IAdditionElement)

return element.getFirst()+element.getSecond();

//@@end

}

When I enter the values it does'nt get added. Am I missing something in the type. I have set type as float.

Please let me know your inputs.

Thanks,

Shilpa