# Master Data Integration and the One Domain Model: sharing master data across SAP's cloud

> Decide when SAP Master Data Integration should carry cost centers, partners and workforce data between SAP systems, and how it meets Master Data Governance.

- Course: Orchestrate, Unit 26 · Integration in depth
- Page: https://erpfde.com/topics/master-data-integration-and-one-domain-model/
- Updated: 2026-11-30
- Reading time: Foundational 8 min, Deep 35 min

Independent learning resource. Not affiliated with, sponsored by or endorsed by SAP SE. SAP and other SAP products mentioned are trademarks of SAP SE in Germany and other countries.

## Foundational layer

### The 60-second version

Every SAP cloud application keeps its own copy of some master data. SuccessFactors needs cost centers to assign people. A field service app needs customers and their addresses. S/4HANA needs the people who record time. Someone has to keep those copies the same.

**SAP Master Data Integration (MDI)** is SAP's service on SAP Business Technology Platform (BTP) for that job. It is a hub: one system sends each change in, and the hub hands it to the systems that need it. SAP's training says it covers initial loads, ongoing synchronization, control over which data goes where, and monitoring ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution)).

The hub speaks one language: the **SAP One Domain Model (ODM)**, SAP's shared definition of objects such as business partner, cost center and workforce person. Only objects defined in ODM travel through MDI (same page).

MDI moves data; it doesn't clean it, merge duplicates or approve changes. That is **SAP Master Data Governance (MDG)**'s work (same page). The decision for a leader: **use MDI for the standard master data flows between SAP's applications, keep governance in MDG or your own process, and give every flow one source system and one owner.**

This topic continues with the course's fictional company, **Calder Pumpworks**.

### Why it matters to the business

Master data copies drift. When they do, the cost lands in other departments, usually weeks later.

Calder has a live example from the [hire-to-retire topic](https://erpfde.com/topics/hire-to-retire-touchpoints/) (course values). Its rework area cost center `CP11-435` closed on 30 September 2026. The nightly file that sends cost centers to the HR system last ran on 14 September, and nobody noticed it had stopped. On 19 October HR hired a technician onto the closed cost center, and S/4HANA refused the assignment. October payroll held 7,350.00 USD of wages charged to the closed cost center until someone fixed it.

What a hub changes:

- **Fewer interfaces to build and watch.** Each application connects to the hub once, instead of to every other application.
- **Missed changes are caught up.** Consumers ask the hub for everything since their last read, so an outage delays changes instead of losing them.
- **One rule for who owns what.** A distribution model says which system provides an object and which systems receive it, with filters on records and fields.
- **Lower cost between SAP cloud products.** An SAP field service blog post describes MDI as commercially free for integration between SAP-branded cloud solutions ([SAP Community](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136)). Confirm your own terms with SAP.

What it doesn't change: bad data in the source stays bad in every copy, only faster.

### How SAP does it

As of 30 November 2026, from SAP's pages:

- **SAP Master Data Integration** runs on SAP BTP. SAP's lesson says there is exactly one MDI tenant per landscape, that applications sync their local master data with it, and that it offers a REST events API with initial and delta loads, plus SOAP for business partners ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution)).
- **Distribution models** are kept in a separate BTP subscription, which the lesson calls Business Data Orchestration and its help links call SAP Master Data Orchestration (same page). Keep the two apart in plans and tickets: they are configured separately.
- **Which products use it.** SAP's pages name SuccessFactors Employee Central (cost centers and workforce data), SAP Field Service Management (business partners, products, equipment, workforce), SAP Ariba and SAP Fieldglass ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution), [SAP Community](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136)).
- **Cost centers to SuccessFactors.** For S/4HANA 2025, SAP deprecated the software component behind the older point-to-point Cloud Integration flows and "strongly recommends" MDI for new implementations and upgrades ([SAP KBA 3727053](https://userapps.support.sap.com/sap/support/knowledge/en/3727053)).
- **Not for ECC.** SAP's MDG FAQ says SAP ECC is not included and SAP doesn't intend to invest in old releases with MDI ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)).
- **Master Data Governance.** MDG on S/4HANA replicates with its Data Replication Framework; the BTP-based MDG, cloud edition replicated through MDI ([sap.com](https://www.sap.com/products/data-cloud/master-data-governance/pricing.html)). SAP's FAQ now says SAP is discontinuing the cloud edition: no renewals, existing subscriptions honored to contract end ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)). The page gives no date.
- **Reltio.** SAP completed its acquisition of Reltio, a master data management provider, on 7 May 2026, filed under SAP Business Data Cloud ([SAP News](https://news.sap.com/2026/05/sap-completes-acquisition-of-reltio/)). The announcement doesn't mention MDI or ODM, so don't assume a link yet.

> **Note** **For functional consultants.** Master data replication changes three things in your work. **Configuration:** a distribution model and its filters decide which cost centers, partners and fields reach each application; they belong in your design, next to the organization structure. **Test cases:** add a closed cost center, a partner changed in the wrong system, and a consumer that was offline for a week. **Data ownership:** each object has one providing system, so a change made in the receiving system is either refused or overwritten. Tell the users which screen is the real one.

### Choosing the route: a decision guide

| Question | If yes | If no |
| --- | --- | --- |
| Are both ends SAP cloud applications or S/4HANA, and is the object in ODM? | MDI is the first choice | Cloud Integration or another route |
| Is the source ECC? | Not MDI; use ALE, Cloud Integration, or wait for the move to S/4HANA | Continue |
| Do you need fields outside ODM, or to change values on the way? | A second route for those fields; MDI doesn't offer field or value mapping ([SAP Community](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136)) | MDI alone |
| Is it really master data? Prices and stock are not | Cloud Integration or an API | Continue |
| Must duplicates be merged or changes approved first? | MDG in front, MDI after it | MDI from the source system |
| Can more than one system edit the object? | Pick one provider; others request changes there | One provider |

### Questions to ask

1. Which master data objects travel between our SAP applications today, by which route, and who notices when a feed stops?
2. Which of these flows does SAP now cover with MDI, and which of our point-to-point flows has SAP deprecated, as with cost centers in S/4HANA 2025?
3. For each object, which system is the provider? Are users still allowed to edit it anywhere else?
4. Which records and fields does each receiving application really need? Do bank details or personal data travel where they shouldn't?
5. Do we need fields that ODM doesn't cover? What carries them, and who owns that second route?
6. Do we have separate MDI tenants for test and production, and who watches the monitoring?
7. Does our plan depend on MDG, cloud edition? What does our account team propose instead?
8. What are our contract terms for MDI between SAP products, and for any non-SAP application we connect?

### Common misconceptions

- **"MDI is a master data management system."** It moves records. Consolidation, data quality and central governance are outside its scope ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution)).
- **"Any system can feed the hub."** For distribution models, SAP's lesson says only ABAP-based systems such as S/4HANA act as providers (same page).
- **"ODM covers every field."** It covers a shared core. SAP's FAQ says attributes outside it need custom expansions or other mechanisms ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)).
- **"It will connect our ECC too."** SAP's FAQ says ECC is not included (same page).
- **"Two sources are safer than one."** Two providers for the same object to the same consumer means whichever writes last wins. SAP's lesson recommends one provider per consumer.

### Key terms

- **SAP Master Data Integration (MDI):** SAP's BTP service that replicates master data between applications through one hub.
- **SAP One Domain Model (ODM):** SAP's shared definition of business objects that applications map their own objects to.
- **Provider:** the system that sends an object's changes to the hub.
- **Consumer:** a system that receives an object's changes from the hub.
- **Distribution model:** the rule that connects a provider to a consumer for one object type, with its filters.
- **Object selection filter:** decides which records reach a consumer.
- **Data scope filter:** decides which parts of a record reach a consumer.
- **Delta load:** a request for every change since the consumer's last read.
- **Key mapping:** the link between the IDs that different systems give the same record.
- **SAP Master Data Governance (MDG):** SAP's product for creating, approving, consolidating and checking master data.

### Check yourself

1. What does SAP Master Data Integration do?
   - A. It merges duplicate records and approves master data changes
   - B. It replicates master data between applications through one hub
   - C. It stores the company's only copy of all master data
   - D. It cleans addresses and tax numbers before records are saved

   Answer: B. SAP's lesson describes MDI as a hub for initial loads, ongoing sync, control over distribution and monitoring. Consolidation, quality and central governance are outside its scope and belong to MDG.

2. Calder's cost center feed to HR stopped on 14 September. What would a hub with delta loads have changed?
   - A. HR would have received a fresh full file every night
   - B. S/4HANA would have reopened the closed cost center
   - C. HR would have caught up on missed changes after the outage
   - D. The hire would have been approved by finance automatically

   Answer: C. A consumer asks the hub for every change since its last read, so an outage delays changes instead of losing them. The closure of CP11-435 would have reached HR before the hire.

3. Calder's Augsburg company still runs ECC until July 2027. Which plan for its master data fits SAP's position?
   - A. Connect the ECC system to MDI as a second provider now
   - B. Use MDI for Augsburg after installing the ODM model in ECC
   - C. Move Augsburg's cost centers through MDI by file upload
   - D. Use another route until Augsburg moves into S/4HANA

   Answer: D. SAP's MDG FAQ says ECC is not included in MDI and SAP doesn't plan to invest there. Augsburg's flows keep their current route and move to MDI with the rollout.

4. Sales wants the CRM and S/4HANA to both send customer changes to the hub. What should you ask?
   - A. Whether the CRM can send its changes in real time
   - B. Which one system owns customer data for each consumer
   - C. Whether both systems can use the same MDI instance
   - D. How many customers the hub can store at once

   Answer: B. Two providers for the same object let the last writer win, so an old copy can overwrite a fresh change. SAP recommends one provider per consumer; the other system requests changes in the owning one.

5. A field service app needs a custom field that ODM doesn't define. What does SAP's FAQ point to?
   - A. Waiting until SAP adds the field to the model
   - B. Storing the field in the hub as free text
   - C. A custom expansion or another replication mechanism
   - D. Copying the field by hand once a month

   Answer: C. SAP's FAQ says attributes outside ODM need custom expansions or other mechanisms. In practice that is a second, owned route, such as a Cloud Integration flow.

6. Your plan relies on SAP Master Data Governance, cloud edition. What is the risk?
   - A. It works only with ECC systems and not S/4HANA
   - B. It replicates through IDocs, which MDI can't read
   - C. It requires a separate MDI tenant for each user
   - D. SAP is discontinuing it, with no renewals

   Answer: D. SAP's MDG FAQ says the BTP-based cloud edition is being discontinued: renewals aren't possible and existing subscriptions run to contract end. Ask your account team what replaces it in your plan.

## Deep layer

### Mental model

Think of MDI as a **change log with a switchboard**.

1. **The change log.** A provider writes each change to the hub. A consumer reads the log from where it last stopped, using a delta load. The hub doesn't care when the consumer reads, so an outage is a delay, not a loss.
2. **The switchboard.** A distribution model decides which provider's changes go to which consumer for one object, and filters records and fields on the way.
3. **The shared vocabulary.** Everything in the log is shaped as ODM, so each application maps its own object to ODM once, not to every partner.

What it is not: a place to edit data, a quality gate, or a mapping engine. Governance sits in front of it, and anything outside ODM goes around it.

### How it works

#### The hub and its clients

SAP's lesson describes the moving parts ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution)):

| Part | What it does | Architect's concern |
| --- | --- | --- |
| MDI tenant | The hub; SAP says exactly one per landscape | Calder reads "landscape" as one stage: one tenant for test, one for production |
| Clients | Connected applications, each with its own service instance | An SAP blog's setup FAQ says one instance per connected business application, plus one for configuration ([SAP Community](https://community.sap.com/t5/technology-blog-posts-by-sap/sap-master-data-integration-mdi-services-set-up-faqs/ba-p/13493632)) |
| REST events API | Initial load, then delta loads that return all changes since the last call | Consumers keep their own position in the log |
| SOAP APIs | For business partners and their relationships | The same FAQ said SOAP covers business partner and product only, as of 2021; other objects use REST |
| Initial load | Initial upload by providers, initial download by consumers | Plan it like a migration: volumes, order, a reconciliation |
| Monitoring | Part of the service | Needs an owner per tenant |

```mermaid
flowchart LR
  S4P[S/4HANA CP10<br/>provider] -->|changes| MDI[MDI tenant<br/>change log + key mapping]
  SFEC[SuccessFactors EC] -->|workforce| MDI
  MDO[Orchestration<br/>distribution models] -.rules.-> MDI
  MDI -->|cost centers| SFEC
  MDI -->|partners, equipment| FSM[Field Service<br/>Management]
  MDI -->|workforce| S4P
```

#### Distribution models, filters and push or pull

A distribution model has a name, a description, an object type and version, and connects providers to consumers. Activating it replicates it to the clients. The rules from SAP's lesson (same page):

- **Only ABAP-based systems, such as S/4HANA or MDG cloud edition, act as providers** for distribution models.
- **One provider to one consumer** is recommended.
- **Object selection filters** decide which records go to a consumer; **data scope filters** decide which parts of each record go.
- **Push** means the provider sends changes and the consumer acknowledges them; **pull** means the consumer runs a scheduler and asks.

An SAP blog on business partner setup lists the BTP roles that maintain models, collected into a role collection for orchestration administrators ([SAP Community](https://blogs.sap.com/2021/03/09/configuring-sap-master-data-integration-for-business-partners-replication/)). Treat model changes like configuration changes: transported or at least reviewed, not edited live in production.

#### The One Domain Model

ODM is the model that applications map their own objects to; SAP's MDG FAQ calls it the "lingua franca" across applications ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)). Its identity rules are written down in SAP's ODM vocabulary for OData ([SAP on GitHub](https://sap.github.io/odata-vocabularies/vocabularies/ODM.html)):

| Term | Meaning |
| --- | --- |
| `root` | Marks an entity type as an ODM root entity, with its own identity and lifetime |
| `oid` | Names the field holding the ODM identifier, which identifies a root entity in a customer landscape; it must be stable and unique at least within its type and landscape |
| `entityName` | Names the ODM concept without a version, so consumers can find APIs for the same entity |
| `codeList`, `oidReference` | Code lists and references to other entities; marked experimental |

The OID is why key mapping works. S/4HANA numbers a customer `10000002`; Field Service Management numbers it its own way; both point at the same OID. The business partner setup blog shows dedicated key mapping SOAP services that carry these links back and forth ([SAP Community](https://blogs.sap.com/2021/03/09/configuring-sap-master-data-integration-for-business-partners-replication/)).

ODM is a core, not everything. SAP's FAQ says attributes outside it need custom expansions or other mechanisms ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)), and the MDG pricing page describes the cloud edition's model as ODM with "core attributes only" ([sap.com](https://www.sap.com/products/data-cloud/master-data-governance/pricing.html)).

#### The S/4HANA side

S/4HANA sends master data to MDI through the **Data Replication Framework (DRF)**, the same framework MDG uses. A 2022 SAP Community walkthrough for cost centers to Employee Central shows the shape ([SAP Community](https://blogs.sap.com/2022/01/31/step-by-step-for-setting-up-the-cost-center-replication-from-s-4hana-to-sap-successfactors-employee-central-using-the-sap-btp-master-data-integration-service/)):

1. Create one MDI instance for S/4HANA and one for Employee Central, with service keys.
2. In S/4HANA, create the HTTP destinations, run report `FI_CCTR_SETUP_DESTINATION` and maintain the OAuth profile `FIN_CO_CCTR`.
3. In `DRFIMG`, define a business system for MDI and a replication model (the post calls it `MDI_CC`) with the outbound implementation `FI_CO_CCTR`, then activate it.
4. In Employee Central's Security Center, create the OAuth configuration and point the cost center scenario at MDI.

Check the current guide for your release before you follow these steps: the post is from 2022.

#### When MDI and when Cloud Integration

SAP's field service post compares the two for S/4HANA Cloud to Field Service Management ([SAP Community](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136)):

| Object or need | MDI | Cloud Integration |
| --- | --- | --- |
| Business partner, contacts, products, product groups | Yes | Yes |
| Workforce person | Yes | No |
| Equipment and functional locations | Yes | Through another route, delta only |
| Product price, product stock | No | Yes |
| Field or value mapping changes | Not offered | In the flow |
| Many SAP applications in the landscape | Hub and spoke, the post's strategic choice | Point to point |

For cost centers to Employee Central, SAP's support article settles it from S/4HANA 2025: the software component under the point-to-point flows is deprecated, MDI is the primary route, and the flows stay only as a temporary fallback ([SAP KBA 3727053](https://userapps.support.sap.com/sap/support/knowledge/en/3727053)).

### Build it yourself: review Calder's master data distribution design

You will run a small lab with two parts. **Review** checks a design of Calder's MDI tenants, clients and flows against eleven course rules. **Simulate** shows, with a stand-in hub, why three of them exist: delta loads, one provider, and filters with key mapping.

```mermaid
flowchart LR
  I[--init] --> D[design_draft.json]
  I --> V[design_reviewed.json]
  D --> R[review: rules MD01-MD11]
  V --> R
  R --> OUT[verdict per flow:<br/>FIX or KEEP]
  S[simulate delta, providers, filters] --> W[why the rules exist]
```

**Before you start:** complete [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/) and [Set up for Unit 26](https://erpfde.com/topics/set-up-for-unit-26/). This walkthrough needs none of the setup's trials.

> **Note** New words. **JSON** is a text format for structured data. A **design file** lists the hub's tenants, the connected applications (clients) and the flows (distribution models); its layout is the course's, not an SAP format. A **stand-in** is a few lines of Python that imitate the behavior SAP describes; it is not SAP software. A **delta token** is the consumer's bookmark in the change log. **Exit code** is the number a program returns; `2` here means at least one rule failed.

> **Warning** The rule IDs `MD01` to `MD11`, the objects in scope, instance names, streets and values are course labels. The rules follow SAP's pages where the table in Step 4 says so; the rest are course rules.

#### What you need

- Python and your `orchestrate-course` folder with its `.venv`, from the setup topic.
- No account, no network and no extra libraries. The script uses built-in modules only and has no randomness, so your output matches the samples exactly.
- About 35 minutes. Everything is free.

#### Step 1: Open the course folder and turn on the virtual environment

1. Open VS Code, choose **File > Open Folder**, and open `orchestrate-course`.
2. Open a terminal: **Terminal > New Terminal**.
3. If the prompt doesn't start with `(.venv)`, turn it on:

   - **Windows (PowerShell):**

     ```powershell
     .venv\Scripts\Activate.ps1
     ```

   - **macOS / Linux:**

     ```bash
     source .venv/bin/activate
     ```

4. Create the unit folder if it doesn't exist yet:

   - **Windows (PowerShell):**

     ```powershell
     New-Item -ItemType Directory -Force unit26
     ```

   - **macOS / Linux:**

     ```bash
     mkdir -p unit26
     ```

#### Step 2: Create the script

1. In VS Code, create a new file `unit26/mdi_lab.py`.
2. Paste the code below and save.

```python
"""Review a master data distribution design and see why the rules exist.

Course lab for Unit 26, "Master Data Integration and the One Domain Model".
Built-in modules only, no randomness, no network, no SAP system.

  python unit26/mdi_lab.py --init              write the sample designs
  python unit26/mdi_lab.py review              review unit26/mdi/design_draft.json
  python unit26/mdi_lab.py review --file unit26/mdi/design_reviewed.json
  python unit26/mdi_lab.py simulate delta      nightly file versus a change log with a delta token
  python unit26/mdi_lab.py simulate providers  one provider versus two for the same object
  python unit26/mdi_lab.py simulate filters    selection and scope filters, and key mapping
  python unit26/mdi_lab.py --self-test         check the built-in samples

Rule IDs, objects in scope, names and values are course labels, not SAP
formats. The hub here is a stand-in, not SAP Master Data Integration.
"""

import argparse
import copy
import json
import sys
import uuid
from pathlib import Path

FOLDER = Path("unit26") / "mdi"
AS_OF = "2026-11-30"

# Objects the course treats as in scope for the hub, after SAP's pages
# (business partner, cost center, plant, product, workforce person,
# equipment and functional location are named there). A course list.
IN_SCOPE = {
    "Business partner", "Business partner relationship", "Cost center",
    "Plant", "Product", "Product group", "Workforce person",
    "Equipment", "Functional location",
}
ABAP_KINDS = {"s4hana", "mdg"}
SENSITIVE = {"Business partner": "bank details"}
OUTSIDE = {"cloud", "third-party"}

DRAFT = {
    "company": "Calder Pumpworks (fictional)",
    "as_of": AS_OF,
    "tenants": [
        {"id": "calder-mdi", "subaccount": "calder-int-prod", "stages": ["test", "prod"],
         "monitor_owner": None},
    ],
    "clients": [
        {"id": "S4P", "app": "S/4HANA CP10 production", "kind": "s4hana", "stage": "prod",
         "tenant": "calder-mdi", "instance": "mdi-s4"},
        {"id": "S4Q", "app": "S/4HANA CP10 quality", "kind": "s4hana", "stage": "test",
         "tenant": "calder-mdi", "instance": "mdi-s4"},
        {"id": "ECP", "app": "ECC CP20 production", "kind": "ecc", "stage": "prod",
         "tenant": "calder-mdi", "instance": "mdi-ecc"},
        {"id": "SF-EC", "app": "SuccessFactors Employee Central", "kind": "cloud", "stage": "prod",
         "tenant": "calder-mdi", "instance": "mdi-cloud"},
        {"id": "FSM", "app": "SAP Field Service Management", "kind": "cloud", "stage": "prod",
         "tenant": "calder-mdi", "instance": "mdi-cloud"},
        {"id": "CRM", "app": "CRM (non-SAP)", "kind": "third-party", "stage": "prod",
         "tenant": "calder-mdi", "instance": "mdi-crm"},
    ],
    "models": [
        {"id": "DM01", "object": "Cost center", "provider": "S4P", "consumer": "SF-EC",
         "via": "distribution model", "selection": None, "scope": None, "owner": "00100312"},
        {"id": "DM02", "object": "Cost center", "provider": "ECP", "consumer": "SF-EC",
         "via": "distribution model", "selection": None, "scope": None, "owner": "00100312"},
        {"id": "DM03", "object": "Workforce person", "provider": "SF-EC", "consumer": "S4P",
         "via": "direct", "selection": None, "scope": None, "owner": "00100306"},
        {"id": "DM04", "object": "Business partner", "provider": "S4P", "consumer": "FSM",
         "via": "distribution model", "selection": "role customer", "scope": None, "owner": None},
        {"id": "DM05", "object": "Business partner", "provider": "CRM", "consumer": "FSM",
         "via": "distribution model", "selection": None, "scope": None, "owner": "00100296"},
        {"id": "DM06", "object": "Product price", "provider": "S4P", "consumer": "FSM",
         "via": "distribution model", "selection": None, "scope": None, "owner": "00100315"},
    ],
    "extra_fields": [
        {"object": "Business partner", "field": "test certificate e-mail", "needed_by": "FSM",
         "route": None},
    ],
}


def reviewed_design():
    d = copy.deepcopy(DRAFT)
    d["tenants"] = [
        {"id": "calder-mdi-test", "subaccount": "calder-int-test", "stages": ["test"],
         "monitor_owner": "00100292"},
        {"id": "calder-mdi-prod", "subaccount": "calder-int-prod", "stages": ["prod"],
         "monitor_owner": "00100292"},
    ]
    d["clients"] = [
        {"id": "S4P", "app": "S/4HANA CP10 production", "kind": "s4hana", "stage": "prod",
         "tenant": "calder-mdi-prod", "instance": "mdi-s4p"},
        {"id": "S4Q", "app": "S/4HANA CP10 quality", "kind": "s4hana", "stage": "test",
         "tenant": "calder-mdi-test", "instance": "mdi-s4q"},
        {"id": "SF-EC", "app": "SuccessFactors Employee Central", "kind": "cloud", "stage": "prod",
         "tenant": "calder-mdi-prod", "instance": "mdi-sfec"},
        {"id": "FSM", "app": "SAP Field Service Management", "kind": "cloud", "stage": "prod",
         "tenant": "calder-mdi-prod", "instance": "mdi-fsm"},
        {"id": "CRM", "app": "CRM (non-SAP)", "kind": "third-party", "stage": "prod",
         "tenant": "calder-mdi-prod", "instance": "mdi-crm"},
    ]
    d["models"] = [
        {"id": "DM01", "object": "Cost center", "provider": "S4P", "consumer": "SF-EC",
         "via": "distribution model", "selection": "company code CP10", "scope": None,
         "owner": "00100312"},
        {"id": "DM03", "object": "Workforce person", "provider": "SF-EC", "consumer": "S4P",
         "via": "direct", "selection": None, "scope": None, "owner": "00100306"},
        {"id": "DM04", "object": "Business partner", "provider": "S4P", "consumer": "FSM",
         "via": "distribution model", "selection": "role customer, not intercompany",
         "scope": "without bank details", "owner": "00100250"},
        {"id": "DM05", "object": "Business partner", "provider": "S4P", "consumer": "CRM",
         "via": "distribution model", "selection": "role customer",
         "scope": "without bank details", "owner": "00100250"},
    ]
    d["extra_fields"] = [
        {"object": "Business partner", "field": "test certificate e-mail", "needed_by": "FSM",
         "route": "Cloud Integration flow, owner 00100292"},
    ]
    d["retired"] = [
        {"id": "DM02", "why": "ECC is not connected; CP20's cost centers move with the July 2027 rollout"},
        {"id": "DM06", "why": "prices are not master data in the hub; Cloud Integration flow instead"},
    ]
    return d


def check(design):
    """Return a list of (scope, rule, status, text)."""
    out = []
    clients = {c["id"]: c for c in design["clients"]}
    tenants = {t["id"]: t for t in design["tenants"]}
    # MD01 one tenant per landscape (stage), and every client in its stage's tenant
    stage_tenants = {}
    for t in design["tenants"]:
        for s in t["stages"]:
            stage_tenants.setdefault(s, []).append(t["id"])
        if len(t["stages"]) > 1:
            out.append((t["id"], "MD01", "FAIL", f"one tenant serves {', '.join(t['stages'])}"))
        else:
            out.append((t["id"], "MD01", "OK", f"tenant for {t['stages'][0]} only"))
        if t.get("monitor_owner"):
            out.append((t["id"], "MD10", "OK", f"monitoring owner {t['monitor_owner']}"))
        else:
            out.append((t["id"], "MD10", "FAIL", "nobody owns the tenant's monitoring"))
    # MD02 one instance per connected application; MD03 no ECC
    seen = {}
    for c in design["clients"]:
        seen.setdefault(c["instance"], []).append(c["id"])
    for c in design["clients"]:
        share = seen[c["instance"]]
        if len(share) > 1:
            out.append((c["id"], "MD02", "FAIL", f"instance {c['instance']} shared with "
                        + ", ".join(x for x in share if x != c["id"])))
        else:
            out.append((c["id"], "MD02", "OK", f"own instance {c['instance']}"))
        if c["kind"] == "ecc":
            out.append((c["id"], "MD03", "FAIL", "ECC is not a supported client"))
        t = tenants.get(c["tenant"])
        if t and c["stage"] not in t["stages"]:
            out.append((c["id"], "MD01", "FAIL", f"{c['stage']} client in a tenant for "
                        + ", ".join(t["stages"])))
    # Models
    pairs = {}
    for m in design["models"]:
        pairs.setdefault((m["object"], m["consumer"]), []).append(m["provider"])
    for m in design["models"]:
        mid = m["id"]
        prov, cons = clients.get(m["provider"]), clients.get(m["consumer"])
        if m["object"] in IN_SCOPE:
            out.append((mid, "MD04", "OK", f"{m['object']} is in the hub's scope"))
        else:
            out.append((mid, "MD04", "FAIL", f"{m['object']} is not master data in the hub"))
        if m["via"] == "distribution model":
            if prov and prov["kind"] in ABAP_KINDS:
                out.append((mid, "MD05", "OK", f"provider {m['provider']} is ABAP-based"))
            else:
                out.append((mid, "MD05", "FAIL", f"provider {m['provider']} can't feed a distribution model"))
        if prov and prov["kind"] == "ecc":
            out.append((mid, "MD03", "FAIL", "provider is ECC"))
        provs = pairs[(m["object"], m["consumer"])]
        if len(provs) > 1:
            out.append((mid, "MD06", "FAIL", f"{m['consumer']} gets {m['object']} from "
                        + " and ".join(provs)))
        else:
            out.append((mid, "MD06", "OK", f"one provider for {m['object']} to {m['consumer']}"))
        if m.get("owner"):
            out.append((mid, "MD07", "OK", f"owner {m['owner']}"))
        else:
            out.append((mid, "MD07", "FAIL", "no owner"))
        if m["object"] in SENSITIVE and cons and cons["kind"] in OUTSIDE:
            if m.get("scope"):
                out.append((mid, "MD08", "OK", f"data scope: {m['scope']}"))
            else:
                out.append((mid, "MD08", "FAIL", f"{SENSITIVE[m['object']]} go to {m['consumer']}"))
        if m["via"] == "distribution model":
            if m.get("selection"):
                out.append((mid, "MD09", "OK", f"selection: {m['selection']}"))
            else:
                out.append((mid, "MD09", "WARN", "no selection filter: every record goes"))
    for f in design.get("extra_fields", []):
        key = f"{f['object']}.{f['field']}"
        if f.get("route"):
            out.append((key, "MD11", "OK", f"outside the model, route: {f['route']}"))
        else:
            out.append((key, "MD11", "FAIL", f"outside the model and no route to {f['needed_by']}"))
    return out


def review(path):
    design = json.loads(Path(path).read_text(encoding="utf-8"))
    print(f"{design['company']}: master data distribution design as of {design['as_of']}")
    for t in design["tenants"]:
        print(f"  tenant {t['id']} in {t['subaccount']} for {', '.join(t['stages'])}")
    print()
    results = check(design)
    order = [t["id"] for t in design["tenants"]] + [c["id"] for c in design["clients"]] \
        + [m["id"] for m in design["models"]] \
        + [f"{f['object']}.{f['field']}" for f in design.get("extra_fields", [])]
    models = {m["id"]: m for m in design["models"]}
    for scope in order:
        rows = [r for r in results if r[0] == scope]
        if not rows:
            continue
        if scope in models:
            m = models[scope]
            print(f"{scope} {m['object']}: {m['provider']} -> {m['consumer']} ({m['via']})")
        else:
            print(scope)
        for _, rule, status, text in rows:
            print(f"  {status:<4} {rule} {text}")
        if scope in models:
            bad = any(r[2] == "FAIL" for r in rows)
            print(f"    verdict {'FIX' if bad else 'KEEP'}")
    for r in design.get("retired", []):
        print(f"{r['id']} retired: {r['why']}")
    counts = {s: sum(1 for r in results if r[2] == s) for s in ("OK", "WARN", "FAIL")}
    print()
    print(f"{counts['OK']} OK, {counts['WARN']} WARN, {counts['FAIL']} FAIL "
          f"across {len(design['models'])} flows")
    return 2 if counts["FAIL"] else 0


# ---------- simulations ----------

COST_CENTER_LOG = [
    # (sequence, timestamp, cost center, change)
    (1, "2026-09-14 08:00", "CP11-300", {"name": "Purchasing", "valid_to": None}),
    (2, "2026-09-30 17:00", "CP11-435", {"name": "Rework area", "valid_to": "2026-09-30"}),
    (3, "2026-10-12 10:00", "CP11-460", {"name": "Utilities", "valid_to": None}),
]
START = {"CP11-300": {"name": "Purchasing", "valid_to": None},
         "CP11-410": {"name": "Assembly", "valid_to": None},
         "CP11-420": {"name": "Test bench", "valid_to": None},
         "CP11-435": {"name": "Rework area", "valid_to": None}}


def hire(copy_of, cc, day):
    rec = copy_of.get(cc)
    if rec is None:
        return f"refused: {cc} unknown in HR"
    if rec["valid_to"] and rec["valid_to"] < day:
        return f"refused at entry: {cc} closed {rec['valid_to']}"
    return f"accepted on {cc} (HR thinks it is open)"


def state(hr):
    v = hr["CP11-435"]["valid_to"]
    return f"closed {v}" if v else "open"


def sim_delta():
    print("Cost centers from S4P to SuccessFactors Employee Central (course values).")
    print("Change log in S4P:")
    for seq, ts, cc, ch in COST_CENTER_LOG:
        what = f"closed {ch['valid_to']}" if ch["valid_to"] else "changed or created"
        print(f"  {seq} {ts} {cc} {ch['name']} {what}")
    print()
    # 1. nightly full file whose job last ran 2026-09-14
    hr = copy.deepcopy(START)
    for seq, ts, cc, ch in COST_CENTER_LOG:
        if ts[:10] <= "2026-09-14":
            hr[cc] = dict(ch)
    print("1. Nightly file, job last ran 2026-09-14 01:00 (nobody noticed):")
    print(f"   HR copy: {len(hr)} cost centers, CP11-435 {state(hr)}")
    print(f"   2026-10-19 hire 00100231 on CP11-435: {hire(hr, 'CP11-435', '2026-10-19')}")
    print("   later: S/4HANA refuses the payroll posting on the closed cost center")
    # 2. delta with token, consumer down 2026-09-28 to 2026-10-08
    hr = copy.deepcopy(START)
    token = 0
    print("2. Change log with a delta token; Employee Central's pull is down 2026-09-28 to 2026-10-08:")
    for day in ("2026-09-14", "2026-09-27", "2026-10-08", "2026-10-15"):
        new = [e for e in COST_CENTER_LOG if e[0] > token and e[1][:10] <= day]
        for seq, ts, cc, ch in new:
            hr[cc] = dict(ch)
            token = seq
        if new:
            print(f"   {day} pull from token {new[0][0] - 1}: {len(new)} change(s), token now {token}")
        else:
            print(f"   {day} pull from token {token}: nothing new")
    print(f"   HR copy: {len(hr)} cost centers, CP11-435 {state(hr)}")
    print(f"   2026-10-19 hire 00100231 on CP11-435: {hire(hr, 'CP11-435', '2026-10-19')}")
    return 0


def sim_providers():
    print("Hallam Fluid Systems (10000002) moves its receiving dock (course values).")
    events = [
        ("2026-11-02 09:00", "S4P", "455 Canal Street", "customer service changes the ship-to street"),
        ("2026-11-02 22:00", "CRM", "1200 Mill Road", "CRM's nightly sync sends its older copy"),
    ]
    for label, providers in (("Two providers (S4P and CRM):", {"S4P", "CRM"}),
                             ("One provider (S4P); the CRM only consumes:", {"S4P"})):
        print(label)
        street = "1200 Mill Road"
        for ts, src, value, why in events:
            if src in providers:
                street = value
                print(f"  {ts} {src}: {why} -> hub has {street}")
            else:
                print(f"  {ts} {src}: {why} -> refused, {src} is not a provider")
        print(f"  2026-11-03 07:30 FSM sends the technician to {street}")
    return 0


PARTNERS = [
    {"id": "10000001", "name": "Brennock Water Utility", "role": "customer", "intercompany": False, "bank": "on file"},
    {"id": "10000002", "name": "Hallam Fluid Systems", "role": "customer", "intercompany": False, "bank": "on file"},
    {"id": "10000010", "name": "Calder Pumpworks GmbH", "role": "customer", "intercompany": True, "bank": "on file"},
    {"id": "20000001", "name": "Orrin Motor Works", "role": "supplier", "intercompany": False, "bank": "on file"},
    {"id": "20000005", "name": "Larkspur Freight Lines", "role": "supplier", "intercompany": False, "bank": "on file"},
]


def odm_id(local):
    return str(uuid.uuid5(uuid.NAMESPACE_URL, f"calder-course/business-partner/{local}"))


def sim_filters():
    print("Business partners from S4P to SAP Field Service Management (course values).")
    for label, selection, scope in (
            ("1. No filters:", lambda p: True, lambda p: p),
            ("2. Selection role customer, not intercompany; scope without bank details:",
             lambda p: p["role"] == "customer" and not p["intercompany"],
             lambda p: {k: v for k, v in p.items() if k != "bank"})):
        sent = [scope(p) for p in PARTNERS if selection(p)]
        print(label)
        for p in sent:
            fields = ", ".join(k for k in p if k not in ("id", "name"))
            print(f"   {p['id']} {p['name']}: {fields}")
        print(f"   {len(sent)} sent, bank details in {sum(1 for p in sent if 'bank' in p)}")
    print("3. Key mapping after FSM confirms (FSM numbers its own records):")
    for n, p in enumerate([p for p in PARTNERS if p["role"] == "customer" and not p["intercompany"]], start=1):
        print(f"   {odm_id(p['id'])}  S4P {p['id']}  FSM C-{n:04d}")
    return 0


def write_samples():
    FOLDER.mkdir(parents=True, exist_ok=True)
    for name, data in (("design_draft.json", DRAFT), ("design_reviewed.json", reviewed_design())):
        p = FOLDER / name
        p.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
        print(f"wrote {p.as_posix()}")
    return 0


def self_test():
    checks = []

    def count(design, status):
        return sum(1 for r in check(design) if r[2] == status)

    d, v = DRAFT, reviewed_design()
    checks.append(("draft OK", count(d, "OK"), 18))
    checks.append(("draft WARN", count(d, "WARN"), 4))
    checks.append(("draft FAIL", count(d, "FAIL"), 19))
    checks.append(("reviewed OK", count(v, "OK"), 30))
    checks.append(("reviewed WARN", count(v, "WARN"), 0))
    checks.append(("reviewed FAIL", count(v, "FAIL"), 0))
    checks.append(("DM02 is ECC", any(r[0] == "DM02" and r[1] == "MD03" for r in check(d)), True))
    checks.append(("DM05 provider", any(r[0] == "DM05" and r[1] == "MD05" and r[2] == "FAIL"
                                        for r in check(d)), True))
    checks.append(("CP11-435 old copy", hire(START, "CP11-435", "2026-10-19").startswith("accepted"), True))
    closed = dict(START, **{"CP11-435": {"name": "Rework area", "valid_to": "2026-09-30"}})
    checks.append(("CP11-435 new copy", hire(closed, "CP11-435", "2026-10-19").startswith("refused"), True))
    checks.append(("odm id stable", odm_id("10000001"), odm_id("10000001")))
    checks.append(("odm ids differ", odm_id("10000001") != odm_id("10000002"), True))
    passed = 0
    for name, got, want in checks:
        ok = got == want
        passed += ok
        if not ok:
            print(f"FAIL {name}: got {got}, expected {want}")
    print(f"{passed} of {len(checks)} self-test checks passed")
    return 0 if passed == len(checks) else 1


def main():
    parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
    parser.add_argument("--init", action="store_true", help="write the sample designs")
    parser.add_argument("--self-test", action="store_true", help="check the built-in samples")
    sub = parser.add_subparsers(dest="cmd")
    r = sub.add_parser("review", help="review a design file")
    r.add_argument("--file", default=str(FOLDER / "design_draft.json"))
    s = sub.add_parser("simulate", help="run a simulation")
    s.add_argument("which", choices=["delta", "providers", "filters"])
    args = parser.parse_args()
    if args.init:
        return write_samples()
    if args.self_test:
        return self_test()
    if args.cmd == "review":
        if not Path(args.file).exists():
            print(f"{args.file} not found: run python unit26/mdi_lab.py --init first")
            return 1
        return review(args.file)
    if args.cmd == "simulate":
        return {"delta": sim_delta, "providers": sim_providers, "filters": sim_filters}[args.which]()
    parser.print_help()
    return 0


if __name__ == "__main__":
    sys.exit(main())
```

#### Step 3: Write the sample files and check them

1. Run:

   ```bash
   python unit26/mdi_lab.py --init
   ```

   You see:

   ```text
   wrote unit26/mdi/design_draft.json
   wrote unit26/mdi/design_reviewed.json
   ```

   `--init` writes fresh copies each time, so run it again only when you want the samples back.

2. Run the self-test:

   ```bash
   python unit26/mdi_lab.py --self-test
   ```

   You see `12 of 12 self-test checks passed`.

3. Open `unit26/mdi/design_draft.json`. It is the partner's first design: one MDI tenant in the production integration subaccount `calder-int-prod` (from the [BTP account model](https://erpfde.com/topics/btp-account-model/)), six connected applications and six flows.

> **Note** On Windows, if `python` opens the Microsoft Store or isn't found, use `py` instead in every command.

#### Step 4: Review the partner's draft design

1. Run:

   ```bash
   python unit26/mdi_lab.py review
   ```

2. The output starts like this:

   ```text
   Calder Pumpworks (fictional): master data distribution design as of 2026-11-30
     tenant calder-mdi in calder-int-prod for test, prod

   calder-mdi
     FAIL MD01 one tenant serves test, prod
     FAIL MD10 nobody owns the tenant's monitoring
   S4P
     FAIL MD02 instance mdi-s4 shared with S4Q
   S4Q
     FAIL MD02 instance mdi-s4 shared with S4P
   ECP
     OK   MD02 own instance mdi-ecc
     FAIL MD03 ECC is not a supported client
   ```

3. The last line reads:

   ```text
   18 OK, 4 WARN, 19 FAIL across 6 flows
   ```

   Every flow except `DM03` reads `verdict FIX`, and the exit code is `2`.

The rules:

| Rule | Checks | Source |
| --- | --- | --- |
| `MD01` | One tenant per stage; no client in another stage's tenant | SAP's one tenant per landscape; reading a landscape as a stage is a course rule |
| `MD02` | Each connected application has its own instance | SAP blog's setup FAQ |
| `MD03` | No ECC client or provider | SAP's MDG FAQ |
| `MD04` | The object is master data in the hub's scope | Course list from SAP's pages; prices and stock are out |
| `MD05` | A distribution model's provider is ABAP-based (S/4HANA or MDG) | SAP Learning |
| `MD06` | One provider per object for each consumer | SAP Learning's recommendation |
| `MD07` | Every flow has an owner | Course rule |
| `MD08` | Business partners to a non-ERP consumer leave out bank details (data scope filter) | Course rule |
| `MD09` | A distribution model has a selection filter (a warning) | Course rule |
| `MD10` | Someone owns each tenant's monitoring | Course rule |
| `MD11` | Every field outside ODM that a consumer needs has a named route | SAP's MDG FAQ; the owner is a course rule |

Read the findings that matter most:

- `calder-mdi` serves test and production. A test system's changes would reach production consumers.
- `DM02` sends Augsburg's cost centers from ECC, which MDI doesn't support, and gives Employee Central a second provider for cost centers.
- `DM05` makes the CRM a provider of business partners next to S/4HANA. The CRM is not ABAP-based, and Field Service Management now has two sources.
- `DM06` sends prices, which are not master data in the hub.

#### Step 5: See why delta loads matter

1. Run:

   ```bash
   python unit26/mdi_lab.py simulate delta
   ```

2. You see:

   ```text
   Cost centers from S4P to SuccessFactors Employee Central (course values).
   Change log in S4P:
     1 2026-09-14 08:00 CP11-300 Purchasing changed or created
     2 2026-09-30 17:00 CP11-435 Rework area closed 2026-09-30
     3 2026-10-12 10:00 CP11-460 Utilities changed or created

   1. Nightly file, job last ran 2026-09-14 01:00 (nobody noticed):
      HR copy: 4 cost centers, CP11-435 open
      2026-10-19 hire 00100231 on CP11-435: accepted on CP11-435 (HR thinks it is open)
      later: S/4HANA refuses the payroll posting on the closed cost center
   2. Change log with a delta token; Employee Central's pull is down 2026-09-28 to 2026-10-08:
      2026-09-14 pull from token 0: 1 change(s), token now 1
      2026-09-27 pull from token 1: nothing new
      2026-10-08 pull from token 1: 1 change(s), token now 2
      2026-10-15 pull from token 2: 1 change(s), token now 3
      HR copy: 5 cost centers, CP11-435 closed 2026-09-30
      2026-10-19 hire 00100231 on CP11-435: refused at entry: CP11-435 closed 2026-09-30
   ```

3. Read it: the stopped file left HR with a September picture, and the hire went through. With a change log, Employee Central was down for ten days and still caught up, because it read from its bookmark, not from "today's file". The hire is refused at entry, in HR, where it is cheap to fix.

#### Step 6: See why one provider matters

1. Run:

   ```bash
   python unit26/mdi_lab.py simulate providers
   ```

2. You see:

   ```text
   Hallam Fluid Systems (10000002) moves its receiving dock (course values).
   Two providers (S4P and CRM):
     2026-11-02 09:00 S4P: customer service changes the ship-to street -> hub has 455 Canal Street
     2026-11-02 22:00 CRM: CRM's nightly sync sends its older copy -> hub has 1200 Mill Road
     2026-11-03 07:30 FSM sends the technician to 1200 Mill Road
   One provider (S4P); the CRM only consumes:
     2026-11-02 09:00 S4P: customer service changes the ship-to street -> hub has 455 Canal Street
     2026-11-02 22:00 CRM: CRM's nightly sync sends its older copy -> refused, CRM is not a provider
     2026-11-03 07:30 FSM sends the technician to 455 Canal Street
   ```

3. Read it: the stand-in applies changes in the order they arrive, as any hub without a single owner must. The CRM's stale copy wins, and a technician drives to the old dock. With S/4HANA as the only provider, the CRM receives Hallam's new street instead of overwriting it.

#### Step 7: See filters and key mapping

1. Run:

   ```bash
   python unit26/mdi_lab.py simulate filters
   ```

2. You see:

   ```text
   Business partners from S4P to SAP Field Service Management (course values).
   1. No filters:
      10000001 Brennock Water Utility: role, intercompany, bank
      10000002 Hallam Fluid Systems: role, intercompany, bank
      10000010 Calder Pumpworks GmbH: role, intercompany, bank
      20000001 Orrin Motor Works: role, intercompany, bank
      20000005 Larkspur Freight Lines: role, intercompany, bank
      5 sent, bank details in 5
   2. Selection role customer, not intercompany; scope without bank details:
      10000001 Brennock Water Utility: role, intercompany
      10000002 Hallam Fluid Systems: role, intercompany
      2 sent, bank details in 0
   3. Key mapping after FSM confirms (FSM numbers its own records):
      7b6406ab-4646-5674-ba77-218a380f7c0b  S4P 10000001  FSM C-0001
      effc4328-388f-5b5c-856a-1b2517af2dc1  S4P 10000002  FSM C-0002
   ```

3. Read it: without filters, suppliers, a carrier and Calder's own German company reach the technicians' app, with bank details. The selection filter keeps the two customers; the data scope filter drops the bank details. Each record then has one stand-in ODM ID that both systems' numbers point to.

> **Note** These records, streets and IDs come from made-up data, not from a real SAP system. The stand-in IDs are generated the same way every run; real OIDs come from the hub. The filter fields MDI offers depend on the object; check them for each object before you design.

#### Step 8: Review the corrected design

1. Run:

   ```bash
   python unit26/mdi_lab.py review --file unit26/mdi/design_reviewed.json
   ```

2. The last lines read:

   ```text
   DM02 retired: ECC is not connected; CP20's cost centers move with the July 2027 rollout
   DM06 retired: prices are not master data in the hub; Cloud Integration flow instead

   30 OK, 0 WARN, 0 FAIL across 4 flows
   ```

   The exit code is `0`.

3. Compare the two files in VS Code (right-click one, **Select for Compare**, then **Compare with Selected** on the other). The fixes: separate tenants in `calder-int-test` and `calder-int-prod`, one instance per application, ECC removed, the CRM turned into a consumer, filters on every model, owners everywhere, and a Cloud Integration route for the one field outside ODM.

#### Step 9 (sketch): Set up a real tenant

> **Note** This step is a **sketch**. It needs an SAP BTP global account with entitlements for MDI and the orchestration service, and administrator access to S/4HANA and the receiving application. [The BTP account model](https://erpfde.com/topics/btp-account-model/) and [BTP security](https://erpfde.com/topics/btp-security-model/) cover the BTP side.

1. In the BTP cockpit, in the integration subaccount for one stage, create the MDI instances (one per application, one for configuration) and their service keys.
2. Subscribe to the orchestration service and assign its administrator roles to the integration team, not to the business.
3. Connect S/4HANA through DRF with the replication model and outbound implementation that SAP's guide for your object and release names.
4. Connect the consumer with its own instance, then create, review and activate the distribution model with its filters.
5. Run the initial load in test, reconcile counts against the source, then repeat in production.
6. Add each tenant, instance and model to your design file and run the review.

#### Step 10: Save your work

```bash
git add unit26/mdi_lab.py unit26/mdi
git commit -m "Unit 26: master data distribution design review for Calder"
```

#### How the code works

| Part | What it does |
| --- | --- |
| `DRAFT`, `reviewed_design()` | The partner's design and the corrected one, as Python data written to JSON by `--init` |
| `IN_SCOPE` | The course's list of objects the hub carries, after SAP's pages |
| `check()` | Applies `MD01` to `MD11` to tenants, clients, flows and extra fields |
| `review()` | Prints each item with its findings, a verdict per flow (`FIX` if anything fails), and the totals; exit code 2 on a failure |
| `sim_delta()` | Compares a nightly file that stopped with a change log read from a bookmark |
| `sim_providers()` | Applies two providers' changes in arrival order, then only the owner's |
| `sim_filters()`, `odm_id()` | Applies a selection and a data scope filter, then shows a stand-in key map |
| `self_test()` | Twelve checks on the built-in samples, so you can tell a broken copy from an edited file |

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized, or `command not found` | Python isn't installed, or the terminal can't find it | Repeat the Python step of Set up your computer and open a new terminal; on macOS/Linux use `python3` until `.venv` is active |
| `No module named ...` | A different script was pasted, or an import was added | The script needs built-in modules only; paste it again from Step 2 |
| `design_draft.json not found` | Step 3 hasn't run, or you are in another folder | Run `python unit26/mdi_lab.py --init` from `orchestrate-course` |
| `json.decoder.JSONDecodeError` | A comma or bracket is missing after an edit | VS Code marks the line; fix it and run again |
| `KeyError: 'via'` or another field | A new flow is missing a field | Copy an existing flow and change its values |
| Your counts differ from the samples | The files were edited | Run `--self-test`, then `--init` to restore the samples |
| A company proxy blocks downloads | Not used here | The lab needs no network |

### The SAP way

What SAP provides, as of 30 November 2026:

- **SAP Master Data Integration** on SAP BTP, with REST events APIs, SOAP for business partners, key mapping and monitoring ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution)).
- **The orchestration service** for distribution models and filters, a separate subscription (same page).
- **Prebuilt connections** from SAP applications: S/4HANA through DRF, SuccessFactors Employee Central, Field Service Management, SAP Ariba and SAP Fieldglass, per object (same page; [SAP Community](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136)).
- **The One Domain Model**, described for OData by SAP's ODM vocabulary ([SAP on GitHub](https://sap.github.io/odata-vocabularies/vocabularies/ODM.html)).
- **Master Data Governance** for governance in front of replication. MDG on S/4HANA uses DRF; the cloud edition used MDI and is being discontinued ([sap.com](https://www.sap.com/products/data-cloud/master-data-governance/pricing.html), [SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)). [Master data every module depends on](https://erpfde.com/topics/master-data-every-module-depends-on/) explains what MDG governs.
- **Licensing note.** SAP's field service post calls MDI commercially free between SAP-branded cloud solutions ([SAP Community](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136)). Third-party consumers, which SAP's FAQ routes through Integration Suite ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)), may carry other terms; ask your account team.

### Build vs. SAP

| Need | SAP | Your own | Use which |
| --- | --- | --- | --- |
| Cost centers from S/4HANA to Employee Central | MDI, SAP's recommendation from S/4HANA 2025 | Point-to-point flows or files | MDI; the old flows only as a temporary fallback |
| Business partners to Field Service Management | MDI or Cloud Integration | Files | MDI in a landscape with several SAP apps; Cloud Integration if you need value mapping |
| Master data from ECC | ALE and IDocs, Cloud Integration | Files | Not MDI; plan the move with the ECC exit |
| Fields outside ODM | Cloud Integration | A custom service | A second, owned flow |
| Duplicate merging and approval | MDG | Spreadsheet reviews | MDG or a documented process before replication |
| Non-SAP consumers | Integration Suite, per SAP's FAQ | Direct extracts | Integration Suite |

### Architecture view

**Where it sits.** MDI runs on BTP in the integration subaccount of each stage. S/4HANA reaches it outbound through DRF; cloud applications connect with their own instances.

```mermaid
flowchart LR
  subgraph PROD[calder-int-prod]
    MDIP[MDI tenant<br/>calder-mdi-prod]
  end
  S4P[S4P CP10] -- DRF --> MDIP
  MDIP --> SFEC[SuccessFactors EC]
  SFEC -- workforce --> MDIP
  MDIP --> S4P
  MDIP --> FSM[Field Service Mgmt]
  MDIP --> CRM[CRM]
  ECP[ECP CP20 ECC] -. not connected .-> MDIP
  S4P -- Cloud Integration --> FSM
```

**Non-functional requirements.**

| Requirement | Typical target | What breaks if missed |
| --- | --- | --- |
| Freshness | Changes reach consumers within minutes; outages caught up from the log | Hires on closed cost centers, visits to old addresses |
| Completeness | Initial load reconciled to the source by count per object | Missing records discovered by users |
| Ownership | One provider per object and consumer | Stale copies overwrite fresh changes |
| Data minimization | Filters on records and fields per consumer | Bank and personal data in apps that don't need it |
| Stage separation | One tenant per stage | Test data in production apps |
| Visibility | Failed replications seen and owned | A silent feed, as in September |

**Integration and identity.** MDI calls are application to application with technical credentials from service keys; SAP's 2021 setup FAQ said business-user scenarios weren't supported ([SAP Community](https://community.sap.com/t5/technology-blog-posts-by-sap/sap-master-data-integration-mdi-services-set-up-faqs/ba-p/13493632)). So the hub doesn't check a person's authorizations: the filters are the access control. Keep service keys in the credential register from [services, instances and bindings](https://erpfde.com/topics/btp-services-and-bindings/) and rotate them.

**The decision to record** (short ADR form from the [design-doc topic](https://erpfde.com/topics/writing-a-solution-design-doc/)):

- **Context.** `I13` sends cost centers from `CP10` to SuccessFactors Employee Central; today a nightly file, which stopped unnoticed in September. Calder plans an S/4HANA upgrade, and SAP deprecates the point-to-point flows' software component with S/4HANA 2025.
- **Options.** A: keep the file and add an alert. B: SAP's point-to-point Cloud Integration flows. C: MDI, with a selection filter on company code `CP10`.
- **Decision.** C. It follows SAP's recommendation, survives the upgrade, and catches up after outages.
- **Consequences.** Two MDI tenants (test and production) with owners; DRF configuration in `S4D` transported through `S4Q` to `S4P`; an initial load reconciled before go-live. Augsburg's cost centers join after the July 2027 rollout, when `CP20` lives in `CP10`'s system.

**What a design review will ask.**

1. For each object, which system is the provider, and where are users stopped from editing it elsewhere?
2. Which records and fields does each consumer receive, and why does it need them?
3. Which needed fields fall outside ODM, and what carries them?
4. How are test and production separated, and who watches each tenant?
5. How was the initial load reconciled, and how will the next one be?

> **Note** The filter field (company code) and the upgrade plan in this ADR are course assumptions. Check which filters MDI offers for cost centers in your release.

### Production concerns

- **Security and authorizations.** Service keys are technical credentials; keep them out of code and rotate them. Limit orchestration roles to the integration team. Because filters decide who sees what, review them like authorizations.
- **Data protection.** Workforce data is personal data. Send each consumer only the records and fields it needs, and record why.
- **Evaluation.** Test with a closed cost center, a consumer offline for a week, a change made in the wrong system, and a record that fails in the consumer. The lab's simulations are the starting cases.
- **Cost.** MDI between SAP cloud products is described as free; the work is setup, initial loads and reconciliation. Budget the DRF configuration per object and per release.
- **Operations.** Watch replication status in the hub and in DRF on the S/4HANA side. A consumer that refuses a record leaves it waiting; someone owns that queue.
- **Clean core.** MDI and DRF are standard; custom extract programs and files are what it replaces. Fields outside ODM need a second route, which should use released APIs ([SOAP and OData services](https://erpfde.com/topics/soap-and-odata-services-in-depth/)).

### Where AI fits

AI changes three things here, as of November 2026:

- **Agents read the copies.** An agent in SuccessFactors or Field Service Management answers from that application's copy of master data. If the copy is stale, the agent is confidently wrong. Replication health is part of an agent's readiness, as [master data quality as AI readiness](https://erpfde.com/topics/master-data-quality-as-ai-readiness/) argues.
- **Shared IDs help retrieval.** Key mapping and ODM IDs let a tool join the same customer across systems without guessing by name, which [semantic search over master data](https://erpfde.com/topics/semantic-search-over-sap-master-data/) otherwise has to do.
- **Data products.** SAP's master data strategy now also runs through SAP Business Data Cloud, where Reltio joined in 2026 ([SAP News](https://news.sap.com/2026/05/sap-completes-acquisition-of-reltio/)). How it relates to MDI is not stated on the pages read for this topic; [Business Data Cloud](https://erpfde.com/topics/sap-knowledge-graph-and-business-data-cloud/) covers the platform.

### Pitfalls

- **One tenant for every stage.** Test changes reach production consumers.
- **Two providers for one object.** The stale copy wins.
- **Expecting MDI to fix data.** It copies bad data faster; govern first.
- **Assuming every field travels.** Check ODM's coverage per object before you promise a field.
- **Planning MDI for ECC.** SAP doesn't support it; keep ECC on its current route until the move.
- **No filters.** Every record and field goes everywhere, including bank details.
- **Confusing the two services.** MDI and the orchestration service are separate subscriptions with separate roles; a ticket for one often belongs to the other.
- **Following a 2021 guide on a 2025 release.** The setup steps change; use SAP's guide for your object and release.

### Exercise

Calder's service manager wants the customers' pumps in Field Service Management, so technicians see what is installed at each site, with the warranty end date.

1. Open `unit26/mdi/design_reviewed.json`. Add a flow at the end of the `models` list (put a comma after the closing brace of `DM05`):

   ```json
   {"id": "DM07", "object": "Equipment", "provider": "S4P", "consumer": "FSM",
    "via": "distribution model", "selection": null, "scope": null, "owner": null}
   ```

2. Add a field at the end of the `extra_fields` list (a comma after the existing entry):

   ```json
   {"object": "Equipment", "field": "warranty end date", "needed_by": "FSM", "route": null}
   ```

3. Run `python unit26/mdi_lab.py review --file unit26/mdi/design_reviewed.json`. `DM07` shows `FAIL MD07` and `WARN MD09`, the new field shows `FAIL MD11`, and the last line reads `33 OK, 1 WARN, 2 FAIL across 5 flows`.
4. Fix `DM07`: set `"selection": "customer pumps only"` and `"owner": "00100315"` (the service manager). Fix the field: set `"route": "Cloud Integration flow, owner 00100292"`.
5. Run the review again. `DM07` reads `verdict KEEP` and the last line reads `36 OK, 0 WARN, 0 FAIL across 5 flows`.
6. Write `unit26/mdi/decision_dm07.md` with the four ADR headings: why equipment goes through MDI, why the warranty date needs a second route, and who owns each.

**Done when:** the review prints `36 OK, 0 WARN, 0 FAIL across 5 flows` and `decision_dm07.md` records the decision. The design file feeds the [interface monitoring and error handling topic](https://erpfde.com/topics/interface-monitoring-and-error-handling/).

> **Note** The counts come from made-up data and course rules, not from a real SAP system.

### Going further

For readers who want the identity model behind replication.

- **The ODM vocabulary.** SAP's [ODM vocabulary](https://sap.github.io/odata-vocabularies/vocabularies/ODM.html) separates the ODM identifier (`oid`), stable within its type and landscape, from local IDs that each system keeps. Reading an API's `$metadata` for these annotations tells you whether two APIs describe the same entity, which is the first question when you join data across SAP products.
- **Concept names without versions.** `entityName` names the concept, not a version, so a consumer can find every API for the same entity even as versions change (same page). A distribution model, by contrast, names an object type and version ([SAP Learning](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution)), so a model is a contract you revisit when SAP moves an object to a new version.
- **Why a shared model.** With one model, each application maps its objects once, to ODM, instead of once per partner; with ten applications that is ten mappings instead of up to forty-five pairs. SAP's FAQ also warns that ODM and MDI evolve over time ([SAP Community](https://pages.community.sap.com/topics/master-data-governance/faq)), so record which object versions each model uses.
- **Push versus pull.** Pull puts the schedule in the consumer and is easy to reason about after outages; push lowers latency but relies on acknowledgments. The lab's delta simulation is a pull consumer; with push, check what the provider does when the consumer stops acknowledging.

### Check yourself

1. In the delta simulation, why does Employee Central still learn that CP11-435 closed after a ten-day outage?
   - A. The hub resends a full copy of all cost centers every night
   - B. It reads the change log from its own bookmark, the delta token
   - C. S/4HANA repeats the change until the consumer answers
   - D. The hire's refusal triggers a reload of the cost center list

   Answer: B. A delta load returns every change since the consumer's last call. The stand-in's token stayed at 1 during the outage, so the next pull picked up the closure and the new cost center.

2. Which system can act as a provider in an MDI distribution model, according to SAP's lesson?
   - A. Any SAP cloud application connected to the tenant
   - B. Any system with a REST client and a service key
   - C. An ABAP-based system such as S/4HANA or MDG cloud edition
   - D. Only the MDI tenant's own configuration instance

   Answer: C. SAP's lesson says only ABAP-based systems like S/4HANA or MDG cloud edition act as providers for distribution. That is why the draft's CRM provider fails MD05.

3. The draft uses one MDI tenant for S4Q and S4P. What is the risk, and what does the review ask for?
   - A. Slower replication; one larger tenant
   - B. Higher cost; one shared instance for both systems
   - C. Test changes reaching production consumers; one tenant per stage
   - D. Duplicate IDs in S/4HANA; a new number range in S4Q

   Answer: C. In one tenant, a change made in the quality system can flow to production consumers such as Employee Central. SAP says one tenant per landscape; the course reads each stage as a landscape.

4. Field Service Management needs a test certificate e-mail that ODM doesn't define. What does the reviewed design do?
   - A. Adds the field to the hub's business partner object
   - B. Sends it through an owned Cloud Integration flow
   - C. Stores it in the bank details field the scope filter drops
   - D. Leaves it out until SAP adds it to ODM

   Answer: B. SAP's FAQ says attributes outside ODM need custom expansions or other mechanisms. The reviewed design names a Cloud Integration flow with an owner, which passes MD11.

5. Why does the reviewed design retire DM02, Augsburg's cost centers from ECC?
   - A. Employee Central doesn't accept cost centers from Germany
   - B. ECC isn't supported, and it was a second provider
   - C. The rollout already moved Augsburg's cost centers into CP10
   - D. Cost centers aren't an object MDI carries

   Answer: B. SAP's FAQ says ECC is not included in MDI, and DM02 also gave Employee Central a second provider for cost centers. Augsburg joins after its July 2027 move into CP10's system.

6. What do the filters in the filters simulation change?
   - A. They change Calder's customer numbers to FSM's numbers
   - B. They encrypt bank details before sending them to FSM
   - C. They send every partner but mark suppliers as inactive
   - D. Which partners reach FSM, and which of their fields

   Answer: D. The selection filter keeps the two customers; the data scope filter drops bank details. Mapping the numbers is key mapping, which comes after.

7. Calder upgrades CP10 to S/4HANA 2025 and still sends cost centers to Employee Central with the point-to-point flows. What does SAP's support article say?
   - A. The flows are the preferred route for private cloud systems
   - B. Cost centers can no longer reach Employee Central at all
   - C. Use MDI; the flows remain only as a temporary fallback
   - D. Switch to a nightly file from a custom report

   Answer: C. SAP's article says the software component behind the flows is deprecated with S/4HANA 2025 and strongly recommends MDI. The flows stay on the Business Accelerator Hub for backward compatibility only.

8. How does a key map let two systems agree on Hallam's record?
   - A. Both systems switch to the same customer number
   - B. The consumer reuses the provider's number as its own
   - C. Both local numbers point to one stable ODM identifier
   - D. The hub matches the records by name every night

   Answer: C. The ODM vocabulary defines the OID as stable and unique within its type and landscape, while each system keeps its local ID. The key map links S4P 10000002 and FSM's own number to that ID.

## Sources

- [Implementing SAP Master Data Integration and Orchestrating Distribution (SAP Learning, SAP BTP Fundamentals Level 3, read 2026-11-30)](https://learning.sap.com/courses/sap-btp-fundamentals-level-3-advanced-services-integration-enterprise-architecture/implementing-sap-master-data-integration-and-orchestrating-distribution): Central hub; exactly one MDI tenant per landscape; only objects defined in SAP One Domain Model; REST events API with initial and delta loads, SOAP for business partner and relationships; distribution models in the orchestration service; only ABAP-based systems such as S/4HANA or MDG cloud edition as providers for distribution; one provider to one consumer recommended; object selection and data scope filters; push and pull; consolidation, quality and central governance out of scope
- [SAP Master Data Governance FAQ (SAP Community topic page, read 2026-11-30)](https://pages.community.sap.com/topics/master-data-governance/faq): MDI distributes master data based on ODM; ODM and MDI evolve over time; S/4HANA to S/4HANA replication with MDI for the range covered by ODM, other attributes need custom expansions or other mechanisms; SAP ECC not included; SOAP interfaces supported until further notice; SAP discontinues the BTP-based MDG, cloud edition (no renewals, Free Tier gone, existing subscriptions honored to contract end); no date on the page
- [SAP Knowledge Base Article 3727053: Replicating Cost Centers from SAP S/4HANA 2025 to SuccessFactors Employee Central: Choosing between MDI and Cloud Integration (CPI) (read 2026-11-30)](https://userapps.support.sap.com/sap/support/knowledge/en/3727053): Software component ODTFINCC, the base of the point-to-point Cloud Integration flows, deprecated with S/4HANA 2025; SAP strongly recommends MDI for cost centers to Employee Central for new implementations and upgrades to 2025; flows stay on the Business Accelerator Hub for backward compatibility as a temporary fallback
- [MDI vs. CPI: Master Data Decisions for SAP S/4HANA Cloud to SAP Field Service Management (SAP Community, CRM and CX blog posts by SAP, read 2026-11-30)](https://community.sap.com/t5/crm-and-cx-blog-posts-by-sap/mdi-vs-cpi-master-data-decisions-for-sap-s-4hana-cloud-to-sap-field-service/ba-p/14263136): MDI for complex landscapes, hub and spoke; no field or value mapping customization in MDI; business partner, contacts, products and product groups by both; product price and stock by Cloud Integration only; workforce person by MDI only; equipment and functional locations by MDI; MDI commercially free between SAP-branded cloud solutions
- [ODM Vocabulary, com.sap.vocabularies.ODM.v1 (SAP OData vocabularies on GitHub, read 2026-11-30)](https://sap.github.io/odata-vocabularies/vocabularies/ODM.html): Terms root, oid, entityName, codeList (experimental), oidReference (experimental); the OID identifies a root entity in a customer landscape, stable and unique at least within its type and landscape; entityName names the ODM concept without a version
- [Configuring SAP Master Data Integration for Business Partners Replication (SAP Community blog, 2021, read 2026-11-30)](https://blogs.sap.com/2021/03/09/configuring-sap-master-data-integration-for-business-partners-replication/): Business partner only; MDI instance per business system with an application type; orchestration roles collected in a role collection; SOAP endpoints for business partner, relationships and key mapping replication and confirmation
- [SAP Master Data Governance pricing (sap.com, read 2026-11-30)](https://www.sap.com/products/data-cloud/master-data-governance/pricing.html): Comparison: MDG on S/4HANA private or on-premise replicates with the Data Replication Framework; MDG, cloud edition on BTP uses the One Domain Model (core attributes) and replicates through MDI and SOAP; public cloud uses S/4HANA Public Edition replication services
- [SAP Master Data Integration (MDI) Services: Set up FAQs (SAP Community, technology blog posts by SAP, written 2021, read 2026-11-30)](https://community.sap.com/t5/technology-blog-posts-by-sap/sap-master-data-integration-mdi-services-set-up-faqs/ba-p/13493632): A tenant is a BTP subaccount; one instance per connected business application plus one for configuration; SOAP only for business partner and product, REST (ODM-based) for other objects; application-to-application authentication only, as of 2021
- [Step by step for setting up the cost center replication from S/4HANA to SAP SuccessFactors Employee Central using the SAP BTP Master Data Integration service (SAP Community, 2022, read 2026-11-30)](https://blogs.sap.com/2022/01/31/step-by-step-for-setting-up-the-cost-center-replication-from-s-4hana-to-sap-successfactors-employee-central-using-the-sap-btp-master-data-integration-service/): One MDI instance each for S/4HANA and Employee Central; report FI_CCTR_SETUP_DESTINATION, OAuth profile FIN_CO_CCTR, DRFIMG business system MDI, replication model MDI_CC with outbound implementation FI_CO_CCTR; Employee Central OAuth configuration in the Security Center
- [SAP Completes Acquisition of Reltio (SAP News, 7 May 2026, read 2026-11-30)](https://news.sap.com/2026/05/sap-completes-acquisition-of-reltio/): SAP completed the acquisition of Reltio, a master data management provider; tagged SAP Business Data Cloud and master data management; no mention of MDI, MDG or ODM
