# Aerospace and defense MRO AI: work scope, parts and the signature AI never gives

> Where AI predicts work scope and parts in an MRO shop, what SAP ships for it as of November 2026, and which steps stay with a certified person.

- Course: Orchestrate, Unit 16 · Industry playbooks
- Page: https://erpfde.com/topics/aerospace-and-defense-mro-ai/
- Updated: 2026-11-26
- Reading time: Foundational 8 min, Deep 34 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

Aircraft parts are not thrown away when they wear out. Pumps, actuators, landing gear and engines come off the aircraft, go to a repair shop, get taken apart, fixed and tested, and go back into service. This business is called **maintenance, repair and overhaul (MRO)**. Every unit has a serial number and a history that must follow it for life.

An MRO shop has two hard planning problems. It doesn't know how much work a unit needs until it is opened (the **work scope**). And it often waits weeks for parts it only discovers it needs at teardown. Both problems cost turnaround time, and an airline waiting for a part may have an aircraft on the ground.

AI helps where the shop's own history can predict: which scope a unit with this removal reason and these hours usually needs, so parts can be ordered before teardown. AI can also draft paperwork and summarize history. Two things stay with people by law and by design: the signature that returns a part to service, and the decision to ship a controlled part abroad.

### Why it matters to the business

Turnaround time is what MRO customers buy. A shop that quotes 20 days and delivers in 35 loses the contract, and the customer pays for spare units to cover the gap. The usual reason for a late unit is a part that was not on the shelf when the teardown found the need.

Take a fictional component repair station, **Wrenfield Aero Components**, which overhauls aircraft fuel pumps. A pump arrives with a leak. Most leaking pumps need a seal kit and a bearing set; some need a new impeller, which takes 45 days to buy. If the shop orders impellers only after teardown, every unit that needs one is late. If it stocks impellers for every pump, cash sits on the shelf. A prediction from the shop's own teardown history sits between those extremes.

The same idea appears in our running company. The fictional Calder Pumpworks repairs customer pumps in its own shop (see [quality, projects and service](https://erpfde.com/topics/quality-projects-and-service/)) and maintains its own test bench (see [maintain to settle](https://erpfde.com/topics/maintain-to-settle-plant-maintenance/)). Aerospace adds three things on top: every serial number must be traceable for life, every release needs a certified signature, and many parts are export controlled.

The risks are specific. A wrong prediction costs a late unit or excess stock, which is recoverable. A wrong record or a missing signature can make a part unairworthy, which is not. A controlled part shipped without a license is a legal breach. The design of any AI here starts from those three.

### How SAP does it

As of November 2026, SAP covers MRO with its asset management and industry functions, and adds AI in a few places. Each status below is what SAP's page said when opened for this topic.

- **The MRO core.** SAP's defense and security maintenance page lists base and line maintenance, maintenance for components, engines and complex assets, configuration management, maintenance programs and service parts fulfillment ([SAP for Defense and Security](https://www.sap.com/abm/dod/maintenance.html)). SAP's learning course for S/4HANA Defense & Security adds the **Configuration Control** component, which checks an asset's installed parts against a master parts list ([SAP Learning](https://learning.sap.com/courses/sap-s-4hana-defense-security-overview/explaining-the-d-s-maintenance-processes)).
- **MRO inventory AI.** SAP Integrated Business Planning (IBP) has an *AI-assisted MRO inventory analysis* feature that explains in plain language what drives recommended safety stocks and reorder points. SAP listed it as generally available in its Q1 2026 release highlights ([SAP News, April 2026](https://news.sap.com/2026/04/sap-business-ai-release-highlights-q1-2026/)). It needs IBP.
- **Failure prediction.** *Failure curve analytics* in SAP Asset Performance Management estimates the probability of failure for groups of equipment with a failure mode. Its page says AI Units are required ([sap.com](https://www.sap.com/products/scm/asset-performance-management-failure-curve-analytics.html)).
- **Maintenance planning agents.** The *Maintenance Planner Agent* page names SAP S/4HANA Cloud Private Edition, requires AI Units and offers beta registration; it shows no general availability label ([sap.com](https://www.sap.com/products/erp/maintenance-planner-agent.html)). The *Operational Maintenance Planning Agent* is only for customers in an Early Adopter Care program ([sap.com](https://www.sap.com/netherlands/products/scm/operational-maintenance-planning-agent.html)).
- **Partners.** Several MRO add-ons are listed on the SAP Store, such as HCLTech's iMRO for SAP ERP and S/4HANA Private Edition ([SAP Store](https://www.sap.com/sk/products/scm/partners/hcl-america-solutions-inc-hcl-imro4.html)).
- **Export control.** SAP Global Trade Services (GTS) determines whether a license is needed from the item's classification and destination, and blocks export documents until one is assigned ([SAP Learning](https://learning.sap.com/learning-journeys/discovering-the-basics-of-sap-global-trade-services/managing-product-related-export-control_f56a90ac-6e81-464c-8d03-a4ad038ea489)).

What SAP doesn't ship as a named feature (as far as the pages show) is work-scope prediction from teardown history. That is the gap a shop or partner most often builds for.

### Where AI helps in an MRO shop, step by step

| Step | What happens | AI's role | Who decides |
| --- | --- | --- | --- |
| Induction | Unit arrives with a removal reason and its hours | Predict likely work scope from history | Shop planner |
| Parts | Order what teardown is likely to need | Expected parts for the week, pre-order long-lead items | Buyer |
| Teardown and inspection | Technician finds the real condition | Summarize the unit's past visits and known issues | Technician |
| Repair | Work to the approved data | Find the right procedure revision (retrieval) | Technician |
| Records | Write what was done | Draft the record from the technician's notes | Technician |
| Release | Sign the part back into service | None: AI never signs | Certifying person |
| Shipping | Send the part to the customer | Flag classification gaps | Trade compliance |
| Planning ahead | Size stock and spare units | Explain inventory drivers, failure curves | Planner |

> **Note** **For functional consultants.** AI in MRO changes your data, not just your screens. Removal reasons and findings must be coded at teardown (not free text only), serial numbers must be kept on every movement, and the release step needs a role that only certified people hold. Test cases should include a unit with no history, a technician who tries to release, and a controlled part to a restricted destination. Roles for the assistant must exclude any signing or shipping authority.

### Questions to ask

1. What share of our late units were late because of a part found at teardown? That number sizes the prize.
2. Are removal reasons and teardown findings coded in SAP, or only in free text and paper? Prediction needs codes.
3. Which of SAP's maintenance AI features are generally available on our edition, and which need AI Units or an early adopter program?
4. Who may sign a release, and how is that enforced in the system, not only in a procedure?
5. Which of our parts and technical documents are export controlled, and may they be sent to a cloud model at all?
6. Does our partner's MRO add-on already predict scope or parts, and on whose data?

### Common misconceptions

- **"AI can approve routine releases."** The release signature belongs to a certified person and approves that work only. An assistant can draft; it cannot be the signer.
- **"Predict scope, then skip the inspection."** A prediction plans parts and labor. The teardown still decides what is done.
- **"SAP's maintenance agents are ready to buy."** As of November 2026, the planning agents' pages show beta registration or an early adopter program, not general availability.
- **"Export control is a shipping problem."** It also applies to technical data, including what you put into a prompt or a training set.
- **"More stock is the safe answer."** It trades late units for cash on shelves. A prediction lets you stock the long-lead parts that matter.

### Key terms

- **MRO (maintenance, repair and overhaul):** the business of keeping aircraft, engines and components airworthy, often for other companies' fleets.
- **Work scope:** the depth of work a unit needs at the shop, such as test only, repair or full overhaul.
- **Teardown:** taking a unit apart to inspect it; the point where the real work scope becomes known.
- **Rotable (repairable):** a serial-numbered part that is repaired and reused many times rather than replaced.
- **Release to service:** the signed statement by a certified person that work was done correctly and the part may be used.
- **Configuration control:** checking that the parts installed in an asset match what is allowed for it.
- **Export license:** permission from an authority to send a controlled item or technical data to a destination.
- **Turnaround time (TAT):** days from a unit's arrival at the shop to its dispatch.

### Check yourself

1. Why does work-scope prediction matter to an MRO shop's business?
   - A. It removes the need to inspect the unit at teardown
   - B. Long-lead parts can be ordered before the teardown
   - C. It replaces the certified signature on routine repairs
   - D. It sets the price the customer pays for each unit in the contract

   Answer: B. Late units usually come from parts found at teardown that take weeks to arrive. Predicting the likely scope from history lets the shop order those parts early. The teardown still decides the real work.

2. A vendor proposes that its AI sign off routine repairs to save time. What is the right response?
   - A. Accept it for repairs below a value limit
   - B. Accept it if the model is above 99% accurate
   - C. Decline: the release signature belongs to a certified person
   - D. Accept it if a person reviews a random sample of releases each month

   Answer: C. Under the US rule for maintenance records, the signature of the certified person approves the return to service for that work. An assistant may draft the record, but it cannot be the signer, however accurate it is.

3. Which SAP AI capability for MRO was listed as generally available in SAP's Q1 2026 release highlights?
   - A. The Operational Maintenance Planning Agent
   - B. AI-assisted MRO inventory analysis in SAP IBP
   - C. Work-scope prediction from teardown history
   - D. The Maintenance Planner Agent for all editions

   Answer: B. SAP listed IBP's AI-assisted MRO inventory analysis as generally available in Q1 2026. The planning agents' pages showed beta registration or an early adopter program, and SAP names no work-scope predictor.

4. What must be in place in SAP before a shop can predict work scope well?
   - A. A subscription to every SAP maintenance agent
   - B. A large language model trained on aviation manuals
   - C. A rule that every unit gets a full overhaul
   - D. Coded removal reasons and teardown findings per serial number

   Answer: D. A prediction learns from the shop's own history. If reasons and findings live only in free text or on paper, there is nothing reliable to learn from.

5. Why should a leader ask about export control before choosing a cloud AI service for MRO?
   - A. Controlled technical data in prompts can need a license too
   - B. Cloud models cannot read part numbers
   - C. Export control applies only to finished aircraft
   - D. SAP GTS blocks every AI service by default

   Answer: A. Export control covers technical data as well as goods. Sending controlled documents to a model hosted elsewhere can be an export, so the trade compliance team must decide what may go in.

6. An AI parts forecast says the shop will probably need two impellers this week, with a 45-day lead time. Who decides to order them?
   - A. The model, since it computed the need
   - B. The certifying technician who signs releases
   - C. The buyer, using the forecast as input
   - D. The customer whose unit is in the shop

   Answer: C. The forecast is advice for the person who owns the decision. Ordering stays with the buyer, who weighs the forecast against cash and the cost of a late unit.

## Deep layer

### Mental model

**An MRO shop is a factory that doesn't know its bill of materials until it opens the box.** A production order for a new pump knows its parts in advance. A repair order for a used pump knows only a probability of parts. AI's job is to turn the shop's history into those probabilities early enough to act on them.

Around that sits a fence AI must never cross. The serial number's history is a legal record, the release is a personal signature, and a controlled part can't leave without a license. Everything AI produces lands on the planning side of the fence, as drafts and probabilities. The record, the signature and the shipment stay on the other side, with people and with hard checks in SAP.

### How it works

A unit's life in the shop follows the maintenance order flow you know from [maintain to settle](https://erpfde.com/topics/maintain-to-settle-plant-maintenance/), with three differences: the asset belongs to a customer, the unit moves as a serial number, and the record is regulated.

```mermaid
flowchart LR
  A[Unit removed<br/>reason + hours] --> B[Induction<br/>repair order]
  B --> P{{Predict scope}}
  P --> Q[Pre-order<br/>long-lead parts]
  B --> T[Teardown and<br/>inspection]
  T --> R[Repair to<br/>approved data]
  R --> D{{Draft record}}
  D --> S[Certified person<br/>signs release]
  S --> E[Export check]
  E --> X[Ship to customer]
  T -. findings coded .-> H[(Teardown<br/>history)]
  H -.-> P
```

The double-bordered boxes are where AI works. Three mechanics matter.

**Work-scope prediction is a classification problem.** The inputs are what you know at induction: part number, removal reason, hours or cycles since the last shop visit, the operator, sometimes the environment. The label is the scope found at teardown. A simple frequency model per reason and hours band is a fair first baseline; a trained classifier (see [classification and the metrics that matter](https://erpfde.com/topics/classification-and-the-metrics-that-matter/)) comes later. The output is a probability per scope, not one answer, because the parts decision needs the probabilities.

**Parts need is expected value, summed over the week.** The chance a unit needs a part is the sum of the probabilities of the scopes that use it. Summed over every unit arriving this week, that gives an expected need per part. Compare it with stock and order the gap, earliest for the longest lead time. This is the same arithmetic a planner would use for a forecast, applied to repair demand.

**Records and releases are rules, not predictions.** The US rule for maintenance records, 14 CFR 43.9, asks for a description of the work (or a reference to acceptable data), the completion date, the name of the person who did it if different, and the signature, certificate number and kind of certificate of the person approving it. It also says that signature approves return to service only for the work performed ([eCFR](https://www.ecfr.gov/current/title-14/chapter-I/subchapter-C/part-43/section-43.9)). Other authorities set their own rules; check which apply to your shop. An AI-drafted record is therefore a draft until a qualified person completes and signs it, and the system should refuse anything else.

**Export control is a lookup with a block.** In SAP GTS, license determination uses the item's classification and the destination, and an export document without the needed license is blocked until one is assigned ([SAP Learning](https://learning.sap.com/learning-journeys/discovering-the-basics-of-sap-global-trade-services/managing-product-related-export-control_f56a90ac-6e81-464c-8d03-a4ad038ea489)). AI can find unclassified parts or odd destinations; the block itself is deterministic.

### Build it yourself: Wrenfield's work-scope and parts check

You will build a small script that does a shop planner's Monday morning for the fictional Wrenfield Aero Components. It learns work scope from synthetic teardown history, predicts scope and parts for three pumps arriving this week, drafts a record for each, and then enforces the two fences: only a registered certifier can sign a complete record, and a controlled part can't ship to a restricted destination without a license.

**Before you start:** complete [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/). Unit 16 has no setup topic of its own; this script needs only Python's built-in modules.

```mermaid
flowchart LR
  H[Synthetic history<br/>240 visits, seed 42] --> M[Frequency model]
  M --> BT[Back-test vs<br/>baseline]
  M --> W[This week's<br/>3 units]
  W --> PA[Expected parts<br/>vs stock]
  W --> DR[Draft records<br/>unit16/mro/*.json]
  DR --> SG{sign: certifier<br/>+ complete?}
  SG -->|no| RF[REFUSED]
  SG -->|yes| RL[RELEASED]
  RL --> SH{ship: license<br/>needed?}
  SH -->|missing| BL[BLOCKED]
  SH -->|ok| OK[CLEAR TO SHIP]
```

> **Note** New words in this walkthrough:
> - **Back-test:** train on older records, test on newer ones you held back, and count how often the model was right.
> - **Baseline:** the simplest rule you must beat; here "always predict the most common scope".
> - **Add-one smoothing:** adding one to every count so a combination never seen still gets a small probability instead of zero.
> - **Subcommand:** the word after the script name (`report`, `sign`, `ship`) that picks what the script does.
> - **JSON:** a plain-text format for structured data; each draft record is saved as a `.json` file.

#### What you need

- Your `orchestrate-course` folder with its `.venv` virtual environment.
- About 30 minutes.
- Cost: free. No account, no network, no model calls.

#### Step 1: Open your 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 folder for this unit:

   - **Windows (PowerShell):**

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

   - **macOS / Linux:**

     ```bash
     mkdir -p unit16
     ```

#### Step 2: Create the script

1. In VS Code, create the file `unit16/mro_workscope.py`, paste the code below, and save.

```python
"""Work-scope prediction, parts check and release gate for a component repair shop.

Unit 16, aerospace and defense MRO topic. Built-in modules only, seed 42.
Wrenfield Aero Components is fictional; every number here is synthetic.

  python unit16/mro_workscope.py report
  python unit16/mro_workscope.py sign SN-4471 --by C-117
  python unit16/mro_workscope.py ship SN-4471 --to XV
"""
import argparse
import json
import math
import random
from collections import Counter, defaultdict
from pathlib import Path

SEED = 42
SCOPES = ["TEST", "REPAIR", "OVERHAUL"]
REASONS = ["LOWFLOW", "LEAK", "VIBR", "SCHED"]

# Parts each work-scope consumes (course values).
SCOPE_PARTS = {
    "TEST": {},
    "REPAIR": {"SEAL-KIT": 1, "BRG-SET": 1},
    "OVERHAUL": {"SEAL-KIT": 1, "BRG-SET": 1, "IMPELLER": 1, "HOUSING-LINER": 1},
}
STOCK = {"SEAL-KIT": 3, "BRG-SET": 2, "IMPELLER": 0, "HOUSING-LINER": 1}
LEAD_DAYS = {"SEAL-KIT": 5, "BRG-SET": 12, "IMPELLER": 45, "HOUSING-LINER": 30}

# Units arriving at the shop this week (fictional serial numbers).
INCOMING = [
    {"serial": "SN-4471", "part": "FP-410", "reason": "LEAK", "hours_since_overhaul": 5200, "customer_country": "US"},
    {"serial": "SN-4486", "part": "FP-410", "reason": "LOWFLOW", "hours_since_overhaul": 11800, "customer_country": "CA"},
    {"serial": "SN-4502", "part": "FP-410", "reason": "VIBR", "hours_since_overhaul": 9400, "customer_country": "XV"},
]

# People who may sign a release (course register, fictional numbers).
CERTIFIERS = {"C-117": {"name": "Certifying technician 117", "valid_to": "2027-06-30"}}
TODAY = "2026-11-26"

# Export rules: control class of the part x destination (course labels).
PART_CONTROL = {"FP-410": "EC-9"}
LICENSE_NEEDED = {("EC-9", "XV")}
LICENSES = {}  # none on file

FOLDER = Path(__file__).parent / "mro"


def band(hours):
    if hours < 6000:
        return "LOW"
    if hours < 10000:
        return "MID"
    return "HIGH"


def make_history(n=240):
    """Synthetic shop visits: the scope found at teardown depends on reason and hours."""
    rng = random.Random(SEED)
    weights = {
        ("SCHED", "LOW"): [70, 25, 5], ("SCHED", "MID"): [40, 45, 15], ("SCHED", "HIGH"): [10, 40, 50],
        ("LEAK", "LOW"): [15, 75, 10], ("LEAK", "MID"): [5, 70, 25], ("LEAK", "HIGH"): [5, 45, 50],
        ("VIBR", "LOW"): [20, 60, 20], ("VIBR", "MID"): [10, 50, 40], ("VIBR", "HIGH"): [5, 25, 70],
        ("LOWFLOW", "LOW"): [25, 45, 30], ("LOWFLOW", "MID"): [10, 40, 50], ("LOWFLOW", "HIGH"): [5, 20, 75],
    }
    rows = []
    for i in range(n):
        reason = rng.choice(REASONS)
        hours = rng.randrange(1000, 14000, 100)
        scope = rng.choices(SCOPES, weights=weights[(reason, band(hours))])[0]
        rows.append({"visit": f"V-{i + 1:04d}", "reason": reason, "band": band(hours), "scope": scope})
    return rows


def train(rows):
    counts = defaultdict(Counter)
    for r in rows:
        counts[(r["reason"], r["band"])][r["scope"]] += 1
    return counts


def predict(counts, reason, hb):
    """Probabilities per scope with add-one smoothing, so an unseen pair still answers."""
    c = counts.get((reason, hb), Counter())
    total = sum(c.values()) + len(SCOPES)
    return {s: (c[s] + 1) / total for s in SCOPES}


def backtest(rows):
    tr, te = rows[:180], rows[180:]
    counts = train(tr)
    baseline = Counter(r["scope"] for r in tr).most_common(1)[0][0]
    hit = sum(max(predict(counts, r["reason"], r["band"]).items(), key=lambda kv: kv[1])[0] == r["scope"] for r in te)
    base = sum(baseline == r["scope"] for r in te)
    return counts, baseline, hit, base, len(te)


def part_chances(probs):
    """Chance a unit needs each part = sum of P(scope) over the scopes that use it."""
    return {part: sum(p for s, p in probs.items() if part in SCOPE_PARTS[s]) for part in STOCK}


def draft_record(unit, scope):
    return {
        "serial": unit["serial"], "part": unit["part"], "status": "DRAFT",
        "work_description": f"Predicted scope {scope}; confirm at teardown and describe the work performed.",
        "completion_date": None, "performed_by": None,
        "certifier": None, "certificate": None, "signature": None,
        "note": "Drafted by the assistant. Not a release. Only a certifying person signs.",
    }


def cmd_report():
    rows = make_history()
    counts, baseline, hit, base, n = backtest(rows)
    print(f"History: {len(rows)} synthetic shop visits (seed {SEED}); trained on 180, tested on {n}")
    print(f"Back-test: predictor right on {hit}/{n} ({hit / n:.0%}); always-{baseline} baseline {base}/{n} ({base / n:.0%})")
    counts = train(rows)  # use all history for this week's units
    FOLDER.mkdir(exist_ok=True)
    week = Counter()
    for unit in INCOMING:
        hb = band(unit["hours_since_overhaul"])
        probs = predict(counts, unit["reason"], hb)
        scope = max(probs.items(), key=lambda kv: kv[1])[0]
        shown = "  ".join(f"{s} {p:.2f}" for s, p in probs.items())
        print(f"\n{unit['serial']} {unit['part']} reason {unit['reason']}, {unit['hours_since_overhaul']} h ({hb})")
        print(f"  scope odds: {shown}  -> plan for {scope}")
        chances = part_chances(probs)
        week.update(chances)
        print("  parts: " + "  ".join(f"{part} {c:.2f}" for part, c in chances.items()))
        path = FOLDER / f"{unit['serial']}.json"
        if not path.exists():
            path.write_text(json.dumps(draft_record(unit, scope), indent=2))
            print(f"  draft record written: {path.name} (status DRAFT)")
    print("\nParts for this week's units (expected need = sum of chances):")
    for part, need in week.items():
        order = max(0, math.ceil(need) - STOCK[part])
        action = f"order {order} now (lead {LEAD_DAYS[part]} d)" if order else "covered by stock"
        print(f"  {part:<14} expected {need:.2f}  stock {STOCK[part]}  {action}")


def cmd_sign(serial, by, work, done, performer):
    path = FOLDER / f"{serial}.json"
    if not path.exists():
        raise SystemExit(f"REFUSED: no record for {serial}. Run 'report' first.")
    rec = json.loads(path.read_text())
    problems = []
    cert = CERTIFIERS.get(by)
    if cert is None:
        problems.append(f"{by} is not in the certifier register")
    elif cert["valid_to"] < TODAY:
        problems.append(f"{by}'s certificate ran out on {cert['valid_to']}")
    if not work or work.startswith("Predicted scope"):
        problems.append("work description is still the assistant's prediction; describe the work performed")
    if not done:
        problems.append("completion date missing")
    if not performer:
        problems.append("person who performed the work missing")
    if problems:
        print(f"REFUSED: {serial} stays {rec['status']}")
        for p in problems:
            print(f"  - {p}")
        raise SystemExit(1)
    rec.update(status="RELEASED", work_description=work, completion_date=done, performed_by=performer,
               certifier=by, certificate=by, signature=f"signed by {by} on {TODAY}")
    path.write_text(json.dumps(rec, indent=2))
    print(f"RELEASED: {serial} signed by {by}; record saved to {path.name}")


def cmd_ship(serial, to):
    path = FOLDER / f"{serial}.json"
    rec = json.loads(path.read_text()) if path.exists() else None
    if rec is None or rec["status"] != "RELEASED":
        raise SystemExit(f"BLOCKED: {serial} has no signed release record")
    cls = PART_CONTROL.get(rec["part"])
    if cls is None:
        raise SystemExit(f"BLOCKED: {rec['part']} has no control class; classify it first")
    if (cls, to) in LICENSE_NEEDED and (rec["part"], to) not in LICENSES:
        raise SystemExit(f"BLOCKED: {rec['part']} ({cls}) to {to} needs an export license; none on file")
    print(f"CLEAR TO SHIP: {serial} ({rec['part']}, {cls}) to {to}")


def main():
    ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    sub = ap.add_subparsers(dest="cmd", required=True)
    sub.add_parser("report")
    s = sub.add_parser("sign")
    s.add_argument("serial")
    s.add_argument("--by", required=True)
    s.add_argument("--work", default="")
    s.add_argument("--done", default="")
    s.add_argument("--performer", default="")
    sh = sub.add_parser("ship")
    sh.add_argument("serial")
    sh.add_argument("--to", required=True)
    a = ap.parse_args()
    if a.cmd == "report":
        cmd_report()
    elif a.cmd == "sign":
        cmd_sign(a.serial, a.by, a.work, a.done, a.performer)
    else:
        cmd_ship(a.serial, a.to)


if __name__ == "__main__":
    main()
```

The history is generated, not real: each visit draws a removal reason and hours at random with seed 42, and the scope found at teardown follows fixed course odds per reason and hours band. `XV` is the fictional country Valdoria, as in the course lab; `EC-9` is a course label for a controlled class, not a real classification.

#### Step 3: Run the weekly report

1. Run:

   ```bash
   python unit16/mro_workscope.py report
   ```

2. You should see exactly this:

```text
History: 240 synthetic shop visits (seed 42); trained on 180, tested on 60
Back-test: predictor right on 31/60 (52%); always-REPAIR baseline 26/60 (43%)

SN-4471 FP-410 reason LEAK, 5200 h (LOW)
  scope odds: TEST 0.15  REPAIR 0.67  OVERHAUL 0.19  -> plan for REPAIR
  parts: SEAL-KIT 0.85  BRG-SET 0.85  IMPELLER 0.19  HOUSING-LINER 0.19
  draft record written: SN-4471.json (status DRAFT)

SN-4486 FP-410 reason LOWFLOW, 11800 h (HIGH)
  scope odds: TEST 0.07  REPAIR 0.27  OVERHAUL 0.67  -> plan for OVERHAUL
  parts: SEAL-KIT 0.93  BRG-SET 0.93  IMPELLER 0.67  HOUSING-LINER 0.67
  draft record written: SN-4486.json (status DRAFT)

SN-4502 FP-410 reason VIBR, 9400 h (MID)
  scope odds: TEST 0.07  REPAIR 0.50  OVERHAUL 0.43  -> plan for REPAIR
  parts: SEAL-KIT 0.93  BRG-SET 0.93  IMPELLER 0.43  HOUSING-LINER 0.43
  draft record written: SN-4502.json (status DRAFT)

Parts for this week's units (expected need = sum of chances):
  SEAL-KIT       expected 2.71  stock 3  covered by stock
  BRG-SET        expected 2.71  stock 2  order 1 now (lead 12 d)
  IMPELLER       expected 1.28  stock 0  order 2 now (lead 45 d)
  HOUSING-LINER  expected 1.28  stock 1  order 1 now (lead 30 d)
```

> **Note** Every number above comes from synthetic data and shows the method, not a result from a real shop or SAP system. The 52% against 43% says only that a frequency model beats "always repair" on data built to contain a pattern.

Read it as a planner would. SN-4502 is close to a coin toss between repair and overhaul (0.50 against 0.43), so it is the unit to open first. The impeller order is driven by two units' partial chances, not one certain overhaul. The course rule rounds the expected need up; a real shop would weigh holding cost against the cost of a late unit.

#### Step 4: Try to sign the assistant's draft

1. Try to release SN-4471 with only a certifier ID:

   ```bash
   python unit16/mro_workscope.py sign SN-4471 --by C-117
   ```

2. The script refuses:

```text
REFUSED: SN-4471 stays DRAFT
  - work description is still the assistant's prediction; describe the work performed
  - completion date missing
  - person who performed the work missing
```

3. Try someone who isn't in the certifier register:

   ```bash
   python unit16/mro_workscope.py sign SN-4486 --by C-200 --work "x" --done 2026-11-26 --performer T-204
   ```

```text
REFUSED: SN-4486 stays DRAFT
  - C-200 is not in the certifier register
```

#### Step 5: Sign as the certifying technician, then ship

1. Sign SN-4471 with the work actually done:

   ```bash
   python unit16/mro_workscope.py sign SN-4471 --by C-117 --work "Replaced shaft seal kit and bearing set; flow and leak test passed" --done 2026-11-26 --performer T-204
   ```

```text
RELEASED: SN-4471 signed by C-117; record saved to SN-4471.json
```

2. Ship it to the US customer, then try SN-4502 before and after it is signed:

   ```bash
   python unit16/mro_workscope.py ship SN-4471 --to US
   python unit16/mro_workscope.py ship SN-4502 --to XV
   python unit16/mro_workscope.py sign SN-4502 --by C-117 --work "Overhauled: impeller, bearings, seals and liner replaced; tests passed" --done 2026-11-26 --performer T-204
   python unit16/mro_workscope.py ship SN-4502 --to XV
   ```

```text
CLEAR TO SHIP: SN-4471 (FP-410, EC-9) to US
BLOCKED: SN-4502 has no signed release record
RELEASED: SN-4502 signed by C-117; record saved to SN-4502.json
BLOCKED: FP-410 (EC-9) to XV needs an export license; none on file
```

To run the walkthrough again from the start, delete the `unit16/mro` folder.

#### Step 6: Save your work in Git

```bash
git add unit16/mro_workscope.py
git commit -m "Unit 16: MRO work-scope and parts check with release gate"
```

The signed records in `unit16/mro/` are test output; keep them out of Git or delete them.

#### What each part of the code does

| Part | What it does |
| --- | --- |
| `make_history()` | Generates 240 shop visits with seed 42; scope odds depend on reason and hours band |
| `train()`, `predict()` | Counts scopes per reason and band; returns smoothed probabilities |
| `backtest()` | Trains on the first 180 visits, tests on the last 60, compares with the most common scope |
| `part_chances()` | Turns scope probabilities into the chance each part is needed |
| `cmd_report()` | Predicts this week's units, sums expected parts, writes `DRAFT` records |
| `cmd_sign()` | Refuses unless the certifier is registered and valid and the record is complete and no longer the prediction |
| `cmd_ship()` | Refuses unless the record is released and the part has a class and, where needed, a license |

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized / `command not found` | Python isn't on your path, or `.venv` isn't active | Turn on `.venv` (Step 1). On macOS/Linux try `python3` |
| `can't open file ... mro_workscope.py` | You're in the wrong folder or the file has another name | Run from `orchestrate-course`; check the file is `unit16/mro_workscope.py` |
| `error: the following arguments are required: cmd` | No subcommand given | Add `report`, `sign` or `ship` |
| Numbers differ from the expected output | The code was changed, or `SEED` isn't 42 | Paste the script again; the output is fixed by the seed |
| `REFUSED: no record for SN-...` | `report` hasn't run, or the `mro` folder was deleted | Run `report` first |
| `ModuleNotFoundError` | An import was added | The script needs built-in modules only; undo the change |
| Network or proxy errors | Not possible from this script | It makes no network calls; check you ran the right file |

### The SAP way

What follows is how SAP's pages described each piece when opened on 26 November 2026. Check the current status before you plan around any of them.

#### The MRO system of record

SAP describes MRO capabilities for defense and aerospace that include base and line maintenance, maintenance for components, engines and complex assets, configuration management, maintenance programs, multiresource planning and scheduling, and service parts warehousing and fulfillment ([SAP for Defense and Security](https://www.sap.com/abm/dod/maintenance.html)). In SAP S/4HANA Defense & Security, SAP's course shows the standard plant maintenance objects (notification, maintenance plan including multiple counter plans, order, task list), installation and dismantling of equipment, and the **Configuration Control** component, which checks an asset's structure against a master parts list ([SAP Learning](https://learning.sap.com/courses/sap-s-4hana-defense-security-overview/explaining-the-d-s-maintenance-processes)). That is where serial numbers, installed configurations and the order history live, and it is what any AI must read from and never bypass.

Partner add-ons fill MRO-specific gaps on the same core. HCLTech's iMRO, for example, is listed on the SAP Store as an add-on for SAP ERP and S/4HANA Cloud Private Edition, with aerospace and defense among its industries ([SAP Store](https://www.sap.com/sk/products/scm/partners/hcl-america-solutions-inc-hcl-imro4.html)). Ask any partner whether it predicts scope or parts, and on which data.

#### AI SAP ships around maintenance

| Capability | What it does | Status on SAP's page | Licensing note on the page |
| --- | --- | --- | --- |
| IBP AI-assisted MRO inventory analysis | Explains drivers of recommended safety stocks and reorder points in plain language | Generally available (Q1 2026 highlights) | Needs SAP IBP |
| AI-assisted retrieval of equipment information in service management | Summary of customer equipment, warranty and service history | Generally available, S/4HANA Cloud Private Edition (Q1 2026 highlights) | Not stated in the highlights |
| Failure curve analytics (SAP Asset Performance Management) | Probability of failure per group of equipment and failure mode, with Weibull curves | No status word on the page | AI Units required |
| Maintenance Planner Agent | Helps planners build maintenance backlogs | Beta registration offered, no GA label | AI Units required; Private Edition |
| Operational Maintenance Planning Agent | Weekly and biweekly work plans from strategies, one backlog | Early Adopter Care only | Private Edition |

Sources: [Q1 2026 highlights](https://news.sap.com/2026/04/sap-business-ai-release-highlights-q1-2026/), [failure curve analytics](https://www.sap.com/products/scm/asset-performance-management-failure-curve-analytics.html), [Maintenance Planner Agent](https://www.sap.com/products/erp/maintenance-planner-agent.html), [Operational Maintenance Planning Agent](https://www.sap.com/netherlands/products/scm/operational-maintenance-planning-agent.html). SAP's A&D learning content points to the SAP Business AI Feature Catalog in SAP Discovery Center and SAP Roadmap Explorer for the current list ([SAP Learning](https://learning.sap.com/courses/introducing-the-aerospace-defense-industry/maximizing-value-for-the-aerospace-and-defense-industry-with-sap-business-ai)).

Two observations for a builder. First, most of this targets a plant maintaining its own equipment, while a repair station's scope problem is about customers' units arriving in the shop; failure curves help an operator plan removals, not a shop plan teardown parts. Second, none of the pages names work-scope prediction from teardown findings. That remains a build, on SAP data.

#### Export control

SAP GTS determines whether an export needs a license from the item's classification (an ECCN for US rules) and the destination, manages licenses in the *Manage Licenses* app, and blocks export documents without a license until one is assigned ([SAP Learning](https://learning.sap.com/learning-journeys/discovering-the-basics-of-sap-global-trade-services/managing-product-related-export-control_f56a90ac-6e81-464c-8d03-a4ad038ea489)). Your AI design should depend on that block, not reproduce it.

### Build vs. SAP

| Need | Use SAP | Build (or partner) | Why |
| --- | --- | --- | --- |
| Serial numbers, configuration, order history | SAP EAM and the D&S or partner MRO functions | Never | It's the legal and financial record |
| Explaining stock targets for MRO parts | IBP's MRO inventory analysis, if you run IBP | Only without IBP | Generally available and built on the planner's own run |
| Failure probability for a fleet of equipment | Failure curve analytics in SAP APM | When AI Units aren't available | Same method, but SAP's runs on the asset data you already keep |
| Work-scope prediction at induction | Not named on SAP's pages | Yes, on BTP with SAP data | The gap specific to repair shops |
| Drafting records from technician notes | Not named | Yes, with a hard release gate | Must never write the signature |
| Export license check | SAP GTS | Never | A deterministic, auditable block |
| Planning backlogs with an agent | Maintenance planning agents, when GA on your edition | Only if urgent, with a plan to retire | Beta and early adopter today |

### Architecture view

**Where it sits.** S/4HANA (or ECC with an MRO add-on) holds the serial-numbered units, repair orders, findings and stock. A work-scope service on SAP BTP reads teardown history, predicts at induction and writes a recommendation back as a note or a draft purchase requisition. GTS checks exports. Long-lead parts may come through SAP Business Network from suppliers.

```mermaid
flowchart LR
  subgraph S4[S/4HANA: MRO core]
    RO[Repair orders<br/>serial numbers]
    FN[Coded findings]
    ST[Stock and requisitions]
  end
  subgraph BTP[SAP BTP]
    WS[Work-scope<br/>service]
    DR[Record drafting]
  end
  GTS[SAP GTS<br/>license check]
  RO --> WS
  FN --> WS
  WS -->|draft requisition| ST
  RO --> DR
  DR -->|draft only| RO
  RO --> GTS
```

**Non-functional requirements.**

| Requirement | Typical target | What breaks if missed |
| --- | --- | --- |
| Data residency and access for technical data | Controlled data stays in approved regions and with approved people | An unlicensed export of technical data |
| Traceability | Every prediction and draft logged with model version and inputs | You can't show why a part was ordered or a record was worded |
| Latency | Prediction within minutes of induction; batch is fine | Parts ordered a day late on a 45-day item matters little; a week matters |
| Availability | Shop runs without the AI | If induction waits on the model, turnaround gets worse |
| Cost | Under the cost of one late unit a month | The business case fails |

**Integration and identity.** The service reads maintenance orders, equipment and findings through released APIs (the [maintain to settle](https://erpfde.com/topics/maintain-to-settle-plant-maintenance/) topic lists the ones verified there) and writes only drafts: a note on the order, or a purchase requisition that a buyer converts. It runs under a technical user with read access to the shop's plant and create access to requisitions only. Signing and shipping stay with named users whose roles the technical user never holds.

**The decision to record.**

- *Context:* Late units come from teardown surprises; SAP ships no work-scope predictor.
- *Options:* (1) stock every long-lead part; (2) build a BTP work-scope service that drafts requisitions; (3) wait for SAP's maintenance agents.
- *Decision:* Option 2, drafts only, with the release and export checks left to SAP and named people.
- *Consequences:* Teardown findings must be coded from now on; the model is reviewed quarterly against actual scope; retire it if SAP ships an equivalent.

**What a design review will ask.**

1. Where does controlled technical data go, and who approved it?
2. What happens to induction if the service is down?
3. How do you know the prediction still works after a fleet or operator mix changes?
4. Can the service's technical user sign, release or ship anything? Show the role.
5. Who owns the model when the shop lead changes?

### Production concerns

- **Authorizations.** The assistant's technical user must not hold release, usage decision or shipping authorizations. Test this with a negative test in every release (see [human approval in AI workflows](https://erpfde.com/topics/human-approval-in-ai-workflows/)).
- **Export-controlled data.** Treat manuals, drawings and repair procedures as potentially controlled. A model hosted in another country, or staff from other countries with access to logs, can create an export. Ask trade compliance before any document goes into a prompt, an index or a training set.
- **Records.** Keep the AI draft and the signed record separate, with who changed what. The signed record is the one that counts; the draft is evidence of how it was written.
- **Evaluation.** Measure scope accuracy against the baseline by reason and by part number, and parts fill rate at teardown. Watch for drift when a new operator or a new part revision arrives (see [building an evaluation harness](https://erpfde.com/topics/building-an-evaluation-harness/)).
- **Cost.** A frequency or tabular model costs little to run. Language models for drafting cost per call; budget them per unit inducted.
- **Clean core.** Keep the model and its data side by side on BTP; write back only through released APIs and standard documents.

### Pitfalls

- **Training on uncoded findings.** If teardown results are free text, the model learns the technician's writing style, not the pump.
- **Predicting one scope and ordering for it.** The parts decision needs the probabilities; the most likely scope alone hides long-lead risk.
- **Letting the draft look final.** A draft with a filled signature field will be signed without reading. Leave the fields empty and say it is a draft.
- **Ignoring units with no history.** A new part number gets smoothed, uninformative odds. Show "no prediction" instead.
- **Sending manuals to a public model.** The fastest way to an export problem.
- **Counting the model's win as the shop's.** Measure turnaround and late units, not just accuracy.

### Exercise

Make the script admit when it doesn't know.

1. Add a fourth unit to `INCOMING`: serial `SN-4519`, part `FP-410`, reason `CONTAM`, 4,000 hours, customer country `US`.
2. Run `report` and notice that `CONTAM` gets the same odds for every scope: it was never seen.
3. Add a constant `MIN_VISITS = 10`. In `cmd_report()`, count the history visits with the unit's reason and band.
4. When the count is below `MIN_VISITS`, print `NO PREDICTION: <n> visits for <reason>/<band>; ask the shop lead`, skip its parts, and still write a draft record with the description "No prediction; describe the work performed."
5. Run `report` again and check that the week's parts totals are the same as before.

**Done when** `SN-4519` prints `NO PREDICTION: 0 visits for CONTAM/LOW; ask the shop lead`, the three other units print exactly as in Step 3, and `sign SN-4519` refuses until a real description is given. Keep the script: a later industry topic and your portfolio can reuse the release gate.

### Check yourself

1. In the script, why does the parts check sum probabilities instead of using each unit's most likely scope?
   - A. Summing is faster to compute than picking the maximum
   - B. Long-lead parts can be needed even when overhaul isn't likeliest
   - C. The most likely scope is wrong more often than a random guess would be
   - D. SAP requires expected values on purchase requisitions

   Answer: B. SN-4502 is planned as a repair, yet it has a 0.43 chance of needing an impeller with a 45-day lead time. Summing chances across the week shows that risk; the most likely scope alone hides it.

2. What does the back-test result of 52% against a 43% baseline tell you?
   - A. The model is ready to replace the planner's judgment
   - B. Wrenfield's real shop will cut its late units by nine percentage points
   - C. The method beats a simple rule on synthetic, patterned data
   - D. The add-one smoothing is causing the model to lose accuracy

   Answer: C. The data is synthetic and made to contain a pattern, so the numbers show the method works, not a business result. A real shop needs its own back-test by reason and part number.

3. Under 14 CFR 43.9, which element of a maintenance record should an AI assistant never fill in?
   - A. The description of the work, drafted from technician notes
   - B. The completion date taken from the order confirmation
   - C. The signature and certificate of the person approving the work
   - D. The serial number of the unit being repaired

   Answer: C. The rule makes the approving person's signature the approval for return to service for that work. An assistant may draft the description from notes, but the signature, certificate number and kind of certificate belong to the person.

4. A technician runs `sign` with only `--by C-117` on the assistant's draft. Why does the script refuse?
   - A. C-117 is not in the certifier register
   - B. The record is incomplete and still holds the prediction
   - C. The part is export controlled and so it cannot be released at all
   - D. Records can only be signed after shipping

   Answer: B. The gate checks both who signs and whether the record is complete. A prediction is not a description of work performed, so the record stays a draft until the technician writes what was done.

5. Which SAP maintenance AI was described as generally available when this topic was written?
   - A. The Maintenance Planner Agent on every edition
   - B. The Operational Maintenance Planning Agent for all customers
   - C. A work-scope predictor in S/4HANA Defense & Security
   - D. IBP's AI-assisted MRO inventory analysis

   Answer: D. SAP's Q1 2026 highlights list IBP's MRO inventory analysis as generally available. The planner agent offered beta registration, the operational agent was limited to Early Adopter Care, and no page named a work-scope predictor.

6. Your work-scope service runs on BTP. An auditor asks whether it could release a unit by mistake. What is the strongest answer?
   - A. Its technical user lacks release rights, proven by a negative test
   - B. The model's accuracy is above the agreed threshold
   - C. The prompt tells the model never to release units
   - D. Technicians review a sample of its drafts every month before posting

   Answer: A. A prompt or an accuracy number doesn't stop an action. Only missing authorizations do, and a negative test in each release proves it.

7. A repair procedure manual may be export controlled. Your team wants to index it for a retrieval assistant on a cloud model. What should happen first?
   - A. Index it, since retrieval doesn't send the whole document
   - B. Remove part numbers from the text and then index it
   - C. Ask trade compliance whether the data and hosting need a license
   - D. Let SAP GTS check each prompt before it is sent

   Answer: C. Technical data can be controlled like goods, and hosting or access abroad can be an export. GTS checks export documents, not prompts, so the decision sits with trade compliance before anything is indexed.

## Sources

- [14 CFR 43.9: Content, form, and disposition of maintenance, preventive maintenance, rebuilding, and alteration records (eCFR)](https://www.ecfr.gov/current/title-14/chapter-I/subchapter-C/part-43/section-43.9): Opened 2026-11-26 (eCFR up to date as of 22 October 2026). An entry needs a description of the work, the completion date, the name of the person who did it if different, and the signature, certificate number and kind of certificate of the person approving it; the signature is the approval for return to service for that work only
- [SAP for Defense and Security: maintenance (sap.com)](https://www.sap.com/abm/dod/maintenance.html): Opened 2026-11-26. No page date. Lists MRO capabilities: multiresource maintenance planning and scheduling, base maintenance, line maintenance, maintenance for components, maintenance for engines and complex assets, configuration management, maintenance programs, service parts warehousing and fulfillment, flight operations support for defense; names SAP Asset Strategy and Performance Management as part of SAP Intelligent Asset Management
- [Explaining the D&S Maintenance Processes (SAP Learning, Exploring Fundamentals of SAP S/4HANA Defense & Security)](https://learning.sap.com/courses/sap-s-4hana-defense-security-overview/explaining-the-d-s-maintenance-processes): Opened 2026-11-26. No date. Plant maintenance and SAP EAM objects (notification, maintenance plans including multiple counter plans, order, task list), installation and dismantling of equipment, the Configuration Control component with a master parts list and configuration check, the Status Board app
- [Maximizing Value for the Aerospace and Defense Industry with SAP (SAP Learning)](https://learning.sap.com/courses/introducing-the-aerospace-defense-industry/maximizing-value-for-the-aerospace-and-defense-industry-with-sap-business-ai): Opened 2026-11-26. No date. Names predictive maintenance, inventory forecasting, production scheduling and quality monitoring as A&D applications of SAP Business AI; points to the SAP Business AI Feature Catalog in SAP Discovery Center and SAP Roadmap Explorer. No status words
- [SAP Business AI: Release Highlights Q1 2026 (SAP News, 14 April 2026)](https://news.sap.com/2026/04/sap-business-ai-release-highlights-q1-2026/): Opened 2026-11-26. General availability: SAP Integrated Business Planning, AI-assisted MRO inventory analysis (natural-language summaries of what drives recommended safety stock and reorder points); SAP S/4HANA Cloud Private Edition, AI-assisted retrieval of equipment information in service management
- [Maintenance Planner Agent (sap.com)](https://www.sap.com/products/erp/maintenance-planner-agent.html): Opened 2026-11-26. No page date. Solution type AI Agent; works with SAP S/4HANA Cloud Private Edition; 'AI Units are currently required'; resources include 'Register for Beta Testing'; no GA label; vendor claim of a 40% planner productivity increase
- [Operational Maintenance Planning Agent (sap.com)](https://www.sap.com/netherlands/products/scm/operational-maintenance-planning-agent.html): Opened 2026-11-26. No page date. Turns maintenance strategies into weekly and biweekly work plans with preventive, predictive and corrective work in one backlog; SAP S/4HANA Cloud Private Edition; only for eligible customers enrolled in an Early Adopter Care (EAC) program
- [SAP Asset Performance Management, failure curve analytics (sap.com)](https://www.sap.com/products/scm/asset-performance-management-failure-curve-analytics.html): Opened 2026-11-26. No page date. AI Feature; Weibull distributions to predict probability of failure for groups of technical objects tied to a failure mode; works with SAP Asset Performance Management; AI Units currently required
- [HCLTech iMRO: extends SAP ERP, EAM and iAM for complex asset maintenance (SAP Store partner listing)](https://www.sap.com/sk/products/scm/partners/hcl-america-solutions-inc-hcl-imro4.html): Opened 2026-11-26. No page date. Partner add-on (extensions and add-ons) for MRO on SAP ERP and SAP S/4HANA Cloud Private Edition; industries include aerospace and defense; quotation feature
- [Managing Product-Related Export Control (SAP Learning, Discovering the Basics of SAP Global Trade Services)](https://learning.sap.com/learning-journeys/discovering-the-basics-of-sap-global-trade-services/managing-product-related-export-control_f56a90ac-6e81-464c-8d03-a4ad038ea489): Opened 2026-11-26. No date. Dual-use items need licenses for export in the EU and other Wassenaar Arrangement states; SAP GTS license determination uses the item's classification (ECCN) and destination; licenses managed in the Manage Licenses app; export documents without a license are blocked until one is assigned
