src.dackar.RCA.cmms_integration.sap_pm_cmms_adapter¶
sap_pm_cmms_adapter — SAPPMCMMSAdapter skeleton.
Implements CMMSContextAdapter for SAP Plant Maintenance using the SAP OData API (PM Maintenance Notifications / Orders). Plant teams fill in the connection details and field mappings. See CMMS_INTEGRATION_GUIDE.md §4 for the full implementation guide.
- Dependencies (not installed by default):
pip install requests
Attributes¶
Classes¶
Live SAP PM adapter — fetches Maintenance Notifications (CRs) and |
Module Contents¶
- src.dackar.RCA.cmms_integration.sap_pm_cmms_adapter._DEFAULT_NOTIFICATION_ENDPOINT = '/sap/opu/odata/sap/PMMAINTNOTIF_ODATA/MaintenanceNotificationSet'[source]¶
- src.dackar.RCA.cmms_integration.sap_pm_cmms_adapter._DEFAULT_ORDER_ENDPOINT = '/sap/opu/odata/sap/API_MAINTORDER/MaintenanceOrderSet'[source]¶
- class src.dackar.RCA.cmms_integration.sap_pm_cmms_adapter.SAPPMCMMSAdapter(base_url, username, password, plant=None, notification_endpoint=_DEFAULT_NOTIFICATION_ENDPOINT, order_endpoint=_DEFAULT_ORDER_ENDPOINT, timeout=30)[source]¶
Live SAP PM adapter — fetches Maintenance Notifications (CRs) and Maintenance Orders (WOs) via the SAP OData API.
- Parameters:
base_url (str) – SAP system base URL, e.g.
"https://sap.plant.corp".username (str) – SAP user name (basic auth).
password (str) – SAP password (basic auth). Consider using a service account with read-only PM authorisations.
plant (Optional[str]) – SAP plant code (e.g.
"1000").notification_endpoint (str) – OData path for maintenance notifications.
order_endpoint (str) – OData path for maintenance orders.
timeout (int) – HTTP request timeout in seconds.
- abstractmethod fetch(primary_asset_id, sister_component_ids, lookback_from, lookback_to, event)[source]¶
Fetch Maintenance Notifications and Orders from SAP PM.
TODO — plant teams implement: 1. Map sister_component_ids to SAP equipment IDs using the KG
sap_equipment_id property (same property used for CAP export).
- Build OData $filter (see
_build_odata_filter): Equipment in (‘EQ-001’,’EQ-002’) and MaintNotifCreationDate ge datetime’{lookback_from}’ and MaintNotifCreationDate le datetime’{lookback_to}’
- Build OData $filter (see
GET {notification_endpoint}?$filter=…&$format=json
GET {order_endpoint}?$filter=…&$format=json
- Map SAP field names to the cmms_context schema:
NotifNo → cr_id MaintNotifType → cr_type (e.g. M1, M2, M3, M4) UserStatus → status (see _map_status) Priority → priority ShortText → short_description LongText → long_text FunctLoc → functional_location Equipment → equipment_id MaintNotifCreationDate → created_date
Set is_sister_equipment=True for records on sister equipment IDs.
Return {“cr_records”: […], “wo_records”: […]}
- _build_odata_filter(equipment_ids, lookback_from, lookback_to)[source]¶
Build an OData $filter string for SAP PM notifications.
Note: SAP OData datetime literals use the format
datetime'2025-10-01T00:00:00'(no timezone — SAP uses plant local time by default).- Parameters:
equipment_ids (List[str])
lookback_from (str)
lookback_to (str)
- Return type:
str