S/4HANA + pharma GxP
AI for SAP S/4HANA in Pharmaceuticals: Read-Only, GxP-Aware Answers From Batch and Quality Data
Short answer
AI for SAP S/4HANA in pharma works best as a read-only layer that answers questions about batches, QM inspection lots, deviations and stock without touching GxP records. It runs on your own infrastructure, shows the query behind each answer and keeps any write or disposition decision with qualified staff under your quality system.
- ERP
- SAP S/4HANA, SAP QM, SAP ATTP
- Industries
- Pharmaceuticals, Life Sciences
- Written for
- Head of Quality
Pharmaceutical manufacturing in SAP is dominated by one idea: the record is the product. A batch cannot ship without a documented manufacturing history, inspection results, a usage decision and release by a qualified person. In S/4HANA this means batch management, QM inspection lots with usage decisions, process orders, deviation and CAPA records, and often integration with an MES and LIMS that own parts of the story.
That setup produces a familiar problem. The data exists, but assembling it takes expertise. Preparing for a regulatory inspection, answering a customer complaint or deciding whether a quarantined batch can be released all require someone to pull data from several screens and systems, often under time pressure.
It also imposes constraints on AI that other industries do not have. EU GMP Annex 11 and 21 CFR Part 11 expect computerised systems that affect product quality to be validated, secured and auditable. A language model that writes into a GxP record, or whose behavior changes silently with a model update, is a validation problem. A read-only assistant that retrieves and summarises data, with a human making every decision, is a very different risk profile.
This page describes that second kind of AI on S/4HANA: what it can answer, how to deploy it so that it stays out of the validated state of your core system, and what to ask any vendor, including us, before it goes near production.
What usually gets in the way
The problems we hear most from head of quality teams running SAP S/4HANA.
Batch history assembly for release and inspection
A batch review spans process order confirmations, component batches, inspection results, deviations and equipment records. Reviewers spend a large share of their time collecting and cross-checking rather than assessing.
Deviation and CAPA trend blindness
Quality notifications and deviations are logged individually, but recurring causes across products, lines and suppliers are hard to see without custom reports.
Inspection readiness pressure
Inspectors ask for traceability of a batch from raw material to distribution on short notice. Teams rehearse this exercise because answering it live is difficult.
Validation burden discourages tooling
Any change to a validated computerised system carries documentation cost. This makes teams cautious about adding features to the core SAP system, which is reasonable but leaves reporting needs unmet.
Serialization and supply chain visibility
Track and trace obligations such as DSCSA in the United States and the EU Falsified Medicines Directive generate data in ATTP or a similar system that must reconcile with batch and shipment data in the ERP.
Where AI earns its place in SAP S/4HANA
Each use case names the ERP objects it reads or writes, so your ERP team can judge the integration effort before anyone commits budget.
Batch genealogy in one query
A reviewer asks for every component batch, supplier lot and inspection result behind a finished batch, and the assistant produces a cited genealogy from goods movements and inspection lots.
Touches: MCH1/MCHA batches, MATDOC component movements, QALS/QAVE inspection results, process order AFKO/AFPO
Outcome: Reduces the data collection portion of batch record review and inspection mock drills, leaving assessment to qualified staff.
Open deviation and quarantine status board
QA managers ask which batches are in quality inspection or blocked stock, with linked quality notifications, ages and owners.
Touches: MCHB blocked and QI stock, QMEL notifications, usage-decision status on inspection lots
Outcome: Gives a live status view that otherwise requires a manually maintained tracker.
Recurring deviation theme detection
The assistant clusters notification text and cause codes by product, equipment and shift and reports patterns for a quality council to review.
Touches: QMEL notification text and codes, work center and equipment master, process order operations
Outcome: Highlights repeated causes earlier than periodic manual trending, while CAPA decisions stay with the quality unit.
Stability and retest date monitoring
Warehouse and QA staff ask which batches approach retest or expiry dates, and the assistant lists them with stock location and open sales orders.
Touches: MCH1 shelf-life data, recurring inspection settings, MCHB stock, VBBE allocations
Outcome: Reduces last-minute scrambles and avoidable write-offs.
Serialization reconciliation support
The assistant compares quantities shipped per batch in the ERP with serialized units reported in the track-and-trace system and lists discrepancies for investigation.
Touches: Delivery documents LIKP/LIPS, batch records, ATTP serialization data where deployed
Outcome: Surfaces mismatches before they appear in an exchange with a trading partner or authority.
Supplier and material qualification overview
Procurement and QA ask which approved suppliers supply a given raw material, the latest audit and lot rejection history and any open complaints.
Touches: Source lists, vendor info records, QM vendor evaluation, inspection lots by vendor
Outcome: Supports qualification reviews with evidence in one place.
Procedure and deviation-report drafting aid
Using retrieved SOPs and the structured facts of a deviation, the assistant drafts a summary for the investigator to edit, tagged as a draft until reviewed.
Touches: QMEL deviation data, document management SOP references, batch and equipment context
Outcome: Saves writing time while accountability and the final text remain with the investigator.
Reference architecture
A read-only AI layer separate from the validated SAP production environment, reading via released APIs or a replica. The model and index run on your infrastructure, and every answer carries its sources, supporting review and audit.
- 1
Validated source, separate consumer
S/4HANA remains the system of record and its validated state is untouched; the AI layer consumes data through display-only access.
- 2
Replica or API access
CDS views and OData for light queries; a replica for batch genealogy and trend queries that join large tables.
- 3
Private model serving
Open-weight models pinned to a version, served on your hardware, with change control over model updates.
- 4
Citation and audit trail
Each answer lists the records it used and is logged with user, time and question, which supports reviews and inspections.
- 5
Human decision boundary
Drafts and summaries are labelled as such; no GxP decision, signature or record change is made by the AI layer.
Integration notes for your ERP team
- Read from a replica where possible, so reporting queries never compete with batch release transactions or MRP.
- Pin the model version and record it in the log; treat a model update as a controlled change.
- Link QM inspection results to batches using the standard keys so genealogy queries do not rely on text matching.
- If an MES or LIMS holds part of the record, integrate through its documented API and cite the system of origin in answers.
- Use display-only SAP roles and avoid sharing user accounts with the AI service.
- Keep SOP retrieval indexes limited to approved effective versions so superseded procedures are not quoted.
Deployment options
On-prem, outside the validated system boundary
Manufacturers with strict data and validation policies
AI stack lives on your hardware, reading from a replica, with its own lifecycle and change control.
Private cloud in a qualified environment
Companies already qualifying cloud infrastructure for GxP workloads
Deployed in your qualified tenancy with documented configuration and access control.
Per-site deployment
Groups with local regulatory and data residency rules
Each site queries local data while sharing governance, semantic definitions and model versions.
Compliance and data control
How the architecture supports your obligations. Certification and accountability stay with your organisation; the design keeps the evidence straightforward.
EU GMP Annex 11 and 21 CFR Part 11
Keep the AI layer read-only and outside GxP record creation. Where it supports regulated decisions, apply a risk-based assessment and your validation approach. Compliance remains your responsibility.
GAMP 5
Classify the tool by intended use, document model versions and test against defined acceptance criteria with change control.
Data integrity (ALCOA+)
Citations and query logs help show where information came from, and read-only access avoids altering original records.
DSCSA and EU FMD
Supports reconciliation reporting from ERP and serialization data. Trading-partner exchange and verification stay in your serialization systems.
Privacy and clinical data rules
Keep clinical or patient-related data out of scope unless a specific, assessed use case requires it.
Where Netray fits
ERPray
Read-only natural-language access to batch, inspection and stock data with visible queries and SAP roles respected, deployable on-prem.
DataRay
For combining ERP data with LIMS exports, SOP libraries and file-share records in one on-prem chat interface.
Custom build
For deviation trend analysis or draft-assist workflows that need tailored, validated behavior.
How an engagement runs
Phase 1 . 2 to 3 weeks
Discovery and risk assessment
- -Intended-use statement
- -Initial risk assessment with quality unit
- -Data and system boundary map
Phase 2 . 4 weeks
Foundation
- -Replica or API access with display-only roles
- -Pinned model environment
- -Logging and citation design
Phase 3 . 6 weeks
Pilot
- -Defined question set with acceptance criteria
- -Accuracy evaluation with QA reviewers
- -Test documentation
Phase 4 . Ongoing
Operate
- -Change control for models and prompts
- -Periodic accuracy review
- -Expansion to further sites
Questions to ask any vendor, including us
A short list that separates real SAP S/4HANA AI work from a chatbot demo.
- Is the tool strictly read-only, and how is that enforced?
- How are model versions controlled and changes documented?
- Can every answer be traced to the source records?
- Does the vendor claim validation, or provide support for yours?
- Where are logs stored and how long are they kept?
- How are superseded SOPs kept out of answers?
- What is the failure behavior when data is missing?
Frequently asked questions
Can AI be used with a GxP SAP system?
Yes, when scoped carefully. A read-only layer that retrieves and summarises data, with a human making every GxP decision, has a more manageable risk profile than one that writes records. You still need a risk-based assessment, documented intended use and change control. This is not legal or regulatory advice, so involve your quality unit.
Does it need to be validated?
That depends on intended use and your validation policy. A tool that only helps users find information may need lighter treatment than one influencing release decisions. Document the intended use, test against acceptance criteria and control model changes, then let your quality unit decide the level of formality.
Can it support batch record review?
It can assemble genealogy, inspection results and deviations into one cited view to reduce collection time. The review and release decision stay with qualified staff, and records should still be checked against the source system.
Will it touch the SAP validated state?
It should not. Using released APIs or a replica with display-only roles keeps the production configuration unchanged. Any write-back features should be excluded in a first deployment and added only after a separate assessment.
What about SAP ATTP and serialization?
The assistant can compare ERP shipment data with serialization data where you expose it, helping find discrepancies. Serialization events, verification requests and trading-partner messages remain in the dedicated systems.
Can we run it fully on-prem?
Yes. Open-weight models can be served locally with vLLM or Ollama, with retrieval over your SOPs and ERP replica inside your network. Hardware sizing depends on user count and document volume, and should be tested in a pilot.
Related guides
AI for SAP S/4HANA, Running On-Prem or in Your Private Cloud
Run AI on SAP S/4HANA without sending ERP data to a public API. On-prem and private-cloud architecture, CDS views, OData, and honest deployment trade-offs.
SAP QM + on-prem AIAI for SAP Quality Management: Notifications, 8D, and CAPA Without the Manual Drafting
AI grounded on SAP QM data that triages notifications, drafts 8D and CAPA reports, and summarizes inspection trends, deployed on-prem for full traceability.
SAP EWM + S/4HANA + private AIAI for SAP EWM: Ask About Warehouse Tasks, Handling Units and Stock in Plain English
AI for SAP Extended Warehouse Management: ask about warehouse tasks, handling units and storage bins in plain English, with a private model close to S/4HANA.
SAP BTP + self-hosted AISAP BTP and a Private LLM: Where the Generative AI Hub Fits and Where It Doesn't
Where SAP BTP's Generative AI Hub fits and where a self-hosted LLM belongs instead. CAP, Integration Suite, and an architecture decision framework.
SAP AI Buyer GuideSAP AI Consulting for On-Prem and Private Deployments
What to demand from an SAP AI consulting partner when data must stay on-prem or private: OData/BAPI mechanics, Joule vs. private LLM, and buyer questions.
SAP ECC 6.0 + AIGet AI Value From SAP ECC Now, and Use It to De-Risk the Move to S/4HANA
SAP ECC 6.0 mainstream maintenance ends in 2027. Add AI value on ECC now, using its existing BAPIs and IDocs, and use it to de-risk the S/4HANA migration.
Plan it with numbers
AI Pilot-to-Production Readiness Assessment
Score your AI pilot against the ten gates that decide whether it reaches production, and get a prioritized list of the gaps blocking deployment.
Free ToolERP Data Quality for AI Assessment
Score item master, customer, vendor, and transaction data quality to find out whether your ERP is ready to ground an AI copilot, forecast, or chatbot.
Free ToolCost of Quality (COQ) Calculator
Add up prevention, appraisal, internal failure, and external failure costs to see your total COQ, its share of revenue, and your gap to world-class performance.
GuideLot Traceability in Electronics Manufacturing
Lot traceability in electronics manufacturing explained: component-level genealogy, ERP lot control setup, IPC-1782 levels, recall readiness, and AI-driven trace.
GuideInfor M3 Lot Traceability Configuration Guide
Configure Infor M3 lot traceability with forward and backward tracking, recall management, lot status workflows, and serialization for regulated industries.
GuideSAP to Infor LN Migration: Assessment Framework
Evaluate migrating from SAP ECC or S/4HANA to Infor LN. Assessment framework covering costs, risks, functional gaps, and realistic timelines.
Talk it through with an engineer who knows SAP S/4HANA
Bring one real question your team cannot answer from the ERP today. We will map the data path, the model, and where it runs, and tell you honestly if AI is the wrong tool for it.