Tutorial: 7. Change Tracking API

7. Change Tracking API

The SAP HANA REST Application Programming Interface (REST API) includes a Change Tracking API that enables you to make use of specific lifecycle-management features included with the SAP HANA Repository via HTTP.

Change Tracking is integrated with the SAP HANA XS Repository transport tool set. For example, with change tracking enabled, you can ensure that an export operation includes only the latest approved versions of repository objects.

The information in this section describes how to use the REST API's Change Tracking API. Note that the API can only be used if change tracking is enabled in the SAP HANA system.

Contents

Change tracking

Display Change-Tracking Status

To obtain the current status of change tracking in the system, for example, enabled or disabled, you can send a GET request to the "change" entry point of the REST API. If the change tracking feature is enabled in the target system, the resulting response is true. If change tracking is disabled in the target system or not supported by the system, the response to the the GET status request is false.

Example Request

GET /sap/hana/xs/dt/change

Example Response

HTTP/1.1 200 OK


{
"ChangeTrackingStatus": true
}

Managing Change Lists

Create a Change List

A change list can be created for the current user by sending a POST request to the "change" entry point of the REST API. The response includes the ChangeID of the created list.

Example Request

POST /sap/hana/xs/dt/change

X-CSRF-Token: "65ABA3082325A3408FBE71C87929102B"

Example Response

HTTP/1.1 200 OK


{
"ChangeId":"ABC//1234"
}

Display Change List for a User

This request returns all change lists, for which the specified user is a contributor. By providing the optional parameter Status, you can ensure that the response includes the corresponding status for each change list displayed.

Example Request

GET /sap/hana/xs/dt/base/change

SapBackPack: {'User': 'XYZ', 'Status': 1}

Example Response

HTTP/1.1 200 OK


[
{
"changeID":"ABC//1234",
"status":1,
"description":"",
"createdOn":"2014-04-09T13:26:58.868Z",
"createdBy":"XYZ"
},
{
"changeID":"ABC//1235",
"status":1,
"description":"",
"createdOn":"2014-04-09T14:08:53.024Z",
"createdBy":"XYZ"
}
]

Tracking Objects

Display Status of a Single File

Individual files can either be assigned to a change list or not. The ChangeId associated with the change list is provided in the corresponding response parameter. If no change list exists, the value of ChangeID is null. In addition, the specified user can be either a contributor for the change list or not. If the user is a contributor to the specified list, the parameter User is included in the response; otherwise User is set to null.

Example Request

GET /sap/hana/xs/dt/base/change/MyProj/SomeFile.txt

Example Response

HTTP/1.1 200 OK


{
"ChangeId":"ABC//1234",
"User":"XYZ"
}

Display Status of Multiple Files

For requests to display the status of multiple files, you can group the files into the following sets:

  • Files not assigned to any change list
  • Files assigned to a change list, where the current user is a contributor
  • Files assigned to a change list, where the current user is NOT a contributor

All files included in the list are considered in the request.

Example Request

GET /sap/hana/xs/dt/base/change

SapBackPack: '{"MassTransfer":true, "MassTransferData": [{"Path":"MyProj/myfolder/destination1.txt"}, ...]}'

Example Response

HTTP/1.1 200 OK


{
"Unassigned":[{"Path":"MyProj/myfolder/destination1.txt", "ChangeId":null}],
"AssignedContributor":[{"Path":"MyProj/myfolder/destination2.txt", "ChangeId":"M17//1295"}],
"AssignedNotContributor":[]
}

Display Status of Multiple Files in a Package

For requests to display the status of multiple files included in a Repository package, you can group multiple files into the following sets:

  • Files not assigned to any change list
  • Files assigned to a change list, where the current user is a contributor
  • Files assigned to a change list, where the current user is NOT a contributor

All files in the package are considered in the request (recursively).

Example Request

GET /sap/hana/xs/dt/base/change/MyProj/myfolder

SapBackPack: '{"MassTransfer":true}'

Example Response

HTTP/1.1 200 OK


{
"Unassigned":[{"Path":"MyProj/myfolder/destination1.txt", "ChangeId":null}],
"AssignedContributor":[{"Path":"MyProj/myfolder/destination2.txt", "ChangeId":"M17//1295"}],
"AssignedNotContributor":[]
}