How to Automate ERP Data Entry from Technical Drawings with SAP

· Written by Jochen Mattes

Available in:

You can automate the transfer of dimensions, materials, tolerances, and title-block data from 2D technical drawings directly into SAP — without manual re-keying. This article walks through the architecture, field mapping, and working code for a Werk24-to-SAP integration that replaces hours of data entry per drawing with a 15-second API call.


Why this matters

Every manufacturing company that runs SAP has the same bottleneck: someone receives a technical drawing (PDF or scan), reads it manually, and types the extracted data into SAP transactions — MM01 for material masters, CS01 for BOMs, CA01 for routings, QM for inspection characteristics. The process is:

  • Slow: 15–45 minutes per drawing, depending on complexity.
  • Error-prone: Transposition errors in tolerances, wrong material codes, missed GD&T callouts.
  • Unscalable: Every new RFQ, engineering change, or supplier onboarding triggers the same manual work.
  • Invisible: There's no audit trail connecting the SAP record back to the specific callout on the drawing.

Werk24's API extracts structured PMI (Product Manufacturing Information) from the drawing and returns it as JSON. SAP's interfaces (BAPIs, IDocs, or OData) accept structured data. The integration connects the two.


Architecture overview

┌─────────────┐     ┌───────────┐     ┌─────────────┐     ┌───────────┐
│  Drawing     │────▶│  Werk24   │────▶│  Middleware  │────▶│   SAP     │
│  (PDF/scan)  │     │  API      │     │  (Python)   │     │  (BAPI /  │
└─────────────┘     └───────────┘     └─────────────┘     │  OData)   │
                         │                   │             └───────────┘
                    Structured JSON      Field mapping
                    (dims, GD&T,         + validation
                     materials,
                     title block)

Werk24 extracts → middleware maps → SAP consumes. The middleware is a lightweight script (Python, Node, or ABAP) that:

  1. Sends the drawing to Werk24.
  2. Receives structured JSON.
  3. Maps JSON fields to SAP fields.
  4. Calls the appropriate SAP interface (BAPI, IDoc, or OData).
  5. Logs the result and links back to the source drawing.

Step 1: Extract data from the drawing

Install the Werk24 Python SDK and obtain a trial license:

pip install werk24
werk24 init        # walks you through license setup
werk24 health-check  # verify everything works

Then extract structured data from a drawing using the async client:

import asyncio
from werk24 import (
    Werk24Client,
    AskMetaData,
    AskFeatures,
    AskInsights,
)

async def extract_drawing(path: str):
    """Read a technical drawing and collect metadata + features."""
    results = {}

    with open(path, "rb") as fh:
        drawing = fh.read()

    async with Werk24Client() as client:
        async for message in client.read_drawing(
            drawing,
            [AskMetaData(), AskFeatures(), AskInsights()],
        ):
            # Each message contains a response for one of the asks
            results[message.ask_type] = message

    return results

result = asyncio.run(extract_drawing("drawing.pdf"))

The SDK connects via WebSocket, streams results as they become available, and handles authentication automatically (using the license from werk24 init). Each message is a typed response object — ResponseMetaDataComponentDrawing, ResponseFeaturesComponentDrawing, or ResponseInsightsComponentDrawing — with structured fields you can access directly.

Here's a simplified view of the response structure (shown as JSON for readability — the SDK returns typed Pydantic objects):

AskMetaDataResponseMetaDataComponentDrawing:

{
  "identifiers": [
    { "value": "W24-0815-A", "identifier_type": "DRAWING_ID" }
  ],
  "designation": "Bearing housing",
  "weight": { "value": 2.35, "unit": "kg" },
  "material_options": [
    {
      "material_combination": [
        { "raw_ocr": "X5CrNi18-10", "designation": "1.4301", "standard": "EN 10088-1" }
      ]
    }
  ],
  "general_tolerances": { "tolerance_standard": "ISO_2768", "tolerance_class": "m" },
  "bill_of_material": {
    "rows": [
      { "position": "1", "part_number": "W24-0816", "designation": "Shaft", "quantity": { "value": 1, "unit": "ST" } }
    ]
  }
}

AskFeaturesResponseFeaturesComponentDrawing:

{
  "dimensions": [
    {
      "label": "120 ±0.05",
      "confidence": { "score": 0.97 },
      "size": {
        "value": 120.0, "unit": "mm",
        "tolerance": { "deviation_upper": 0.05, "deviation_lower": -0.05 }
      }
    }
  ],
  "threads": [
    { "label": "M8x1.25", "diameter": { "value": 8.0, "unit": "mm" }, "depth": { "value": 15.0, "unit": "mm" } }
  ],
  "roughnesses": [
    { "conditions": [{ "parameter": "Ra", "value": { "value": 1.6, "unit": "µm" } }] }
  ],
  "gdnts": [
    { "characteristic": "POSITION", "zone": { "value": { "value": 0.05, "unit": "mm" } }, "datums": [{ "label": "A" }, { "label": "B" }] }
  ]
}

Every field includes a confidence score. Set a threshold (e.g., ≥ 0.95 for auto-accept, < 0.95 for human review) to prevent bad data from entering SAP.


Step 2: Map Werk24 fields to SAP fields

This is where the business logic lives. The mapping depends on which SAP module you're targeting.

Material Master (MM01 / BAPI_MATERIAL_SAVEDATA)

The AskMetaData response (ResponseMetaDataComponentDrawing) provides title-block and material data:

Werk24 response fieldSAP fieldSAP tableNotes
metadata.identifiers[0].valueMATNRMARAPart / drawing number
metadata.material_options[0].material_combination[0].standardNORMTMARAMaterial standard (DIN/EN)
metadata.weight.valueNTGEWMARANet weight
metadata.weight.unitGEWEIMARAWeight unit
metadata.designationMAKTXMAKTMaterial short text
metadata.material_options[0].material_combination[0].designationWRKSTMARCMaterial specification

Bill of Materials (CS01 / BAPI_BOM_ITEM_CREATE)

If the drawing contains a parts list, AskMetaData returns metadata.bill_of_material with structured rows:

Werk24 response fieldSAP fieldNotes
metadata.bill_of_material.rows[].part_numberIDNRKComponent material number
metadata.bill_of_material.rows[].quantity.valueMENGEQuantity
metadata.bill_of_material.rows[].quantity.unitMEINSUnit of measure
metadata.bill_of_material.rows[].designationOJTXPItem text

Quality Management (QM — Inspection Characteristics)

The AskFeatures response (ResponseFeaturesComponentDrawing) provides dimensions, GD&T, and surface finish:

Werk24 response fieldSAP fieldNotes
features.dimensions[].size.valueTarget valueNominal dimension
features.dimensions[].size.tolerance.deviation_upperUpper limitUpper tolerance
features.dimensions[].size.tolerance.deviation_lowerLower limitLower tolerance
features.roughnesses[].conditions[0].valueTarget valueRa/Rz characteristic
features.gdnts[].zone.valueTolerance bandPosition/flatness/etc.

Step 3: Push data into SAP

Option A: BAPI call via RFC (PyRFC)

from pyrfc import Connection

sap = Connection(
    ashost="sap-server.example.com",
    sysnr="00",
    client="100",
    user="WERK24_SVC",
    passwd="<service-password>",
)

# Assuming `metadata` is the ResponseMetaDataComponentDrawing from Step 1
part_number = metadata.identifiers[0].value if metadata.identifiers else "UNKNOWN"
material_designation = (
    metadata.material_options[0].material_combination[0].designation
    if metadata.material_options and metadata.material_options[0].material_combination
    else ""
)

headdata = {
    "MATERIAL": part_number,
    "IND_SECTOR": "M",       # Mechanical engineering
    "MATL_TYPE": "HALB",      # Semi-finished product
}

clientdata = {
    "MATL_GROUP": "010",
    "BASE_UOM": "ST",
    "NET_WEIGHT": float(metadata.weight.value) if metadata.weight else 0,
    "UNIT_OF_WT": metadata.weight.unit if metadata.weight else "KG",
    "NORM": material_designation,
}

resp = sap.call(
    "BAPI_MATERIAL_SAVEDATA",
    HEADDATA=headdata,
    CLIENTDATA=clientdata,
    CLIENTDATAX={
        "MATL_GROUP": "X", "BASE_UOM": "X",
        "NET_WEIGHT": "X", "UNIT_OF_WT": "X", "NORM": "X",
    },
)

if resp["RETURN"]["TYPE"] == "S":
    print(f"Material {headdata['MATERIAL']} created.")
else:
    print(f"Error: {resp['RETURN']['MESSAGE']}")

Option B: OData / SAP API Business Hub

For S/4HANA Cloud or SAP BTP, use the OData API_PRODUCT_SRV:

import requests

s4_base = "https://my-s4hana.example.com/sap/opu/odata/sap/API_PRODUCT_SRV"
headers = {
    "Authorization": "Bearer <s4-oauth-token>",
    "Content-Type": "application/json",
    "X-CSRF-Token": "<fetched-token>",
}

payload = {
    "Product": part_number,
    "ProductType": "HALB",
    "BaseUnit": "ST",
    "NetWeight": str(metadata.weight.value) if metadata.weight else "0",
    "WeightUnit": metadata.weight.unit if metadata.weight else "KG",
    "IndustrySector": "M",
}

resp = requests.post(
    f"{s4_base}/A_Product",
    headers=headers,
    json=payload,
)
print(resp.status_code, resp.json())

Option C: IDoc (for batch/async workflows)

Generate a MATMAS05 IDoc XML from the Werk24 JSON and drop it into SAP's inbound queue. Best for bulk imports (e.g., processing a drawing archive).


Step 4: Confidence-gated workflow

Not every extraction should go straight to SAP. Use Werk24's confidence scores to build a three-tier workflow:

ConfidenceActionVolume (typical)
≥ 0.95Auto-create in SAP~70% of fields
0.80 – 0.95Route to human review queue~20% of fields
< 0.80Flag for manual entry~10% of fields
from decimal import Decimal

THRESHOLD_AUTO = Decimal("0.95")
THRESHOLD_REVIEW = Decimal("0.80")

# features is a ResponseFeaturesComponentDrawing from Step 1
for dim in features.dimensions:
    score = dim.confidence.score if dim.confidence else Decimal("0")
    if score >= THRESHOLD_AUTO:
        push_to_sap(dim)
    elif score >= THRESHOLD_REVIEW:
        send_to_review_queue(dim)
    else:
        flag_for_manual_entry(dim)

This prevents bad data from entering SAP while still automating the majority of entries.


Step 5: Traceability — link SAP records back to the drawing

Every SAP record should reference the source drawing and the exact location of the extracted value. Werk24 provides pixel-level coordinates (bounding boxes) for each extracted field. Store these as document links in SAP:

  • Attach the original drawing as a DMS document (transaction CV01N).
  • Store the Werk24 upload_id and per-field coordinates in a custom SAP table or as a classification characteristic.
  • When an auditor or quality engineer questions a value, they can trace it back to the exact callout on the original drawing.

What this looks like in production

A typical production deployment processes drawings in one of two modes:

Event-driven (real-time): New drawing arrives via email, EDI, or supplier portal → middleware extracts via Werk24 → auto-populates SAP → notifies the responsible engineer if any field needs review. Processing time: 15–30 seconds per drawing.

Batch (archive digitization): Existing drawing archive (thousands of PDFs/TIFFs) → batch upload to Werk24 → middleware processes results overnight → SAP records created in bulk → review queue for low-confidence items. Throughput: ~3,000 drawings/day on the provisioned tier.


Common questions

How accurate is the extraction?

Werk24 achieves 95%+ accuracy on standard technical drawings. With custom quality gates trained on your specific drawing conventions, accuracy reaches 99%. Every field includes a confidence score so you can decide programmatically what to auto-accept vs. route for review.

What if our drawings use non-standard conventions?

Werk24 supports ISO and ASME/ANSI standards, processes 7 languages, and handles both native CAD-generated PDFs and 20+ year old scans. For company-specific conventions (custom title block layouts, proprietary material codes), a custom quality gate can be configured.

Which SAP versions are supported?

Any SAP system that exposes BAPIs (ECC 6.0+), IDocs, or OData APIs (S/4HANA). The integration is at the API level — Werk24 doesn't install anything inside SAP. The middleware runs on your infrastructure or in the cloud.

How long does integration take?

Proof of concept: a few hours with the code samples above. Production integration with field mapping, confidence gating, error handling, and DMS linking: 2–6 weeks depending on the number of SAP modules involved. Werk24 includes integration support in all paid tiers.

What about data residency and security?

Data is processed in the EU (Frankfurt) or USA (customer choice). Encrypted in transit and at rest. Configurable retention from immediate deletion to 21 days. Drawings never leave the selected region and are never used to train shared models.