Orchestrate

Report an issue

Something wrong, out of date or unclear? Tell us. Corrections are prioritized over new topics. You don't need to sign in.

0 / 2000

Don't include personal or confidential company details. Reports are reviewed with AI assistance.

Interface monitoring and error handling: what to watch where, alerts that reach the right owner, and run books

Decide where each interface's failures wait, who hears about them, how business users find and fix their own errors, and what a run book says.

Updated Nov 30, 2026
Foundational layer · 8 min read

The 60-second version

Every interface fails sometimes. A partner sends a part number nobody knows, a receiving system is down for twenty minutes, a bank file doesn't arrive. Monitoring and error handling decide what happens next: where the failed message waits, who hears about it, how quickly, and what they do.

Most landscapes get this wrong in the same three ways:

  1. Everything goes to one mailbox. Every failure and every retry sends an email to the integration team. Hundreds of messages a day, most of them noise, and the one that matters sits unread.
  2. Business errors go to technical people. An unknown part number can only be fixed by customer service, in master data. If the alert reaches an integration developer first, it waits for a forward.
  3. Nobody notices what didn't happen. A file that never arrives raises no error. Treasury finds out when the cash position looks wrong at mid-morning.

Done well, each interface has a short, written answer to five questions: Where do failed messages wait? Who owns technical errors and who owns business errors? How does an owner find one message by an order number? What raises an alert, and to whom? What does the run book say for each error?

The decision for a leader: every interface needs both owners named, and alerts must go to the person who must act, not to a shared inbox. This topic uses the course's fictional company, Calder Pumpworks, and eight of its interfaces.

Why it matters to the business

Interfaces carry orders, cash and production plans. A failure nobody sees costs more than one that stops the line, because people keep acting on the wrong picture. In the lab for this topic, Calder replays one Monday morning of failures through two designs (the numbers come from made-up data and show the method, not a real system):

  • Unknown part number. Hallam, a distributor, sends six orders with a new part number. Under the partner's draft, the alerts sit in a shared mailbox until the 08:00 check, then get forwarded: customer service hears 120 minutes after the first order failed. Under the reviewed design, one alert reaches the customer service desk and someone acts within 35 minutes.
  • The missing bank statement. No file means no error. The draft notices at 10:30, when treasury asks why cash looks wrong. A missing-message check at 07:00 tells treasury at once.
  • A leaver's mailbox. Test bench file errors went to a technician who left in October. Production found out three hours later.
  • The intercompany price mismatch wasn't found at all that morning, because nobody had an alert on that interface.

Across the morning, the draft sent 22 alerts for 8 problems; the business found 4 of them first and one not at all. The reviewed design sent 9 alerts and every owner heard within 35 minutes.

The other cost is audit and support. If logs are kept 30 days and a customer disputes an order from two months ago, there is nothing to show. If anyone with an administrator role can edit a message's data without a log, an auditor will ask how you know what was changed.

How SAP does it

As of November 2026, these SAP pieces cover interface monitoring and error handling:

  • SAP Integration Suite, Cloud Integration has its own monitor. Each message gets a processing log with a status such as Completed, Retry, Failed or Escalated (SAP documentation). Messages waiting for a retry sit in queues that an administrator can retry, move or delete (SAP documentation). Monitoring data is kept 30 days by default; longer needs archiving, where the service plan offers it (SAP documentation).
  • SAP Application Interface Framework (AIF), part of SAP S/4HANA, gives business users a view of the interfaces they are responsible for, where they can correct a message's data, restart it or cancel it (SAP Help Portal).
  • SAP Cloud ALM is SAP's central tool for alerts across a hybrid landscape. Its Integration & Exception Monitoring correlates single messages across systems, searches them by business attributes such as an order number, and sends alerts to an inbox, by email, or into tickets (SAP documentation, SAP Support).
  • SAP Solution Manager, which many on-premise customers still use for interface monitoring, leaves mainstream maintenance on 31 December 2027; SAP recommends moving to SAP Cloud ALM before then (SAP Support).

SAP gives you the monitors, the queues and the alert engine. Which owner gets which alert, and what they do next, is yours to design. Under RISE, interfaces are also yours to watch: the non-functional design topic found that SAP's standard system monitoring excludes them.

What to watch, and who acts

Kind of failure Example at Calder Where it waits Who must act Good alert
Business error Unknown distributor part on an EDI order A queue or an error status in S/4HANA The business owner (customer service) One alert per family, to the business desk
Technical error, fixes itself S/4HANA unreachable for 15 minutes, retries succeed The retry queue Nobody, if retries succeed None; alert only if retries run out
Technical error, stays A sender nobody recognizes The integration platform's error queue The integration team To on-call, at once
Backlog The plant system is down, 10 orders queue up A queue The integration team When the oldest message waits longer than a set time
Synchronous error The CRM's availability check fails for 20 minutes Nowhere: the user sees an error The integration team When the error rate passes a threshold
Nothing arrived The bank statement is missing at 07:00 Nowhere The business owner (treasury) A missing-message check at the deadline

Questions to ask

  • For each interface, who owns technical errors and who owns business errors, by name?
  • Where does a failed message wait, and how long before it is deleted?
  • Can a customer service user find a failed order by the customer's purchase order number?
  • Which failures raise an alert, to which team, and does a retry that succeeds raise one?
  • For each file or job that runs on a schedule, who hears when it doesn't arrive?
  • Who may change a message's data before reprocessing it, and is the change logged?
  • Is there a run book entry for every error code, and when was it last used?
  • Are our monitors on a tool SAP will keep maintaining after 2027?

Common misconceptions

  • "More alerts mean better monitoring." An alert per message and per retry buries the one that matters. Group repeats into one alert per family, and stay quiet when retries succeed.
  • "The integration team owns all interface errors." Most errors are business data: unknown customers, parts, prices. The integration team can't fix them and shouldn't be the first to hear.
  • "No errors means the interface is fine." A file that never arrives and a schedule that never ran produce no errors. Only a missing-message check catches them.
  • "Turn on full tracing in production so we can see everything." SAP recommends its most detailed log levels for development and test only, and they expire automatically.
  • "SAP monitors our interfaces under RISE." SAP runs the systems. Watching your interfaces and fixing their errors stays with you.

Key terms

All course terms, A to Z, in the glossary

  • Message processing log: Cloud Integration's record of one message: its steps, status and errors.
  • Retry: an automatic new attempt to deliver a message after a technical error.
  • Error family: failures with the same cause, such as six orders with the same unknown part.
  • Business error: a failure only the business can fix, usually in master data.
  • Technical error: a failure in connections, credentials, mappings or capacity.
  • Missing-message check (heartbeat): an alert raised when an expected message hasn't arrived by a deadline.
  • Business key: a value the business knows, such as a customer purchase order number, written into the logs so people can search for it.
  • Run book: for each error code, what to check, how to fix it, how to reprocess, and when to cancel instead.
  • SAP Application Interface Framework (AIF): an S/4HANA framework for monitoring interfaces and correcting their errors, built for business users.
  • SAP Cloud ALM: SAP's cloud tool for application lifecycle management, including central integration monitoring and alerts.

Check yourself

Pick one answer for each question. The explanation appears after you choose.

1Calder's distributor sends six orders with an unknown part number. Who should get the first alert?

Answer: B. An unknown part is a business error: only customer service can add the cross-reference and reprocess. Sending it to integration first adds a forwarding delay, which cost Calder 120 minutes in the lab's draft design.

2The bank statement doesn't arrive one morning. What catches this before treasury notices?

Answer: D. A file that never arrives produces no failed message, so error alerts stay silent. Only a check that expects the file by a deadline, with treasury as the owner, turns its absence into an alert.

3Retries deliver three orders after S/4HANA was down for 15 minutes. What should the monitoring do?

Answer: D. Retries exist to absorb short outages. Alerting on each one creates noise that buries the real problems; the alert belongs to the case where retries are exhausted and a person must act.

4Why should every interface log a business key such as the customer's purchase order number?

Answer: B. People ask about orders by the numbers they know, not by technical message IDs. With the key in the logs, customer service finds the failed message itself instead of opening a ticket.

5What should a leader check about Calder's interface monitoring before 2028?

Answer: B. SAP Solution Manager's mainstream maintenance ends on 31 December 2027, and SAP recommends moving to SAP Cloud ALM before then. Monitoring built on Solution Manager needs a plan.

6Who should be allowed to change a failed message's data before it is reprocessed?

Answer: D. Correcting data is sometimes the fastest fix, but it changes a business document's source. Named owners and a change log let you show an auditor who changed what and why.
Deep layer · 40 min read

Mental model

A failed message is a work item with an owner, not a log line. Monitoring answers two questions for every failure: where does the work item wait, and who must pick it up. Everything else (alerts, dashboards, run books) exists to get the item from the first place to the second person quickly, without burying them in noise.

Three consequences follow:

  1. Classify before you route. Each error code is either technical (the integration team fixes it, the message runs again unchanged) or business (a business owner fixes data, then the message runs again). The integration lead's toolkit introduced this split; this topic wires alerts to it.
  2. Alert on decisions, not events. A retry that succeeds needs no decision. Six messages with the same unknown part need one decision. A file that didn't arrive needs a decision even though nothing failed.
  3. Make the item findable by the business. If the logs carry the customer's purchase order number, the person who must act can find the message without a ticket.

How it works

Where a message can fail, and where it waits

A message from a distributor to S/4HANA crosses several components. Each one has its own place where failures wait and its own monitor:

flowchart LR
  P[Distributor EDI] --> CI[Cloud Integration flow]
  CI -->|retry| Q[(JMS queue I10_ERR)]
  CI --> S4[S/4HANA inbound]
  S4 -->|error| E[(IDoc status 51 or AIF error)]
  CI -.logs.-> ALM[SAP Cloud ALM]
  S4 -.logs.-> ALM
  ALM --> A[Alert to owner]
Component Where failures wait Local monitor Typical owner
Cloud Integration Message processing log; JMS queues for retries Monitor Message Processing, queue monitor Integration team
B2B (Trading Partner Management) Interchanges in the B2B monitor B2B monitoring Integration team, then business
S/4HANA inbound IDocs IDoc status 51 and others IDoc monitor, covered in IDocs in depth Business owner for data errors
S/4HANA with AIF AIF messages in error /AIF/ERR or the Fiori message monitoring apps Business owner, by recipient
Event broker Dead-message queues, covered in the event mesh topic Broker's queue view Integration team
File transfer Error folders, reject files, covered in file and batch interfaces Job and message monitors Business owner for rejects
Synchronous API Nowhere: the caller gets an error API Management analytics, covered in API Management in depth Integration team

The design rule: for every interface, name the place where failed messages wait. A synchronous call has none, so it needs an error-rate alert instead.

Cloud Integration: statuses, queues and the business key

Cloud Integration writes a message processing log for each message. SAP documents these statuses (SAP documentation):

Status Meaning (paraphrased) Alert?
Completed Delivered No
Processing Still running Only if it runs far too long
Retry An error occurred and a retry started automatically No, unless retries run out
Escalated An error occurred and no retry was triggered Yes
Failed Final: not delivered, no retries possible Yes
Cancelled A queue entry was cancelled by hand No; record who and why
Discarded A scheduler-started run that was restarted on another node No
Abandoned Interrupted or not updated for a long time; may resume Yes, if it doesn't resume

Messages that wait for a retry sit in JMS queues. In the queue monitor, each message shows Waiting, Overdue, Failed or Blocked; Overdue means it passed its Due At date, which comes from the sender adapter's Retention Threshold for Alerting. Blocked messages were involved in repeated node crashes and aren't restarted automatically. An administrator can retry a message (non-exclusive queues; roles PI_Integration_Developer or PI_Administrator), move up to 100 messages to another queue, or delete it (PI_Administrator) (SAP documentation). Retry and delete are business-relevant actions: a deleted order message is an order nobody will ever see.

The business key comes from headers the flow sets. SAP_ApplicationID becomes the Application Message ID you can filter on, and it can be set in a Content Modifier step. A Correlation ID ties together the logs of flows that call each other (SAP documentation). The queue monitor also shows SAP_MessageType, SAP_Sender, SAP_Receiver and a custom status from SAP_MessageProcessingLogCustomStatus. Setting SAP_ApplicationID to the customer purchase order number is one line in the flow design and saves many support tickets.

Log levels and retention

The log level decides what the processing log records (SAP documentation):

Level What is recorded Production use
None Nothing No: failures become invisible
Error Failed messages only Careful: a final successful retry isn't recorded, so the log stays at Retry or Failed although the message arrived
Info Basic information, details for failed messages The default choice
Debug Every step SAP recommends development or test only; expires after 24 hours in Cloud Foundry
Trace Every step plus message content Development or test only; expires after 10 minutes by default, content kept 1 hour by default

Trace records payloads, which may hold personal or commercial data. Treat switching it on in production as a change with an owner and a reason.

Monitoring data in Cloud Integration is kept 30 days by default. To keep it longer, archive it to a content management system that supports CMIS 1.1, if your service plan includes archiving; SAP notes that archived data isn't encrypted in that system (SAP documentation). Decide per interface: orders and bank statements usually need evidence for longer than 30 days.

S/4HANA: IDocs and the Application Interface Framework

Inside S/4HANA, failed inbound messages wait where they stopped: an IDoc in status 51, a SOAP message in error, an AIF message in error. The IDocs topic covers IDoc statuses and reprocessing; the SOAP and OData topic covers service errors.

SAP Application Interface Framework (AIF) puts a business-facing layer on top. Its SAP Help Portal documentation describes (SAP Help Portal, Interface Monitor):

  • Interface Monitor (/AIF/IFMON): an overview of the interfaces a user is responsible for.
  • Monitoring and Error Handling (/AIF/ERR): restart a message, cancel it (status Canceled Manually), change its data, or maintain a missing value mapping from the error message.
  • Recipients: developers configure in Customizing which recipients get alerts for an interface, so business users see only their own area. A user gets one alert e-mail for the first failed message of an interface and no more until they confirm that alert.
  • Key fields: an interface can define fields, such as an order number, that users search and group by.

In S/4HANA Cloud, SAP described the message monitoring apps as built on AIF. SAP's November 2021 blog names Message Monitoring for Integration Experts and Message Monitoring for Administrators, available from S/4HANA 2021 and S/4HANA Cloud 2108, alongside the earlier Message Monitoring app for business users; they can edit a payload, restart and cancel, with edits written to a change log (SAP blog, 2021). App names change between releases, so check the current SAP Fiori apps reference library for yours.

The control that matters: who may change a message's data. AIF writes the change to a log and lets you restrict editing by authorization. Name the owners in the run book.

Central monitoring: SAP Cloud ALM

Local monitors are where you fix; a central monitor is where you notice. As of November 2026, SAP positions SAP Cloud ALM as the central tool for monitoring and alerting across cloud and on-premise systems (SAP documentation). Its Integration & Exception Monitoring (SAP Support):

  • shows message status per system or cloud service, grouped into scenarios;
  • correlates a message's steps across components and shows related messages such as retries;
  • lets users search by business attributes such as an order number, if the component sends that context;
  • raises alerts to an Alert Inbox, where someone assigns a processor, comments, postpones or confirms; event actions can create an alert, send an e-mail to verified recipients or start an operation flow.

What it collects depends on the product. For SAP S/4HANA and SAP Business Suite, SAP lists AIF messages, IDocs, web service messages and PI messages, plus exceptions such as ABAP runtime errors, update errors, gateway errors and aborted jobs, each tied to an ST-PI support package (SAP Support). For SAP S/4HANA Cloud Public Edition the list is shorter, and SAP notes that OData and API messages of custom (Z) interfaces aren't shown (SAP Support). For Cloud Integration, Cloud ALM reads the existing processing logs, so the flow's log level decides what appears (SAP Support); the connection uses a Process Integration Runtime service instance with plan api and monitoring roles (SAP Support).

SAP Solution Manager's mainstream maintenance ends on 31 December 2027, and SAP recommends completing the move to Cloud ALM before then; SAP Focused Run remains an option for large on-premise landscapes (SAP Support).

Alert design

Good alerting is a short list of rules, applied per interface:

  1. Route by category. Business codes go to the business route; technical codes go to integration on-call.
  2. One alert per family. Repeats of the same code and cause add to an open alert instead of creating new ones.
  3. Quiet on retry. Alert when retries run out (Failed, Escalated), not on Retry.
  4. Backlog by age. For queues, alert when the oldest message has waited longer than a threshold, not per message.
  5. Error rate for synchronous calls. Alert when the failure rate passes a threshold over a window.
  6. Missing-message checks. For every scheduled interface, a deadline by which something must have arrived.
  7. Routes are teams, not people. A personal mailbox dies when the person leaves.

The lab below applies these seven rules to Calder and measures the difference.

The run book

A run book is one table per interface: for each error code, who acts, what to check, how to fix, how to reprocess, and when to cancel instead. It is the artifact a new team member uses at 07:00 on a Monday. The lab writes one from the design file, so the design and the run book can't drift apart.

Build it yourself: Calder's monitoring design, replayed

Before you start: set up your computer with Set up your computer for this course and the unit's own Set up for Unit 26. This lab uses only Python's built-in modules.

You will build a small lab that checks a monitoring design against twelve rules, replays one Monday morning of interface failures through it, searches the logs by a business key and writes a run book. You compare the partner's draft design with a reviewed one.

flowchart LR
  D[design_draft.json] --> R[Review: rules MN01-MN12]
  V[design_reviewed.json] --> R
  E[Monday's 16 events] --> P[Replay: who hears, how fast]
  D --> P
  V --> P
  V --> B[runbook.md]

The eight interfaces come from earlier Unit 26 topics: I02 released production orders to the Rockford MES, I03 the nightly open-order file to the CRM, I08 bank statements, I10 distributor EDI orders, I11 intercompany IDocs with ECC, I12 the CRM's availability check, I13 cost centers to SuccessFactors Employee Central, and I14 test bench result files.

What you need

  • The course folder orchestrate-course with its .venv, from the setup topic.
  • Time: about 45 minutes.
  • Cost: free. No account, no network.

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):

      .venv\Scripts\Activate.ps1
    • macOS / Linux:

      source .venv/bin/activate
  4. Create the unit folder if it doesn't exist yet:

    • Windows (PowerShell):

      New-Item -ItemType Directory -Force unit26
    • macOS / Linux:

      mkdir -p unit26

Step 2: Create the script

  1. In VS Code, create the file unit26/monitor_lab.py.
  2. Paste this script and save it.
"""Interface monitoring lab for Unit 26: review a monitoring design, replay a morning
of interface errors through it, search by business key and write a run book.

Built-in modules only, no randomness. Calder Pumpworks and every value here are
fictional course labels, not SAP settings.
"""
import argparse
import copy
import json
import statistics
import sys
from pathlib import Path

FOLDER = Path(__file__).resolve().parent / "monitoring"
LEAVERS = {"00100094"}
DAY = "2026-11-30"
COLLECT_MIN = 5          # course value: minutes until a failure shows up centrally
FORWARD_MIN = 30         # course value: a forwarded mail reaches the business owner

ROUTES = {
    "INT-ONCALL": {"kind": "tech", "mode": "immediate", "react_min": 10,
                   "to": "Integration on-call (int-oncall@calder-pumpworks.example)"},
    "CS-DESK": {"kind": "biz", "mode": "immediate", "react_min": 30, "to": "Customer service desk"},
    "TREASURY": {"kind": "biz", "mode": "immediate", "react_min": 30, "to": "Treasury"},
    "PROD-SUPERVISORS": {"kind": "biz", "mode": "immediate", "react_min": 30, "to": "Production supervisors"},
    "SALES-OPS": {"kind": "biz", "mode": "immediate", "react_min": 30, "to": "Sales operations"},
    "IC-TEAM": {"kind": "biz", "mode": "immediate", "react_min": 30, "to": "Intercompany team"},
    "CONTROLLING": {"kind": "biz", "mode": "immediate", "react_min": 30, "to": "Controlling"},
}


def iface(iid, name, kind, tech, biz, route, waits, local, key, codes, **extra):
    row = {
        "id": iid, "name": name, "kind": kind, "tech_owner": tech, "biz_owner": biz,
        "biz_route": route, "waits_in": waits, "local_monitor": local,
        "central": True, "central_reason": "", "business_key": key,
        "error_codes": codes, "alert": {"tech": "INT-ONCALL", "biz": route,
                                        "on_retry": False, "group": True},
        "schedule": "", "heartbeat": "", "log_level": "Info", "retention_days": 30,
        "audit": False, "archive_days": 0, "edit_by": "nobody", "edit_logged": True,
        "runbook": {},
    }
    row.update(extra)
    return row


def rb(check, fix, reprocess, cancel):
    return {"check": check, "fix": fix, "reprocess": reprocess, "cancel_when": cancel}


def reviewed():
    rows = [
        iface("I02", "Released production orders to the Rockford MES", "async",
              "00100288", "00100314", "PROD-SUPERVISORS", "Cloud Integration queue I02_CONF",
              "Monitor Message Processing; Manage Message Queues", "production order number",
              {"CONN": "tech", "ORDER_UNKNOWN": "biz"},
              alert={"tech": "INT-ONCALL", "biz": "PROD-SUPERVISORS", "on_retry": False,
                     "group": True, "backlog_min": 15},
              runbook={"CONN": rb("Is the MES reachable from the edge cell?", "Restore the connection",
                                  "Messages in I02_CONF retry by themselves", "Never: orders must arrive"),
                       "ORDER_UNKNOWN": rb("Was the order released twice or deleted?", "Correct the order in S/4HANA",
                                           "Retry the message in the queue", "The order was deleted")}),
        iface("I03", "Open sales order items to the CRM (nightly file)", "file",
              "00100288", "00100296", "SALES-OPS", "SFTP outbound folder and the CRM reject file",
              "Application Jobs; Monitor Message Processing", "run ID",
              {"LATE": "tech", "REJECT": "biz"}, schedule="daily", heartbeat="05:00",
              runbook={"LATE": rb("Did night job BILL finish?", "Restart the extract after BILL",
                                  "Rerun with the same run ID", "Never"),
                       "REJECT": rb("Which rows did the CRM reject?", "Correct the order data",
                                    "Next night's file carries the row again", "The order was closed")}),
        iface("I08", "Bank statements (camt.053)", "file",
              "00100288", "00100280", "TREASURY", "SAP Multi-Bank Connectivity: Manage Bank Messages",
              "Manage Bank Messages", "statement ID", {"MISSING": "biz", "FORMAT": "tech"},
              schedule="daily", heartbeat="07:00", audit=True, archive_days=90,
              runbook={"MISSING": rb("Did the bank send it? Ask the bank's service desk", "Bank resends",
                                     "Import the resent statement once", "Never"),
                       "FORMAT": rb("Which field failed the import?", "Fix the mapping",
                                    "Reprocess the bank message", "Never")}),
        iface("I10", "Distributor purchase orders (EDI to sales orders)", "async",
              "00100292", "00100296", "CS-DESK", "Cloud Integration queue I10_ERR; IDoc status 51 in S4P",
              "Monitor Message Processing; B2B monitor; IDoc monitor", "customer PO (SAP_ApplicationID)",
              {"E01": "tech", "E02": "biz", "E03": "biz", "E04": "tech", "E05": "tech"},
              audit=True, archive_days=90, edit_by="CS-DESK in S/4HANA, with change log",
              runbook={"E01": rb("Is the sender a known partner?", "Onboard the partner or reject",
                                 "Reprocess after onboarding", "Unknown sender stays unknown"),
                       "E02": rb("Which distributor part is unknown?", "Add the customer-material record",
                                 "Reprocess every message of the family", "Never"),
                       "E03": rb("Does an order with this customer PO exist?", "Nothing to fix",
                                 "Do not reprocess", "Always: it is a duplicate"),
                       "E04": rb("Which unit came in?", "Add the unit to the value mapping",
                                 "Retry from I10_ERR", "Never"),
                       "E05": rb("Is S4P up? Are retries still running?", "Wait or restore the connection",
                                 "Retries run by themselves; then retry from I10_ERR", "Never")}),
        iface("I11", "Intercompany orders and invoices (IDoc EDI with ECC)", "async",
              "00100292", "00100280", "IC-TEAM", "IDoc status 51 in ECP and S4P",
              "IDoc monitor in each system", "purchase order number",
              {"IC_PRICE": "biz", "PORT": "tech"}, central=False,
              central_reason="ECC CP20 not connected to Cloud ALM; I11 retires 2027-07-05",
              runbook={"IC_PRICE": rb("Price on PO vs sales order", "Agree the price; correct one side",
                                      "Reprocess the IDoc", "Never"),
                       "PORT": rb("Is the RFC port reachable?", "Fix the connection",
                                  "Resend the IDoc", "Never")}),
        iface("I12", "Availability check while quoting (CRM calls S/4HANA)", "sync",
              "00100292", "00100296", "SALES-OPS", "", "API Management analytics",
              "CRM quote number", {"HTTP_5XX": "tech"},
              alert={"tech": "INT-ONCALL", "biz": "SALES-OPS", "on_retry": False, "group": True,
                     "error_rate_pct": 5, "window_min": 10},
              runbook={"HTTP_5XX": rb("Is S4P or the proxy failing?", "Restore the back end",
                                      "The caller retries; nothing to reprocess", "Not applicable")}),
        iface("I13", "Cost centers to SuccessFactors Employee Central (MDI)", "master",
              "00100292", "00100312", "CONTROLLING", "Master Data Integration log",
              "MDI log; Data Replication Framework", "cost center", {"MD_VALIDATION": "biz", "MDI_DOWN": "tech"},
              runbook={"MD_VALIDATION": rb("Which field failed?", "Complete the cost center",
                                           "Replicate again", "Cost center created by mistake"),
                       "MDI_DOWN": rb("Is MDI reachable?", "Open an SAP incident",
                                      "Replicate again", "Never")}),
        iface("I14", "Test bench result files from the Rockford share", "file",
              "00100288", "00100314", "PROD-SUPERVISORS", "Error folder on the NFS share",
              "Monitor Message Processing", "pump serial number", {"PARSE": "tech"},
              runbook={"PARSE": rb("Is the file complete? Did the bench PC restart?", "Bench writes the file again",
                                   "Move the file back to the inbound folder", "A newer file for the serial exists")}),
    ]
    return {"design": "reviewed", "as_of": DAY, "routes": ROUTES, "interfaces": rows}


def draft():
    d = copy.deepcopy(reviewed())
    d["design"] = "draft"
    d["routes"] = dict(d["routes"])
    d["routes"]["INT-MAILBOX"] = {"kind": "tech", "mode": "checks", "checks": ["08:00", "10:00", "12:00"],
                                  "to": "Shared mailbox int-alerts@calder-pumpworks.example"}
    d["routes"]["MAIL-00100094"] = {"kind": "tech", "mode": "never", "to": "Personal mailbox of 00100094"}
    for r in d["interfaces"]:
        r["alert"] = {"tech": "INT-MAILBOX", "biz": "INT-MAILBOX", "on_retry": True, "group": False}
        r["heartbeat"] = ""
        r["runbook"] = {k: v for k, v in r["runbook"].items() if k in ("E02", "E05", "CONN")}
    by = {r["id"]: r for r in d["interfaces"]}
    by["I08"]["archive_days"] = 0
    by["I10"].update(business_key="", log_level="Trace", archive_days=0,
                     edit_by="anyone with PI_Administrator", edit_logged=False)
    by["I02"]["log_level"] = "Error"
    by["I11"].update(central_reason="", alert={"tech": "", "biz": "", "on_retry": False, "group": False})
    by["I12"].update(biz_owner="", alert={"tech": "", "biz": "", "on_retry": False, "group": False})
    by["I14"]["alert"] = {"tech": "MAIL-00100094", "biz": "MAIL-00100094", "on_retry": True, "group": False}
    return d


def ev(t, iid, code, key, status="FAILED", family=None, found=None, **extra):
    e = {"t": t, "if": iid, "code": code, "key": key, "status": status,
         "family": family or f"{iid}-{code}", "found_by_business": found}
    e.update(extra)
    return e


EVENTS = [
    ev("06:12", "I14", "PARSE", "ES200-0031", found="09:00", detail="file TB1-0612 cut off: bench PC restarted"),
    *[ev(t, "I10", "E02", f"HFS-PO-{8260 + i}", family="I10-E02-HFS-SK-210", found="11:30",
         detail="unknown distributor part HFS-SK-210")
      for i, t in enumerate(["06:30", "06:45", "07:00", "07:15", "07:30", "07:45"])],
    ev("07:00", "I08", "MISSING", "camt.053 for 2026-11-27", status="MISSING", found="10:30",
       detail="no statement arrived by 07:00"),
    ev("07:20", "I10", "E05", "HFS-PO-8266", status="RETRY", family="I10-E05", resolved="07:35",
       detail="S4P not reachable; retries succeeded"),
    ev("07:22", "I10", "E05", "VIS-PO-0420", status="RETRY", family="I10-E05", resolved="07:35",
       detail="S4P not reachable; retries succeeded"),
    ev("07:24", "I10", "E05", "QPS-PO-1110", status="RETRY", family="I10-E05", resolved="07:35",
       detail="S4P not reachable; retries succeeded"),
    ev("08:05", "I02", "CONN", "1100047-1100056", status="WAITING", count=10, resolved="08:55",
       found="08:40", detail="MES unreachable; 10 orders wait in I02_CONF"),
    ev("09:10", "I13", "MD_VALIDATION", "CP11-470", detail="cost center without profit center"),
    ev("09:30", "I12", "HTTP_5XX", "error rate 12%", status="RATE", rate_pct=12, until="09:50",
       found="10:15", detail="CRM users see availability errors"),
    ev("10:00", "I11", "IC_PRICE", "4500000014", detail="455.00 USD on the PO, 480.00 on the sales order"),
    ev("11:00", "I10", "E01", "XYZ-PO-0002", detail="unknown sender XYZTRADE"),
]


def minutes(hhmm):
    h, m = hhmm.split(":")
    return int(h) * 60 + int(m)


def hhmm(total):
    return f"{total // 60:02d}:{total % 60:02d}"


def load(name):
    path = FOLDER / f"design_{name}.json"
    if not path.exists():
        sys.exit(f"{path.name} not found. Run: python unit26/monitor_lab.py --init")
    try:
        return json.loads(path.read_text(encoding="utf-8"))
    except json.JSONDecodeError as err:
        sys.exit(f"{path.name} is not valid JSON (line {err.lineno})")


def check(design):
    out = []
    routes = design["routes"]
    for r in design["interfaces"]:
        i = r["id"]

        def add(rule, level, text):
            out.append((i, rule, level, text))

        bad = [p for p in (r["tech_owner"], r["biz_owner"])
               if len(p) != 8 or not p.isdigit() or p in LEAVERS]
        add("MN01", "FAIL" if bad else "OK", "owners missing or left" if bad else "technical and business owner named")
        if r["kind"] == "sync":
            ok = r["alert"].get("error_rate_pct")
            add("MN02", "OK" if ok else "FAIL", "error rate alert set" if ok else "synchronous call with no error rate alert")
        else:
            add("MN02", "OK" if r["waits_in"] else "FAIL",
                f"failed messages wait in: {r['waits_in']}" if r["waits_in"] else "nowhere to wait")
        used = sorted({x for x in (r["alert"]["tech"], r["alert"]["biz"]) if x})
        dead = [x for x in used if x not in routes or routes[x]["mode"] == "never" or x.startswith("MAIL-")]
        if not used:
            add("MN03", "FAIL", "no alert route")
        elif dead:
            add("MN03", "FAIL", f"alerts go to {', '.join(dead)}")
        else:
            add("MN03", "OK", f"alerts to {', '.join(used)}")
        cats = set(r["error_codes"].values())
        ok4 = (("biz" not in cats or r["alert"]["biz"] == r["biz_route"]) and
               ("tech" not in cats or routes.get(r["alert"]["tech"], {}).get("mode") == "immediate"))
        add("MN04", "OK" if ok4 else "FAIL",
            "business errors to the business, technical to on-call" if ok4 else "errors not split by category")
        add("MN05", "OK" if r["business_key"] else "FAIL",
            f"searchable by {r['business_key']}" if r["business_key"] else "no business key in the logs")
        if r["schedule"]:
            add("MN06", "OK" if r["heartbeat"] else "FAIL",
                f"missing-message check at {r['heartbeat']}" if r["heartbeat"] else "scheduled, but nobody notices a missing run")
        if r["retention_days"] < 30:
            add("MN07", "FAIL", "logs kept under 30 days")
        elif r["audit"] and r["archive_days"] < 90:
            add("MN07", "WARN", "audit-relevant: archive at least 90 days")
        else:
            add("MN07", "OK", f"logs {r['retention_days']} days" + (f", archive {r['archive_days']}" if r["archive_days"] else ""))
        lvl = r["log_level"]
        add("MN08", {"Info": "OK", "Error": "WARN"}.get(lvl, "FAIL"), f"production log level {lvl}")
        if r["central"]:
            add("MN09", "OK", "in the central monitor")
        else:
            add("MN09", "WARN" if r["central_reason"] else "FAIL",
                r["central_reason"] or "not central, no reason given")
        missing = [c for c in r["error_codes"] if c not in r["runbook"]]
        add("MN10", "FAIL" if missing else "OK",
            f"no run book for {', '.join(missing)}" if missing else "run book for every error code")
        ok11 = r["edit_by"] == "nobody" or (r["edit_logged"] and "PI_Administrator" not in r["edit_by"])
        add("MN11", "OK" if ok11 else "FAIL", f"data edits: {r['edit_by']}" + ("" if r["edit_logged"] else ", not logged"))
        noisy = r["alert"]["on_retry"] or not r["alert"]["group"]
        add("MN12", "WARN" if noisy and used else "OK",
            "one alert per message or retry" if noisy and used else "one alert per family, none on retry")
    return out


def review(name):
    design = load(name)
    lines = check(design)
    for i, rule, level, text in lines:
        print(f"{i:4} {rule}  {level:4}  {text}")
    counts = {lv: sum(1 for x in lines if x[2] == lv) for lv in ("OK", "WARN", "FAIL")}
    n = len(design["interfaces"])
    print(f"\n{counts['OK']} OK, {counts['WARN']} WARN, {counts['FAIL']} FAIL across {n} interfaces")
    return counts


def reach(route_name, routes, t_alert, needs):
    """Minute at which the owner who must act learns of it through this route, or None."""
    r = routes.get(route_name)
    if not r or r["mode"] == "never":
        return None
    if r["mode"] == "immediate":
        t = t_alert + r["react_min"]
        return t if r["kind"] == needs else t + FORWARD_MIN
    later = [minutes(c) for c in r["checks"] if minutes(c) >= t_alert]
    if not later:
        return None
    return later[0] + (0 if r["kind"] == needs else FORWARD_MIN)


def replay(name, quiet=False):
    design = load(name)
    routes = design["routes"]
    by = {r["id"]: r for r in design["interfaces"]}
    alerts, families = [], {}
    for e in EVENTS:
        r = by[e["if"]]
        needs = r["error_codes"].get(e["code"], "tech")
        route = r["alert"]["biz"] if needs == "biz" else r["alert"]["tech"]
        t0 = minutes(e["t"])
        fam = families.setdefault(e["family"], {"if": e["if"], "code": e["code"], "start": t0,
                                                "needs": needs, "found": e["found_by_business"],
                                                "owner_at": None, "no_owner": e["status"] == "RETRY"})
        sent = []
        if e["status"] in ("FAILED", "RETRY"):
            if e["status"] == "RETRY" and not r["alert"]["on_retry"]:
                continue
            if route and (not r["alert"]["group"] or not any(a["family"] == e["family"] for a in alerts)):
                sent.append((route, t0 + COLLECT_MIN))
        elif e["status"] == "WAITING":
            limit = r["alert"].get("backlog_min")
            if limit is not None:
                sent.append((route, t0 + limit + COLLECT_MIN))
            elif r["alert"]["on_retry"] and route:
                sent += [(route, t0 + COLLECT_MIN)] * e["count"]
        elif e["status"] == "RATE":
            pct = r["alert"].get("error_rate_pct")
            if pct and e["rate_pct"] >= pct:
                sent.append((route, t0 + r["alert"]["window_min"]))
        elif e["status"] == "MISSING":
            if r["heartbeat"]:
                sent += [(r["alert"]["biz"], t0), (r["alert"]["tech"], t0)]
        for rt, ta in sent:
            alerts.append({"family": e["family"], "route": rt, "at": ta})
            got = reach(rt, routes, ta, needs)
            if got is not None and (fam["owner_at"] is None or got < fam["owner_at"]):
                fam["owner_at"] = got
    rows, waits = [], []
    for name_f, f in families.items():
        if f["no_owner"]:
            continue
        by_alert = f["owner_at"]
        by_biz = minutes(f["found"]) if f["found"] else None
        cands = [x for x in (by_alert, by_biz) if x is not None]
        if not cands:
            rows.append((name_f, f["needs"], "not found today", "-"))
            continue
        first = min(cands)
        how = "alert" if first == by_alert else "business noticed"
        waits.append(first - f["start"])
        rows.append((name_f, f["needs"], how, f"{first - f['start']} min"))
    if not quiet:
        print(f"Replay of {DAY} 06:00-12:00 through the {design['design']} design")
        print(f"{'Family':22} {'Needs':5} {'Owner learned by':18} Wait")
        for fam_name, needs, how, wait in rows:
            print(f"{fam_name:22} {needs:5} {how:18} {wait}")
        found_late = sum(1 for x in rows if x[2] == "business noticed")
        lost = sum(1 for x in rows if x[2] == "not found today")
        print(f"\nAlerts sent: {len(alerts)} for {len(rows)} problems; "
              f"found by the business first: {found_late}; not found today: {lost}")
        print(f"Minutes to the owner who must act: median {statistics.median(waits):g}, max {max(waits)}")
    return {"alerts": len(alerts), "problems": len(rows), "waits": waits, "rows": rows}


def find(key, name):
    design = load(name)
    by = {r["id"]: r for r in design["interfaces"]}
    hits = []
    for e in EVENTS:
        r = by[e["if"]]
        if not r["business_key"]:
            continue
        if key.lower() in e["key"].lower():
            hits.append(e)
    if not hits:
        print(f"No message carries '{key}' in the {name} design's logs.")
        return 0
    for e in hits:
        r = by[e["if"]]
        print(f"{DAY} {e['t']}  {e['if']}  {e['status']:7} {e['code']:13} {r['waits_in']}")
        print(f"{'':17}{r['business_key']}: {e['key']}  {e['detail']}")
    return len(hits)


def runbook():
    design = load("reviewed")
    routes = design["routes"]
    lines = [f"# Interface run book (Calder Pumpworks, fictional), as of {design['as_of']}", ""]
    for r in design["interfaces"]:
        lines += [f"## {r['id']} {r['name']}", "",
                  f"- Technical owner: {r['tech_owner']} (alerts to {r['alert']['tech'] or 'none'})",
                  f"- Business owner: {r['biz_owner']} (alerts to {r['alert']['biz'] or 'none'})",
                  f"- Failed messages wait in: {r['waits_in'] or 'the caller (synchronous)'}",
                  f"- Search by: {r['business_key'] or 'NOT SEARCHABLE'}",
                  f"- Who may change message data: {r['edit_by']}", ""]
        if r["heartbeat"]:
            lines.insert(len(lines) - 1, f"- Missing-message check: alert if nothing arrives by {r['heartbeat']}")
        lines += ["| Code | Who | Check | Fix | Reprocess | Cancel when |", "| --- | --- | --- | --- | --- | --- |"]
        for code, cat in r["error_codes"].items():
            step = r["runbook"].get(code)
            who = routes.get(r["alert"]["biz" if cat == "biz" else "tech"], {}).get("to", "TO DECIDE")
            if step:
                lines.append(f"| {code} | {who} | {step['check']} | {step['fix']} | {step['reprocess']} | {step['cancel_when']} |")
            else:
                lines.append(f"| {code} | {who} | TO DECIDE | TO DECIDE | TO DECIDE | TO DECIDE |")
        lines.append("")
    path = FOLDER / "runbook.md"
    path.write_text("\n".join(lines), encoding="utf-8")
    print(f"Wrote {path.relative_to(FOLDER.parent.parent)} ({len(design['interfaces'])} interfaces)")


def init():
    FOLDER.mkdir(parents=True, exist_ok=True)
    for name, data in (("draft", draft()), ("reviewed", reviewed())):
        path = FOLDER / f"design_{name}.json"
        if path.exists():
            print(f"{path.name} already exists; delete it first to get the sample back")
            continue
        path.write_text(json.dumps(data, indent=2), encoding="utf-8")
        print(f"Wrote {path.name}")


def self_test():
    results = []

    def expect(label, got, want):
        results.append(got == want)
        print(f"{'OK  ' if got == want else 'FAIL'} {label}: {got}")

    lines_d = check(draft())
    lines_r = check(reviewed())
    expect("draft FAIL count", sum(1 for x in lines_d if x[2] == "FAIL"), 27)
    expect("reviewed FAIL count", sum(1 for x in lines_r if x[2] == "FAIL"), 0)
    expect("reviewed WARN count", sum(1 for x in lines_r if x[2] == "WARN"), 1)
    expect("routing of an I10 E02", hhmm(reach("CS-DESK", ROUTES, minutes("06:35"), "biz")), "07:05")
    expect("mailbox read at the next check",
           hhmm(reach("INT-MAILBOX", draft()["routes"], minutes("06:35"), "biz")), "08:30")
    expect("events in the morning", len(EVENTS), 16)
    expect("minutes()", minutes("07:45"), 465)
    expect("hhmm()", hhmm(465), "07:45")
    print("\nAll checks passed." if all(results) else "\nSome checks failed: paste the script again.")
    return all(results)


def main():
    p = argparse.ArgumentParser(description="Interface monitoring lab (Unit 26)")
    p.add_argument("--init", action="store_true", help="write the two sample designs")
    p.add_argument("--review", choices=["draft", "reviewed"])
    p.add_argument("--replay", choices=["draft", "reviewed"])
    p.add_argument("--find", metavar="KEY", help="search the morning's logs by business key")
    p.add_argument("--design", choices=["draft", "reviewed"], default="reviewed")
    p.add_argument("--runbook", action="store_true", help="write monitoring/runbook.md")
    p.add_argument("--self-test", action="store_true")
    a = p.parse_args()
    if a.init:
        init()
    elif a.review:
        review(a.review)
    elif a.replay:
        replay(a.replay)
    elif a.find:
        find(a.find, a.design)
    elif a.runbook:
        runbook()
    elif a.self_test:
        sys.exit(0 if self_test() else 1)
    else:
        p.print_help()


if __name__ == "__main__":
    main()
  1. Check that the copy is complete:

    python unit26/monitor_lab.py --self-test
    OK   draft FAIL count: 27
    OK   reviewed FAIL count: 0
    OK   reviewed WARN count: 1
    OK   routing of an I10 E02: 07:05
    OK   mailbox read at the next check: 08:30
    OK   events in the morning: 16
    OK   minutes(): 465
    OK   hhmm(): 07:45
    
    All checks passed.

Step 3: Write the two designs

python unit26/monitor_lab.py --init
Wrote design_draft.json
Wrote design_reviewed.json

Open unit26/monitoring/design_draft.json. Each interface has its owners (tech_owner, biz_owner), the business route, where failures wait, the business key, its error codes with a category (tech or biz), the alert settings, a schedule and missing-message deadline, the log level, retention, who may edit data, and run book entries.

Step 4: Review the partner's draft

python unit26/monitor_lab.py --review draft

The output lists every rule per interface and ends with:

I14  MN03  FAIL  alerts go to MAIL-00100094
I14  MN04  FAIL  errors not split by category
I14  MN05  OK    searchable by pump serial number
...
54 OK, 9 WARN, 27 FAIL across 8 interfaces

The twelve rules (course rules, built on SAP's documentation where noted):

Rule Checks Draft finding
MN01 Technical and business owner named, neither a leaver I12 has no business owner
MN02 Failed messages have a place to wait; synchronous calls have an error-rate alert I12 has neither
MN03 Alerts go to a team route that someone reads I14 goes to leaver 00100094; I11 and I12 have no route
MN04 Business codes to the business route, technical codes to on-call Everything goes to a shared mailbox read at 08:00, 10:00 and 12:00
MN05 A business key in the logs (for Cloud Integration, SAP_ApplicationID) I10 has none
MN06 Scheduled interfaces have a missing-message deadline I03 and I08 have none
MN07 Logs kept at least 30 days; audit-relevant interfaces archived 90 days I08 and I10 keep only SAP's default 30 days (WARN)
MN08 Production log level Info (Error warns; Debug, Trace or None fail), after SAP's guidance I10 runs at Trace; I02 at Error (WARN)
MN09 In the central monitor, or a written reason why not I11 is outside Cloud ALM with no reason
MN10 A run book entry for every error code Most codes missing
MN11 Data edits by named owners and logged I10: anyone with PI_Administrator, not logged
MN12 One alert per family, none on retry Alerts on every message and retry (WARN)

Step 5: Replay Monday morning through the draft

The lab holds sixteen events from Monday 2026-11-30, 06:00 to 12:00: a cut-off test bench file at 06:12, six Hallam orders with unknown part HFS-SK-210 from 06:30, a bank statement missing at 07:00, three orders retried successfully while S/4HANA was unreachable, ten production orders queued while the MES was down, a cost center rejected by Master Data Integration, twenty minutes of availability-check errors, an intercompany price mismatch on PO 4500000014, and an order from an unknown sender.

python unit26/monitor_lab.py --replay draft
Replay of 2026-11-30 06:00-12:00 through the draft design
Family                 Needs Owner learned by   Wait
I14-PARSE              tech  business noticed   168 min
I10-E02-HFS-SK-210     biz   alert              120 min
I08-MISSING            biz   business noticed   210 min
I02-CONN               tech  business noticed   35 min
I13-MD_VALIDATION      biz   alert              80 min
I12-HTTP_5XX           tech  business noticed   45 min
I11-IC_PRICE           biz   not found today    -
I10-E01                tech  alert              60 min

Alerts sent: 22 for 8 problems; found by the business first: 4; not found today: 1
Minutes to the owner who must act: median 80, max 210

How the replay counts (course assumptions): a failure reaches the central monitor 5 minutes after it happens; the shared mailbox is read at 08:00, 10:00 and 12:00; a forwarded mail reaches the business owner 30 minutes later; "business noticed" is the time the event says a user complained. The three successful retries need no owner and don't appear as a problem, but in the draft they still sent three alerts.

Step 6: Replay through the reviewed design

python unit26/monitor_lab.py --review reviewed
python unit26/monitor_lab.py --replay reviewed
89 OK, 1 WARN, 0 FAIL across 8 interfaces
Replay of 2026-11-30 06:00-12:00 through the reviewed design
Family                 Needs Owner learned by   Wait
I14-PARSE              tech  alert              15 min
I10-E02-HFS-SK-210     biz   alert              35 min
I08-MISSING            biz   alert              30 min
I02-CONN               tech  alert              30 min
I13-MD_VALIDATION      biz   alert              35 min
I12-HTTP_5XX           tech  alert              20 min
I11-IC_PRICE           biz   alert              35 min
I10-E01                tech  alert              15 min

Alerts sent: 9 for 8 problems; found by the business first: 0; not found today: 0
Minutes to the owner who must act: median 30, max 35

The one warning left is I11: ECC CP20 isn't connected to Cloud ALM, and the interface retires with the rollout on 2027-07-05. That is an accepted exception with a reason, which is what MN09 asks for. The bank statement sends two alerts (treasury and on-call), which is why 9 alerts cover 8 problems.

Step 7: Find a message by the customer's order number

Hallam's buyer calls about order HFS-PO-8262. Search both designs:

python unit26/monitor_lab.py --find HFS-PO-8262 --design draft
python unit26/monitor_lab.py --find HFS-PO-8262
No message carries 'HFS-PO-8262' in the draft design's logs.
2026-11-30 07:00  I10  FAILED  E02           Cloud Integration queue I10_ERR; IDoc status 51 in S4P
                 customer PO (SAP_ApplicationID): HFS-PO-8262  unknown distributor part HFS-SK-210

In the draft, customer service would open a ticket and wait for an integration developer to search by time and sender. With the business key, they find it, see the cause, and know the fix (add the customer-material record, then reprocess the family).

Step 8: Write the run book

python unit26/monitor_lab.py --runbook
Wrote unit26/monitoring/runbook.md (8 interfaces)

Open unit26/monitoring/runbook.md. Each interface lists its owners, where failures wait, the search key, who may change data, the missing-message deadline if any, and a table of codes. A code without an entry shows TO DECIDE.

Step 9 (sketch): Apply it to a real landscape

  1. In each Cloud Integration flow, set SAP_ApplicationID to the business key in a Content Modifier, and record each flow's log level from Manage Integration Content.
  2. In SAP Cloud ALM, connect the Cloud Integration tenant and S/4HANA under Landscape Management, group interfaces into scenarios, and switch on the monitoring categories you need.
  3. Define alert events per scenario with the route from your design file, and turn off alerts for Retry.
  4. In S/4HANA, assign business users to their AIF recipients, and restrict who may edit message data.
  5. Fill one design entry per interface, run the review, and publish the run book.

Step 10: Save your work

git add unit26/monitor_lab.py unit26/monitoring
git commit -m "Unit 26: interface monitoring design and run book"

How the code works

Part What it does
ROUTES, reviewed(), draft() The alert routes and the two designs, written to JSON by --init
EVENTS Monday morning's sixteen events, with the time a user would have complained
check() Applies MN01 to MN12 to every interface
reach() When the owner who must act hears through a route: at once, at the next mailbox check, or after a forward
replay() Sends each event through the design's alert settings, groups families and measures the wait
find() Searches the events by business key, only where the design logs one
runbook() Writes runbook.md from the reviewed design
self_test() Eight checks on the built-in samples

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; on macOS/Linux use python3 until .venv is active
No module named ... A different script was pasted 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/monitor_lab.py --init from orchestrate-course
already exists; delete it first --init doesn't overwrite your edits Delete the file only if you want the sample back
is not valid JSON (line N) A comma or bracket is missing after an edit VS Code marks the line; fix it and run again
KeyError with a field name A new interface or route is missing a field Copy an existing entry and change its values
Your counts differ from the samples The files were edited Run --self-test, then --init in a fresh folder
A company proxy blocks downloads Not used here The lab needs no network

The SAP way

What SAP provides, as of 30 November 2026:

Need SAP offering Notes
Monitor flows and queues Cloud Integration Monitor Statuses, queue actions, SAP_ApplicationID filter; 30 days of data by default (SAP documentation)
Keep logs longer Cloud Integration archiving to a CMIS system Depends on the service plan
Explain a failed flow AI-assisted Error Resolution in Cloud Integration For Failed logs only; proposes a root cause, the first failed step and a solution; monthly fair-usage quota; depends on the service plan (SAP documentation)
Business users fix their own errors in S/4HANA SAP Application Interface Framework /AIF/ERR in SAP GUI; Fiori message monitoring apps, which SAP's 2021 blog dates to S/4HANA 2021 and S/4HANA Cloud 2108
B2B partners B2B monitoring in Trading Partner Management Covered in B2B and EDI
Central view and alerts SAP Cloud ALM Integration & Exception Monitoring Content differs by product; Cloud Integration logs read as they are
Large on-premise landscapes, service providers SAP Focused Run SAP's documentation recommends it for these cases
Legacy central monitoring SAP Solution Manager Mainstream maintenance ends 31 December 2027
Application telemetry on BTP SAP Cloud Logging and SAP Alert Notification Covered in observability on BTP

Build vs. SAP

Situation Use Why
Interfaces through Cloud Integration and S/4HANA Cloud ALM for alerts, local monitors for fixing Correlation and alert inbox come with it
Business users must fix data errors in S/4HANA AIF recipients and the message monitoring apps Built for this, with a change log
A non-SAP middleware in the path Its own monitor, forwarding alerts into your ticket tool Cloud ALM shows only what it can read
Custom Z OData interfaces in Public Edition An error-rate alert at the caller or in API Management Cloud ALM doesn't show them, per SAP's content page
Missing-message checks A small scheduled check per interface, unless your central monitor covers that interface's schedule Absence is the one failure that logs nothing
A dashboard of your own Only on top of the same design file A second definition of owners drifts

Architecture view

Where it sits. Monitoring is a layer across the landscape: local monitors in Cloud Integration, S/4HANA (IDocs, AIF, services), the event broker and file transfer; a central monitor (SAP Cloud ALM) that reads them; and alert routes into team inboxes, e-mail, chat or the ticket tool. The diagram in How it works shows the path for one interface.

Non-functional requirements.

Requirement Typical target (course values) What breaks if missed
Time to the right owner Within 30 minutes on working days Orders wait, customers call first
Noise One alert per family; none on successful retry Real alerts drown
Missing messages Deadline per scheduled interface Silent failures found hours later
Evidence Logs 30 days; orders and bank 90 days archived Disputes and audits can't be answered
Data protection Trace only with a change record; payload access restricted Personal or commercial data in logs
Tool lifecycle No dependency on SAP Solution Manager after 2027 Unsupported monitoring

Integration and identity. Cloud ALM connects to Cloud Integration through a Process Integration Runtime instance with plan api and OAuth client credentials (SAP Support); for ABAP systems, SAP ties each monitoring category to an ST-PI support package (SAP Support). Business users fix errors in S/4HANA under their own user, so their authorizations decide which interfaces and fields they can touch. Alert routes should be groups in your identity provider, not named individuals.

The decision to record.

  • Context: Calder's interfaces send all failures to one shared mailbox; business errors wait for forwards; scheduled interfaces have no missing-message checks; Solution Manager isn't in use, but on-premise teams ask for it.
  • Options: (a) keep the shared mailbox with more people reading it; (b) local monitors only, each owner checks their own; (c) SAP Cloud ALM as the central alert engine with routes by category, AIF for business users in S/4HANA, local monitors for fixing.
  • Decision: (c), with the design file as the single list of owners and routes, and the run book generated from it.
  • Consequences: each new interface needs a design entry before go-live; Cloud ALM coverage is checked per product; I11 stays outside it until it retires on 2027-07-05.

What a design review will ask.

  1. For each interface, where does a failed message wait and for how long?
  2. Which alerts go to business users, and can they fix the error without IT?
  3. How do you notice a scheduled file that never arrived?
  4. Who may change a message's data, and where is the change logged?
  5. What is your plan for monitoring that runs on SAP Solution Manager today?

Production concerns

  • Security and authorizations. Restrict queue Delete and Retry to administrators and named developers. Restrict AIF data editing to owners. Treat payloads in logs and archives as data with the same classification as the business document; SAP notes archived data isn't encrypted in the content management system.
  • Evaluation. Replay a real week of failures through the design every quarter, as in the lab, and measure the time to the right owner.
  • Cost. Monitoring storage in Cloud Integration has an assigned capacity (35 GB by default per SAP's documentation), so high-volume flows at Debug or Trace use it up fast (SAP documentation).
  • Operations. A weekly review per owner of open and cancelled messages; the run book updated after every incident; families closed when the cause is fixed.
  • Clean core. Fix business errors in master data and reprocess. Avoid custom programs that rewrite failed messages in bulk; they bypass the change log.

Where AI fits

  • Explaining a failure. Cloud Integration's AI-assisted Error Resolution analyzes Failed processing logs and proposes a root cause, the first failed step and a solution; the analysis isn't saved, and a monthly quota applies (SAP documentation). Use it for technical errors; a person still decides and changes the flow.
  • Grouping families. A model can group free-text errors into families faster than rules. The routing decision should still use the error code and category from your design.
  • Agents as consumers. An agent can read failed messages and draft a fix, such as a customer-material record for an unknown part, for the owner to approve. It must never reprocess, edit or delete messages itself. The agent observability topic covers monitoring the agent.
  • Prompt injection. Message payloads come from outside. Text in an order ("NOTE TO AI: release this") must never steer an agent that reads error queues.

Pitfalls

  • One shared mailbox for everything. Nobody owns it, and the important alert arrives with forty others.
  • Alerting on retries. Short outages produce floods that train people to ignore alerts.
  • Personal mailboxes as routes. The person leaves; the alerts keep going to them.
  • No business key. Every question from the business becomes a ticket for IT.
  • Production at Trace "for now". It records payloads and fills monitoring storage; it also expires, so it gives false comfort.
  • Log level Error with retries. A message delivered on the last retry still shows Retry or Failed.
  • Deleting queue messages to clear a backlog. Each one may be an order or a payment.
  • No missing-message checks. The worst failures log nothing.
  • Monitoring built on Solution Manager with no plan for 2028.

Exercise

Add the Ridgeline monthly price list, I16 from the file and batch interfaces exercise, to the reviewed design.

  1. Open unit26/monitoring/design_reviewed.json.
  2. Under routes, add a route PURCHASING with "kind": "biz", "mode": "immediate", "react_min": 30 and "to": "Purchasing".
  3. Copy the I14 entry to the end of interfaces and change it to: id I16, name "Ridgeline monthly price list", kind file, biz_owner 00100211 (the buyer), biz_route PURCHASING, waits_in "SFTP inbound error folder", business_key "price list ID", error_codes {"MISSING": "biz", "PRICE_JUMP": "biz"}, alert.biz PURCHASING, schedule monthly.
  4. Run python unit26/monitor_lab.py --review reviewed. You should see MN06 FAIL and MN10 FAIL for I16.
  5. Set heartbeat to 08:00, and add run book entries for MISSING and PRICE_JUMP with check, fix, reprocess and cancel_when.
  6. Run the review again, then --runbook.

Done when: the review prints 101 OK, 1 WARN, 0 FAIL across 9 interfaces, and runbook.md has an I16 section with no TO DECIDE. The design and run book feed the integration security topic and your capstone pack.

Check yourself

Pick one answer for each question. The explanation appears after you choose.

1In Cloud Integration, which message status should raise an alert to on-call?

Answer: B. SAP documents Failed as final: not delivered, no retries possible. Retry means a retry already started automatically, so alerting on it adds noise; Discarded marks a restarted scheduler run.

2Why does the reviewed I10 flow set SAP_ApplicationID to the customer purchase order number?

Answer: C. SAP_ApplicationID becomes the Application Message ID in the monitor, which can be used as a filter. In the lab, customer service found HFS-PO-8262 only in the design that logged the key.

3A team sets production flows to log level Error to save storage. What goes wrong with retries?

Answer: B. SAP documents that at Error, a final successful retry isn't recorded, so the status stays at Retry or Failed. People then chase messages that actually arrived.

4Ten orders wait in queue I02_CONF while the MES is down. What is the reviewed design's alert?

Answer: A. A backlog is one problem, so one alert by age is enough, sent to the team that can restore the connection. Per-message alerts flooded the draft with ten mails.

5What does SAP Cloud ALM show for a Cloud Integration flow that runs at log level None?

Answer: D. SAP's content page says Cloud ALM captures only existing message processing logs, so the flow's log level decides what appears. At None, no data is recorded.

6A customer service user must fix an unknown part on an inbound order in S/4HANA. What fits best?

Answer: D. AIF shows business users the interfaces of their recipient and lets them fix data, restart or cancel, with changes logged. An administrator role in Cloud Integration is far too wide, and deleting loses the order.

7Calder's bank statement must arrive by 07:00. What would you add so treasury hears when it doesn't?

Answer: B. A file that never arrives creates no message and no failure, so error alerts stay silent. In the lab, the missing-message check cut the wait from 210 to 30 minutes.

8What should Calder plan for interface monitoring that customers run on SAP Solution Manager?

Answer: D. SAP states that Solution Manager's mainstream maintenance ends on 31 December 2027 and recommends completing the transition to SAP Cloud ALM before then.
NextIntegration security: authentication between systems, certificates, OAuth, message-level security and secretsDecide how each system proves who it is, keep every certificate renewed before it breaks an interface, and know when TLS is not enough.

Sources

Sign in to track your progress

We'll email you a one-time sign-in link. No password needed.

or

Tell us a little about you

Optional, every field. It helps us pitch answers to your questions at the right level and decide which topics to write next. It is never shown publicly, and you can change or clear it anytime from the account menu.

SAP areas you work in