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

logger

JsonDict

_DEFAULT_NOTIFICATION_ENDPOINT

_DEFAULT_ORDER_ENDPOINT

Classes

SAPPMCMMSAdapter

Live SAP PM adapter — fetches Maintenance Notifications (CRs) and

Module Contents

src.dackar.RCA.cmms_integration.sap_pm_cmms_adapter.logger[source]
src.dackar.RCA.cmms_integration.sap_pm_cmms_adapter.JsonDict[source]
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.

base_url[source]
username[source]
password[source]
plant = None[source]
notification_endpoint = '/sap/opu/odata/sap/PMMAINTNOTIF_ODATA/MaintenanceNotificationSet'[source]
order_endpoint = '/sap/opu/odata/sap/API_MAINTORDER/MaintenanceOrderSet'[source]
timeout = 30[source]
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).

  1. 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}’

  2. GET {notification_endpoint}?$filter=…&$format=json

  3. GET {order_endpoint}?$filter=…&$format=json

  4. 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

  5. Set is_sister_equipment=True for records on sister equipment IDs.

  6. Return {“cr_records”: […], “wo_records”: […]}

Parameters:
  • primary_asset_id (str)

  • sister_component_ids (List[str])

  • lookback_from (str)

  • lookback_to (str)

  • event (JsonDict)

Return type:

JsonDict

_auth()[source]

Return (username, password) tuple for requests basic auth.

_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

static _map_status(sap_status)[source]

Map SAP user status codes to cmms_context schema values.

Delegates to the shared normalize_cmms_status() so Maximo, SAP, and generic codes normalize identically wherever a status enters.

Parameters:

sap_status (str)

Return type:

str