This document tries to explain more technical background regarding calculated fields created by AET. It talks about technical implementation of calculated fields and how to trace & debug if you find it does not work as expected.

how to create calculated field

This document will not cover how to create new field via AET step by step, as plenty of documents could be found in SCN.

I just launch AET and create a new field on Product header. Mark “Calculated” checkbox in field creation dialog:

/wp-content/uploads/2014/02/clipboard1_393508.png

in this document, I just use the simple logic as example: the content of this calculated field comes from the email address maintained in my user profile, and it could be automatically converted to lower case, as I select the TOLOWER String function in formula definition below:

/wp-content/uploads/2014/02/clipboard2_393536.png

Below is the result: the email address maintained in my user profile will be filled automatically to this extension field in UI.

/wp-content/uploads/2014/02/clipboard3_393537.png

What artifacts are generated for the calculated field in the backend

Lots of artifacts are also generated under the hood in the ABAP backend. All of them works together with AET framework to ensure the calculation logic is executed smoothly in the runtime.

1. What is the new field added to Genil model?

We have defined the calculation logic on the extension field. Click F2 and identify its technical attribute name: ZZFLD0000YP.

/wp-content/uploads/2014/02/clipboard4_393538.png


Then we can look into Genil component PROD in tcode GENIL_MODEL_BROWSER, and find the extension field is modelled as one field of dependent object ProdSetCRM_EXT_MAT, which could be available via Aggregration ProductSetCRM_EXT_MAT from root node. So we are sure in the runtime, the field ZZFLD0000YP will be filled by AET framework with my email address.

/wp-content/uploads/2014/02/clipboard5_393540.png

We can also view the new field via tcode AXTSHOW, input field name ZZFLD0000YP and execute report.

From result we could know that technically speaking, one FDT rule with two parameter mappings are generated for the calculated field we create via AET.

/wp-content/uploads/2014/02/clipboard6_393541.png

The rule type FDT_FORMULA in the above picture gives us a hint that the rule could be viewed by BRF( Business Rule Framework) workbench. The workbench could be launched via the following Webdynpro application:

/wp-content/uploads/2014/02/clipboard7_393545.png


Workbench->Open Object:

/wp-content/uploads/2014/02/clipboard8_393546.png

Search application via RULE ID 0050569457471EE3A6D6AF56EF33F505 found in report execution result:

/wp-content/uploads/2014/02/clipboard9_393547.png

click Formula node in the left navigation tree, click “Start Simulation” button:

/wp-content/uploads/2014/02/clipboard10_393548.png

Maintain simulation test data and click Execute:

/wp-content/uploads/2014/02/clipboard11_393549.png

Simulation done successfully, we get expected result.

/wp-content/uploads/2014/02/clipboard12_393550.png

3. the new generated mapping class

Query the table FDT_CC_0000 with rule ID got from tcode AXTSHOW, you can find there is also a new class /FDT/00O2TJ6G8AL233VMEEX143HVF generated.

/wp-content/uploads/2014/02/clipboard13_393551.png

we will discuss the usage of this mapping class in debugger chapter of this document.

How to trace the calculation logic done in the runtime

Before the introduction of debugging calculation logic in the runtime, we first look into how to trace the calculation logic. Sometimes by tracing it is possible to find the issue root cause to avoid time wasted in debugging.

1. maintain the user parameter AXT_RULE_TRACE_MODE as X in your user profile.

/wp-content/uploads/2014/02/clipboard14_393552.png


2. goto tcode SAAB, activate checkgroup AXT_GENERAL.

/wp-content/uploads/2014/02/clipboard15_393553.png

activate the kogpoints:

/wp-content/uploads/2014/02/clipboard16_393554.png

after activation, re-launch your application in UI. You should find many log entries written in SAAB.

Double click on the entries and you could observe the expected email address is successfully written into <LV_FDT_RESULT>.

/wp-content/uploads/2014/02/clipboard17_393555.png

How to debug the calculation logic in the runtime

If trace function still could not help you find the root cause why the extension field does not work as you expected, you have to debug it yourself.

Please always ensure the calculation logic works fine in simulation mode, before you start debugging.

The question is where we could set breakpoint for starting? The generated mapping class /FDT/00O2TJ6G8AL233VMEEX143HVF is a good place, just set a breakpoint in its method IF_FDT_GEN~PROCESS. However it is better if we could know how our mapping class is called by AET framework.

Everytime the GET_PROPERTY of CL_CRM_BOL_ENTITY is called, inside it the method MAKE_VALID_STATE is called to evaluate whether a reread or property calculation is necessary.

/wp-content/uploads/2014/02/clipboard18_393556.png

as our calculated field is filled by mail address of “USER”, the data source provider class for it is maintained in the table below:

/wp-content/uploads/2014/02/clipboard19_393557.png

the class is responsible for email address retrieve via user BAPI:

/wp-content/uploads/2014/02/clipboard20_393558.png

/wp-content/uploads/2014/02/clipboard21_393559.png

and our mapping class is called here:

/wp-content/uploads/2014/02/clipboard22_393560.png

why the calculated field is empty when UI is in display mode

as is explained earlier, the calculation logic is triggered in line 93, however when the product instance is searched out from database and shown in product UI in display mode, the property_calculator_registered of the bol entity is initial, so the calculation logic has no chance to execute.

/wp-content/uploads/2014/02/clipboard23_393561.png

only when a BOL entity is locked by edit button, the lock event will trigger focus changed event and lead to the creation of new dependent object ProductSetCRM_EXT_MAT’s entity,

/wp-content/uploads/2014/02/clipboard24_393562.png

the flag =>V is filled by BOL framework here.

/wp-content/uploads/2014/02/clipboard25_393563.png

In display mode all the above logic has no chance to executed thus the calculated field is displayed as empty in UI.

Hope this document is helpful for you when dealing with AET calculated field.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply