Real-Time Vehicle Visualization in the TM Cockpit Map
When managing transportation resources in SAP Transportation Management (TM), planners often need to know where their vehicles are in real time. SAP TM offers a Transportation Cockpit where trucks and trailers can be planned, monitored and visualised on a map. However, showing live positions on the map requires more than just activating a feature – you need to feed TM with up‑to‑date latitude and longitude data for each vehicle.
This article explains how to implement a real‑time tracking solution in SAP TM. We will create an external API service that accepts location updates from a mobile app and writes them to the TM database table /SCMTMS/RES_POS
. Once this data is available, the TM Cockpit can display the current vehicle positions on its map. The steps below summarise the approach and show what needs to be configured.
How SAP TM stores vehicle positions
SAP TM uses the table /SCMTMS/RES_POS
to record the last location of each resource (vehicle). Each record stores the resource identifier, the timestamp of the last report, the latitude and longitude and other attributes such as the transportation activity. According to SAP’s documentation, the Transportation Activity code is maintained together with the resource in the last location table /SCMTMS/RES_POS
. This table is the basis for view resources on the map.
A summary of the key fields you will populate is shown below:
Field | Description |
---|---|
RESOURCE_ID | Identifier of the truck resource. |
UUID | Internal unique identifier of the resource. |
TIMESTAMP | Date and time of the last position update. |
RESOURCE_NAME | Descriptive name of the resource (vehicle). |
LONGITUDE | Longitude coordinate. |
LATITUDE | Latitude coordinate. |
LOCATION_UUID | Management unit/location identifier. |
LAST_REPORTED | Indicator that this is the most recent position. |
TRANS_ACTIVITY | Transportation activity code (e.g. “Loaded”, “Gate‑in”). |
Each time you receive a position update from a vehicle, you must write these fields (especially LATITUDE
, LONGITUDE
and TIMESTAMP
) to /SCMTMS/RES_POS
for that resource.
Building the external API service
- Create an ICF service or OData endpoint: In the SAP TM system, create a new Internet Communication Framework (ICF) service or OData service that can accept HTTP requests. This service will act as an API for external systems to update positions.
- Define the interface: The service should accept payloads containing the resource identifier, latitude, longitude and optionally the transportation activity. For example:
{
"resourceId": "CAM-0255",
"latitude": -23.5000,
"longitude": -46.6000,
"activity": "LOADED"
}
- Implement the logic: Inside the service implementation, read the payload and update table
/SCMTMS/RES_POS
. If a record for the resource already exists, update theLONGITUDE
,LATITUDE
,TIMESTAMP
andLAST_REPORTED
fields. If not, insert a new record. Also updateTRANS_ACTIVITY
if you need to track activities (such asLOADED
,GATE-IN
orUNLOADED
). - Security and authorisation: Use basic authentication or OAuth to protect the service. Restrict it to the transport companies or driver apps that are allowed to send location data.
Updating positions from the driver’s mobile app
To provide real‑time positions, you need an application running on the driver’s mobile phone. In the project implemented by the author, the application from www.portaldotransportador.com was used. This app runs in the background on the driver’s phone and sends the current latitude and longitude every minute while the vehicle is working. Here is what you need to do:
- Integrate the app with your API: Configure the app to call the API endpoint you created in SAP TM. Each minute (or an appropriate interval) the app should send the vehicle’s identifier and its current coordinates.
- Work schedule: To avoid unnecessary updates outside working hours, the app should only send updates when the vehicle is on duty. You can achieve this by enabling and disabling the background service based on the driver’s schedule.
- Error handling: Make sure the app handles network errors gracefully and retries failed requests.
With this setup, SAP TM will receive a stream of position updates and will continually overwrite the last reported location for each vehicle.
Displaying vehicles on the Cockpit map
Once location updates are available in /SCMTMS/RES_POS
, the Transportation Cockpit can show them on its map. Follow these steps:
- Open the Cockpit: Go to the Transportation Cockpit and choose the view that contains your trucks.
- Select vehicles: In the Trucks tab, select the vehicles you want to display on the map.
- Choose “Update Map”: Click the Update Map button. The system reads the last positions from
/SCMTMS/RES_POS
and plots each selected vehicle on the map. - Verify positions: The vehicles should now appear at their last reported locations. The map will refresh based on the positions stored in the table.
Below you can see how the Cockpit looks before and after loading the positions:
Before selecting vehicles and updating the map
Figure 1: Truck list in the Transportation Cockpit before updating the map. No markers are shown on the map.
After selecting vehicles and updating the map
Figure 2: After selecting trucks and clicking “Update Map”. Each vehicle is displayed on the map at its last reported location.
Tips for a smooth implementation
- Data frequency vs. performance: Updating positions every minute provides excellent accuracy but increases the database writes and network traffic. Adjust the interval based on your business needs and system capacity.
- Use proper time zones: Always store timestamps in a standard format (UTC) and convert them to the user’s time zone in the UI. This ensures the “last updated” information is accurate.
- Transportation activity codes: If you want to colour-code or filter vehicles by their status (e.g. “Loaded” vs “Unloaded”), maintain the
TRANS_ACTIVITY
field accordingly. - Clean up old records: Consider scheduling a job to archive or delete outdated entries from
/SCMTMS/RES_POS
to keep the table small and performant.
Conclusion
By integrating a mobile tracking app with a custom API service in SAP TM, you can visualize the live positions of your vehicles in the Transportation Cockpit. The key is to update the table /SCMTMS/RES_POS with latitude, longitude and timestamp values for each vehicle. Once the data is in place, the Cockpit’s Update Map function displays the current positions in real time. With this visibility, planners can track vehicles live and proactively adjust routes or assignments, resulting in more efficient and informed planning decisions.