cancel
Showing results for 
Search instead for 
Did you mean: 

calculated attribute?

Former Member
0 Kudos

Hi,

Wat is the actual use of this and also giv me some sample for this..when and wher we use it?

**Helpful answers will be appreciated...

GS

Accepted Solutions (0)

Answers (4)

Answers (4)

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi

The values of context attributes are normally saved in node elements of a controller context at runtime, and with data binding are displayed in the UI using a generic formatting mechanism (for Dictionary-based types).

In many cases, saved context data should be transferred identically, instead it should be converted before the display. A typical example is displaying an address text based on name and gender. Using the two context attributes Name=’Maier’ and Gender=’male’, the standardized address text 'Dear Mr. Maier!’ should be displayed in the user interface. This text can be saved by defining an additional value attribute Address in the controller context. In multiple context nodes, each individual node element would then have the additional context attribute called Address, where the name would be saved redundantly as part of the address.

Calculated context attributes are a more elegant way of handling the example. These are not saved specially in the context, they are calculated (read) where necessary by the controller instead. “Where necessary” can mean that UI elements should display the content of a calculated attribute, or that the value is accessed by the program in the controller coding. The calculation method is called automatically by the Web Dynpro runtime environment. A calculated context attribute is calculated in an automatically generated access method using signature

<CalcAttrType> get<NodeName><CalcAttrName>(<NodeName>Element element).

For a calculated context attribute called FullNameCalc of type String in node UserData in the context of the FormView view, this results in access method

java.lang.String getUserDataFullNameCalc(

IPrivateFormView.IUserDataElement element).

The calculation method is called automatically where necessary by the Web Dynpro runtime environment. It passes a reference to the node element to which the calculated context attribute refers. If this method were defined in a multiple node with cardinality 0..n, for example, then the access method would be called for each node element that is available in the node at runtime. In this way, the full name of a customer could be displayed in a third table column, consisting of first and last names. The access method would be called for each row (each node element) in the table.

It is expected that the access method for calculating a calculated context attribute is based on the same node element’s other attributes.

Within the generated access method for a context attribute, the context attribute to be calculated should not be accessed, as this results in the access method being called recursively. A recursion termination occurs only if you implement a recursion condition.

According to the Web Dynpro naming convention, calculated context attributes should contain the ending Calc for Calculated in the name, such as SalutationCalc or TotalPriceCalc. This makes the application coding easier to read with respect to the components from the calculated context attributes.

Regards

Kalyan

Former Member
0 Kudos

Hi Jansi and fistae...

Thanks for u r kind replies... This infm is enough for me ...

GS

former_member201361
Active Contributor
0 Kudos

hi,

refer this thread for information about the calculated variables.

[]

library for the calculated Attribute :

[http://help.sap.com/saphelp_nw70/helpdata/en/7f/a0384162316532e10000000a1550b0/frameset.htm]

thanks and regards

Fistae

Edited by: Fistae on Apr 21, 2008 12:19 PM

Former Member
0 Kudos

Hi Satish,

Refer to the following link of help.sap.com which will answer your question.

http://help.sap.com/saphelp_nw04s/helpdata/en/7f/a0384162316532e10000000a1550b0/frameset.htm

Thanks n Regards,

Jhansi Miryala