cancel
Showing results for 
Search instead for 
Did you mean: 

Real advantage of calculated attribute Web Dynpro

Former Member
0 Kudos

Hi,

I read some docs about calculated attribute but i couldn't get the real advantage of it. I know this is very much usefull when we are using file download UI element in table.

One document says this will be usefull to calculate he total price of a shopping cart. I think instead of using this calculated attribute we can use normal attribute, where we can store the total price.

Please let me know what are advantages of this calculated attribute.

Thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Tatayya,

Check this recent thread as an example where calculated attributes are preferred:-

Regards,

Anagha

monalisa_biswal
Contributor
0 Kudos

The benefit of the calculated attribute is, its getter method get called everytime the nodelement is accessed.

So if you want one attribute to get calculated whenever there is a change in any of the attribute in the node element, you can write the logic in the calculator method.

For example Total value Calculation. It should be updated everytime there is a change in quantity in any of the attribute of the node. If there is a button to increase value and another button to decrease value.

You have to make sure total calculation is present in both buttons' event handler.

It is also useful for displaying text for a selected value from EVS.

Hope this helps!

Monalisa

Former Member
0 Kudos

Thanks Biswal.

Now It's very clear to me

Former Member
0 Kudos
Former Member
0 Kudos

Thanks for your reply.

I have gone throgh the vedio. my doubt in the given example in the vedio is..

after clicking button only we are getting salutation. If that is the case we can use one more normal attribute instead of calculated attribute and we can form the salutation and we can assign the value to attribute.

Let me know what is the advantage we are getting using this calculated attribute.

Thanks

former_member185086
Active Contributor
0 Kudos

Hi

A calculated attribute is an attribute that is not stored by the element, but calculated each time the attribute is accessed. Therefore it must be marked in the IDE and controller methods must be declared.

Calculated attributes can have getters and (unless they are read only) setters. The getter calls the declared controller method with the following signature:

AttrClass getNodenameAttributename(NodenameElement element);

It is expected to calculate and return the value based on other values of the element.

The setter is only generated if the attribute is not marked read only. It has the following signature:

void setNodenameAttributename(NodenameElement element, AttrClass value);

This method is expected to modify other attributes of the element based on the given value. It does not mark anything changed by itself. Only the modification of other attributes leads to updates of the GUI.

(The above method names are proposals of the IDE. You may change them.)

you could use the getter in order to get a form of address like "Mr. Metodi Mladenov" from the following fields of an address book: Last Name, First Name, Gender, Address.

Advantage is : Implementing some intelligence based on the given data like if Customer Code is DEL123011

so(and it is given that it start from City<ddd>code) so we can retrieve city + City code information based on this infromation

Best Regards

Satish Kumar

Edited by: satish jhariya on Mar 17, 2009 6:09 PM

Former Member
0 Kudos

The question is could we not use normal context attribute with read only = true and a setter method instead of the calculated attribute?

What great difference would it make if we do?

former_member185086
Active Contributor
0 Kudos

Hi

For this see the famous Chris Whealy [ Video|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e093a9d8-c00e-2b10-7dae-b72c3a8c5536] and [help thread|;

Best Regards

Satish Kumar