All tables, structures, function modules and classes will be generated automatically, if you create a table enhancement using Application Enhancement Tool (AET). However, sometimes you might want to calculate some fields instead of storing it in database.
The AET is not supporting such virtual fields. Therefore you have to implement it manually.
Solution 1: Create an additional attribute in the context node of the generated UI component and place a calculation in the getter method. Deactivate coding of setter and i-getter method.
Solution 2: Enhance structures ?_WORK, ?_ATTR and ?_BOL_ATTR by an additional attribute. Place your calculation at the end of method GET_DETAIL of class CL_AXT_TABLES_API (define and use a table name dependent BADI for high quality solution). Add a value attribute with the same name to context node of the generated UI component. Don’t change the generated code here since it will read the data from BOL/GenIL as wanted.
Conclusion 1: Development should be restricted to a minimum. Whenever source code can be avoided, it should be avoided. Therefore solution 1 is preferred from a supportability perspective, if there are only few virtual fields required.
Conclusion 2: Business logic should be placed in API or BOL/GenIL layer instead of UI layer to be reused UI independently. Therefore solution 2 is preferred from an architecture perspective, if several virtual fields are required or if a high quality and high flexible solution is requested.