Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
uday_kamte2
Discoverer

Data Privacy


Data privacy and protection is an important topic especially when it comes to custom extensions you might develop with SAP Cloud Application Studio (PDI). The intent of this blog is to make customers and partners aware of the reuse library functions available in cloud application studio that can be used to identify the document deletion and business partner deletion runs.

Those of you would like to get an overview of this topic and what it means for ByDesign customers can refer to this comprehensive blog post written by my colleague Jan. For the details about what these entities mean and how they can be scoped in the system you can refer to this blog post.

Add-on scripts


The add-on scripts are developed to enrich the data and react to the events associated with the custom business objects or standard business object extensions. These add-on scripts can cover a wide range of spectrum; from straight forward ones that enriches extension fields to fairly complicated solutions that have intensive logic.

 


The details of the SAP help document for Actions, Events and Validations can be found here.

Document Deletion


When a business object instance is deleted the events listed above along with OnSave validation are triggered and the ABSL script in them is executed. During the normal course of instance deletion executing these scripts is logical and unavoidable.

However, once the document chain reaches its end of retention, all the documents (business object instances) that are part of this chain are deleted. During the course of this deletion executing the script in the events AfterModify, BeforeSave, AfterLoading and OnSave validations could be avoided.

Document deletion run can involve large volume of data - in case of one of the ByDesign customer the deletion run had more than 200 thousand records in it! As you can imagine, execution of add-on scripts for these records takes inordinate amount of time – when, in fact, the logic in these scripts isn’t relevant due to the document’s end of retention and hence the scripts’ executions in this case should be avoided.

Identifying the Deletion Context


The following code snippet explains how an ABSL script can be enhanced to check if it being executed during the course of deletion run – both Business Partner Deletion and Document deletion – and how its execution can be avoided.


 
/*
Add your SAP Business ByDesign scripting language implementation for:
Business Object: xxx
Node: xxx
Event: AfterModify

Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
- This script file is mass-enabled, i.e. the keyword "this"
refers to a collection of node instances.
- The solution uses this script if:
- the value of any field in the node in which this script is contained is modified.
- the node itself is modified by another business object within the same solution.
*/

import ABSL;

var delBP = DeletionContext.IsBupaDeletion(); // Business Partner Deletion

var delDoc = DeletionContext.IsDocDeletion(); // Document Deletion

if (delBP || delDoc)
{
return;
}

 

The link to SAP help document for these reuse libraries can be found here.

Deletion of Custom business object instances


If there are custom business objects that have a business transaction association with the standard business object, such custom object instances can be deleted using OnDelete event during document deletion by identifying the deletion context. This is important because the document chain would only include standard business objects, hence deletion of custom objects has to be handled separately.



/*
Add your SAP Business ByDesign scripting language implementation for:
Business Object: xxx
Node: Root
Event: OnDelete

Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
- The solution uses this script when the instance of the business object gets deleted and SAVE is triggered.
- The fields on the current node are always read-only.
- The fields from other nodes follow regular read/write behavior.
*/

import ABSL;

var delBP = DeletionContext.IsBupaDeletion(); // Business Partner Deletion

var delDoc = DeletionContext.IsDocDeletion(); // Document Deletion

if (delBP || delDoc)
{
// Implement the logic to delete custom objects associated with the deleted object instance
}

Internal Communication scenarios


The deletion context should also be used in the exits of internal communication scenarios to ensure the communication is not triggered during document deletion.

I have highlighted usage of Change and Cancel conditions, however, in some cases similar adoption could be required in Start condition as well.

The link to SAP help document for the exits in internal communication scenarios can be found here.




 
/*
Add your SAP Business ByDesign scripting language implementation for:
Business Object: xxx
Node: Root
Service Integration Name:
ConditionEvaluation: Change

Script file signature
----------------------------
Parameter: InReconciliation type Boolean
Returns: Boolean

Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
Condition Evaluation
*/

import ABSL;

var delBP = DeletionContext.IsBupaDeletion(); // Business Partner Deletion

var delDoc = DeletionContext.IsDocDeletion(); // Document Deletion

if (delBP || delDoc)
{
return false; // Set change condition as false during Document or BP deletion
}
else
{
// Alternate/Existing logic for change condition
return true;
}

/*
Add your SAP Business ByDesign scripting language implementation for:
Business Object: xxxx
Node: Root
Service Integration Name:
ConditionEvaluation: Cancel

Script file signature
----------------------------
Parameter: InReconciliation type Boolean
Returns: Boolean

Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
Condition Evaluation
*/

import ABSL;

var delBP = DeletionContext.IsBupaDeletion(); // Business Partner Deletion

var delDoc = DeletionContext.IsDocDeletion(); // Document Deletion

if (delBP || delDoc)
{
return true; // Set cancel condition as true during Document or BP deletion
}
else
{
// Alternate/Existing logic for cancel condition
}

Importance of Adoption


My advice to the customers and partners would be to follow this approach, not just for the Root/Header node but also for scripts belonging to the child nodes as well. As a deletion run can end up having huge number of records, not doing so will have a detrimental impact on the performance and execution of the run.