Find the insights and best practices about our product.
🤖 Trackline – Proactive automation
🔎 SmartCheck – Digital evidence
🚀 Use cases by sector
Food sector
Construction sector
Industrial sector
Logistics sector
👤 Role based use cases
📊 Use cases by functionality
🤝🏻 Partners
Integration of Trackline with SAP

Integration of Trackline with SAP
Export documents and additional data from Trackline to SAP
Learn step by step how to integrate Trackline with SAP
Trackline is a functionality of the Code Contract platform that enables end-to-end automation of information collection, without changing the way you work and without requiring manual records.

If you want to integrate Trackline with SAP to retrieve documents and process data, follow these steps using JWT token authentication.

Step 1: Get the authentication token

SAP must authenticate to the Trackline API via a POST request to obtain a JWT token. This token will be used in subsequent requests.

Request from SAP (HTTP Request)

POST /login HTTP/1.1  
Host: api.codecontractplattform.com
Content-Type: application/json

{
"email": "sap_integration_user",
"password": "sap_secure_password"
}

Expected response

HTTP/1.1 200 OK  
Content-Type: application/json

{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmV..."
}

The token value must be stored in SAP and sent with each request as a Bearer Token in the authorization header.

Step 2: Query additional data and files in Trackline from SAP

Query additional process data

SAP can retrieve information about a specific process using process_id or process_name.

Request from SAP

GET /track-line/ext/track-path/metadata?process_id=12345 HTTP/1.1  
Host: eapi.codecontractplattform.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmV...

Expected response

{
"process_id": "12345",
"name": "SAP Billing Process",
"status": "In Progress",
"created_at": "2024-02-09T10:30:00Z",
"documents": [
{
"doc_id": "98765",
"doc_name": "Invoice_001.pdf",
"doc_type": "Invoice"
}
]
}

SAP can use this information to manage processes and documents automatically.

Download an attachment

Once metadata is obtained, SAP can download an attachment using its attachment_id.

Request from SAP

GET /track-line/ext/attachment/file?attachment_id=98765 HTTP/1.1  
Host: eapi.codecontractplattform.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmV...

Expected response (File)
The server will respond with a PDF, XML, or the appropriate format, which SAP can store or process.

SAP Integration (ABAP Code Example)

DATA: lv_url TYPE string,
lv_token TYPE string,
lo_http_client TYPE REF TO if_http_client,
lv_response TYPE string.

* 1. Get the authentication token
lv_url = 'https://api.codecontractplattform.com/api/login'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = lo_http_client.

lo_http_client->request->set_header_field( name = 'Content-Type' value = 'application/json' ).
lo_http_client->request->set_cdata( '{"email": "sap_integration_user", "password": "sap_secure_password"}' ).

CALL METHOD lo_http_client->send.
CALL METHOD lo_http_client->receive.

lv_response = lo_http_client->response->get_cdata( ).

* Extract token from response (simple example)
lv_token = 'extract_token_from_lv_response'.

* 2. Query additional process data in Trackline
CLEAR: lv_url.
lv_url = 'https://api.codecontractplattform.com/api/track-line/ext/track-path/metadata?process_id=12345'.

CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = lo_http_client.

lo_http_client->request->set_header_field( name = 'Authorization' value = |Bearer { lv_token }| ).

CALL METHOD lo_http_client->send.
CALL METHOD lo_http_client->receive.

lv_response = lo_http_client->response->get_cdata( ).

WRITE: / 'Response:', lv_response.

Summary

✔️ Step 1: SAP retrieves JWT Token via authentication.
✔️ Step 2: SAP queries process metadata with process_id.
✔️ Step 3: SAP downloads attachments via attachment_id.
✔️ Step 4: SAP can automate these processes using ABAP or another technology.

If you need more information or support, contact the Code Contract team. 🚀