You can create a read-only field enhancement associated with a formula expression. The formula expression can be comprised of operations, constants, and application-specific data attributes.
You define the formula expression in the Calculated Field Value
block.
If you have enabled the expert mode, you can see the name of the BOL (business object layer) object for which you are creating a calculated field.
In the field details, you have selected the Calculated (Read-only)
checkbox.
You are using the WebClient UI. This function is not available in Floorplan Manager for Web Dynpro ABAP.
You can use operations to calculate the value of the field at runtime. You can select the operations displayed in the Operations
block by clicking them. In addition, you can enter the following operations manually: <, >, =, >=, <=, +, -, *, /.
The operations are provided by Business Rule Framework plus (BRFplus). For each operation, you can display the documentation by choosing the ?
icon. For more information about BRFplus, see .
Note
Calculated fields have some restrictions regarding CRM application data usage and BRFplus integration. For more information, see SAP Note 1457617.
You can also define custom operations. For more information, see the following:
Documentation for Business Add-in (BAdI) BRFplus Application Exit
(AXT_BRFPLUS_APPL_EXIT
)
You can display global attribute tags (left table) by filtering on the UI object type. You can add them to the formula expression by clicking them. They are inserted at your cursor position. If you want to cut and paste attribute tags, make sure that you cut the complete tag: <VALUE[...]>. For information about global attribute tags, see Global Attribute Tag.
You can use the existing attribute tags from the table. In addition, you can create new attribute tags in Customizing for UI Framework
under .
To use an attribute tag in a formula, the following conditions must be met:
The field type of the attribute tag must fit to the position in the formula.
You can use attribute tags based on different field types together within a formula. However, make sure that they are appropriate for the operation and the position within the formula.
Example
You have defined a formula expression that contains the timepoint
field type. The result of the calculation can be a Boolean value.
To create calculated fields as currency and quantity fields, you have defined a reference field in Customizing for UI Framework
under .
The attribute tag must be accessible from the BOL object where the new calculated field is created.
User attribute tags and constant attribute tags are always accessible. BOL attribute tags are accessible in the following cases:
The BOL entity exists at runtime.
Example
A BOL attribute tag for contact details of an account that has no contacts is not accessible.
One of the following applies:
The BOL object that is to be enhanced by the calculated field must be in the path of the BOL attribute tag.
The path to the attribute tag is unique. That is, there must only be one path (one relation) from the root object to the enhanced BOL object.
The BOL attribute tag path has only 1:1 relations.
Calculated fields are added to a BOL object. The BOL object that is enhanced depends on the enhanced business object part that you have selected. The Application Enhancement Tool (AET) uses only the path of the BOL attribute tag. The path of the BOL attribute tag starts with the root object and follows the relations to an attribute. The AET has to find a path from the enhanced BOL object that contains the calculated field to the attribute of the BOL attribute tag.
The relation is not an association. Associations cannot be traced backward from child object to parent object.
In the formula expression, you can use field enhancements, fields from table enhancements, or application fields.
Note
You can use a field enhancement as an operand, but not a calculated field. That is, you can create a calculated field based on another field enhancement, but not based on other calculated fields.
Example
You have created a field called Discount
. You want to create a calculated field called Price
in which you would use the discount to calculate the price.
Proceed as follows:
Create and generate the field that you want to use in the calculation.
Create BOL attribute tags for this field as required in Customizing for UI Framework
under or in the WebClient
UI by pressing F2 and choosing the Tag
pushbutton.
Create a calculated field in a field enhancement and add the attribute tag in the formula expression.
BOL attribute tags are defined based on an existing BOL object. Since the BOL object needs to be generated with a table enhancement, you have to proceed as follows to use BOL attribute tags:
Generate the table enhancement without the calculated field.
Create BOL attribute tags for this BOL object.
Edit the table enhancement and use the attribute tag in the formula expression.
If the path of a BOL attribute tag contains at least one 1:n relation, a table of data is returned by the BOL attribute tag. In this case, you have to use the table operations to get only one result value, which can be passed to the calculated field as result of the formula.
Global attribute tags, for example <VALUE[BOL:BP_ACCOUNT:ID]>, can have a length of up to 255 characters. They are not passed to BRFplus directly, but converted to BRFplus parameters. The string literals in formula expressions can have a length of up to 60 characters. If you try to define a literal that is longer, for example, if you want to calculate the URL of an image, an error is displayed. You can use two shorter strings instead of one and concatenate them.
Example
You want to calculate the URL of an image, but the following formula fails:
CONCATENATE( 'http://URL_that_has_more_than_60_characters/', <VALUE[BOL:BP_ACCOUNT:ID]> ).
You can concatenate this URL string using two shorter strings:
CONCATENATE( 'http://first_part_of_the_URL_that_has_more_than_60_characters', CONCATENATE('_second_part_of_the_URL_that_has more_than_60_characters/', <VALUE[BOL:BP_ACCOUNT:ID]> )).
You can choose the Check
pushbutton to validate the formula expression. If you do not validate the formula, the AET automatically validates the formula when you choose the Back
pushbutton.
The field types of the AET and BRFplus are slightly different. If you choose the Check
pushbutton, the calculated field that displays the result of the formula is checked against the field types of BRFplus. For this reason, you may encounter valid formulas that
do not work at runtime, since the checks could not be executed at design time.
If the calculation of a field fails at runtime and the field is displayed on the UI, a standard user sees the message Calculation for field <field name> failed
.
Some fields are not displayed on the current view, but they are calculated, since the calculation is performed when the BOL entity is read.
Example
Errors from sales order fields are not displayed on the opportunity overview page.
On the search result page, you do not see the calculated field, but the calculation has happened. Therefore, the message is not displayed on the search result page or overview page.
Technical users can increase their message level by setting the user parameter BSPWD_USER_LEVEL
to 6. This displays all messages of the calculation. For example, a calculation message is created if either an attribute tag cannot be resolved
at runtime because a relation points to BOL entities that do not exist yet, or if the field types within the calculation do not match.
You define the field details.
You add the operation that is to be used to calculate the field value.
You insert one or more global attribute tags as operands.
If necessary, you create new global attribute tags.
Note
You may have to generate the enhancement first.
You validate the formula.
You save and generate the enhancement.
The following table shows whether BOL attribute tags can be used in the calculated fields of the enhanced BOL objects:
BOL Attribute Tag |
BOL Object |
|||||
---|---|---|---|---|---|---|
OrderHeader |
Account |
ShipmentData |
Item |
PricingData |
ScheduleLine |
|
|
Yes |
No Associations cannot be traced backward |
Yes (a unique parent relation exists) |
Yes The BOL attribute tag path has only 1:1 relations |
Yes The BOL attribute tag path has only 1:1 relations |
Yes The BOL attribute tag path has only 1:1 relations |
|
Yes |
Yes |
Yes (a unique parent relation exists) |
Yes The BOL attribute tag path has only 1:1 relations |
Yes The BOL attribute tag path has only 1:1 relations |
Yes The BOL attribute tag path has only 1:1 relations |
|
Yes |
No Associations cannot be traced backward |
Yes |
Yes The BOL attribute tag path has only 1:1 relations |
Yes The BOL attribute tag path has only 1:1 relations |
Yes The BOL attribute tag path has only 1:1 relations |
|
Yes (the result is a table and you have to use the table functions) |
No Associations cannot be traced backward |
Yes A unique parent relation exists (the result is a table and you have to use the table functions) |
Yes |
No * |
No * |
|
Yes (the result is a table and you have to use the table functions) |
No Associations cannot be traced backward |
Yes A unique parent relation exists (the result is a table and you have to use the table functions) |
Yes |
No * |
No * |
|
Yes (the result is a table and you have to use the table functions) |
No Associations cannot be traced backward |
Yes A unique parent relation exists (the result is a table and you have to use the table functions) |
Yes |
Yes |
No * |
|
Yes |
No Associations cannot be traced backward |
Yes A unique parent relation exists (the result is a table and you have to use the table functions) |
Yes (the result is a table and you have to use the table functions) |
No * |
Yes |
* The root object has more than one path to the enhanced BOL object. The Item has two possible parent objects, that is, OrderHeader and Item itself. Due to the SubItemsRelation, an item is its own parent object.