Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
With 1902, there are couple of enhancements being released which will help you improve the performance of the code that you write.

It is recommended to adopt these changes in your code to realize the performance improvements.

Access to node id of a root or a sub-node in loop and where statements


With 1902, you will find new fields NodeID, ParentNodeId and RootNodeID in the ABSL script code completion, depending on the node on which the ABSL script is being implemented. These fields help you to read the node instances using the primary-foreign key relationship. NodeID is the primary key for any node instance in any business object instance.

Example: An opportunity has NodeID on root level, but also every item also has a NodeID. The item id cannot identify a node across many opportunities because it is only unique for one specific opportunity, but the NodeID can help you identify an item. The ParentNodeId will have the foreign key relationship to the root node (opportunity header in this case). Similarly, if sub-node like ItemParty and you can use the RootNodeId as a foreign key relationship to the Root node. The ParentNodeID will fetch you the parent Item node from the ItemParty node.

 



This enhancement significantly improves the way you build ABSL code. Consider for example you have two collections of node instances – one for Items, and another for ItemProducts. If you had write a business logic based on fields of Opportunity Items and Item products, you had to implement using code like below.
foreach(var item in OpptItems){
foreach(var itemproduct in OpptItemProds){
if(itemproduct.ToParent.ID == Item.ID){
//Logic
}
}
}

With the new fields of NodeID and ParentNodeId, the new code would look like:
foreach(var item in OpptItems){
itemproduct = ItemProducts.where( n ==> n.ParentNodeID == item.NodeID);
//Logic
}

Limitation: The fields are not available in the repository explorer, so if you executed a query for an object, you will not find the field in the query result or when sub nodes.

 

Check for before and after values of nodes and node elements


 

There’s a new context function called ‘GetFromDB’ available with 1902 release. The function fetches the records from the database for the node and node collection including the dependent object node like Notes, and Attachment and extension nodes. With this function, you will now be able to compare the buffer field values to the database field value and build custom logic around this check.

Earlier when you had requirement to implement a logic by comparing the database and buffer image of a record, you had to write to below logic or something similar.
var query = Activity.QueryByElements;
var resultset;
var selectionParam = query.CreateSelectionParams();
selectionParam.Add(query.ID, "I","EQ",this.GetFirst().ID);
selectionParam.Add(query.ProcessingTypeCode,"I","EQ","0001");
resultset = query.ExecuteFromDBDataOnly(selectionParam);
var DBPrioData = resultset.GetFirst().PriorityCode;
var BufPrioRet = this.GetFirst().PriorityCode;
if(DBPrioData != BufPrioRet){
//Logic
}

This code has a lot of limitation like, it executes a query, which impacts the performance. Moreover, you can build logic only for the current node.

With the new context function, the code looks like:
var BufPrioRet = this.GetFirst().PriorityCode;
var DBPrio = this.GetFirst().GetFromDB().PriorityCode;
if(DBPrioData != BufPrioRet){
//Logic
}

With this you improve the performance of your code and build logic by comparing not just the current node fields but also sub-node fields, extension nodes/fields as well as dependent object fields.
4 Comments