Change History (Reuse Library)

Posted on Posted in SAP Business ByDesign

In the previous article, we learned, how to embed a change log in the custom business object. Change HistoryHere we are going to learn, how to capture the same in the ABSL scripting.

Change History is a SAP reuse library, which contains a function that you can use to retrieve data from a supplied Business Object and its nodes that were changed during the given period based on the Platform Change Document service.

Prerequisites

Should have a knowledge on Change History (Business Object).

Change History

For more information about the change history Business Object creation, see http://blog.sankaranss.com/2017/06/22/change-history/.


Description

Syntax: <BusinessObject>.Read(“NameSpace”, UUID, NodeID, FromDate, ToDate, User );

  1. BusinessObjectName defines the name of the Business Object.
  2. Define the namespace, e.g,. AP.CRM.Global:Lead.
  3. UUID: Retrieve current instant UUID. To get current UUID, Context.GetCurrentIdentityUUID()
  4. NodeID provides the NodeID of the Root node for the requested instance.
  5. The other four parameters are optional:
    • NodeName: Restricts the result to given node
    • ToChangeDateTime: If no value is given the current date and time is taken
    • FromChangeDateTime: If no value is given 30 days earlier than the ToChangeDateTime is used
    • ChangerUUID: Only the changes made to the respective user are returned

Example for SAP Business Object

// get all changes of SAP Business Object Lead based upon Lead Root node ID

var myLeadRootNodeId : UUID;
myLeadRootNodeId = …
var currentUser = Context.GetCurrentIdentityUUID();
var myChanges = ChangeHistory.Read( “AP.CRM.Global:Lead”, myLeadRootNodeId, “Root”, this.FromDateTime, this.ToDateTime, currentUser );


Example for Custom Business Object

// get all changes of Custom Business Object MyOwnBusinessObject based upon own BO Root node ID

var currentUser = Context.GetCurrentIdentityUUID();
var myChanges = ChangeHistory.Read(“MyOwnBusinessObject”,  this.GetObjectNodeReference().UUID, “Root”);


Testing

Debug the code and check the output as shown in the below screenshot.

Change History

If you like to add some points to this article, kindly leave your points as comments. Don’t forget to subscribe it.

Reference: © 2017 SAP SE. All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *