ECC Names and Types in Rust
This book lists SAP ECC tables as Rust types: every ABAP field, the Rust name it becomes, the Rust type that holds it, and the generated struct. It is built from the ABAP Dictionary itself (a DD02T and DD03L export), so a new table is a new row in the export, not a new chapter to write.
DD03L export ─▶ 11ty + lib/naming.js ─▶ site/ddic.json ─▶ src/codegen.rs ─┬─▶ Rust structs (build.rs)
└─▶ this book (cargo run --bin book)
The same code writes the structs and these pages, and tests/book.rs fails if the book and the
compiled code disagree.
- What is ABAP?: SAP’s language and its Dictionary, the ABAP types, and the three parsers: DDIC (11ty), Rust (Serde) and the XanoScript generator.
- Naming: how
/ACME/GPCbecomesacme_gpc, and every name in this book that needed more than lower-casing. - Types: how DATS, NUMC, CURR and the
"X"flag become Rust types. - Google Merchant Center: which ECC fields feed which product attribute, with machine data (identifiers, amounts, units, dates, stock) highlighted in pink and a worked example.
- GraphQL: Product and User: a
Productshaped like the Merchant API v1 product input (attributes per Google’s product data specification) and a separateUserwith the customer’s personal data and consent ledger. Every field says where it comes from. - Rust structs and GraphQL types: each Product and User field as GraphQL type, converted Rust struct, Merchant API struct and ECC source.
- Consent gaps, CRM Sync gap fill and Plan: Xano buildout: what ECC can’t say about consent, what Shopify, Google and CRM Sync fill in, the Xano ledger that holds it, and the plan for generating the Xano tables and CSV uploads from this book’s map.
- ECC direct to Google: what it replaces: why converting ECC straight to Merchant Center takes S/4HANA off the path to Google but replaces neither the upgrade nor the consent layer.
- An alternative to a full S/4HANA upgrade: a diagram of what moves from ECC to Xano and Cloudflare, what it replaces in S/4HANA and Salesforce, the benefits, and the routes compared.
- Data layer compared: ECC, Xano, Shopify and Google Cloud against Databricks, Snowflake and Fabric, and how one typed Serde record reaches any destination.
- ERP programmes in public: Revlon, Nike, Coty, Diageo, AB InBev and Honda: what happened, the reported penalty and the lesson for this layer, plus the next escalation: Shopify’s GraphQL and token changes, and agentic commerce.
- One page per table, grouped by namespace, with its key, fields, generated struct and a sample record where there is one.
- Field index: every ABAP field A to Z, with the tables it appears in.
Using a type
use abap_to_rust::sap::Kna1;
let c: Kna1 = serde_json::from_str(r#"{"MANDT":"100","KUNNR":"0000012345","ZZ_MKT_OPTIN":"X"}"#)?;
assert!(c.zz_mkt_optin); // "X" -> true
assert_eq!(c.kunnr, "0000012345"); // leading zeros kept
let back = serde_json::to_string(&c)?; // ABAP names again
Scope
The tables and fields here are illustrative subsets of standard ECC tables, plus a made-up /ACME/
customer namespace. Field lists come from fixtures/dd03l.csv, not from a live system. Export DD03L
from your own system to get your fields, your appends and your Z tables.
What is ABAP?
ABAP (Advanced Business Application Programming) is SAP’s own programming language. SAP ECC is largely written in it, and so are the custom reports, interfaces and add-ons companies build on top of SAP. ABAP also defines how ECC stores its data, and that part is what this book reads.
Four terms
| Term | What it is | In this book |
|---|---|---|
| Rust struct | A named Rust type with a fixed set of typed fields. The compiler checks every use, so a field can’t be missing, misspelled or the wrong type. | One struct per SAP table, generated from the Dictionary: sap::Kna1 has kunnr: String, erdat: Option<NaiveDate>, loevm: bool. Plus hand-written structs for what Google receives: merchant::Product, merchant_api::ProductInput. |
| Dictionary | In SAP, the ABAP Dictionary (DDIC): the metadata that describes every table, field, data element and type. Not to be confused with a Rust or Python “dictionary” (a key-value map, HashMap in Rust), or a JSON object. | The DDIC export (DD02T, DD03L) is the input. Every struct, GraphQL type, Xano table and page is generated from it. |
| JSON formatter | Code that turns a typed value into JSON text and back. In Rust that is Serde: #[derive(Serialize, Deserialize)] on a struct, serde_json for the JSON itself, and attributes or helper modules for any field whose JSON form differs from its Rust form. | Two directions. ABAP format for ECC records: #[serde(rename = "KUNNR")] keeps SAP’s field names, and src/abap.rs formats flags as "X" / "" and dates as YYYYMMDD. Google format for the Merchant API: #[serde(rename_all = "camelCase")] writes offerId, skip_serializing_if leaves out empty fields, and prices are written as micros strings ("129000000"). |
| Beautiful Soup | A Python library that parses HTML or XML into a tree you can search by tag, class or attribute. It reads markup as it is, including imperfect markup, and writes nothing back to the source. | Not used in this repo. It is the design-side counterpart of the DDIC parser: in the front-end pipeline (Webflow export → Beautiful Soup → component map → 11ty), it reads a Webflow export’s classes, data-* attributes and CMS rows into a JSON component map, as step 1 here reads DD03L into site/ddic.json. Its output is a Python dictionary (a key-value map) written out as JSON. |
The same KNA1 customer in each form:
| Form | Example |
|---|---|
| Dictionary (DD03L row) | KNA1,ERDAT,10,,ERDAT_RF,DATS,8,0,Created On |
| ECC record (JSON, ABAP format) | {"KUNNR": "0000012345", "ERDAT": "20240115", "LOEVM": ""} |
| Rust struct | Kna1 { kunnr: "0000012345", erdat: Some(2024-01-15), loevm: false, … } |
And a Webflow product card, read by Beautiful Soup:
| Form | Example |
|---|---|
| Webflow export (HTML) | <div class="product-card" data-sku="HM-QUEEN-01"><h3 class="product-title">Heated mat, queen</h3></div> |
| Beautiful Soup (Python) | card = soup.select_one(".product-card") → {"component": "product-card", "sku": card["data-sku"], "title": card.h3.get_text()} |
| Component map (JSON) | {"component": "product-card", "sku": "HM-QUEEN-01", "title": "Heated mat, queen"} |
The design side and the ERP side meet on the identifier: the card’s data-sku is the material’s offerId (MARA-MATNR),
so the page renders the converted record instead of a copy typed into the design.
And the same price, formatted for each side:
| Form | Example |
|---|---|
ECC condition record (KONP-KBETR, KONP-KONWA) | 129.00, USD |
Rust (merchant::Money) | Money { amount: 129.00 (Decimal), currency: "USD", decimals: 2 } |
Merchant API JSON (merchant_api::Price) | {"amountMicros": "129000000", "currencyCode": "USD"} |
The ABAP Dictionary
Every table and field in ECC is described in the ABAP Dictionary (DDIC). Two of its own tables are the input to this book:
| DDIC table | What it lists | Example row |
|---|---|---|
DD02T | Each table and its description | KNA1: General Data in Customer Master |
DD03L | Each table’s fields: position, key flag, data element, ABAP type, length, decimals | KNA1-KUNNR: key, CHAR 10, Customer Number |
Names carry ownership. SAP’s own tables have plain names (KNA1, MARA). A company’s additions start with Z or Y
(ZZ_MKT_OPTIN, a custom field appended to KNA1), or sit in a registered namespace between slashes (/ACME/CONSENT).
Naming shows how each becomes a Rust name.
ABAP types
| ABAP type | What it holds | Example | Rust type |
|---|---|---|---|
CHAR | Fixed-length text, padded with blanks | NAME1 = Example Retail Inc. | String |
NUMC | Digits stored as text; the leading zeros are part of the value | KUNNR = 0000012345 | String |
CHAR 1 flag | X is true, blank is false | LOEVM = X (deleted) | bool |
DATS | A date as YYYYMMDD; 00000000 means none | ERDAT = 20240115 | Option<NaiveDate> |
TIMS | A time as HHMMSS | UTIME = 021500 | Option<NaiveTime> |
CURR, QUAN, DEC | Packed decimals; a currency amount takes its decimals from the CUKY field it points to | KBETR = 129.00 | Decimal |
CLNT, LANG, CUKY, UNIT | Client, language key, currency key, unit | SPRAS = E | String |
INT1 to INT8 | Integers | SEQNO = 1 | u8 to i64 |
ABAP has no null. An empty field holds its initial value: blanks, zero or 00000000. So the converter maps an
initial value to None only where it means “not set” (a date), and keeps it as a value where it is one (a zero quantity).
The full rule table is on Types.
The parsers
Three steps turn a DDIC export into Rust, JSON for Google and XanoScript for Xano. Each fails loudly on what it can’t translate, naming the field, rather than guessing.
DD02T + DD03L export (CSV)
│
▼ 1. DDIC parser: 11ty (web/_data/ddic.js + lib/naming.js)
site/ddic.json ── tables, fields, Rust names, Rust types, Merchant map, consent map
│
├─▶ 2a. Rust code generator: build.rs + src/codegen.rs ─▶ structs (sap::Kna1, acme::Consent …), schema.graphql, this book
│
├─▶ 2b. Rust record parsers: Serde + src/abap.rs ─▶ an ECC record (JSON from RFC, IDoc or SE16) into those structs
│
└─▶ 3. XanoScript generator: src/xano.rs ─▶ xano/tables/*.xs table definitions + CSV uploads
1. The DDIC parser (11ty)
web/_data/ddic.js reads fixtures/dd02t.csv and fixtures/dd03l.csv (as from SE16 or an RFC_READ_TABLE dump).
lib/naming.js decides each name once: it splits a namespace (/ACME/CONSENT → namespace acme, struct Consent),
makes field names valid in Rust (/ACME/GPC → acme_gpc), and picks the Rust type from the type rules. A DDIC type with
no rule stops the build and names the field. The output is site/ddic.json; lib/naming.test.js tests the rules.
2a. The Rust code generator
build.rs reads site/ddic.json with Serde and writes one struct per table. Each field keeps its ABAP name for
reading and writing, and says how to parse it:
/// `KUNNR` CHAR 10 (key): Customer Number
#[serde(rename = "KUNNR")]
pub kunnr: String,
/// `ERDAT` DATS 8: Created On
#[serde(rename = "ERDAT", default, with = "crate::abap::dats")]
pub erdat: Option<chrono::NaiveDate>,
/// `LOEVM` CHAR 1: Central Deletion Flag
#[serde(rename = "LOEVM", default, with = "crate::abap::xflag")]
pub loevm: bool,
Key fields are required; every other field defaults to ABAP’s initial value when it is missing. The same generator writes
schema.graphql and these pages, and tests/book.rs fails if the book and the compiled code disagree.
2b. The Rust record parsers
src/abap.rs holds the Serde helpers for ABAP’s internal formats. They parse and write back, and refuse anything that
isn’t a valid ABAP value:
| Helper | Reads | Writes back | Refuses |
|---|---|---|---|
abap::xflag | "X" → true; "" or " " → false | "X" or "" | Any other text, e.g. "Y" |
abap::dats | "20240115" → 2024-01-15; "00000000" or "" → None | YYYYMMDD; None → "00000000" | An impossible date |
abap::tims | "021500" → 02:15:00; "" → None | HHMMSS | An impossible time |
abap::timestamp | 20261103021500 (number or string, UTC) → a date-time; 0 → None | The same 14 digits | A malformed stamp |
So the KNA1 record {"KUNNR":"0000012345","ERDAT":"20240115","LOEVM":"",…} parses into a sap::Kna1 with
kunnr = "0000012345", erdat = Some(2024-01-15) and loevm = false, and writes back unchanged. tests/convert.rs
checks that round trip, VBAK’s amount and time, the consent ledger’s newest row, and that missing keys and bad values are refused.
3. The XanoScript generator
XanoScript is Xano’s own language for tables, functions and endpoints. src/xano.rs writes one table definition per Xano
table from the same map, and cargo run --bin xano-buildout writes them to xano/tables/*.xs with the CSV uploads:
table "merchant_product" {
description = "Google Merchant Center products in the Merchant API v1 shape, flattened. No personal data."
auth = false
schema {
int id { description = "Row ID" }
text idempotency_key filters=trim { description = "SHA-256 of the row's source, subject and value: a replayed import writes nothing" }
text offer_id filters=trim { description = "id (machine; MARA-MATNR)" }
…
}
index = [ {type: "primary", field: [{name: "id"}]}, {type: "btree|unique", field: [{name: "idempotency_key", op: "asc"}]} … ]
}
The rules it applies:
- Optional means nullable.
?on the type makes a column nullable and?on the name makes it optional; an optional column here is always both, so a missing price is null, never 0. - Every row has an idempotency key, unique-indexed, so a replayed import writes nothing twice.
- Personal columns are marked
sensitive. - It generates, it doesn’t apply. The
.xsfiles are written to the repo; changes to a live workspace are applied one confirmed step at a time, as in Plan: Xano buildout.
The XanoScript side generates Xano’s language rather than parsing it. The parsing happens on the ABAP side: the DDIC in step 1 and the records in step 2b.
Where it runs: the full stack
The parsers on this page are one layer of a larger stack. Design and ERP data enter on two sides, meet on the same identifiers, and land in one system of record.
Design side ERP side
Webflow (designers) SAP ECC: DD02T / DD03L + records (RFC, IDoc, SE16)
│ export: HTML, CSS, CMS CSV │
▼ ▼
Python + Beautiful Soup 11ty DDIC parser ─▶ site/ddic.json
│ component map (JSON) │
▼ ▼
11ty: HTML from the component map Rust: structs, Serde record parsers, Merchant API JSON, XanoScript
│ │
└──────────────┬──────────────────────────┘
▼
Cloudflare: Workers + static assets serve the pages (petite-vue, UIkit, no compile step),
carry consent at the edge, and run AI calls after the release gate
│
▼
Xano: the system of record ─ each instance in its own Docker container on Kubernetes, data in PostgreSQL
│
▼
Google (Merchant, Ads, BigQuery) · Shopify · other warehouses, through the release gate
| Layer | Tools | Job | Status here |
|---|---|---|---|
| Design | Webflow | Designers keep designing; classes and CMS fields are the contract | Outside this repo |
| Design parser | Python, Beautiful Soup | Webflow export → JSON component map | Outside this repo |
| ERP parser | 11ty, lib/naming.js | DD03L export → site/ddic.json | Built |
| Typed core | Rust, Serde | Structs, record parsing, Google’s JSON, XanoScript | Built: runs as cargo commands |
| Rust nested in other layers | Rust as a Python extension (PyO3), as WebAssembly in a Worker, or inside a Tauri / Dioxus app | The same conversion rules wherever the data is handled | Proposed |
| Edge and AI | Cloudflare Workers, static assets | Serve the pages, enforce consent before any tag, run AI calls behind the release gate | The CRM Sync Worker is live; the book is a static-assets Worker |
| System of record | Xano on Docker and Kubernetes, PostgreSQL | One record for products, customers, consent and the ledger | Live; tables generated from this book |
| Destinations | Google Merchant, Google Ads, BigQuery, Shopify | Listings, conversions, audiences, analytics | Through the release gate; the Merchant sender is planned |
Why PostgreSQL underneath matters. The record lives in PostgreSQL tables, not in a proprietary store, so its shape is ordinary relational data: tables export as CSV and back up with the workspace. How directly the database itself can be reached depends on the Xano plan. The rules (types, names, consent) live in this repo’s code, not in the database, so they move with it.
Xano’s description of its own platform: Xano technology, Xano, the scalable visual BaaS.
Extending the data: BigQuery transfers and segment consent gaps
BigQuery is a destination in the stack above, not a system of record. Google’s BigQuery Data Transfer Service can extend the ECC data with commerce and media data, but each transfer brings consent gaps of its own, on top of the ECC consent gaps. Two transfers are covered here:
- The Shopify transfer, in Preview: 57 Admin GraphQL objects, one shop per transfer, through a custom Shopify app.
- The YouTube Channel transfer: 20 channel,
playlist and reach reports, each landed as a
p_table plus a view. The fields are in the YouTube Reporting API reference.
What each source is keyed by
| Source | Key | Grain | Consent it carries |
|---|---|---|---|
| ECC (CSV or IDoc extract) | KUNNR, MATNR, VBELN (leading zeros) | Header / item rows, delta batches | None (see Consent gaps) |
| Shopify transfer | GIDs (gid://shopify/Customer/…) | Nested objects landed as separate tables | Email and SMS marketing on Customers; no browser tracking consent |
| YouTube Channel transfer | channel_id, video_id, date | Aggregates by country, age group, gender, subscribed status, traffic source | None needed: no viewer is identified |
None of the three shares a key with another. The crosswalk (KUNNR ↔ Shopify GID ↔ consent subject, MATNR ↔ product
GID ↔ video_id) belongs in Xano, next to the consent ledger, not in BigQuery.
Segment consent gaps
A media segment built from YouTube data is a cohort, for example GB · 18–24 · subscribed · from YouTube search · watched video X. It is never a list of people: the channel reports have no viewer-level IDs. Consent therefore governs the other side of the join, the customer data a segment is matched or activated against.
| Gap | Where it shows up | What’s missing | Closest existing gap |
|---|---|---|---|
| Customer data lands without a consent filter | Shopify Customers, Orders, Segments, Metafields_Customer are copied on every run; the page states no PII handling | A filter or pseudonymisation at ingest, keyed to the consent ledger | Purpose |
| Two consents that never meet | Shopify carries email / SMS marketing; browser tracking consent (Customer Privacy API, Consent Mode v2) never reaches the Admin API | A join of both to one subject in the ledger | Before there is a customer |
| Email consent is not ads consent | A Shopify email opt-in is not ad_user_data or ad_personalization | A check of both ad signals before any Customer Match upload beside a YouTube segment | Audiences |
| Erasure doesn’t follow the copy | Nothing says a Shopify customers/redact reaches BigQuery; snapshots kept for history keep the person | A purge job triggered by the redact webhooks, with a receipt | Data subject requests |
| Minors in the audience | YouTube age groups include 13–17 | 13–17 excluded from every activation segment; reporting only | Minor status |
| Region and residency | The Shopify page states no data location; YouTube rows carry the viewer’s country, not the regime | The dataset location chosen per regime (EU / UK data in an EU dataset; KR held until a KR-resident store exists) | Region |
| Thresholded rows | Small cohorts come back as country ZZ, province US-ZZ, or NULL age group, gender and traffic detail | ZZ / NULL kept as an explicit unknown cohort, not dropped | (new) |
| Time that doesn’t line up | YouTube days run midnight to midnight Pacific; Shopify uses the shop’s time zone; ECC uses server local time | Every source converted to UTC before a date join | Time |
| Retention and backfill | YouTube reports are kept 60 days; a backfill arrives as a new report ID for the same period | Snapshots in BigQuery, replaced (not appended) on backfill, with an expiry per purpose | Retention |
Why the gaps skew the weighting
Segments and the models built on them (bidding, recommendations, LLM retrieval) inherit the gaps:
- Opt-in rates differ by market. YouTube aggregates count everyone who watched; the Shopify and GA4 side counts only consented shoppers. Comparing the two overstates the YouTube-to-purchase effect where opt-in is low (EU, UK).
- Percentages are not counts.
channel_demographics_a1has onlyviews_percentage; weight it byviewsfromchannel_basic_a3for the same date, video and country, or a video with ten views counts as much as one with a million. - Demographics don’t cross. Age and gender can’t be split by traffic source or device: they are separate reports. A segment that combines them is a model, and should be labelled one.
- The largest store dominates. One transfer per shop means a union of stores; without balancing by market, the biggest market sets the weights.
- No product key on media. The channel reports have no SKU, so the
video_id↔MATNRlink is one more row in the Xano crosswalk.
API reference naming: Shopify and YouTube
Each source names things its own way. The Rust names follow the same rules as Naming: one module per
source, UpperCamelCase structs, snake_case fields, the source’s name kept on the wire with #[serde(rename …)]. These
structs are proposed; the generator covers ECC only today.
| Source | Source name | BigQuery name | Rust (proposed) | Rule |
|---|---|---|---|---|
| Shopify Admin GraphQL | Object Order, fields displayFinancialStatus, totalPriceSet | Transfer object Orders | shopify::Order, display_financial_status | #[serde(rename_all = "camelCase")] keeps GraphQL’s names on the wire |
| Shopify | Metafields_Product | Metafields_Product | shopify::MetafieldsProduct | The underscore joins owner and type; drop it in the struct name |
| Shopify | ID gid://shopify/Order/5012345 | String | ShopifyGid (newtype) | Keep the full GID; parse the numeric tail only for joins |
| YouTube Channel | Report channel_basic_a3 | Table p_channel_basic_a3_<suffix>, view channel_basic_a3_<suffix> | youtube::ChannelBasicA3 | p_ is the table, no prefix is the view; <suffix> is set when the transfer is created |
| YouTube Content Owner | Report content_owner_basic_a4 | p_content_owner_basic_a4_<suffix> | youtube::ContentOwnerBasicA4 | Same pattern, content_owner_ in front |
| YouTube (both) | Version _a1 … _a4 | Part of the name | Part of the struct name | A new version is a new table: pin queries to views, and treat a version change as a schema change |
Names to check in your own dataset, because Google’s Content Owner page lists them irregularly: the province view as
content_owner_province_3_<suffix> (no a), the playlist playback-location view and the playlist traffic-source table
without <suffix>.
What a Content Owner transfer adds. A channel transfer covers the brand’s own channels. A Content Owner (a YouTube
partner managing many channels) also gets assets, claims, references, video metadata and the money:
content_owner_estimated_revenue_a1 (estimated_partner_revenue, ad_impressions, estimated_cpm, by video_id,
claimed_status, uploader_type, country_code), content_owner_ad_rates_a1, and system-managed ad, subscription
(red), Shorts, payment and tax tables. Revenue is creator-side income, not shopper data, but it is finance data:
it belongs next to the ledger, under the same retention rules.
One meaning, four names. The fields that join sources rarely share a name or a format:
| Meaning | ECC | Shopify | YouTube | GA4 export |
|---|---|---|---|---|
| Country | LAND1 (SAP country key) | countryCode (enum) | country_code (ISO 3166-1, ZZ when thresholded) | geo.country (a country name) |
| Region | REGIO | provinceCode | province_code (US- states only) | geo.region (a name) |
| Product | MATNR | Variant sku, product GID | none (map video_id in Xano) | items.item_id |
| Order | VBELN; Shopify order often in BSTNK | Order GID, name (#1001) | none | ecommerce.transaction_id |
| Day | DATS, server local time | DateTime (UTC) | Pacific day | event_date in the property’s time zone |
| Money | KBETR + KONWA | shopMoney / presentmentMoney | estimated_*_revenue | ecommerce.purchase_revenue |
Normalise once, in the Rust core: ISO 3166-1 / 3166-2 codes, UTC timestamps, ISO 4217 currency with an amount type, and one product key from the Xano crosswalk.
The event funnel, and where consent decides
The funnel crosses from cohorts to people at one point: the click to the site. Above it, everything is aggregate; below it, a person can be followed only with consent.
| # | Stage | Source and field | Key carried forward | Grain | Needed to record it per person |
|---|---|---|---|---|---|
| 1 | Impression | YouTube channel_reach_basic_a1.video_thumbnail_impressions | video_id | Cohort | Nothing: no person is recorded |
| 2 | View | channel_basic_a3.views, engaged_views, by subscribed_status, country_code | video_id, country_code | Cohort | Nothing |
| 3 | Click to site | Link with utm_source=youtube&utm_content=<video_id>; GA4 session_start | video_id → session | The bridge | analytics_storage granted; otherwise only a modelled conversion |
| 4 | Product view | GA4 view_item, items.item_id | MATNR / SKU | Person (session) | analytics_storage |
| 5 | Add to cart, checkout | GA4 add_to_cart, begin_checkout | SKU, session | Person | analytics_storage. The Shopify transfer has no cart or abandoned-checkout object, so these stages come from GA4 only |
| 6 | Order | Shopify Orders, OrderLineItems; GA4 purchase | Order GID = transaction_id | Person | The order itself needs no consent (it is the contract); joining it to the session needs analytics_storage |
| 7 | ERP order | ECC VBAK / VBAP | VBELN, Shopify order in BSTNK | Person | None, but the shopper’s consent still governs any use beyond fulfilment |
| 8 | Fulfilment, return, refund | Shopify Fulfillments, Returns, Refunds; ECC deliveries and billing | Order, VBELN | Person | None for the transaction; the purpose limit carries over |
| 9 | Re-engage | Google Ads Customer Match beside a YouTube segment | Hashed email | Person | ad_user_data and ad_personalization, checked by the release gate; never email consent alone |
Where the funnel breaks: if stage 3 has no consent, stages 4 to 9 can still be counted (orders are real), but not tied to the video. The YouTube-to-revenue figure is then modelled for that share, and the model should say so per market.
Globalised data governance: requirements per session and per segment
The same pages and segments serve several regimes, so the rules are decided twice: once per session, at the edge, before anything loads; and once per segment, before anything leaves BigQuery or Xano. These are the requirements the stack enforces; the legal reading of each market is for counsel to confirm.
Per session (the Cloudflare Worker, on the first request):
| Requirement | US (state privacy laws) | EU (GDPR, ePrivacy, DMA) | UK (UK GDPR, PECR) | KR (PIPA) |
|---|---|---|---|---|
| Default before a choice | Analytics on; sale / share and targeted ads off if GPC is sent | Everything off until opt-in | Everything off until opt-in | Everything off until opt-in |
| Tags before the banner is answered | Necessary only where GPC is sent | Necessary only | Necessary only | Necessary only |
| Signals recorded | GPC, sale / share opt-out | analytics_storage, ad_storage, ad_user_data, ad_personalization | Same four | Separate consents per purpose, plus overseas transfer |
| Region and regime | ISO 3166-2 at decision time (state matters) | ISO 3166-2 at decision time | ISO 3166-2 at decision time | ISO 3166-2 at decision time |
| Where the session’s data is stored | US | EU | UK or EU | Held until a KR-resident store exists |
| Child age threshold | Under 13 (COPPA) | 13 to 16, by member state | Under 13 | Under 14 needs a guardian’s consent |
| Ledger entry | Append-only, UTC, sequence number, banner version | Same | Same | Same |
Per segment (the release gate, before any export or activation):
| Requirement | Rule |
|---|---|
| Purpose | Each segment is labelled reporting or activation; only activation may leave for Google Ads, and only through the release gate |
| Minimum cohort size | Keep YouTube’s thresholding (ZZ / NULL stay unknown) and add your own floor on segments built from your data; no segment below it is exported |
| Minors | 13–17 YouTube cohorts are reporting-only; any person under the regime’s child threshold is never in an activation segment |
| Consent per member | Every person in an activation segment has ad_user_data and ad_personalization granted at export time, read live from the ledger, not from a cached copy |
| Residency | The segment is built and stored in the dataset of its regime; EU / UK people are not copied to a US dataset to be joined |
| Cross-border transfer | EU / UK to US needs a lawful transfer basis; KR to anywhere needs the shopper’s separate overseas-transfer consent |
| Mixed-regime segments | A segment spanning regimes takes the strictest rule of any member’s regime, or is split by regime |
| Withdrawal and erasure | A withdrawal or a customers/redact removes the person from every segment before the next export; the export records which version it used |
| Retention | Each segment has an expiry per purpose; YouTube snapshots are kept only as long as reporting needs them |
| Receipt | Every export writes a receipt (segment, version, count, regime, gate decision) to the ledger, so any audience upload can be traced back |
The yt_segment view
bigquery/yt_segment.sql applies
the per-segment rules above to the YouTube Channel transfer. It is a draft: written against the documented report
fields and not yet run against a live dataset (the checks to make first are in its header).
| Step | What it does | Rule it applies |
|---|---|---|
| Read the views | channel_basic_a3 and channel_demographics_a1, not the p_ tables | A backfill or version change is absorbed by the view |
| Normalise the mix | Shares of views_percentage within each date, video, country, subscribed and live / on-demand row, summing to 1 | Percentages are not counts |
| Weight by views | Each share × views (and engaged views, watch time, subscribers gained) → est_* columns | A video with ten views doesn’t count as much as one with a million |
| Keep the unknowns | ZZ country and NULL age / gender become an explicit unknown cohort; a row with no demographics keeps all its views as one | Thresholded rows are kept, not dropped |
| Convert the day | day_start_utc / day_end_utc from the Pacific (UTC-8) YouTube day | Every source in UTC before a date join |
| Label the regime | US, UK, EU / EEA, KR, unknown or other, from country_code | Rules come from the viewer’s regime |
| Label the purpose | reporting_only for 13–17, unknown age or country, KR (on hold) and cohorts below the floor; otherwise activation_candidate | Minors are never activated; activation still passes the release gate |
| Key the segment | segment_key, a SHA-256 of the cohort’s dimensions | Every export receipt can name the segment it used |
Channel-level rows carry an empty video_id. The view keeps join keys as '' and turns them into NULL only in its
output: a join on NULL matches nothing, and those rows would lose their demographics.
-- yt_segment: YouTube Channel cohorts, weighted by views, with governance flags.
--
-- Book: What is ABAP? → Extending the data → Segment consent gaps / Governance per segment.
-- Sources (YouTube Channel transfer, views not p_ tables, so a backfill or version change is absorbed by the view):
-- channel_basic_a3_SUFFIX date, channel_id, video_id, live_or_on_demand, subscribed_status, country_code
-- + views, engaged_views, watch_time_minutes, subscribers_gained
-- channel_demographics_a1_SUFFIX same dimensions + age_group, gender → views_percentage only
--
-- What this view is: aggregate cohorts. There are no viewer IDs in the source, so nothing here is personal data and
-- consent is not checked here. Consent applies when a segment is matched or activated against customer data, in the
-- release gate (Xano), never in BigQuery.
--
-- Rules applied (book: Governance per segment):
-- * views_percentage is weighted by views from channel_basic for the same row grain, never used raw
-- * thresholded rows (country ZZ, NULL age_group / gender) stay as an explicit 'unknown' cohort
-- * AGE_13_17 is reporting-only, always
-- * cohorts below the floor are reporting-only
-- * the YouTube day is midnight to midnight Pacific Standard Time (UTC-8, fixed), converted to UTC here
--
-- Replace before creating: PROJECT, DATASET, SUFFIX (the table suffix set on the transfer).
-- The dataset must be in the same location as the commerce data it will be joined to (EU / UK data → EU dataset).
--
-- sed -e 's/PROJECT/my-project/g' -e 's/DATASET/youtube_eu/g' -e 's/SUFFIX/brand/g' bigquery/yt_segment.sql \
-- | bq query --use_legacy_sql=false
--
-- To check on a real dataset before relying on it (not verified: no dataset was available when this was written):
-- 1. The type of `date` (STRING 'YYYYMMDD' or DATE): handled both ways below, confirm with INFORMATION_SCHEMA.
-- 2. Whether the transfer's views already keep only the latest report per day after a backfill. If they don't,
-- deduplicate on the full dimension set, keeping the most recent load.
-- 3. The age_group / gender values (expected AGE_13_17 … AGE_65_, FEMALE / MALE / GENDER_OTHER).
CREATE OR REPLACE VIEW `PROJECT.DATASET.yt_segment`
OPTIONS (
description = 'YouTube Channel cohorts weighted by views. Aggregate only: no viewer IDs. Activation only through the Xano release gate.'
) AS
WITH params AS (
SELECT
50 AS min_cohort_views, -- own floor on top of YouTube's thresholding; tune per market
['AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE','IT','LV','LT','LU','MT','NL',
'PL','PT','RO','SK','SI','ES','SE','IS','LI','NO'] AS eea_countries
),
basic AS (
SELECT
COALESCE(SAFE.PARSE_DATE('%Y%m%d', CAST(date AS STRING)), SAFE_CAST(CAST(date AS STRING) AS DATE)) AS yt_date,
channel_id,
IFNULL(video_id, '') AS video_id, -- '' = channel-level row; join keys stay non-NULL
IFNULL(live_or_on_demand, '') AS live_or_on_demand,
IFNULL(subscribed_status, '') AS subscribed_status,
COALESCE(NULLIF(country_code, ''), 'ZZ') AS country_code,
SUM(views) AS views,
SUM(engaged_views) AS engaged_views,
SUM(watch_time_minutes) AS watch_time_minutes,
SUM(subscribers_gained) AS subscribers_gained
FROM `PROJECT.DATASET.channel_basic_a3_SUFFIX`
GROUP BY 1, 2, 3, 4, 5, 6
),
demo AS (
SELECT
COALESCE(SAFE.PARSE_DATE('%Y%m%d', CAST(date AS STRING)), SAFE_CAST(CAST(date AS STRING) AS DATE)) AS yt_date,
channel_id,
IFNULL(video_id, '') AS video_id,
IFNULL(live_or_on_demand, '') AS live_or_on_demand,
IFNULL(subscribed_status, '') AS subscribed_status,
COALESCE(NULLIF(country_code, ''), 'ZZ') AS country_code,
COALESCE(age_group, 'unknown') AS age_group, -- NULL = thresholded
COALESCE(gender, 'unknown') AS gender,
SUM(views_percentage) AS views_percentage
FROM `PROJECT.DATASET.channel_demographics_a1_SUFFIX`
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8
),
-- Normalise the mix within each row grain, so the shares sum to 1 whether views_percentage is 0–1 or 0–100.
demo_share AS (
SELECT
*,
SAFE_DIVIDE(
views_percentage,
SUM(views_percentage) OVER (
PARTITION BY yt_date, channel_id, video_id, live_or_on_demand, subscribed_status, country_code)
) AS share
FROM demo
),
-- Every basic row gets a mix; a row with no demographics at all becomes one 'unknown' cohort with share 1.
weighted AS (
SELECT
b.yt_date,
b.channel_id,
b.video_id,
b.live_or_on_demand,
b.subscribed_status,
b.country_code,
COALESCE(d.age_group, 'unknown') AS age_group,
COALESCE(d.gender, 'unknown') AS gender,
COALESCE(d.share, 1) AS share,
d.share IS NULL AS demographics_missing,
b.views * COALESCE(d.share, 1) AS est_views,
b.engaged_views * COALESCE(d.share, 1) AS est_engaged_views,
b.watch_time_minutes * COALESCE(d.share, 1) AS est_watch_time_minutes, -- assumes watch time follows the view mix
b.subscribers_gained * COALESCE(d.share, 1) AS est_subscribers_gained,
b.views AS row_views
FROM basic AS b
LEFT JOIN demo_share AS d
USING (yt_date, channel_id, video_id, live_or_on_demand, subscribed_status, country_code)
)
SELECT
-- Segment identity
TO_HEX(SHA256(CONCAT(
channel_id, '|', IF(video_id = '', 'channel', video_id), '|', country_code, '|', age_group, '|', gender, '|',
subscribed_status, '|', live_or_on_demand))) AS segment_key,
w.yt_date,
TIMESTAMP(DATETIME(w.yt_date), '-08:00') AS day_start_utc, -- YouTube day, PST fixed
TIMESTAMP(DATETIME(DATE_ADD(w.yt_date, INTERVAL 1 DAY)), '-08:00') AS day_end_utc,
w.channel_id,
NULLIF(w.video_id, '') AS video_id,
IF(w.video_id = '', 'channel', 'video') AS segment_level,
w.country_code,
w.age_group,
w.gender,
NULLIF(w.subscribed_status, '') AS subscribed_status,
NULLIF(w.live_or_on_demand, '') AS live_or_on_demand,
-- Weighted metrics (estimates: demographics are a share, not a count)
w.share,
w.est_views,
w.est_engaged_views,
w.est_watch_time_minutes,
w.est_subscribers_gained,
w.row_views,
-- Data quality
w.country_code = 'ZZ' AS country_thresholded,
w.age_group = 'unknown' AS demographics_thresholded,
w.demographics_missing,
-- Regime of the viewer's country (the regime the segment's activation rules come from)
CASE
WHEN w.country_code = 'US' THEN 'US'
WHEN w.country_code = 'GB' THEN 'UK'
WHEN w.country_code IN UNNEST(p.eea_countries) THEN 'EU'
WHEN w.country_code = 'KR' THEN 'KR'
WHEN w.country_code = 'ZZ' THEN 'unknown'
ELSE 'other'
END AS regime,
-- Governance
w.age_group = 'AGE_13_17' AS is_minor_cohort,
CASE
WHEN w.age_group = 'AGE_13_17' THEN 'reporting_only:minor'
WHEN w.age_group = 'unknown' THEN 'reporting_only:unknown_age'
WHEN w.country_code = 'ZZ' THEN 'reporting_only:unknown_country'
WHEN w.country_code = 'KR' THEN 'reporting_only:kr_hold' -- until a KR-resident store exists
WHEN w.est_views < p.min_cohort_views THEN 'reporting_only:below_floor'
ELSE 'activation_candidate' -- still needs the release gate
END AS segment_purpose
FROM weighted AS w
CROSS JOIN params AS p;
The rule is the same as for ECC: BigQuery reads consent, it never decides it. Every segment export to Google Ads passes through the release gate in Xano, as every other destination in the stack does.
Why 11ty, and when Astro
Astro would work. 11ty is used because it is the simpler tool for what this book asks of it, and because the portability that matters sits in the Rust core, not in the site generator.
Why 11ty here
- It is a data parser as much as a site builder.
web/_data/ddic.jsreads the DD03L export and writessite/ddic.jsonthrough 11ty’s data step: plain JavaScript, no component model, no bundler. - It ships no JavaScript of its own. The output is HTML; islands are added afterwards, after consent, by the Worker or one tag.
- Its templates are ones teams already know. 11ty can use Liquid, the language of Shopify themes, or Nunjucks.
- It has few moving parts. No Vite and no framework runtime, which matters for a handoff team.
Where Astro is stronger
- Built-in islands (
client:load,client:visible) and components for React, Vue or Svelte when a page needs them. - Typed content collections with schemas, useful when the content model grows.
- The trade-off for this design: Astro islands are built by Vite, so they belong to an Astro build. The islands on this page load into any platform’s theme without one.
Rust works everywhere. The rules live in the Rust core, so the site generator is replaceable: 11ty and Astro would both
read site/ddic.json and render it, and swapping them changes nothing about how a price, a date or a consent decision is
converted.
| The Rust core compiles to | Runs in |
|---|---|
| A native command-line tool | cargo run today: structs, Merchant API JSON, XanoScript |
| WebAssembly | A Cloudflare Worker, or a browser island |
| A Python extension (PyO3) | The design pipeline, beside Beautiful Soup |
| A desktop or mobile app | Tauri or Dioxus |
One rule is not in Rust yet. Naming (/ACME/GPC → acme_gpc) is decided in lib/naming.js at the 11ty step, and the
Rust build only checks it. Moving naming into the Rust core is what makes “Rust everywhere” complete: then 11ty, Astro or
anything else only renders.
One repository, islands per requirement
For a client handoff, the whole stack fits in one repository, one package per layer. Each page then loads only the pieces its requirements need (“islands”), instead of one framework build for everything.
client-repo/
├── design/ Webflow export + the Beautiful Soup script → component map (JSON)
├── ddic/ DD02T / DD03L export + the 11ty DDIC parser → site/ddic.json
├── core/ The Rust crate: structs, Serde record parsers, Merchant API JSON, XanoScript
├── site/ 11ty: pages from the component map, data from Xano
├── worker/ The Cloudflare Worker: serves the site, consent first, loads islands, calls Xano
├── xano/ Generated .xs table definitions and CSV uploads
└── package.json One npm install; scripts with plain names: dev:site, build:core, deploy:worker
On the page, each requirement is its own island, loaded by the Worker only where that page needs it and only after consent allows it:
| Requirement | Island | Loaded on |
|---|---|---|
| Static content | None: 11ty HTML | Every page |
| A small interactive part (a product card’s variant picker) | petite-vue (about 6 KB) on that element’s v-scope | Pages with that component |
| A server round trip without client state (filters, a form) | HTMX, opt-in | Pages that use it |
| UI behaviour (modal, offcanvas, tabs) | UIkit components (uk-*), the design system the petite-vue islands render into, themed per brand | Pages with those components |
| Motion | GSAP | Pages that animate |
| Heavy compute in the browser (pricing preview, a converter) | The Rust core compiled to WebAssembly | Only that tool’s page |
| Analytics and ad tags | The tag itself | Only after the consent decision allows it |
UIkit is the design system for the Vue islands. UIkit (uk-* classes and attributes) supplies the components and
the brand theme; petite-vue, the Vue layer, supplies the state and the templates. They fit without glue: petite-vue renders
uk-card, uk-modal or uk-navbar markup, and UIkit’s own DOM observer initialises each component as it appears. UIkit
itself is framework-independent JavaScript, so the same components also work in a page with no Vue at all, or with HTMX.
BEM modifiers are plain vanilla code. BEM (Block, Element, Modifier) names every class by what it is: a block
(card), an element inside it (card__title), and a modifier for a variant or state (card--featured). UIkit
follows the same idea with its prefix and hyphens: block uk-card, elements uk-card-body and uk-card-title, modifiers
uk-card-primary and uk-card-small. A modifier is only a class, so changing state needs no framework:
<div class="uk-card uk-card-default uk-card-body product-card" data-sku="HM-QUEEN-01">
<h3 class="uk-card-title product-card__title">Heated mat, queen</h3>
<p class="product-card__price">129.00 USD</p>
</div>
/* The site's own block, in BEM, beside UIkit's: no specificity fights, because each class names one thing. */
.product-card__price { font-variant-numeric: tabular-nums; }
.product-card--out-of-stock .product-card__price { text-decoration: line-through; }
// Vanilla: a modifier is a class toggle.
const card = document.querySelector('.product-card[data-sku="HM-QUEEN-01"]')
card.classList.toggle('product-card--out-of-stock', !inStock)
card.classList.toggle('uk-card-primary', featured)
<!-- The same modifiers from a petite-vue island: state in, class out. -->
<div v-scope="{ inStock: false, featured: true }"
class="uk-card uk-card-body product-card"
:class="{ 'product-card--out-of-stock': !inStock, 'uk-card-primary': featured, 'uk-card-default': !featured }">
The class names are the contract between design and code: Webflow designers set them, Beautiful Soup reads them into the
component map, and the stock state that drives product-card--out-of-stock is availability from the converted ECC record.
No compile step, on any live theme
The islands are plain <script> and <link> tags that bind to classes and data-* attributes already in the page. So they
reach a live theme without rebuilding it, and they enhance progressively: the theme’s HTML works first, and each island
improves it when it loads. A theme change that keeps the classes and data attributes keeps the islands working.
There are two ways in, and neither needs the platform’s build:
- A Cloudflare Worker in front of the site rewrites the theme’s HTML on the way out (HTMLRewriter) and adds the islands after the consent check. The theme isn’t edited at all. This needs the site’s traffic to pass through Cloudflare.
- One tag in the theme’s
<head>, where a Worker can’t sit in front. It loads the same islands from the same place.
| Platform | Where the page’s HTML comes from | How the islands arrive | Note |
|---|---|---|---|
| Shopify | Liquid theme (theme.liquid, sections) | A theme app embed or one tag in theme.liquid | Shopify serves its storefronts through its own edge, so the tag route is the usual one |
| WordPress | PHP theme templates | Worker in front, or one enqueued script in the theme or a small plugin | Works the same with block and classic themes |
| Astro | Static or server-rendered pages | Worker in front, or one tag in the base layout | Astro’s own islands can sit beside these; nothing has to be rebuilt to add ours through the Worker |
| Next.js | React, server- or statically rendered | Worker in front, or one <Script> tag in the root layout | Without the Worker, the layout tag is a one-time change and redeploy; the islands after that change without a rebuild |
| Adobe Experience Manager | HTL page components, client libraries | Worker in front, or one tag in the page component’s head | Authors keep their components and templates |
| Magento / Adobe Commerce | Layout XML and PHTML templates | Worker in front, or one script declared in the theme’s layout head | Works with Luma and Hyvä themes alike |
| Salesforce Commerce Cloud (B2C, SFRA) | ISML templates | Worker in front, or one tag in the page’s htmlHead template | Cartridges and the storefront code stay as they are |
| SAP Commerce (Hybris) | JSP / tag files in the storefront | Worker in front, or one tag in the master template | The back office and the integration to SAP are untouched |
What every row shares: the islands, the consent check and the call to Xano are the same on every platform. Only where the one tag goes differs. The platform keeps rendering its theme; the islands add behaviour; the release gate in Xano decides what any of it may send.
Islands compared with a full framework build
| Islands per requirement | Full framework build (for example Next.js, Nuxt) | |
|---|---|---|
| What ships to the browser | The HTML, plus each island the page uses | The framework runtime and the page’s bundle, then hydration of the page |
| Build step | 11ty renders HTML; islands need no compile step; only the Rust core is compiled | The whole site goes through the framework’s build |
| Who edits | Designers in Webflow; developers own the islands and the core | Developers, for most changes |
| Changing CMS or theme | The same islands load the same way under any theme | The front end is tied to the framework’s routing and data loading |
| Consent | The Worker decides before any island or tag loads | Server rendering and client hydration can send data before the banner has been answered, unless that is designed in |
| Where it fits best | Content and commerce pages with a few interactive parts | App-like interfaces with a lot of shared client state |
The rule: start with static HTML, add an island only for a requirement the HTML can’t meet, and keep every island
optional, so a page still works without it. One repository keeps the islands, the Rust core and the generated Xano tables
in step, and hands over with one npm install.
Naming
Names are decided once, in lib/naming.js, when 11ty builds ddic.json. The Rust build only checks them.
| ABAP | Rust | Rule |
|---|---|---|
Standard table KNA1 | sap::Kna1 | Module sap, UpperCamelCase struct |
/ACME/CONSENT | acme::Consent | The namespace becomes a module; slashes can’t appear in Rust names |
ZSD_ORDER_LOG | z::ZsdOrderLog | Z and Y objects go in module z |
Field KUNNR | kunnr | snake_case |
Field /ACME/GPC | acme_gpc | Namespace joined with _ |
Field TYPE | type_ | Rust keywords get a trailing _ |
Every field keeps its ABAP name on the wire through #[serde(rename = "…")], so a record reads and writes unchanged. Two ABAP names that would become the same Rust name stop the build.
Names in this book that needed more than lower-casing
| Table | ABAP field | Rust field |
|---|---|---|
KNA1 | /ACME/GPC | acme_gpc |
/ACME/CONSENT | (table) | acme::Consent |
Shopify and YouTube names
The naming rules for the BigQuery transfers (Shopify Admin GraphQL objects, YouTube Channel and Content Owner reports) and the fields that join them across sources are in What is ABAP? → API reference naming.
Types
The first matching row wins. A DDIC type with no row stops the build and names the field.
| DDIC type | Condition | Rust type | Helper | Fields in this book | Notes |
|---|---|---|---|---|---|
CLNT, LANG, CUKY, UNIT, NUMC, STRG, SSTR | String | 38 | Text. NUMC stays text because leading zeros are data (0000012345). | ||
CHAR | length 1 and data element XFELD, BOOLE_D, FLAG, XFLAG, LOEVM_X, LOEVM_V, LVOMA, LOEVM_KO, AD_FLGDFNR, AD_FLNOUSE | bool | abap::xflag | 9 | “X” is true, blank is false; anything else is refused. |
CHAR | String | 87 | Text, blank when initial. | ||
DATS | Option<chrono::NaiveDate> | abap::dats | 8 | YYYYMMDD; 00000000 is None. | |
TIMS | Option<chrono::NaiveTime> | abap::tims | 2 | HHMMSS; 000000 is midnight, blank is None. | |
DEC | data element TIMESTAMP | Option<chrono::NaiveDateTime> | abap::timestamp | 1 | YYYYMMDDhhmmss UTC, as a number or a string; 0 is None. |
CURR, QUAN, DEC | rust_decimal::Decimal | 20 | Read and written as strings, scale kept (258.00). Currency comes from the CUKY field it references. | ||
INT1 | u8 | 1 | |||
INT2 | i16 | 0 | |||
INT4 | i32 | 1 | |||
INT8 | i64 | 0 |
ABAP has no null. Key fields are required; every other field defaults to ABAP’s initial value (blank, zero, 00000000) when it is missing, and a None date is written back as 00000000.
Google Merchant Center
Which ECC fields feed which attribute of Google’s product data specification, and how. 27 attributes are mapped: 18 machine data, 6 authored, 3 not in ECC.
| Means | Who may change it | |
|---|---|---|
| machine data | A fact ECC already holds as a code, identifier, amount, unit, date or stock quantity | Nobody: it is converted by a fixed rule in src/merchant.rs and never rewritten or generated. A wrong value is fixed in ECC. |
| Text a person writes, or a mapping a person keeps | People, and AI if it is declared: Google’s structured_title and structured_description carry digital_source_type: trained_algorithmic_media for generated text. | |
| not in ECC | Owned by another system (storefront, DAM) | That system. |
A material with the deletion flag MARA-LVORM set is removed from the feed rather than sent. Values the rules can’t convert (a failed GTIN check digit, a unit Google doesn’t accept) are left out and listed as notes for review, never guessed.
Machine data: converted by rule
| Attribute | ECC source | Rule | Merchant API v1 | Requirement | Section |
|---|---|---|---|---|---|
| id | MARA-MATNR | MATNR as SAP displays it (numeric numbers lose their leading zeros). Must stay stable; prefix a market only if one material is sent to several feeds. | offerIdstring | required | Basic product data |
| availability | MARD-LABSTMARD-INSMEMARD-SPEME | in_stock when unrestricted stock (LABST) in the shipping plants is above zero; stock in quality inspection (INSME) or blocked (SPEME) doesn’t count. preorder and backorder need a date from purchasing or ATP and are not derived. | productAttributes.availabilityenum IN_STOCK / OUT_OF_STOCK / PREORDER / BACKORDER / LIMITED_AVAILABILITY | required | Price and availability |
| price | A004-KSCHLA004-DATABA004-DATBIKONP-KBETRKONP-KPEINKONP-KONWAKONP-LOEVM_KOTCURX-CURRDEC | The PR00 condition valid today and not deletion-flagged: KBETR divided by KPEIN; shifted by TCURX-CURRDEC because SAP stores every amount with 2 decimals (KRW 129000 is stored as 1290.00); written as “129.00 USD”. | productAttributes.pricePrice {amountMicros (int64 string) + currencyCode} | required | Price and availability |
| sale_price | A004-KSCHLA004-DATABA004-DATBIKONP-KBETRKONP-KPEINKONP-KONWATCURX-CURRDEC | A sale condition type (ZSAL in the sample) valid today; same conversion as price. | productAttributes.salePricePrice | optional | Price and availability |
| sale_price_effective_date | A004-DATABA004-DATBI | DATAB/DATBI as ISO 8601 with the sales organisation’s UTC offset (DATS has no time zone). An open-ended DATBI (99991231) omits the attribute so the sale applies until the condition ends. | productAttributes.salePriceEffectiveDateInterval {startTime + endTime} RFC 3339 UTC; end exclusive | optional | Price and availability |
| cost_of_goods_sold | MBEW-VPRSVMBEW-STPRSMBEW-VERPRMBEW-PEINH | Standard price (VPRSV S) or moving average (V) divided by PEINH in the company code currency. Confidential cost data: send it only if finance agrees. | productAttributes.costOfGoodsSoldPrice | optional | Price and availability |
| unit_pricing_measure | MARA-INHALMARA-INHME | Net contents (IS-Retail) such as “750 ml”. EU unit-price rules require it for many goods. | productAttributes.unitPricingMeasure{value + unit} | conditional | Price and availability |
| product_type | MARA-PRDHAT179T-PRODHT179T-VTEXT | The product hierarchy text for each level (5 + 5 + 8 characters) joined with “ > “. | productAttributes.productTypes[]string list | optional | Product category |
| gtin | MARM-EAN11MARM-NUMTPMARA-EAN11MARA-NUMTP | The EAN of the base unit (MARM row where MEINH = MARA-MEINS) or else MARA-EAN11. Sent only with a valid GS1 check digit and never an in-store number (NUMTP IE or GS1 prefixes 02 / 04 / 20-29). | productAttributes.gtins[]string list (up to 10) | conditional | Product identifiers |
| mpn | MARA-MFRPN | Manufacturer part number as stored. | productAttributes.mpnstring | conditional | Product identifiers |
| identifier_exists | MARA-EAN11MARA-MFRPN | “no” when there is neither a valid GTIN nor an MPN. | productAttributes.identifierExistsboolean (default true) | optional | Product identifiers |
| item_group_id | MARA-SATNR | The generic article (IS-Retail) that groups variants. | productAttributes.itemGroupIdstring | conditional | Detailed product description |
| product_weight | MARA-NTGEWMARA-GEWEI | Net weight with the SAP unit mapped (KG to kg / G to g / LB to lb / OZ to oz). | productAttributes.productWeight{value (4 decimals) + unit g / kg / oz / lb} | optional | Detailed product description |
| shipping_weight | MARA-BRGEWMARA-GEWEI | Gross weight; same unit mapping. Required for carrier-calculated rates. | productAttributes.shippingWeight{value + unit} | conditional | Shipping and returns |
| shipping_length | MARM-LAENGMARM-MEABM | Base-unit length; MM and M converted to cm; IN kept. Length / width / height are sent together or not at all. | productAttributes.shippingLength{value + unit in / cm} | conditional | Shipping and returns |
| shipping_width | MARM-BREITMARM-MEABM | As shipping_length. | productAttributes.shippingWidth{value + unit in / cm} | conditional | Shipping and returns |
| shipping_height | MARM-HOEHEMARM-MEABM | As shipping_length. | productAttributes.shippingHeight{value + unit in / cm} | conditional | Shipping and returns |
| ships_from_country | T001W-LAND1 | Country of the shipping plant (ISO 3166-1 alpha-2). | customAttributes[ships_from_country]{name + value}: v1 has no typed field for it | optional | Shipping and returns |
Authored
| Attribute | ECC source | Rule | Merchant API v1 | Requirement | Section |
|---|---|---|---|---|---|
MAKT-MAKTXMAKT-SPRAS | The 40-character short text in the feed language: an internal label to start from. If AI writes or rewrites the title, send structured_title with digital_source_type trained_algorithmic_media. | productAttributes.titlestring | required | Basic product data | |
| The sales text is a long text (READ_TEXT object MVKE id 0001), not a table field. AI-written text goes in structured_description with digital_source_type trained_algorithmic_media. | productAttributes.descriptionstring | required | Basic product data | ||
MARA-MATKL | No ECC field: keep a mapping from material group (or product hierarchy) to the Google taxonomy ID in the system of record. | productAttributes.googleProductCategorystring | optional | Product category | |
MARA-MFRNR | MFRNR is the manufacturer’s vendor number; the brand name comes from that vendor (LFA1-NAME1) or a classification characteristic. Not resolved here. | productAttributes.brandstring | required | Product identifiers | |
MARA-WRKST | Basic material text as entered. | productAttributes.materialstring | conditional | Detailed product description | |
| Classification characteristics (AUSP / CABN); not table fields covered here. Same for size and pattern. | productAttributes.colorstring | conditional | Detailed product description |
Not in ECC
| Attribute | ECC source | Rule | Merchant API v1 | Requirement | Section |
|---|---|---|---|---|---|
| link | The storefront page. Not in ECC. | productAttributes.linkstring | required | Basic product data | |
| image_link | The DAM or CMS. Not in ECC. Google enforces a 500 x 500 px minimum from 2027-01-31. | productAttributes.imageLinkstring | required | Basic product data | |
| condition | Not a material field; new for standard stock. | productAttributes.conditionenum NEW / USED / REFURBISHED | conditional | Detailed product description |
Example: one material
The sample material HM-QUEEN-01 (fixtures/merchant/heated-mat-queen.json) for a US feed on 2026-11-04, price condition PR00, sale condition ZSAL, UTC offset -08:00. tests/merchant.rs checks every value below.
ECC rows in
{
"MARA": {"MANDT":"100","MATNR":"HM-QUEEN-01","ERSDA":"20240115","LVORM":"","MTART":"HAWA","MATKL":"HOME01","MEINS":"ST","BRGEW":"9.800","GEWEI":"KG","NTGEW":"8.250","EAN11":"012345678905","NUMTP":"UC","MFRNR":"0000300100","MFRPN":"HM-Q-2026","PRDHA":"HOMETHEATMATQUEEN0","WRKST":"Cotton / Carbon heating film","SATNR":"HM-QUEEN","INHAL":"0.000","INHME":""},
"MAKT": [{"MANDT":"100","MATNR":"HM-QUEEN-01","SPRAS":"E","MAKTX":"Heated mat, queen"},
{"MANDT":"100","MATNR":"HM-QUEEN-01","SPRAS":"3","MAKTX":"전기매트 퀸"}],
"MARM": [{"MANDT":"100","MATNR":"HM-QUEEN-01","MEINH":"ST","UMREZ":"1","UMREN":"1","EAN11":"012345678905","NUMTP":"UC","LAENG":"1500.000","BREIT":"2000.000","HOEHE":"12.000","MEABM":"MM","BRGEW":"9.800","GEWEI":"KG"}],
"CONDITIONS": [
[{"MANDT":"100","KAPPL":"V","KSCHL":"PR00","VKORG":"US01","VTWEG":"10","MATNR":"HM-QUEEN-01","DATBI":"99991231","DATAB":"20260101","KNUMH":"0000100001"},
{"MANDT":"100","KNUMH":"0000100001","KOPOS":"01","KSCHL":"PR00","KBETR":"129.00","KONWA":"USD","KPEIN":"1","KMEIN":"ST","LOEVM_KO":""}],
[{"MANDT":"100","KAPPL":"V","KSCHL":"ZSAL","VKORG":"US01","VTWEG":"10","MATNR":"HM-QUEEN-01","DATBI":"20261130","DATAB":"20261101","KNUMH":"0000100002"},
{"MANDT":"100","KNUMH":"0000100002","KOPOS":"01","KSCHL":"ZSAL","KBETR":"109.00","KONWA":"USD","KPEIN":"1","KMEIN":"ST","LOEVM_KO":""}]
],
"MARD": [{"MANDT":"100","MATNR":"HM-QUEEN-01","WERKS":"US10","LGORT":"0001","LABST":"42.000","INSME":"3.000","SPEME":"0.000"}],
"MBEW": {"MANDT":"100","MATNR":"HM-QUEEN-01","BWKEY":"US10","BWTAR":"","VPRSV":"S","VERPR":"0.00","STPRS":"46.50","PEINH":"1"},
"T001W": {"MANDT":"100","WERKS":"US10","NAME1":"Los Angeles DC","LAND1":"US","REGIO":"CA"},
"T179T": [{"MANDT":"100","SPRAS":"E","PRODH":"HOMET","VTEXT":"Home"},
{"MANDT":"100","SPRAS":"E","PRODH":"HOMETHEATM","VTEXT":"Heating"},
{"MANDT":"100","SPRAS":"E","PRODH":"HOMETHEATMATQUEEN0","VTEXT":"Heated mats"}],
"CDHDR": [{"MANDANT":"100","OBJECTCLAS":"MATERIAL","OBJECTID":"HM-QUEEN-01","CHANGENR":"0000412001","USERNAME":"MDM_EDIT","UDATE":"20261028","UTIME":"141210","TCODE":"MM02","CHANGE_IND":"U"},
{"MANDANT":"100","OBJECTCLAS":"MATERIAL","OBJECTID":"HM-QUEEN-01","CHANGENR":"0000412118","USERNAME":"BATCH_PIM","UDATE":"20261103","UTIME":"021500","TCODE":"","CHANGE_IND":"U"}],
"TCURX": [{"CURRKEY":"KRW","CURRDEC":0},{"CURRKEY":"JPY","CURRDEC":0}]
}
Feed row out (null = not sent; link, image_link, description and brand come from other systems):
{
"id": "HM-QUEEN-01",
"title": "Heated mat, queen",
"availability": "in_stock",
"price": "129.00 USD",
"sale_price": "109.00 USD",
"sale_price_effective_date": "2026-11-01T00:00-08:00/2026-11-30T23:59-08:00",
"cost_of_goods_sold": "46.50 USD",
"unit_pricing_measure": null,
"product_type": "Home > Heating > Heated mats",
"gtin": "012345678905",
"mpn": "HM-Q-2026",
"identifier_exists": "yes",
"item_group_id": "HM-QUEEN",
"material": "Cotton / Carbon heating film",
"product_weight": "8.25 kg",
"shipping_weight": "9.8 kg",
"shipping_length": "150 cm",
"shipping_width": "200 cm",
"shipping_height": "1.2 cm",
"ships_from_country": "US"
}
What the rules did:
price: KONP-KBETR 129.00 ÷ KPEIN 1, USD has 2 decimals →129.00 USDsale_price_effective_date: A004 DATAB 20261101 / DATBI 20261130 plus the offsetgtin: MARM-EAN11 of the base unitST, check digit valid, not an in-store prefixshipping_length/width/height: MARM inMM→ cmavailability: MARD-LABST 42 unrestricted; the 3 in quality inspection don’t countproduct_type: PRDHA split 5 + 5 + 8 and each level’s T179T text
No notes: every machine value converted.
The same product as a Merchant API v1 product input
POST https://merchantapi.googleapis.com/products/v1/accounts/{account}/productInputs:insert?dataSource=accounts/{account}/dataSources/{dataSource}
{
"offerId": "HM-QUEEN-01",
"contentLanguage": "en",
"feedLabel": "US",
"productAttributes": {
"title": "Heated mat, queen",
"availability": "IN_STOCK",
"price": {
"amountMicros": "129000000",
"currencyCode": "USD"
},
"salePrice": {
"amountMicros": "109000000",
"currencyCode": "USD"
},
"salePriceEffectiveDate": {
"startTime": "2026-11-01T08:00:00Z",
"endTime": "2026-12-01T08:00:00Z"
},
"costOfGoodsSold": {
"amountMicros": "46500000",
"currencyCode": "USD"
},
"productTypes": [
"Home > Heating > Heated mats"
],
"gtins": [
"012345678905"
],
"mpn": "HM-Q-2026",
"itemGroupId": "HM-QUEEN",
"material": "Cotton / Carbon heating film",
"productWeight": {
"value": 8.25,
"unit": "kg"
},
"shippingWeight": {
"value": 9.8,
"unit": "kg"
},
"shippingLength": {
"value": 150.0,
"unit": "cm"
},
"shippingWidth": {
"value": 200.0,
"unit": "cm"
},
"shippingHeight": {
"value": 1.2,
"unit": "cm"
}
},
"customAttributes": [
{
"name": "ships_from_country",
"value": "US"
}
],
"versionNumber": "20261103021500"
}
Google names it accounts/{account}/productInputs/en~US~HM-QUEEN-01. What changes from the feed row:
- Prices are
Priceobjects in micros: 129.00 USD →"amountMicros": "129000000"; KRW 129000 →"129000000000". availabilityis an enum:IN_STOCK, notin_stock.salePriceEffectiveDateis anIntervalin UTC with an exclusive end: the last sale day 2026-11-30 (-08:00) ends at2026-12-01T08:00:00Z.gtinandproduct_typebecome lists:gtins,productTypes.- Weights and dimensions are
{value, unit}objects, at most 4 decimals. identifierExistsdefaults to true, so it is only sent asfalse.ships_from_countryhas no typed v1 field, so it goes incustomAttributes.versionNumberis the newest change document for the material (CDHDR, object class MATERIAL: 2026-11-03 02:15:00). Google refuses an insert into a primary data source whose number is lower than the stored one, so a late or replayed batch can’t overwrite a newer product with older data. It is machine data too.
Both shapes come from one converted Product in src/merchant.rs: feed_row writes the specification’s names and text ("129.00 USD"), and src/merchant_api.rs writes the Merchant API v1 productInputs resource ({"amountMicros": "129000000"}). tests/merchant_api.rs fails if a field path in this table is missing from the API output.
GraphQL: Product and User
Two GraphQL shapes generated from the same map as the Rust structs and the Google Merchant Center chapter. Product attributes follow Google’s product data specification.
Producthas one field per Merchant attribute, named and typed like the Merchant API v1 product input (price: Moneyin micros,availability: Availability,gtins: [String!]). 18 of its fields are machine data.Useris the customer: KNA1 with its address and default e-mail, and the consent ledger. 5 of its fields are personal data, soUseris a separate type: nothing personal is reachable fromProduct, and nothing inUseris sent to Merchant Center.
Every field carries @source(ecc: [...], origin: ...), so a resolver, a reviewer or an agent can see where a value comes from and whether it may be rewritten. marketingOptIn is @deprecated: it is a flag a nightly batch can overwrite, so clients read consent (newest row per purpose wins) instead.
Fields
| Type | Field | GraphQL type | Origin | ECC source |
|---|---|---|---|---|
Product | offerId | ID! | machine | MARA-MATNR |
Product | title | String | MAKT-MAKTXMAKT-SPRAS | |
Product | description | String | ||
Product | link | String | none | |
Product | imageLink | String | none | |
Product | availability | Availability | machine | MARD-LABSTMARD-INSMEMARD-SPEME |
Product | price | Money | machine | A004-KSCHLA004-DATABA004-DATBIKONP-KBETRKONP-KPEINKONP-KONWAKONP-LOEVM_KOTCURX-CURRDEC |
Product | salePrice | Money | machine | A004-KSCHLA004-DATABA004-DATBIKONP-KBETRKONP-KPEINKONP-KONWATCURX-CURRDEC |
Product | salePriceEffectiveDate | DateInterval | machine | A004-DATABA004-DATBI |
Product | costOfGoodsSold | Money | machine | MBEW-VPRSVMBEW-STPRSMBEW-VERPRMBEW-PEINH |
Product | unitPricingMeasure | Measure | machine | MARA-INHALMARA-INHME |
Product | googleProductCategory | String | MARA-MATKL | |
Product | productTypes | [String!] | machine | MARA-PRDHAT179T-PRODHT179T-VTEXT |
Product | brand | String | MARA-MFRNR | |
Product | gtins | [String!] | machine | MARM-EAN11MARM-NUMTPMARA-EAN11MARA-NUMTP |
Product | mpn | String | machine | MARA-MFRPN |
Product | identifierExists | Boolean | machine | MARA-EAN11MARA-MFRPN |
Product | itemGroupId | String | machine | MARA-SATNR |
Product | material | String | MARA-WRKST | |
Product | color | String | ||
Product | condition | Condition | none | |
Product | productWeight | Measure | machine | MARA-NTGEWMARA-GEWEI |
Product | shippingWeight | Measure | machine | MARA-BRGEWMARA-GEWEI |
Product | shippingLength | Measure | machine | MARM-LAENGMARM-MEABM |
Product | shippingWidth | Measure | machine | MARM-BREITMARM-MEABM |
Product | shippingHeight | Measure | machine | MARM-HOEHEMARM-MEABM |
Product | shipsFromCountry | String | machine | T001W-LAND1 |
User | id | ID! | machine | KNA1-KUNNR |
User | name | String | personal | KNA1-NAME1 |
User | email | String | personal | ADR6-SMTP_ADDRADR6-FLGDEFAULTADR6-FLG_NOUSE |
User | phone | String | personal | ADRC-TEL_NUMBER |
User | city | String | personal | KNA1-ORT01 |
User | postalCode | String | personal | KNA1-PSTLZ |
User | region | String | machine | KNA1-REGIO |
User | country | String! | machine | KNA1-LAND1 |
User | language | String | machine | KNA1-SPRAS |
User | createdOn | Date | machine | KNA1-ERDAT |
User | deleted | Boolean! | machine | KNA1-LOEVM |
User | gpcSeen | Boolean | machine | KNA1-/ACME/GPC |
User | marketingOptIn | Boolean | machine | KNA1-ZZ_MKT_OPTIN |
User | consent | [Consent!]! | machine | /ACME/CONSENT |
Schema
schema.graphql in the repository; tests/graphql.rs parses it.
# @generated from site/ddic.json by src/codegen.rs. Do not edit.
"""Where a field's value comes from, and who may change it."""
directive @source(
"""Attribute name in the product data specification."""
attribute: String
"""ECC tables and fields it is converted from."""
ecc: [String!]!
origin: Origin!
) on FIELD_DEFINITION
enum Origin {
"""A code, identifier, amount, unit, date or quantity ECC holds: converted by rule, never rewritten."""
MACHINE
"""Text a person writes. AI-written text must be declared (digital_source_type)."""
AUTHORED
"""Owned by another system."""
NONE
"""Personal data: served only to the customer or a permitted purpose, never sent to Merchant Center."""
PERSONAL
}
scalar Date
scalar DateTime
"""A product, shaped like a Merchant API v1 product input. Attributes: https://support.google.com/merchants/answer/7052112"""
type Product {
"""ISO 639-1, e.g. en."""
contentLanguage: String!
"""A-Z, 0-9, - and _; up to 20."""
feedLabel: String!
offerId: ID! @source(attribute: "id", ecc: ["MARA-MATNR"], origin: MACHINE)
title: String @source(attribute: "title", ecc: ["MAKT-MAKTX", "MAKT-SPRAS"], origin: AUTHORED)
description: String @source(attribute: "description", ecc: [], origin: AUTHORED)
link: String @source(attribute: "link", ecc: [], origin: NONE)
imageLink: String @source(attribute: "image_link", ecc: [], origin: NONE)
availability: Availability @source(attribute: "availability", ecc: ["MARD-LABST", "MARD-INSME", "MARD-SPEME"], origin: MACHINE)
price: Money @source(attribute: "price", ecc: ["A004-KSCHL", "A004-DATAB", "A004-DATBI", "KONP-KBETR", "KONP-KPEIN", "KONP-KONWA", "KONP-LOEVM_KO", "TCURX-CURRDEC"], origin: MACHINE)
salePrice: Money @source(attribute: "sale_price", ecc: ["A004-KSCHL", "A004-DATAB", "A004-DATBI", "KONP-KBETR", "KONP-KPEIN", "KONP-KONWA", "TCURX-CURRDEC"], origin: MACHINE)
salePriceEffectiveDate: DateInterval @source(attribute: "sale_price_effective_date", ecc: ["A004-DATAB", "A004-DATBI"], origin: MACHINE)
costOfGoodsSold: Money @source(attribute: "cost_of_goods_sold", ecc: ["MBEW-VPRSV", "MBEW-STPRS", "MBEW-VERPR", "MBEW-PEINH"], origin: MACHINE)
unitPricingMeasure: Measure @source(attribute: "unit_pricing_measure", ecc: ["MARA-INHAL", "MARA-INHME"], origin: MACHINE)
googleProductCategory: String @source(attribute: "google_product_category", ecc: ["MARA-MATKL"], origin: AUTHORED)
productTypes: [String!] @source(attribute: "product_type", ecc: ["MARA-PRDHA", "T179T-PRODH", "T179T-VTEXT"], origin: MACHINE)
brand: String @source(attribute: "brand", ecc: ["MARA-MFRNR"], origin: AUTHORED)
gtins: [String!] @source(attribute: "gtin", ecc: ["MARM-EAN11", "MARM-NUMTP", "MARA-EAN11", "MARA-NUMTP"], origin: MACHINE)
mpn: String @source(attribute: "mpn", ecc: ["MARA-MFRPN"], origin: MACHINE)
identifierExists: Boolean @source(attribute: "identifier_exists", ecc: ["MARA-EAN11", "MARA-MFRPN"], origin: MACHINE)
itemGroupId: String @source(attribute: "item_group_id", ecc: ["MARA-SATNR"], origin: MACHINE)
material: String @source(attribute: "material", ecc: ["MARA-WRKST"], origin: AUTHORED)
color: String @source(attribute: "color", ecc: [], origin: AUTHORED)
condition: Condition @source(attribute: "condition", ecc: [], origin: NONE)
productWeight: Measure @source(attribute: "product_weight", ecc: ["MARA-NTGEW", "MARA-GEWEI"], origin: MACHINE)
shippingWeight: Measure @source(attribute: "shipping_weight", ecc: ["MARA-BRGEW", "MARA-GEWEI"], origin: MACHINE)
shippingLength: Measure @source(attribute: "shipping_length", ecc: ["MARM-LAENG", "MARM-MEABM"], origin: MACHINE)
shippingWidth: Measure @source(attribute: "shipping_width", ecc: ["MARM-BREIT", "MARM-MEABM"], origin: MACHINE)
shippingHeight: Measure @source(attribute: "shipping_height", ecc: ["MARM-HOEHE", "MARM-MEABM"], origin: MACHINE)
shipsFromCountry: String @source(attribute: "ships_from_country", ecc: ["T001W-LAND1"], origin: MACHINE)
"""Newest change document for the material (CDHDR), YYYYMMDDhhmmss: an older write can't replace a newer one."""
versionNumber: String @source(ecc: ["CDHDR-UDATE", "CDHDR-UTIME"], origin: MACHINE)
}
"""Micros: 1 000 000 = one unit of the currency. KRW and JPY are already shifted from SAP's 2 stored decimals."""
type Money {
amountMicros: String!
"""ISO 4217."""
currencyCode: String!
}
"""UTC; endTime is exclusive."""
type DateInterval {
startTime: DateTime!
endTime: DateTime!
}
type Measure {
value: Float!
"""Google's unit: g, kg, oz, lb, cm, in, ml, l, ..."""
unit: String!
}
enum Availability {
IN_STOCK
OUT_OF_STOCK
PREORDER
BACKORDER
LIMITED_AVAILABILITY
}
enum Condition {
NEW
USED
REFURBISHED
}
"""A customer (KNA1 with its address and e-mail) and their consent. Personal data stays here: it is not part of Product."""
type User {
"""Customer number as SAP displays it (leading zeros dropped for all-digit numbers)."""
id: ID! @source(ecc: ["KNA1-KUNNR"], origin: MACHINE)
"""Name 1 of the customer master."""
name: String @source(ecc: ["KNA1-NAME1"], origin: PERSONAL)
"""The default e-mail address (FLGDEFAULT) that is not marked do-not-use (FLG_NOUSE); ADR6 is reached through KNA1-ADRNR."""
email: String @source(ecc: ["ADR6-SMTP_ADDR", "ADR6-FLGDEFAULT", "ADR6-FLG_NOUSE"], origin: PERSONAL)
"""Telephone from the business address."""
phone: String @source(ecc: ["ADRC-TEL_NUMBER"], origin: PERSONAL)
"""City."""
city: String @source(ecc: ["KNA1-ORT01"], origin: PERSONAL)
"""Postal code."""
postalCode: String @source(ecc: ["KNA1-PSTLZ"], origin: PERSONAL)
"""Region code (ISO 3166-2 subdivision once prefixed with the country)."""
region: String @source(ecc: ["KNA1-REGIO"], origin: MACHINE)
"""ISO 3166-1 alpha-2."""
country: String! @source(ecc: ["KNA1-LAND1"], origin: MACHINE)
"""BCP 47 from the one-character SAP language key (E → en / 3 → ko)."""
language: String @source(ecc: ["KNA1-SPRAS"], origin: MACHINE)
"""Created on."""
createdOn: Date @source(ecc: ["KNA1-ERDAT"], origin: MACHINE)
"""Central deletion flag: a deleted customer is not served."""
deleted: Boolean! @source(ecc: ["KNA1-LOEVM"], origin: MACHINE)
"""Global Privacy Control was received."""
gpcSeen: Boolean @source(ecc: ["KNA1-/ACME/GPC"], origin: MACHINE)
marketingOptIn: Boolean @source(ecc: ["KNA1-ZZ_MKT_OPTIN"], origin: MACHINE) @deprecated(reason: "a flag a batch job can overwrite. Read consent instead.")
"""The append-only consent ledger for this customer; the newest row per purpose wins."""
consent: [Consent!]! @source(ecc: ["/ACME/CONSENT"], origin: MACHINE)
}
"""One row of /ACME/CONSENT: append-only, the newest row per purpose wins."""
type Consent {
purpose: String! @source(ecc: ["/ACME/CONSENT-PURPOSE"], origin: MACHINE)
recordedAt: DateTime! @source(ecc: ["/ACME/CONSENT-RECORDED_AT"], origin: MACHINE)
granted: Boolean! @source(ecc: ["/ACME/CONSENT-GRANTED"], origin: MACHINE)
source: String @source(ecc: ["/ACME/CONSENT-SOURCE"], origin: MACHINE)
seqno: Int @source(ecc: ["/ACME/CONSENT-SEQNO"], origin: MACHINE)
}
type Query {
product(offerId: ID!, contentLanguage: String!, feedLabel: String!): Product
"""Served only to the customer themself or for a permitted purpose."""
user(id: ID!): User
}
Example
The same sample material as the Merchant chapter, and the sample customer from fixtures/records/kna1.json, adr6.json and acme_consent.json. tests/graphql.rs checks that every key in these responses is a field of the schema.
query {
product(offerId: "HM-QUEEN-01", contentLanguage: "en", feedLabel: "US") {
offerId title availability
price { amountMicros currencyCode }
salePrice { amountMicros currencyCode }
salePriceEffectiveDate { startTime endTime }
gtins mpn identifierExists productTypes
shippingWeight { value unit }
shipsFromCountry versionNumber
}
}
{
"data": {
"product": {
"availability": "IN_STOCK",
"gtins": [
"012345678905"
],
"identifierExists": true,
"mpn": "HM-Q-2026",
"offerId": "HM-QUEEN-01",
"price": {
"amountMicros": "129000000",
"currencyCode": "USD"
},
"productTypes": [
"Home > Heating > Heated mats"
],
"salePrice": {
"amountMicros": "109000000",
"currencyCode": "USD"
},
"salePriceEffectiveDate": {
"endTime": "2026-12-01T08:00:00Z",
"startTime": "2026-11-01T08:00:00Z"
},
"shippingWeight": {
"unit": "kg",
"value": 9.8
},
"shipsFromCountry": "US",
"title": "Heated mat, queen",
"versionNumber": "20261103021500"
}
}
}
query {
user(id: "12345") {
id name email country region language createdOn deleted gpcSeen marketingOptIn
consent { purpose recordedAt granted source seqno }
}
}
{
"data": {
"user": {
"consent": [
{
"granted": false,
"purpose": "ads",
"recordedAt": "2026-11-04T10:05:00Z",
"seqno": 0,
"source": "dsr"
},
{
"granted": true,
"purpose": "ads",
"recordedAt": "2026-11-04T10:02:00Z",
"seqno": 0,
"source": "banner"
}
],
"country": "US",
"createdOn": "2024-01-15",
"deleted": false,
"email": "orders@example.com",
"gpcSeen": false,
"id": "12345",
"language": "en",
"marketingOptIn": true,
"name": "Example Retail Inc.",
"region": "CA"
}
}
}
consent returns the ledger; the 10:05 withdrawal (dsr) is newer than the 10:02 grant, so ads consent is withdrawn. marketingOptIn still says true: that is the stale batch-written flag the schema deprecates.
Rust structs and GraphQL types
The same field in each shape it takes: the GraphQL type a client or agent reads, the Rust struct that holds it after
conversion, and the ECC fields it comes from. The GraphQL side is schema.graphql; the Rust side is
src/merchant.rs and src/merchant_api.rs for products and the generated sap::* and acme::* structs for customers.
Origin follows the book’s rule: machine data is converted by a fixed rule and never rewritten, text may be written by people or declared AI, none comes from another system, and personal data never reaches Merchant Center.
Product
Two Rust structs: merchant::Product is the converted ECC record (amounts as Decimal, dates as chrono), and
merchant_api::ProductInput is what the Merchant API v1 receives (amounts in micros as strings, enums upper case).
merchant_api::product_input turns one into the other; tests/merchant_api.rs checks every path.
| GraphQL field | GraphQL type | merchant::Product (converted) | merchant_api::ProductInput (sent) | Origin | ECC source |
|---|---|---|---|---|---|
offerId | ID! | id: String | offer_id: String | machine | MARA-MATNR |
contentLanguage | String! | (feed setting) | content_language: String | ||
feedLabel | String! | (feed setting) | feed_label: String | ||
title | String | title: Option<String> | title: Option<String> | MAKT-MAKTX, MAKT-SPRAS | |
availability | Availability | in_stock: bool | availability: &'static str (IN_STOCK / OUT_OF_STOCK) | machine | MARD-LABST, MARD-INSME, MARD-SPEME |
price | Money | price: Option<Money> (amount: Decimal, currency: String, decimals: u32) | price: Option<Price> (amount_micros: String, currency_code: String) | machine | A004, KONP, TCURX-CURRDEC |
salePrice | Money | sale_price: Option<Money> | sale_price: Option<Price> | machine | A004, KONP, TCURX-CURRDEC |
salePriceEffectiveDate | DateInterval | sale_window: Option<(NaiveDate, NaiveDate, FixedOffset)> (inclusive, local) | sale_price_effective_date: Option<Interval> (UTC, end exclusive) | machine | A004-DATAB, A004-DATBI |
costOfGoodsSold | Money | cost: Option<Money> | cost_of_goods_sold: Option<Price> | machine | MBEW-VPRSV, MBEW-STPRS, MBEW-VERPR, MBEW-PEINH |
unitPricingMeasure | Measure | unit_pricing: Option<Measure> (value: Decimal, unit) | unit_pricing_measure: Option<ValueUnit> (value: f64, unit) | machine | MARA-INHAL, MARA-INHME |
productTypes | [String!] | product_type: Option<String> | product_types: Vec<String> | machine | MARA-PRDHA, T179T-VTEXT |
gtins | [String!] | gtin: Option<String> | gtins: Vec<String> | machine | MARM-EAN11, MARM-NUMTP, MARA-EAN11, MARA-NUMTP |
mpn | String | mpn: Option<String> | mpn: Option<String> | machine | MARA-MFRPN |
identifierExists | Boolean | derived: identifier_exists() | identifier_exists: Option<bool> (sent only as false) | machine | MARA-EAN11, MARA-MFRPN |
itemGroupId | String | item_group_id: Option<String> | item_group_id: Option<String> | machine | MARA-SATNR |
material | String | material: Option<String> | material: Option<String> | MARA-WRKST | |
productWeight | Measure | product_weight: Option<Measure> | product_weight: Option<ValueUnit> | machine | MARA-NTGEW, MARA-GEWEI |
shippingWeight | Measure | shipping_weight: Option<Measure> | shipping_weight: Option<ValueUnit> | machine | MARA-BRGEW, MARA-GEWEI |
shippingLength | Measure | shipping_dims: Option<[Measure; 3]>, [0] | shipping_length: Option<ValueUnit> | machine | MARM-LAENG, MARM-MEABM |
shippingWidth | Measure | shipping_dims, [1] | shipping_width: Option<ValueUnit> | machine | MARM-BREIT, MARM-MEABM |
shippingHeight | Measure | shipping_dims, [2] | shipping_height: Option<ValueUnit> | machine | MARM-HOEHE, MARM-MEABM |
shipsFromCountry | String (ISO 3166-1 alpha-2) | ships_from_country: Option<String> | custom_attributes: Vec<CustomAttribute> (name, value) | machine | T001W-LAND1 |
versionNumber | String | version: Option<i64> (YYYYMMDDhhmmss) | version_number: Option<String> | machine | CDHDR-UDATE, CDHDR-UTIME |
description, googleProductCategory, brand, color | String | not held | not sent from ECC | written by people, or AI if declared | |
link, imageLink, condition | String, String, Condition | not held | not sent from ECC | none | storefront, DAM |
User
There is no single Rust User struct. User in GraphQL is assembled from the generated table structs, so each field
keeps the type its DDIC field has; the resolver joins them on KNA1-ADRNR = ADDRNUMBER.
| GraphQL field | GraphQL type | Rust struct and field | Rust type | Origin | ECC source |
|---|---|---|---|---|---|
id | ID! | sap::Kna1.kunnr | String | machine | KNA1-KUNNR |
name | String | sap::Kna1.name1 | String | personal | KNA1-NAME1 |
email | String | sap::Adr6.smtp_addr, where flgdefault and not flg_nouse | String, bool, bool | personal | ADR6-SMTP_ADDR, ADR6-FLGDEFAULT, ADR6-FLG_NOUSE |
phone | String | sap::Adrc.tel_number | String | personal | ADRC-TEL_NUMBER |
city | String | sap::Kna1.ort01 | String | personal | KNA1-ORT01 |
postalCode | String | sap::Kna1.pstlz | String | personal | KNA1-PSTLZ |
region | String | sap::Kna1.regio | String | machine | KNA1-REGIO |
country | String! | sap::Kna1.land1 | String | machine | KNA1-LAND1 |
language | String | sap::Kna1.spras (E → en, 3 → ko) | String | machine | KNA1-SPRAS |
createdOn | Date | sap::Kna1.erdat | Option<chrono::NaiveDate> | machine | KNA1-ERDAT |
deleted | Boolean! | sap::Kna1.loevm | bool | machine | KNA1-LOEVM |
gpcSeen | Boolean | sap::Kna1.acme_gpc | bool | machine | KNA1-/ACME/GPC |
marketingOptIn (deprecated) | Boolean | sap::Kna1.zz_mkt_optin | bool | machine | KNA1-ZZ_MKT_OPTIN |
consent | [Consent!]! | Vec<acme::Consent> for the customer | see below | machine | /ACME/CONSENT |
Consent
| GraphQL field | GraphQL type | Rust struct and field | Rust type | ECC source |
|---|---|---|---|---|
purpose | String! | acme::Consent.purpose | String | /ACME/CONSENT-PURPOSE |
recordedAt | DateTime! | acme::Consent.recorded_at | Option<chrono::NaiveDateTime> | /ACME/CONSENT-RECORDED_AT |
granted | Boolean! | acme::Consent.granted | bool | /ACME/CONSENT-GRANTED |
source | String | acme::Consent.source | String | /ACME/CONSENT-SOURCE |
seqno | Int | acme::Consent.seqno | i32 | /ACME/CONSENT-SEQNO |
Google Merchant endpoints: product, loyalty, comparison shopping, reviews
Where each record goes in Google, and what of it this book builds. All four use the https://www.googleapis.com/auth/content
OAuth scope, and every write names a data source (accounts/{account}/dataSources/{dataSource}).
| Endpoint | Method and path | Version | Rust struct | GraphQL | What it carries | Here |
|---|---|---|---|---|---|---|
| Product | POST https://merchantapi.googleapis.com/products/v1/{parent=accounts/*}/productInputs:insert?dataSource=...; the processed product is read back with GET .../products/v1/accounts/{account}/products/{contentLanguage~feedLabel~offerId} | v1 | merchant_api::ProductInput | Product | The converted ECC product: identifiers, prices, stock, units, dimensions, versionNumber | Built: src/merchant_api.rs, tests/merchant_api.rs. Nothing sends yet. |
| Loyalty | No endpoint of its own: productAttributes.loyaltyPrograms[] on the same productInputs:insert. Loyalty shipping is set on accounts/{account}/shippingSettings. The program must first be linked in Merchant Center. | v1 | not built: would be ProductAttributes.loyalty_programs: Vec<LoyaltyProgram> | not built: would be Product.loyaltyPrograms | Per tier: programLabel, tierLabel, member price (no higher than the regular price), cashbackForFutureUse, loyaltyPoints, memberPriceEffectiveDate, shippingLabel | Not built. A member price would come from its own SAP condition type, converted like price. Program data, not personal data: who is a member stays on User. |
| Comparison shopping | POST https://css.googleapis.com/v1/{parent=accounts/*}/cssProductInputs:insert: the separate CSS API, for comparison shopping services listing other merchants’ products | v1 | not built | not built | A product input keyed by contentLanguage, feedLabel (the target country, e.g. DE) and identity; feedId is deprecated | Not built. Applies only when acting as, or supplying, a comparison shopping service. One-time API registration required. |
| Reviews | POST https://merchantapi.googleapis.com/reviews/v1beta/{parent=accounts/*}/productReviews:insert?dataSource=... and .../merchantReviews:insert?dataSource=..., with get, list and delete | v1beta | not built | not built | Rating, title, content, review time, language and country, isVerifiedPurchase, isIncentivizedReview, and the reviewer (reviewerId, reviewerUsername, isAnonymous) | Not built. Reviews come from the storefront or a review platform, not ECC. The reviewer is personal data: it belongs with User, under consent, never in Product. Requires a review data source and enrolment in the product ratings programme. |
Two rules follow from the table:
- Loyalty and reviews ride on the product, not the person. A member price is a fact about the product and the tier;
a review is attached to the product’s identifiers. The person behind either (the member, the reviewer) stays on
User, and leaves only through the release gate. - Beta means it can change. Reviews are
v1beta; Google says beta versions are subject to change or removal. Product and loyalty are onv1.
Sources: Products: add and manage, ProductAttributes (v1), including loyaltyPrograms, loyalty_program in the product data specification, CSS API: cssProductInputs.insert, Reviews: product reviews, Reviews: merchant reviews, Merchant API design and versioning.
Where the types differ, and why
- Amounts:
Decimalin Rust keeps SAP’s scale exactly (258.00); GraphQL and the Merchant API carry micros as a string, becauseint64doesn’t fit a JSON number safely. - Dates: Rust holds what ECC means (a local sale window, inclusive); the API gets UTC with an exclusive end.
- Lists: ECC holds one GTIN and one product type per row; Google takes lists, so the converter wraps them.
- Optional vs required: ABAP has no null. A Rust
OptionisNoneonly where ECC’s initial value means “not set” (00000000dates); GraphQL’s non-null!marks the fields a resolver must always return. - Personal data: only
Userholds it. Nothing inProduct,merchant::ProductorProductInputcan carry a name, e-mail or phone, so a product feed can’t leak one.
Consent gaps
ECC has no consent model. It holds identity (KUNNR, address, e-mail), communication flags and blocking, but none of what a consent check needs. These are the 12 gaps, with the ECC fields that come closest. The CRM Sync gap fill chapter shows what fills each one.
The rule that follows from the table: keep consent out of ECC. ECC stays the source of identity and blocking; consent lives in an append-only ledger in Xano that ECC and batch jobs may read but never write.
| Gap | What ECC has | Closest ECC fields | What’s missing |
|---|---|---|---|
| Consent per purpose (analytics, ads, sale / share, email, SMS) | At most a custom ZZ_ flag on KNA1. ADR6-FLG_NOUSE means “don’t use this address”, not “no consent”. | KNA1-ZZ_MKT_OPTINADR6-FLG_NOUSE | A record per purpose: one flag can’t say “email yes, ads no”. |
| Who decided, how and with which banner | Change documents, but only for fields flagged for change documents; custom ZZ_ fields usually aren’t, so a flip leaves no trace. A batch user shows up as the author. | CDHDR-USERNAMECDHDR-TCODECDPOS-VALUE_OLDCDPOS-VALUE_NEW | The source, banner version and actor stored with each decision. |
| An exact, comparable time | DATS dates have no time zone; CDHDR UDATE / UTIME are server local time. | CDHDR-UDATECDHDR-UTIME | UTC timestamps and a sequence number for events in the same second, so the newest row reliably wins. |
| Where consent was given, and under which regime | LAND1 / REGIO are the billing address, not where the shopper was when they decided. | KNA1-LAND1KNA1-REGIO | The region (ISO 3166-2) and regime (US opt-out with GPC, EU / UK opt-in, KR PIPA opt-in) at decision time. |
| Consent before there is a customer | Nothing: a visitor has no KUNNR until they order. | (none) | Consent keyed by a visitor ID and linked to the customer later. |
| Consent for one-time customers | One-time customer accounts share a single KUNNR across many real people. | KNA1-KUNNR | A key for the person, not the shared account. |
| Consent for B2B contact persons | Contact persons (KNVK) hang off the company record. | (none) | Consent per person, not per company. |
| A withdrawal that sticks | A DEBMAS IDoc or a 15-minute middleware job rewrites whole segments, so a stale ZZ_MKT_OPTIN = X overwrites a withdrawal. | KNA1-ZZ_MKT_OPTIN | An append-only ledger; batch jobs read consent and never write it; withdrawals pushed as events. |
| Data subject requests: access, deletion, opt-out of sale | Later enhancement packs add end-of-purpose blocking and ILM deletion, but no request tracking or receipts. | KNA1-LOEVM | A request record with a due date and a receipt from every system it fans out to. |
| Age or minor status | No age field. | (none) | A minor flag where the law requires one. |
| Retention per purpose | Retention is per object (ILM), not per purpose. | (none) | An expiry per purpose. |
| Permission to use a person for ads and audiences | Nothing ties a customer to ads permission. | (none) | ad_user_data and ad_personalization checked before anyone is exported to an audience. |
On a real system, check first whether any custom consent field is flagged for change documents (its data element’s change-document setting). If it isn’t, there is no record today of who changed it or when.
The /ACME/CONSENT table in this book is the shape the ledger takes if it must live in ECC; the Xano ledger in the next chapter adds the columns ECC can’t supply.
Does S/4HANA close the gaps?
Partly. An upgrade to S/4HANA improves the data-protection mechanics, but consent and the global state at decision time still sit outside the ERP core. SAP does sell consent tooling; it is a separate product the ERP receives by integration, which adds one more copy to reconcile rather than one record of truth.
What S/4HANA improves
| ECC gap | In S/4HANA |
|---|---|
| Several customer masters (KNA1, KNVK contact persons) | The Business Partner is mandatory: one record per person or organisation, with relationships for B2B contacts. This narrows the contact person gap. |
| Data subject requests | ILM blocking and deletion at end of purpose, Read Access Logging, and information retrieval to collect one person’s data across objects. |
| Batch-only interfaces | APIs and events exist, though most estates still run IDocs and middleware batches. |
What is still missing
| Gap | Why S/4HANA doesn’t close it |
|---|---|
| Consent per purpose | No per-purpose, append-only ledger in the core: still a flag or a custom field on the Business Partner. SAP’s consent products keep it in a separate system. |
| Region and regime at decision time | The Business Partner holds an address, not where the shopper was, under which regime and with which banner. ERP is not on the path of a browser session. |
| A withdrawal that sticks | If middleware still rewrites whole master-data segments on a schedule, a stale opt-in still overwrites a withdrawal. A new ERP doesn’t change the batch. |
| Retention per purpose | ILM retention follows the business object and its legal hold (tax, commercial), not the purpose of consent. |
| Consent before there is a customer | A Business Partner must exist first; visitors and pre-login consent are out of scope. |
| Audiences | Nothing in ERP checks ad_user_data and ad_personalization before an audience or a BigQuery segment is exported. |
| Residency across regimes | One global instance in one region doesn’t give per-regime storage for EU, UK or KR personal data. |
Why enterprises struggle with compliance. Consent ends up copied across systems that each own something else:
Consent banner / CMP (session) ─┐
Commerce platform ──────────────┤ each holds a copy of "consent",
Marketing cloud / CDP ──────────┼── refreshed on its own schedule,
S/4HANA Business Partner flags ─┤ none on the path of every decision
Warehouse and ad exports ───────┘
- No record wins. When the banner, the CDP and the ERP flag disagree, no one can show which was in force when an export ran.
- Batch delay is a compliance gap. A withdrawal that takes hours to reach an audience job is out of compliance for those hours.
- Ownership is split. Legal owns the policy, marketing the CMP, IT the ERP, data teams the warehouse; no one owns the decision.
- Several ERPs and regions, after acquisitions, multiply every gap above.
- Upgrades treat consent as migration scope. The fields are moved; the decision logic is never designed.
The rule holds through the upgrade: ERP is the source of identity and blocking; consent lives in an append-only ledger beside it, and every export checks it live through the release gate. That is also why the gaps can be closed without a full upgrade: see An alternative to a full S/4HANA upgrade.
The S/4HANA features named here vary by release and by which SAP products are licensed. Check them against the system in front of you: where a consent product is in place, the first gap becomes “a consent store outside ERP that must be reconciled”, not “no consent store”.
CRM Sync gap fill: Shopify / Google → Xano
CRM Sync captures consent at the edge, before any tag loads, and writes it to a ledger in Xano, the system of record. Shopify and Google each hold part of the picture; neither holds all of it, and ECC holds none. For each consent gap:
| Gap | Shopify | CRM Sync | Xano | |
|---|---|---|---|---|
| Consent per purpose (analytics, ads, sale / share, email, SMS) | emailMarketingConsent and smsMarketingConsent on the customer (per channel); Customer Privacy API analytics / marketing / preferences / sale_of_data (per visitor). | Consent Mode v2: analytics_storage, ad_storage, ad_user_data, ad_personalization. | The banner writes one ledger row per purpose, never one combined flag. | purposegranted |
| Who decided, how and with which banner | marketingOptInLevel (single / confirmed opt-in); consentCollectedFrom on SMS consent. | The Consent Mode update that was sent, as evidence. | Every row carries source, banner_version, actor and a hash of the raw signal. | sourcebanner_versionactorevidence_sha256 |
| An exact, comparable time | consentUpdatedAt (ISO 8601, UTC). | - | recorded_at in UTC at the edge, plus seq. | recorded_atseq |
| Where consent was given, and under which regime | Customer Privacy API region for the visitor. | Consent Mode defaults set per region. | Region from the edge request and the Sec-GPC header, resolved to a regime before the banner shows. | regionregimegpc |
| Consent before there is a customer | Customer Privacy API consent for an anonymous visitor. | Consent Mode state per browser. | visitor_id on every row; an identity link to the Shopify customer and KUNNR on first order or sign-in. | subject_typevisitor_ididentity_link |
| Consent for one-time customers | The customer created or matched from the checkout email. | - | Subject keyed by email hash and Shopify customer ID; never by a one-time KUNNR. | email_sha256shopify_customer_id |
| Consent for B2B contact persons | B2B company contacts are customers in their own right. | - | subject_type contact, with the company as context. | subject_typecontact_id |
| A withdrawal that sticks | Customer marketing-consent update webhooks. | A Consent Mode update to denied on the page. | Appends a row, then publishes the withdrawal event; nothing overwrites a row. | idempotency_keyrecorded_atseq |
| Data subject requests: access, deletion, opt-out of sale | customers/data_request, customers/redact and shop/redact webhooks; dataSaleOptOut on the customer. | Remove the person from Customer Match lists. | Fans the request out (Shopify, Google, ECC, Xano) and collects a receipt from each. | dsr_requestdsr_receipt |
| Age or minor status | - | - | An age gate where required; unknown stays unknown. | minor |
| Retention per purpose | - | - | Sets expires_at from the regime’s rule when it writes the row. | expires_at |
| Permission to use a person for ads and audiences | marketing and sale_of_data from the Customer Privacy API. | Customer Match uploads carry consent (adUserData, adPersonalization: GRANTED / DENIED) per person. | Exports only subjects whose newest ad_user_data and ad_personalization rows are granted; Merchant Center products carry no personal data. | entitlement |
The Xano consent ledger
Append-only: rows are added, never updated. The newest row per subject and purpose (by recorded_at, then seq) is the current decision.
| Field | Type | Note |
|---|---|---|
id | int | Row ID. |
idempotency_key | text, unique | One per decision; a replay writes nothing. |
subject_type | enum customer / visitor / contact | |
visitor_id | text | Set before there is a customer. |
kunnr | text | KNA1-KUNNR when known; never a one-time account. |
shopify_customer_id | text | gid://shopify/Customer/… |
email_sha256 | text | Normalised e-mail, hashed: a key, not contact data. |
contact_id | text | B2B contact person. |
purpose | enum analytics / ads / ad_user_data / ad_personalization / sale_share / email / sms | |
granted | bool | |
source | enum banner / shopify / dsr / gpc / import | import rows never grant ads purposes. |
| text | ||
actor | text | Who or what wrote it: shopper, agent, support user, job. |
region | text | ISO 3166-2 at decision time. |
regime | enum us_optout / eu_optin / kr_pipa / … | |
gpc | bool | Sec-GPC seen. |
minor | bool, nullable | |
recorded_at | timestamp (UTC) | |
seq | int | Orders events in the same second. |
expires_at | timestamp, nullable | |
evidence_sha256 | text | Hash of the raw signal (banner payload, webhook body). |
Alongside it: identity_link (visitor → Shopify customer → KUNNR), dsr_request and dsr_receipt (one receipt per system a request fans out to), and an entitlement view computed from the newest rows: what a person may be sent, shown or exported to. Entitlements are derived, never uploaded or edited by hand.
Who writes what
| Writer | May write | May not |
|---|---|---|
| CRM Sync banner (edge) | Ledger rows (source banner, gpc) | Anything in ECC |
| Shopify webhooks | Ledger rows (source shopify), DSR requests | Ads purposes from an e-mail opt-in |
| DSR handler | Ledger rows (source dsr), DSR receipts | Delete ledger rows (they are the proof) |
| One-time import (CSV) | Ledger rows (source import) | Ads purposes, or anything newer than an existing row |
| ECC / middleware batch | Nothing: reads the entitlement view | Consent fields, in ECC or Xano |
| Merchant / Google export | Nothing: reads entitlements and products | Personal data into Merchant Center |
Plan: Xano buildout
Status: Phases 1 to 3 are done; Phase 4 steps 1 to 4 are done (the generator, the four new tables, five columns on the consent log, two on the user table); steps 5 and 6 wait on real exports and the signer endpoint:
cargo run --bin xano-buildout -- --workspace <id> --data-home <home>, tested by tests/xano.rs. The remaining Phase 4 steps
change a live workspace and are applied one confirmed step at a time.
Everything is generated from the same map (site/ddic.json) as the Rust structs, the GraphQL schema and these pages, so the tables,
the CSV headers and the docs can’t drift apart.
What Phase 3 changed
The dry run against the target workspace found most of the consent stack already in place:
| Planned in Phase 1 | Already in the workspace | Now |
|---|---|---|
| A new consent ledger | An append-only consent log, hash-chained and signed, written by the CRM Sync worker | Reused. Add the missing columns; rows go through the worker’s signer so the chain stays valid. |
| A consent entitlement function | A release gate every Google and Shopify payload must pass: latest decision wins, a tie revokes, no decision means denied | Reused. One decision point. A second would disagree with it. |
| A customer table | The storefront user table the gate keys on, with erasure and opt-out tags | Reused. Add kunnr and shopify_customer_id. |
A --hold KR flag | A region policy table with a data home per country | Reused. A person whose data home isn’t the workspace’s is held. |
merchant_product, identity_link, dsr_request, dsr_receipt | Nothing equivalent | Created (step 2). |
One rule follows from how the gate works: it reads consent category marketing as all three ad signals (ad storage, ad user data,
ad personalization). So e-mail and SMS opt-ins are imported as categories newsletter (the worker’s own word for e-mail marketing) and sms, never marketing, and an
e-mail opt-in can never open Customer Match. Shopify’s sale opt-out becomes the user’s opt-out tag, which the gate treats as a
hard stop, not a consent row.
ECC export (DD03L + records) ─┐
Shopify customers (Admin API) ─┼─▶ xano-buildout ─▶ xano/tables/*.xs the 4 new tables
Region policy (snapshot) ─┘ ├▶ plan.json steps 2-6, with the column additions
├▶ csv/storefront_users.csv upserts, matched on e-mail
├▶ csv/consent_records.csv input for the consent signer
├▶ csv/identity_link.csv, merchant_product.csv
├▶ expected_release_decisions.csv what the gate should answer
└▶ report.md what was skipped or held, and why
Phase 4
| Step | What | Changes the workspace |
|---|---|---|
| 1 | Reshape the generator to the existing tables (this page) | No: built |
| 2 | Create merchant_product, identity_link, dsr_request, dsr_receipt (each with a primary id and a unique idempotency_key; the last three point at the user table). Optional columns are nullable, so a missing price is null, never 0. | Yes: done |
| 3 | Add to the consent log: idempotency_key (unique), seq, gpc, expires_at, evidence_sha256. All optional and nullable: existing rows have none of them. Region, regime and banner version are not added: the log already keeps them in its systems_notified JSON. The chain hash and signature cover a fixed set (subject, category, action, consent ID, time, previous hash), so new columns don’t disturb them, and aren’t tamper-evident either. | Yes: done |
| 4 | Add to the user table: kunnr, shopify_customer_id (nullable, sensitive) | Yes: done |
| 5 | Import: users as upserts on e-mail (a blank field is left as is, tags are merged); identity links and products as inserts; consent rows one call at a time through the signer, oldest first. Needs a new admin-only worker endpoint that anchors and signs a backfill row for a known user with its historical time: no existing endpoint does. | Yes |
| 6 | Verify against expected_release_decisions.csv. A live gate call writes a ledger row, so verification uses verify- idempotency keys, or is checked offline. | Only ledger rows |
Phase 5: the session-to-order join (planned)
SAP never sees a shopper’s visit: its sessions belong to logged-in SAP users. What reaches SAP is the order, so the visit has to ride on the order. The join carries the consent session and the ad click from the landing page to the SAP sales order, so a confirmed sale can be reported to Google Ads against the click that led to it, and only if the release gate allows it.
landing ─▶ consent banner ─▶ add to cart ──────────▶ checkout ─▶ Shopify order ─▶ middleware ─▶ SAP sales order
gclid session_id cart attributes: customAttributes: VBAK-BSTNK (or a Z field)
gbraid (consent row) _crm_session, _crm_click _crm_session, _crm_click = Shopify order ID
wbraid (only if ad_storage granted)
│ │
└─▶ visit_click (Xano): session_id → click IDs, landed_at ◀──── SAP confirms the sale ─────────────┘
└─▶ conversion endpoint: order → session → click
→ release gate (google_ads_conversion) → export
| Step | Where | What | Rule |
|---|---|---|---|
| 5.1 | CRM Sync worker, landing request | Read gclid / gbraid / wbraid from the landing URL; write one visit_click row: session_id, the click IDs, landed_at, region | Stored only if ad_storage is granted for the session at that moment. Otherwise nothing is kept: Consent Mode’s own signals cover the denied case. |
| 5.2 | Storefront, add to cart | Set cart attributes _crm_session (the consent session_id) and _crm_click (the visit_click row’s key, not the raw click ID) | Underscore-prefixed attributes are hidden from the shopper at checkout. Never a raw e-mail or click ID in the cart. |
| 5.3 | Shopify | Cart attributes become the order’s customAttributes | No code: Shopify copies them. |
| 5.4 | Middleware (order to SAP) | Keep writing the Shopify order ID to VBAK-BSTNK (or the Z field used today); carry nothing else | SAP holds the order reference only, never the session or the click. |
| 5.5 | CRM Sync worker, on SAP confirmation (sale, return, cancellation) | Look up the Shopify order’s _crm_click → visit_click → click IDs; call the existing conversion endpoint with the order ID, conversion_time from SAP, value and currency | The endpoint already runs the release gate (google_ads_conversion) and the region policy, and stores the order reference only as an HMAC. |
| 5.6 | Xano | Expire visit_click rows after Google’s click-ID lookback (90 days) | A click older than the window can’t be credited; keeping it serves nothing. |
What this needs that doesn’t exist yet: the visit_click table (generated with the others when the step is approved), the
worker’s landing and confirmation hooks, and the storefront’s cart attribute write. Nothing in it changes the consent log or the
release gate, and SAP needs no change beyond the order reference it already carries.
Acceptance:
- A session without
ad_storageleaves novisit_clickrow, and its order carries no_crm_click. - An order whose shopper withdrew ad user data after the click is refused by the gate at confirmation time, not at the click.
- A return or cancellation in SAP reaches Google as an adjustment against the same order reference.
- No raw e-mail, click ID or session ID appears in SAP, in the order’s visible attributes, or in the export.
The CSVs
| File | Rows from | Rules |
|---|---|---|
storefront_users.csv | ECC customer (KNA1 + default e-mail in ADR6) and Shopify customers | Matched on the normalised e-mail. One-time customer numbers are never a key. Deleted customers are left out. tags_add carries rejects_sale_of_data for Shopify’s dataSaleOptOut. |
consent_records.csv | Shopify emailMarketingConsent / smsMarketingConsent (with consentUpdatedAt); the ECC consent table | session_id (the consent log’s existing column) records the visit a decision came from; backfill rows have none, and today only the signed-in path writes it (the anonymous banner path writes it empty, which Phase 5 needs changed). Jurisdiction and regime go into systems_notified. Categories newsletter, sms; an ECC ads row becomes marketing only as a withdrawal: imports never grant ads. Rows without a time are skipped (the gate ignores them anyway). The ECC ZZ_MKT_OPTIN flag is never imported. |
identity_link.csv | People with both a KUNNR and a Shopify ID | user_email is resolved to the user’s ID on import. |
merchant_product.csv | The converter in this book over the ECC export | No personal data. |
Every row carries an idempotency key, so a replayed file writes nothing the second time. The CSVs, plan.json and report.md
are written to xano/ but not committed: from real exports they hold personal data.
On the fixtures the run writes 2 users, 1 identity link, 4 consent rows and 1 product, holds the KR customer (data home kr, not
the workspace’s us) with all of their rows, and reports the ECC flag, the ECC ads grant (its later withdrawal is imported), the
SMS state with no decision, and the sale opt-out turned into a tag.
Expected decisions
expected_release_decisions.csv is computed by an offline copy of the gate’s rules (src/release_gate.rs, tested on its own):
hard stops first (erasure; the opt-out tag refuses the ad signals), then per signal the latest timed decision wins, a tie
revokes, test sources are ignored, and no decision means denied. For the sample customer with an e-mail opt-in, Customer Match is
still refused: the opt-in is category newsletter, which covers no ad signal. The live gate is the authority; the copy follows it.
Open decisions
- Who runs the signer import (step 5), and from where.
- Retention per purpose and regime (sets
expires_at); the gate doesn’t check expiry yet. - Whether the gate should hold ad user data and ad personalization separately:
marketinggrants or revokes them together. - Whether B2B contact persons are in scope for the first import.
- Phase 5: which middleware carries the Shopify order ID into SAP today, and in which field (
BSTNKor a Z field), so the confirmation hook can find the order.
ECC direct to Google: what it replaces
Converting ECC’s own data straight into Google Merchant Center’s shape takes S/4HANA off the path to Google. It does not replace the S/4HANA upgrade, and it does not replace consent data. It makes the consent layer more important, not less.
What it removes
- S/4HANA as a prerequisite for Google commerce. Merchant Center doesn’t care which ERP the data came from. MARA, MAKT, MARM, A004, KONP and MARD already hold title, GTIN, price, units and stock, and the Google Merchant Center page maps them attribute by attribute. Listing products on Google doesn’t wait for S/4HANA or need SAP’s commerce add-ons.
- Commerce from the upgrade’s scope. If feeds to Google were one of the reasons to upgrade, that reason goes away, and the upgrade can be planned on its own schedule.
What it doesn’t remove
- The S/4HANA upgrade. That is driven by the end of ECC support (standard maintenance ends at the end of 2027, paid extended maintenance runs to 2030), and by finance, tax and security patches. A product feed changes none of that. What it does is decouple the two: when ECC is replaced, only the feed’s source changes. The Merchant API shape, the offer IDs and Google’s product history stay the same.
- Consent data. ECC has no consent model. It has flags such as
ZZ_MKT_OPTINand tables such as/ACME/CONSENT, with no time, purpose, source, evidence or withdrawal. Consent gaps lists each missing piece. S/4HANA doesn’t add one either: SAP’s answer is a separately licensed product. Here the CRM Sync gap fill and the Xano consent log fill that gap.
Why a direct path needs the consent layer more
A product feed needs no consent: it is catalog data, with no personal data in it. Once the same pipe carries customer data (KNA1 and ADR6 for Customer Match, enhanced conversions, remarketing), a direct ECC → Google link would skip consent entirely. So the two flows are kept apart:
Products: ECC export ─▶ converter (src/merchant.rs) ─▶ Xano merchant_product ─▶ Merchant API productInputs
People: ECC export ─▶ Xano user table ─▶ release gate ─▶ Google (Customer Match, enhanced conversions)
Nothing about a person reaches Google without passing the release gate. ECC’s opt-in flags are inputs to the gate’s evidence, never the decision.
What a direct path still has to handle
| Issue | Why | Where it is handled |
|---|---|---|
| Freshness | ECC exports in batches. If the price or stock in the feed doesn’t match the product page, Google disapproves the offer. | A refresh window per attribute; versionNumber on each insert so an older batch can’t overwrite a newer one. |
| A page to buy on | Merchant Center needs a product page that can check out, or an agentic checkout. ECC has neither. | The storefront, not the ERP. |
| Prior price | A sale price in the EU must show the lowest price of the previous 30 days (Omnibus), per market. | Price history per market, kept outside ECC’s condition records. |
When markets multiply: the domain is not the key
A direct path works for one market. The second market is where it breaks, and almost never because of ECC.
It breaks when something downstream uses the storefront domain, a URL or a product handle as an identity key.
A domain is a routing and presentation attribute. Identity lives in keys that don’t change when a market
launches: the *.myshopify.com shop handle, the Shopify GID, MATNR and the GTIN.
The TLD, URL and channel side of this (ccTLD vs subfolder, hreflang, Merchant feed labels, Meta and Amazon) is covered in the TLD & Namespace Strategy book. This section covers what that book doesn’t: the ECC-to-Shopify gaps, and the revenue and WMS risk they carry.
One registry row per market
The market is looked up from a registry, never inferred from the host. Every URL is computed from the row plus an immutable key; no system stores a URL as a key.
{
"market": "GB",
"host": "brand.com", "pathPrefix": "/en-gb",
"contentLanguage": "en", "feedLabel": "GB", "currency": "GBP",
"shop": "brand-us.myshopify.com",
"sap": { "vkorg": "2000", "vtweg": "10", "spart": "00" },
"consentJurisdiction": "UK-GDPR",
"live": false
}
live is the launch gate. It flips only when the checks in the risk register below pass.
ECC ↔ Shopify gaps
A gap is a place where ECC and Shopify name the same thing differently, at a different grain, or not at all.
| Gap | ECC | Shopify | What breaks when a market is added | Fix |
|---|---|---|---|---|
| G1 Market ≠ sales area | Sales area: VKORG + VTWEG + SPART | Market | Middleware infers the sales area from the domain and posts a new market’s orders to the wrong sales org | Registry maps market → sales area explicitly |
| G2 Grain | MATNR (CHAR 18 in ECC) = one variant | Product groups variants | A second store or a translation plugin forks the grouping, and itemGroupId splits | Key on MATNR ↔ variant GID ↔ SKU; the PIM owns the grouping key |
| G3 One GTIN vs many | MARM-EAN11 per unit (each, case, pallet) | One barcode per variant | A case GTIN reaches Google, or an each GTIN reaches the WMS | Each consumer reads its own unit (below) |
| G4 Price authority | A004/KONP per sales area, usually net | Market price list, often tax-inclusive | A market goes live before its conditions exist and falls back to a default or FX price | live stays false until condition records exist |
| G5 Location grain | Plant + storage location (T001W, MARD), WM warehouse | Location GID | Inventory pushes keyed by location name break when a node is added | Versioned WERKS/LGORT ↔ location GID table |
| G6 Order identity | VBAK-VBELN; customer PO in VBAK-BSTKD | Order GID; name #1001 repeats across stores | BSTKD deduped on the order name collides across stores; webhook retries duplicate orders | BSTKD = {shop}:{order GID}, deduped with the webhook ID |
| G7 Customer and consent | KNA1, one-time (CPD) accounts; no consent model | Customer GID, marketing consent | A new origin starts with empty consent and ECC never sees it | Consent keyed on customer GID + jurisdiction, in the release gate, never ECC |
| G8 Localized text | MAKT per SPRAS | Translations and localized handles | Any join on handle breaks per language | Handles are output only; joins use GID or MATNR |
| G9 URL construction | None: ECC has no URL | Primary + market domains | The feed’s link is built in middleware with brand.com hardcoded | One url(market, gid) builder for every feed and the edge Worker |
ECC has no concept of a URL. Every URL in an ECC-sourced feed was built by middleware, which is exactly where a hardcoded host ends up.
G3 in this repo
merchant::convert already reads the base unit’s MARM row (MEINH == MARA-MEINS) and validates
it with merchant::gtin, so the Merchant feed gets the each-unit GTIN. A WMS or EDI feed must read the case row
instead. Keying the GTINs by unit makes that choice explicit:
#![allow(unused)]
fn main() {
use std::collections::BTreeMap;
/// MARM-MEINH values the integration reads.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Uom { Ea, Cs, Pl }
pub struct Gtins(BTreeMap<Uom, String>);
impl Gtins {
/// Google and the storefront: the unit a shopper buys.
pub fn consumer(&self) -> Option<&str> { self.0.get(&Uom::Ea).map(String::as_str) }
/// The WMS and EDI: the unit that is picked and shipped.
pub fn case(&self) -> Option<&str> { self.0.get(&Uom::Cs).map(String::as_str) }
}
}
Every value goes through merchant::gtin before it enters the map, so a bad check digit, an in-store number
(NUMTP IE) or a restricted prefix never reaches either consumer.
Worked example: launching the UK
The fragile way: a translation plugin publishes uk.brand.com. The feed builds brand.com/products/ + handle, and
UK handles 404 (G8, G9). A UK order maps to VKORG 1000 because no 2000 mapping exists (G1, G4). The WMS gets the
case GTIN where it expects the each GTIN (G3). Consent captured on the new origin never reaches the customer record
(G7).
The safe way: add a GB row (VKORG 2000, GBP, /en-gb subfolder through Shopify Markets, live: false). Put the
plugin in subdirectory mode. Gate live on A004/KONP for VKORG 2000. None of the failures above can happen,
because none of them read the host.
Market prices and FX: one price, read everywhere
A market price can come from three places, and a fixed price wins over everything else. Google then checks that price against the landing page from anywhere in the world. So every market advertised with a local-currency feed needs a deterministic price.
How Shopify derives a market price
| Layer | What it does | Note |
|---|---|---|
| Automatic conversion | A dynamic rate Shopify updates to real-time rates, or a manual fixed rate | At checkout, automatic conversion uses Shopify’s rates, plus its conversion fee where that applies |
| Adjustment and rounding | A price list adds a percentage on top of FX, then rounds | Shopify’s example: $20 × 1.3 FX × 1.2 (+20%) = $31.20, rounded to $31.99 by a 0.99 rule. Rounding uses Shopify’s per-currency defaults and can’t be customized |
| Fixed price | A price-list price already in the target currency | Applies regardless of FX and rounding |
What Google requires
| Option | How it works | Trade-off |
|---|---|---|
| Local-currency feed | Submit GBP prices for the UK | The feed currency must match the landing page, for every viewer, wherever Google crawls from |
| Google’s currency conversion | One base-currency feed with extra countries; Google shows its converted price next to yours | Feed, page and checkout must still agree in your currency. Google uses Google Finance rates, and this usually earns fewer eligible impressions than a dedicated feed |
If the numbers drift, Merchant Center may update the product’s price to what it finds on the landing page, or disapprove the item.
Where FX breaks the match
- Dynamic rates drift daily. A feed generated at yesterday’s rate disagrees with today’s page. A market on dynamic FX needs its feed resynced at least as often as the rate changes.
- IP-based currency switching. The most common failure. Google checks the page from any location, while Shopify
Markets switches the page currency by visitor IP, so a local-currency feed is rejected. The fix is a market URL
(
/en-gb) in the feedlink, so the URL sets the currency, not geolocation. This is G9 again. - Tax display. Location-based VAT settings in EU and UK stores show the crawler a net or gross price depending on where it seems to come from.
- Structured data and shipping. JSON-LD
offers.pricemust match the feed and page for every product ID, and shipping rates must use the feed’s currency for each country.
The ECC angle: three rate sources
| Rate source | Drives |
|---|---|
| ECC exchange rates (TCURR) | Invoicing and financial postings |
| Shopify market FX | Storefront and checkout |
| Google Finance | Google’s converted ad price |
Each gives a slightly different number, so G4 covers rate authority as well as price authority. (TCURR holds the
rates; TCURX, which merchant::to_money already reads, holds only the currency’s decimals.)
Recommended pattern
- Fixed price lists for every market advertised with a local-currency feed. Source them from A004/KONP for the market’s sales area, or from a nightly job using one agreed rate source plus your own rounding. Feed, page, JSON-LD and the ECC invoice then agree.
- Dynamic FX only for markets you don’t advertise locally. Let Google’s conversion handle those ads off the base-currency feed.
- Build the feed from Shopify’s contextual pricing. The Admin API returns the price of a variant in a given
market context. Write that exact value to the Merchant API (
price.amountMicros+currencyCode) instead of recomputing FX in middleware. - Register FX in the market registry. The feed builder and the edge Worker read these fields, so a market can’t be advertised in local currency unless its prices are fixed.
{
"market": "GB",
"fxMode": "fixed",
"rateSource": "KONP",
"taxDisplay": "inclusive",
"localCurrencyFeed": true
}
Revenue and WMS risk register
Thirteen risks, sorted fastest first; IDs stay stable as rows are added. Five bite on the first order. Assign each an owner before a registry row goes live.
| ID | Risk | Gap | Channel hit | Speed | Detection signal | Pre-launch check |
|---|---|---|---|---|---|---|
| R1 | Orders post to the wrong sales org | G1 | Order capture | Immediate | Order errors by VKORG | Registry row has VKORG, VTWEG, SPART |
| R2 | Price falls back to a default or FX value | G4 | Margin, Shopping disapprovals | Immediate | Price-mismatch alerts; price disapprovals | A004/KONP exist for the sales area |
| R3 | Duplicate sales orders from name collisions or webhook retries | G6 | Overshipment, refunds | Immediate | Duplicate BSTKD count | BSTKD = {shop}:{order GID} + webhook ID |
| R4 | Middleware calls the Shopify Admin API from an IP outside a public app’s allowlist and gets 403 | Host | Order reads, inventory pushes, conversions | Immediate, from 2026-11-20 | 403 rate per integration | Dev Dashboard traffic test passes for every caller |
| R5 | A webhook, OAuth, CORS or AS2 endpoint still points at the old host | G9 | Orders, EDI | Immediate | Webhook failure rate; AS2 MDN failures | No hardcoded host strings left |
| R6 | Feed link doesn’t match the claimed site, or 404s | G9 | Shopping ads, free listings | Hours to days | Disapprovals by feed label; 404 rate | Crawl every feed link: 200 on the claimed site |
| R13 | Feed price drifts from the page: dynamic FX, IP-based currency or location-based VAT | G4, G9 | Shopping ads, free listings | Hours to days | Merchant Center price updates and price-mismatch disapprovals | fxMode: fixed for every locally advertised market; feed link carries the market path |
| R7 | Case GTIN where the each GTIN is expected, or the reverse | G3 | Fulfillment, refunds, Shopping | Days | WMS unmatched-GTIN count; EDI 997 rejects | Every item has valid EA and CS GTINs |
| R8 | A Shopify location isn’t mapped to WERKS/LGORT | G5 | Oversell, stockouts | Days | Inventory sync errors per location | Every location GID maps in the registry |
| R9 | Joins on a localized handle break per language | G2, G8 | WMS SKU match, itemGroupId | Days | Unmatched-SKU count; item-group splits | No join keyed on a handle or URL |
| R10 | Consent starts empty on the new origin, or never reaches the gate | G7 | Compliance, email revenue | Weeks, high severity | Consent coverage per market | Consent keyed on customer GID + jurisdiction |
| R11 | Cookie and attribution reset on a new registrable domain | Host | Paid media (CPA, ROAS) | Indirect, weeks | GA4 self-referrals; consent rate per host | Subfolders, or cross-domain linking set up |
| R12 | Re-indexing, hreflang conflicts, redirect chains | G9 | Organic search, AEO | Gradual, weeks | Indexed pages; rank on top revenue URLs | Crawl confirms one-hop 301s |
Sizing it
revenue at risk = baseline revenue per day × P(failure) × impairment while failing × days to detect and fix
Detection time is the term monitoring changes most: it moves from days to hours. So compare the expected loss with and without the detection signals above. For R1–R3 and R7–R8, add refunds, chargebacks, reships and trading-partner EDI chargebacks, which the formula misses.
In one line
ECC → Merchant through Xano gets products onto Google now, keeps them there through the S/4HANA migration, and keeps consent in a system built for it. It doesn’t avoid the upgrade; it makes it smaller, safer and no longer a commerce deadline.
SAP to Google over EDI: IDocs in, Merchant API out
Google has no EDI endpoint. Merchant Center takes no X12 or EDIFACT, and no IDoc. It takes Merchant API calls (JSON) or feed files. So “SAP to Google EDI” means this: ECC sends IDocs, its own EDI format, to a translator, and the translator writes to the Merchant API. What matters is where the translator sits, which IDocs it accepts, and what it must refuse.
Which IDocs carry what
| IDoc message type | Carries | ECC tables | Goes to Google? |
|---|---|---|---|
MATMAS | Material master: identity, text, units, weights, plants, storage locations | MARA, MAKT, MARM | Yes: becomes the product input |
COND_A | Condition records: list price, sale price, validity dates | A004, KONP | Yes: price, salePrice, salePriceEffectiveDate |
| Stock (no single standard type) | Unrestricted stock by plant and storage location | MARD | Yes: availability. MATMAS carries the storage-location records but not stock quantities; use the IDoc your release already sends for stock (in SAP Retail, LOISTD), or a scheduled RFC read |
DEBMAS | Customer master: name, address, e-mail, opt-in flags | KNA1, ADR6, KNVV | Never directly. Personal data goes through the release gate or nowhere |
ORDERS, ORDRSP, DELVRY (DESADV), INVOIC | Orders, confirmations, deliveries, invoices | VBAK, VBAP | No. Google sends no orders to an ERP. Orders from Google’s agentic checkout land at the storefront first (see below) |
Shops that already send X12 832 (price/sales catalogue) or 846 (inventory) to retail partners have the same data
leaving ECC. A translator can produce both an 832 for a retailer and a Merchant API insert for Google from one
MATMAS + COND_A pair. Only the output differs.
IDoc segments to Merchant API attributes
The translator parses IDoc-XML into the same sap:: structs that the SE16 and RFC paths use, then runs the same
converter (src/merchant.rs). Field rules for each attribute are on the Google Merchant Center page;
this table only says which segment carries the field.
| Segment | Fields used | Table | Merchant API v1 |
|---|---|---|---|
MATMAS E1MARAM | MATNR, EAN11, NUMTP, MFRPN, NTGEW, BRGEW, GEWEI, PRDHA, SATNR | MARA | offerId, gtins[], mpn, weights, productTypes[], itemGroupId |
MATMAS E1MAKTM | SPRAS, MAKTX | MAKT | title (one product input per contentLanguage) |
MATMAS E1MARMM | MEINH, EAN11, LAENG, BREIT, HOEHE, MEABM | MARM | base-unit GTIN, shippingLength / Width / Height |
COND_A E1KOMG | KSCHL, VKORG, VTWEG, MATNR | A004 key | which offer and market the price applies to |
COND_A E1KONH | DATAB, DATBI | A004 validity | salePriceEffectiveDate |
COND_A E1KONP | KBETR, KPEIN, KONWA, LOEVM_KO | KONP | price / salePrice, after the TCURX decimal shift |
EDIDC (control record) | DOCNUM, MESTYP, CREDAT, CRETIM | — | idempotency key and, if nothing better is available, versionNumber |
Two rules from the Merchant page matter more on this path:
- Leading zeros.
MATNRarrives in the IDoc with internal leading zeros (000000000000012345). The converter’sdisplay_matnrstrips them for numeric numbers. A translator that skips that step creates a second offer for the same material. - Decimals.
KBETRinE1KONPis stored with two decimals whatever the currency, as in KONP. KRW and JPY still need the TCURX shift.
The path
ECC
BD52/BD61: change pointers on for MATMAS and COND_A
BD21: change pointers → IDocs (scheduled)
WE20 partner profile → WE21 port, type XML HTTP
│ IDoc-XML over HTTPS, out through Cloudflare Tunnel (no inbound port on ECC's network)
▼
Cloudflare Worker: the translator
verify the caller (mTLS) · parse IDoc-XML into sap:: structs · reject any MESTYP not on the list
│
▼
Rust converter (src/merchant.rs) ─▶ Xano merchant_product (one row per offer, keyed by offerId + feedLabel)
│
▼
Merchant API productInputs:insert?dataSource=… with versionNumber
Nothing in this path writes to ECC. The Worker returns HTTP 200 only after the Xano row is written, so a failure
leaves the IDoc in an error status in ECC (WE02 / BD87) where the SAP team already looks. Status 03 in ECC only
means “handed to the port”. It says nothing about Google, so reconcile against merchant_product as well.
Mixed-up flows are refused at the parser. The Worker accepts MATMAS, COND_A and the chosen stock type. A
DEBMAS sent to the same port by a mistaken partner profile is rejected with a 4xx and logged, not stored. Personal
data reaches Google only through the release gate (ECC direct to Google).
Order, replays and versionNumber
IDocs aren’t guaranteed to arrive in order. BD87 reprocessing, a parallel BD21 run or a resend after an outage can deliver an older price after a newer one. Two protections:
- Idempotency on
DOCNUM. The same IDoc number twice is a no-op in Xano. versionNumberon every insert. Google refuses an insert whose number is lower than the stored one. Use the change document time (CDHDRUDATE+UTIME) when the extract carries it, as on the Merchant page. An IDoc usually doesn’t, so the fallback is the control record’sCREDAT+CRETIM(when ECC created the IDoc), never the Worker’s receive time: a replay is received late but was created early.
A product’s price and its master data arrive in different IDocs (COND_A and MATMAS) at different times. The
translator merges into the Xano row and sends the whole product input; it never sends a half-built product with one
IDoc’s fields.
The file-feed alternative
Older EDI setups often go IDoc → middleware → flat file → SFTP or a scheduled fetch by Merchant Center. That still works, but:
| Merchant API insert | Scheduled file | |
|---|---|---|
| Freshness | Per product, as each IDoc lands | Per file: nothing changes until the next fetch |
| Older data overwriting newer | Refused by versionNumber | A stale file replaces the data source’s contents |
| Errors | Per call, tied to the IDoc that caused them | Per fetch, read from Merchant Center diagnostics |
| Credentials | OAuth service account; short-lived token | SFTP password or a public fetch URL |
The file feed is a fair first step if the middleware already writes one. The API path is the target.
Orders coming back
Google doesn’t send orders to an ERP. When a buyer checks out on Google (for example through UCP agentic checkout),
the order is placed at the storefront, and the storefront’s order is what reaches ECC, usually as an ORDERS IDoc
inbound. That inbound document is the one SAP counts under Digital Access. Settle it before it ships
(Licensing penalties by flow). The product path above is
read-only and outbound and creates no documents in ECC.
What the EDI path still has to handle
| Issue | Why | Where it is handled |
|---|---|---|
| Stock freshness | Stock changes far more often than master data; change pointers on stock flood the queue | A separate, more frequent stock run, or an RFC read on a timer, writing only availability |
| Deletions | A material flagged for deletion (LVORM) or a deleted condition (LOEVM_KO) must take the offer down, not leave it | The converter treats them as out-of-stock or deletes the product input; never ignore the flag |
| Several sales organisations | One MATMAS, several COND_A records for different VKORGs | One product input per feedLabel, priced from that market’s condition |
| Prior price (EU) | Omnibus needs the lowest price of the last 30 days per market | Price history in Xano, built from each COND_A received |
| Partner profile drift | Someone adds a message type to the partner profile in WE20 | The Worker’s allow-list on MESTYP, not the partner profile, decides what is accepted |
In one line
ECC keeps speaking IDoc; a Worker translates MATMAS and COND_A into Merchant API calls through the same Rust
converter, refuses everything else, and nothing about a person or an order goes to Google from ECC’s side.
An alternative to a full S/4HANA upgrade
A full S/4HANA programme usually carries more than the ERP. Commerce feeds, the customer 360, consent and audiences move with it, often onto SAP’s add-ons or onto Salesforce. This page describes the other route: move the data that faces customers and Google out of ECC into Xano and Cloudflare now, and leave finance and logistics for the ERP migration.
It is an alternative to the scope of the upgrade, not to the upgrade itself. ECC support still ends, and FI/CO, MM, SD pricing and tax still need a supported ERP.
What moves
| Data | From ECC | Into Xano | At the Cloudflare edge | Role it replaces |
|---|---|---|---|---|
| Products | MARA, MAKT, MARM, MARD, A004 / KONP | merchant_product, in the Merchant API shape | Merchant feed sender (planned) | Commerce catalog and feeds |
| Customers | KNA1, ADR6, ADRC, KNVV | The user table and identity_link | CRM Sync links visitor, Shopify customer and KUNNR | Customer 360 for marketing |
| Consent | ZZ_MKT_OPTIN, /ACME/CONSENT, as evidence only | The consent log and the release gate | CRM Sync: banner, region, GPC, signer | Consent and preference management |
| Orders and ads | VBAK / VBAP, with the Shopify order ID in BSTNK | The session-to-order join (planned) | Conversion endpoint, behind the release gate | Audiences and attribution |
| Privacy requests | CDHDR / CDPOS change history | dsr_request, dsr_receipt | CRM Sync fans each request out | Privacy request tooling |
Orders themselves don’t move: the order stays in ECC, and only its reference rides to Google. ECC direct to Google explains why the product and people flows are kept apart.
Connections: Consent Mode v2, Shopify with the session ID, Google and BigQuery
One session ID ties the browser’s consent to the Shopify order and the ECC order. Nothing about a person reaches Google before the release gate.
| Step | Where | What |
|---|---|---|
| 1 | Browser | Consent Mode v2 sets its default per region before any tag loads (denied where opt-in applies), then updates on the shopper’s choice: ad_storage, analytics_storage, ad_user_data, ad_personalization. |
| 2 | Cloudflare: CRM Sync worker | Issues the session_id and writes the consent row to Xano. Keeps the ad click (gclid, gbraid, wbraid) in visit_click only if ad_storage is granted. |
| 3 | Shopify | Cart attributes _crm_session and _crm_click (a key, never the raw click ID) become the order’s customAttributes. The storefront reads the Customer Privacy API. |
| 4 | ECC | Middleware writes the Shopify order ID to VBAK-BSTNK. ECC never holds the session, the click or the e-mail. SAP confirms the sale, return or cancellation. |
| 5 | Xano: release gate | On SAP’s confirmation, order → session → click, then the gate reads the person’s consent: latest decision wins, a tie revokes, no decision means denied. |
| Destination | Through the gate? | What goes |
|---|---|---|
| Google Ads | Yes | Offline conversions against the click; Customer Match with ad_user_data and ad_personalization per person; returns as adjustments. |
| Google Merchant Center | No: no personal data | Products from merchant_product. versionNumber keeps an older batch from overwriting a newer one. |
BigQuery, dataset crm_us | Streamed by CRM Sync | consent_log with changed rows only (a consent history, not a poll trace) and channel_revenue for Shopify orders. Per-market datasets are added as markets are. |
Steps 2 to 5 for the ad click are the session-to-order join in Plan: Xano buildout, which is planned, not live.
Benefits
- Google and Shopify now, not after the migration. Products reach Merchant Center from the ECC data that exists today. Nothing waits for a go-live date.
- A smaller S/4HANA project. Catalog content, consent, identity and audiences are out of scope. The migration is the finance and logistics core, which is the part SAP’s support dates actually force.
- The commerce side doesn’t notice the migration. Offer IDs, Google’s product history, the consent log and the identity links all live outside the ERP. When ECC is replaced, only the source of the mapping changes. Most of the tables used here keep their names in S/4HANA (MARA, MAKT, KNA1, VBAK, VBAP, KONP), and those that don’t, such as MARD, are read through compatibility views. This book is generated from the DD03L export, so an S/4HANA export regenerates it.
- Fewer add-on licences for these roles. The roles in the diagram don’t need a separate consent product, a separate customer data platform or a second CRM. What each would cost is outside this book.
- One consent decision. Every payload to Google passes one release gate, reading one append-only, hash-chained log. Two systems can’t disagree about the same person, and the log is the evidence when a regulator asks.
- The facts stay fixed. Identifiers, amounts, units, dates and stock are converted by fixed, tested rules
(
src/merchant.rs,tests/). Nothing generated rewrites them, in ECC or after it.
The alternatives
| Route | What it means | When Google and consent work | What to weigh |
|---|---|---|---|
| Full S/4HANA with SAP’s add-ons | ERP, commerce, customer data and consent move together, onto S/4HANA and SAP’s commerce and consent products | At go-live | The largest scope, one go-live date for everything, and add-on licences |
| S/4HANA plus Salesforce | ERP onto S/4HANA; customers, consent and audiences onto Salesforce | At go-live, plus the CRM integration | Two vendors’ data models for the same person, and an integration between them |
| ECC plus Xano and Cloudflare now, S/4HANA core later | The route on this page | Now | A layer to run alongside ECC; the ERP migration still has to happen |
| Stay on ECC longer | Paid extended maintenance (to 2030) or third-party support | Only if a layer like this one is added | Support cost and a fixed horizon; the layer works the same either way |
The third and fourth routes combine: the layer doesn’t depend on when, or whether, the ERP moves.
Substitutes at the edge
Without an S/4HANA upgrade, and without buying a server-based application, ECC can stay as it is while the front ends change. Cloudflare Workers run the Rust gate compiled to WebAssembly in front of ECC. Each modern front end is a substitute that plugs into that one gate, so it can be swapped without touching ECC or the rules.
Front ends (substitutes, swappable)
Fiori-style UI5 app · AEM page or edge function · Xano + CRM plugin · a form
│
▼
Cloudflare: Workers + the Rust gate (WebAssembly)
verify · parse into typed records · decide (consent, purpose, region) · receipt
│
┌──────────────┼───────────────────┐
▼ ▼ ▼
ECC (unchanged) Xano (system of Shopify · Google · BigQuery
via a tunnel → record: consent, (destinations, after the gate)
OData / RFC / ledger, crosswalk)
IDoc, read-mostly
| Substitute | Replaces | How it connects | Catch |
|---|---|---|---|
| Fiori-style UI5 app at the edge | New S/4HANA Fiori apps | Static UI5 served by a Worker, calling ECC’s OData services (SAP Gateway) through the gate | ECC has fewer, older OData services than S/4HANA; some screens need a custom service or a read model in Xano |
| AEM page or AEM edge function | A commerce or content front end tied to the ERP upgrade | AEM renders; the gate decides what data and which tags reach it | Adobe’s edge features differ by AEM product and licence: check what is licensed |
| Xano connected to BAU systems or a CRM plugin | New S/4HANA objects, a CDP or a new CRM | Xano holds consent, the ledger and the crosswalk; plugins read through the gate | Xano becomes core infrastructure: it needs an owner, backups and a region per regime |
| A form | A custom ABAP transaction or a portal | A Worker validates it, the gate decides, Xano records it; ECC receives a document only if it truly needs one | Every document written to ECC counts under Digital Access |
Why it holds without an upgrade
- ECC stays the source of identity and blocking. Its core doesn’t change, and consent never lives in it (Consent gaps).
- The rules travel as one crate. Rust compiled to WebAssembly runs in the Worker, browser islands, Shopify Functions and batch jobs, with one owner per decision (Parsing at the gate).
- ECC is reached without opening it. A tunnel from the ECC network out to Cloudflare (for example Cloudflare Tunnel) means no inbound ports; the gate is the only route in.
- Substitutes are swappable. Fiori, AEM, a Xano screen and a form all call the same gate. Changing the front end changes nothing in ECC or in the rules.
Conditions to state plainly
- Read-mostly. Reading ECC carries little exposure under Digital Access; orders, returns or form submissions written back into ECC are counted. Settle the licence model first (Licensing penalties by flow).
- ECC’s support clock still runs. This buys time and moves value out of ECC; it does not extend ECC’s maintenance (see below).
- SAP doesn’t support the edge layer. The gate, the Worker and Xano are yours to run: each needs an owner, an availability target and a defined failure mode (Function gating).
- ECC’s interfaces set the limit. Data with no OData service, RFC module or IDoc needs one built in ECC: ABAP work.
- Each platform’s own rules still apply. Shopify’s IP allowlist and expiring tokens, and the exempt, permanent custom-app tokens on ERP links (Shopify’s deadlines).
The rule: ECC stays where it is, mostly read; Cloudflare and the Rust gate sit in front; consent and decisions live in Xano; front ends are substitutes that all call the same gate; and every write back to ECC is a licence question settled before it ships.
What this doesn’t replace
- The ERP. FI/CO, MM postings and inventory, SD pricing conditions, tax and logistics stay in ECC until they move to S/4HANA or another ERP.
- The support deadline. Standard maintenance for ECC ends at the end of 2027; paid extended maintenance runs to 2030.
- The consent check for people. Customer data reaches Google only through the release gate. ECC’s opt-in flags are evidence for it, never the decision.
- Work still to be built. The Merchant feed sender and the session-to-order join are planned, not live. See Plan: Xano buildout.
Function gating across clouds
Once data moves from SAP on AWS or Azure to Shopify, Cloudflare and Google Cloud, ERP is no longer the hub. In a single-ERP estate SAP’s batch schedule was the control; spread across clouds, the only shared point is the release gate. Every flow (the Merchant feed, a BigQuery segment, an audience, an agent call) now depends on it being up, current, and the same everywhere. No cloud provider supplies that gate: each has its own functions, identity, logs and residency controls, and the decision falls between them.
AWS / Azure Cloudflare Google Cloud / Shopify
SAP ECC or S/4 (RISE) ──▶ Workers (edge, consent) ──▶ BigQuery, Merchant, Ads
IDoc / RFC / CSV Xano release gate Shopify Admin API, Shopify Functions
└─────────────── every hop asks the gate ───────────────┘
The dependency gaps
| Gap | What goes wrong | What closes it |
|---|---|---|
| Availability | The gate is a single point of failure for every export | A failure mode per purpose: fail closed for ads and audiences; order fulfilment (the contract) is never gated |
| Freshness at the edge | Consent cached at the edge outlives a withdrawal. Cloudflare KV is eventually consistent: a write can take about 60 seconds to reach every location | Revocations read from a strongly consistent store (a Durable Object, or Xano live); cache only grants, with a short expiry |
| Identity across clouds | AWS IAM, Microsoft Entra, Google Cloud IAM and Shopify app tokens don’t trust each other, so secrets get copied into each | Workload identity federation and short-lived tokens; no long-lived keys stored per cloud |
| The rule forks | The same rule is rewritten for Lambda, Azure Functions, Workers, Cloud Functions and Shopify Functions, and the copies drift | Compile the rule once. Rust to WebAssembly runs in a Worker and in a Shopify Function, and as a native or Python module elsewhere (see Why 11ty, and when Astro) |
| Residency in transit | Both ends are in the EU, but a hop is processed in a US region or at a global edge | A route pinned per regime, checked per hop, not only per endpoint; regional processing settings at the edge |
| Retries and duplicates | A retry between clouds creates a second order, feed item or audience member | An idempotency key made at the source and carried to every destination |
| Audit across clouds | Each cloud’s logs show only its own hop; no one can reconstruct a decision | One correlation ID per decision, a receipt in the Xano ledger for every export, UTC timestamps throughout |
| Rule versions | A rule changes during a batch, and part of it is exported under the old one | Every gate rule versioned; the version written on each receipt |
| Egress | Every hop between clouds is a data-transfer charge, worse with full extracts | Deltas, not full tables; one region per regime |
| Ownership | Each cloud team owns its hop; no one owns the decision | One owner for the gate and its rules; every platform calls it rather than reimplementing it |
What this means for a programme
- The licence position stays manageable. Porting SAP data out to Shopify, Cloudflare and Google Cloud is mostly reads, which carry little exposure under Digital Access. The gate doesn’t change that; any write back (orders, returns) still counts. See Licensing penalties by flow.
- The gate is core infrastructure, not a feature. It needs an availability target, a defined failure mode, a release process and an owner, as the ERP had. Most programmes design the data movement and leave the gate for later; that is where they fail.
- Consent stays where the gaps put it. The gate reads the append-only ledger described in Consent gaps; no cloud on the route holds its own copy of the decision.
The rule: moving SAP data across clouds removes ERP as the hub and makes the release gate the dependency every flow shares. Build it once, run it everywhere (Rust to WebAssembly), read consent from a store that is always current, keep each hop in its regime, and leave one receipt per decision.
Shopify’s 2026–27 token and allowlist deadlines
Shopify is tightening how public apps hold Admin API tokens, which puts two of the gaps above (identity and freshness) on a deadline. Both rules apply to public apps only; custom apps and apps a merchant creates in their own admin are exempt.
| Rule | What it does | Deadline (11:59 PM ET) | Without it |
|---|---|---|---|
| IP allowlist | Limits the networks an app’s Admin API tokens can be used from; other sources get 403 | Nov 12, 2026 for apps using bulk operations (bulkOperationRunQuery, bulkOperationRunMutation); Nov 20, 2026 for all other public apps | Bulk queries and mutations blocked (Nov 12); delisted from the App Store, no new installs, and flagged in the merchant’s Settings > Apps (Nov 20); merchants see a warning in the admin (Jan 15, 2027); Admin API requests fail (Apr 1, 2027). Existing installs keep working until Apr 1, 2027 |
| Expiring offline tokens | Background (“offline”) access tokens last 1 hour and renew through a refresh token: 90 days when issued, replaced with a new one on every refresh | Jan 1, 2027 (the migration deadline; the later dates are notice for merchants, not extra time) | Delisted and blocked from new installs, and flagged in the merchant’s Settings > Apps; existing installs keep working (Jan 1); merchants see a warning in the admin (Jan 15); Admin API requests with a non-expiring token return 403 (Apr 1, 2027) |
New public apps have had to use expiring offline tokens since April 1, 2026; the Jan 1, 2027 date is for apps listed before that.
Sources: IP allowlists are now required for public apps, Restrict API access with an IP allowlist, Use expiring offline access tokens.
Allowlisting an app that runs on Cloudflare
Workers and Pages have no fixed outbound address, and Shopify’s network lookup (GeoLite) finds no ASN for Workers
egress, so allowing Cloudflare’s ASN (13335) blocked every request in the Dev Dashboard’s test, even though Shopify’s
guidance for serverless hosts is to allow the provider’s ASNs (requests with no ASN data are rejected). What works is Cloudflare’s published ranges
(IPv4, IPv6), split to fit Shopify’s limits
(IPv4 /16 or narrower, IPv6 /32 or narrower, up to 250 entries): 47 entries. Run the Dev Dashboard’s test against
the last 30 days of traffic before turning enforcement on.
The limit of this: Cloudflare’s network is shared, so a leaked token still works from anyone’s Worker. It meets the rule; it is not isolation. Anything that calls Shopify from outside Cloudflare with the same token (Xano, a script, a webhook processor elsewhere) is blocked, so route those calls through the gate.
Not to be confused with network_access. The [network_access] section of shopify.app.toml, added in the same
October 2026 security update, is a different control: it declares the outside hosts an app’s code loads from or sends
requests to on store pages (allowed_sources, HTTPS origins) and the hosts shoppers can follow links to without an
exit notice (allowed_navigation_hosts, up to 20). It applies once deployed with shopify app deploy. It does not
restrict where Admin API tokens can be used; the IP allowlist is set only in the Dev Dashboard.
What the allowlist reaches in a Cloudflare and Xano stack
The allowlist applies to one direction only: calls into Shopify’s Admin API with a public app’s token. Calls from Shopify (webhooks), calls to Xano, Google or Webflow, and sign-in through Shopify’s Customer Account API are outside it. Checked on a live stack after enforcement was turned on:
| Part | Its path to Shopify | Affected? |
|---|---|---|
| PIM Sync (catalog, prices, translations to Webflow) | Workers → Admin GraphQL, one request at a time. Reads page through products(first:, after:) with a cursor, plus single lookups (product, markets, locales, metafield definitions). Writes are ordinary mutations, one product or collection per call: productUpdate, metafieldsSet, translationsRegister, priceListFixedPricesAdd, productCreateMedia, publish and unpublish. It never calls bulkOperationRunQuery or bulkOperationRunMutation | No. Its Workers egress from Cloudflare, the token refresh that runs every 15 minutes kept succeeding, and the Nov 12 rule blocks only those two bulk mutations, which it doesn’t call |
| Webhooks into Xano | Shopify → Worker → Xano | No. Inbound to the app, not a call into the Admin API |
| The Configurator (one console in the Webflow Designer, a desktop app or a browser) | Browser → Worker → Shopify | No. The page never calls Shopify itself; the Worker does |
| BYO Cloudflare (a merchant’s own Cloudflare account) | Their Worker → Admin API | No. Every Cloudflare account egresses from the same published ranges |
| BYO Xano (a merchant’s own Xano instance) | Xano → Admin API directly | Yes, with a public app’s token: 403. Route the call through a Worker, or allow the instance’s fixed outbound IP if its plan has one (a few entries at most, out of 250). Unaffected with the merchant’s own custom-app token, which is exempt |
| Login, Claims and Extras (see below) | Worker → Customer Account API, Google, Xano; one Admin API lookup from the Worker | No |
| Logs | (none) | Turn on Workers Logs ([observability] enabled = true in wrangler.toml) on every Worker that calls Shopify, so a 403 after enforcement can be searched rather than guessed at. Log shop domains and status codes, never tokens, secrets or a shopper’s email |
The rule for BYO setups: Admin API calls with the public app’s token leave from Cloudflare. The merchant’s own Xano stays the system of record behind the Worker.
Login, TLS and /auth/me: Claims and Extras
TLS login. TLS (Transport Layer Security) is the encryption behind https://. A TLS login means every step of
sign-in travels encrypted: the password or the OAuth code from the browser to Cloudflare’s edge, and the Worker’s own
calls on to Xano, Google and Shopify. TLS protects the connection, not the identity: it stops anyone on the network
reading or altering the login, but it doesn’t say who the person is. That is what the signed token does. Three
separate controls, at three layers:
| Layer | Control | Answers |
|---|---|---|
| Network | Shopify’s IP allowlist | Is this call coming from an allowed network? |
| Transport | TLS (HTTPS) | Can anyone read or change it on the way? |
| Identity | A signed session token (JWT), checked on every request | Who is this, and are they still allowed? |
The login flow. A person signs in with email and password, Google, or Shopify’s Customer Account API (OpenID Connect, which is not covered by the Admin API allowlist). The Worker checks the result, links the identity to one person in Xano, and returns a signed session token. Logging out puts the token on a revocation list, so a copy left in a browser stops working at once rather than at expiry.
Claims. The facts about who the person is and which accounts are theirs, kept in Xano: the user ID, the linked provider identities (a Google subject ID, a Shopify customer ID), language and verified email. A login attaches to an existing person by email only when the inbox is proven.
Extras. The extra, per-person data a signed-in page may show beyond the claims, such as preferences and member-only content, kept in a separate Xano table so the claims stay minimal.
/auth/me. The endpoint the app calls on every open to ask “who is signed in?” It:
- reads the token from the
Authorization: Bearerheader and verifies its signature and expiry (401if not); - checks the person still exists and isn’t deleted, before anything writes (
401or404otherwise); - reconciles the identities, linking a Google login and a Shopify customer to the same person; this is the one Admin API lookup in the flow, made by the Worker, so the allowlist passes it;
- returns
logged_in, theuser, theclaims, theextrasand theentitlement(what the person may do).
The entitlement it returns is a hint for the page, so it can hide controls the person can’t use. The Worker
re-checks permissions on every request; nothing in the token or in /auth/me is trusted on its own.
Salt, hashing and encryption: what TLS doesn’t cover
TLS protects data while it moves: browser to Cloudflare, Worker to Xano, Worker to Shopify and Google. It does nothing for data once it’s stored. Four other controls cover that, and each one does a different job:
| Control | Direction | Used for | In this stack |
|---|---|---|---|
| TLS | In transit | Every connection | HTTPS from the browser to the Worker, and from the Worker to Xano, Shopify and Google |
| Salted password hash | One way: can be checked, never read back | Passwords | The Worker hashes; Xano stores only the salt and the hash |
| Encryption | Two way: can be read back with the key | Data the system must use again: files, configuration, tokens | AES-GCM with 256-bit keys, under envelope encryption |
| Signed token | Checked, not hidden | Proving who a request is from | The session token (JWT), signed with HMAC-SHA-256 using a secret only the Worker holds |
| Encryption at rest | Storage | Disks and backups | The cloud provider’s (Xano’s hosting, R2, KV) |
What a salt is. A salt is a random value, different for every password, mixed in before hashing. Two people with the same password get different hashes, and a list of precomputed hashes for common passwords (a rainbow table) is useless, because each stored hash would need its own table. The salt is not secret; it is stored next to the hash. What it adds is that every password has to be attacked on its own.
How a password is stored here:
- The Worker generates a 16-byte random salt.
- It derives a 256-bit hash with PBKDF2-SHA-256 over 100,000 iterations. The iterations make each guess slow, so a stolen table of hashes is expensive to crack.
- Xano stores
salt:hash. The password itself never reaches Xano, a log or a backup. - At sign-in the Worker repeats the derivation with the stored salt and compares the result.
100,000 iterations is the maximum PBKDF2 allows in Cloudflare Workers, and below what OWASP currently recommends for PBKDF2-SHA-256 (600,000). Two ways to close the gap: a memory-hard hash (Argon2id, or bcrypt) compiled to WebAssembly in the Worker, or fewer passwords altogether, with sign-in through Google, Shopify or passkeys, where no password hash is stored at all.
Fail closed: the *sshole lesson. The OpenSSH bypass disclosed in November 2026
(sshhole.com) is a salt-and-hash bug. On musl-libc systems, crypt() returns * when it
fails, a password over 256 characters makes it fail, and an account whose stored password is * (meaning “no password
login”) then compares * with * and lets the login in. The rules that follow for any password check:
- A failure is never a value that can match. If hashing fails, the check returns no; it never compares an error output.
- A placeholder is never a hash. An empty field,
*or!means “no password”, and the check refuses before comparing. The check here returns no if the stored value doesn’t split into a salt and a hash. - Limit the input. Refuse passwords over a set length (for example 1,024 bytes) before hashing, rather than letting the hash function truncate or fail.
- Compare in constant time (
crypto.subtle.timingSafeEqualin Workers), so the time a comparison takes reveals nothing about how much of the hash matched.
Applying the rules: the password fix, test first
A review of this stack’s own sign-in against those four rules found two gaps. The stored-value check already failed
closed, but the hash was compared as a string with ===, which stops at the first character that differs, and nothing
limited the password’s length before the slow hash. The fix was written test first:
- The tests came first, and all 13 failed against the code as it was.
- One module (
password.ts) replaced the inline functions, so the rules live in one place that can be tested on its own; signup, login and password reset all call it. - All 13 passed, the full test gate ran before deploy, and an existing account signed in on production afterwards.
| Rule | Before | After | The test that holds it |
|---|---|---|---|
| A placeholder is never a hash | An empty or one-part value returned no | Only a value of exactly the stored form (a 22-character salt, a colon, a 43-character hash) is considered at all | *, !, '', :, null and others, each tried with a 300-character password, never verify; rows one character short or long are refused without being compared |
| A failure is never a value that can match | An error while hashing would have thrown | Any error is a refusal; a password that isn’t a string is refused, not crashed on | Non-string passwords neither verify nor throw |
| Limit the input | No upper limit | At most 1,024 bytes, counted in UTF-8 (a Korean character is 3 bytes), checked before any hashing; signup and reset say so, login answers “invalid credentials” | 1,025 bytes refused and 1,024 accepted; 342 three-byte characters (1,026 bytes) refused |
| Compare in constant time | String === | Byte comparison with crypto.subtle.timingSafeEqual in Workers, a constant-time loop elsewhere; empty values never match | Correct for equal, first-byte, last-byte and different-length inputs; a static check that no string === remains |
| Existing passwords keep working | Same stored form: PBKDF2-SHA-256, 100,000 iterations, 16-byte salt | A row hashed the old way still verifies, and a wrong password against it doesn’t |
The one change a user could notice: a password longer than 1,024 bytes can no longer be set, and one set earlier would need a reset. The tests run in the deploy gate, so a later change that brings back a string comparison, an inline copy of the hashing, or a bare length check fails the build before it ships.
Envelope encryption for files. Each protected file (a 3D asset, for example) gets its own random 256-bit content key, which encrypts the file with AES-GCM; the ciphertext goes to R2. The content key is itself encrypted (“wrapped”) under a key-encryption key, derived with PBKDF2 from a master secret, a salt for that file and a key version. Only the wrapped key is stored, in KV. Rotating one file’s key re-wraps one small value instead of re-encrypting everything, and the master secret never leaves the Worker.
What Xano adds. Xano’s endpoints are HTTPS only, and its own password field type stores a hash rather than the password. Xano’s built-in authentication issues tokens encrypted as JWE, not merely signed. It also has security functions for hashing, HMAC and AES encryption, for teams that keep this logic inside Xano. Here the Worker does the hashing and the encryption, so Xano holds salts, hashes and ciphertext, and a copy of the Xano database on its own gives up no passwords and no plaintext files. Check your Xano plan’s settings for encryption at rest and backups.
The rule: TLS for the wire, a salted slow hash for passwords, encryption for anything that must be read back, a signature for identity, and every check failing closed.
mTLS: proving the caller is one of your machines
Ordinary TLS proves the server to the caller. Mutual TLS (mTLS) also makes the caller present a certificate you issued, checked during the TLS handshake, before a single request byte is read. It answers “is this one of my machines?” It does not answer who the person is, or whether a record can be trusted later. Those are other layers, and a stack needs each one for its own job:
| Layer | What it proves | Example in this stack |
|---|---|---|
| mTLS | The connecting machine holds a certificate you issued | MuleSoft or SAP calling a B2B endpoint |
| Webhook HMAC | The event really came from Shopify, for that app | orders/paid to /webhooks/shopify |
| Bearer token (JWT) | Which signed-in person is calling | A buyer issuing a certificate at /attest |
| API key | Which system or tenant is calling | A Worker calling Xano |
| Signed certificate (Ed25519) | A record was signed by your key and not changed since; anyone can check it later | License and attestation certificates, checked against /.well-known/jwks.json |
Which platforms do what.
- Cloudflare, inbound: API Shield checks client certificates at the edge. Every plan can use mTLS with a Cloudflare-managed certificate authority (CA); Enterprise can upload its own CAs. This is the mTLS for a MuleSoft-to-Cloudflare handoff.
- Cloudflare, outbound: a Worker’s mTLS binding gives it a
fetch()that presents a client certificate in the handshake. If the destination is itself proxied by Cloudflare, the call fails with a 520, so check where the destination is hosted first. - Xano: it can present a client certificate on outbound calls, but has no documented way to require one on its own endpoints. A Worker presenting a certificate to Xano would be checked by nobody, so keep calling Xano with its API key, and if something must reach Xano over mTLS, end the mTLS in front of it (Cloudflare, or a Rust gateway) and call Xano from there.
Where it fits. Put mTLS on the paths machines use, not on the storefront. For example, a /b2b/* path or a
separate hostname for MuleSoft or SAP, with an API Shield rule requiring a valid client certificate and the
existing API key still checked behind it. A stolen key alone then gets no one in, and a stolen certificate
alone doesn’t either.
What mTLS does not do. It doesn’t map a certificate to a user or role (matching the certificate’s name to a caller is application logic), and it doesn’t revoke a certificate by itself: keep a revocation list (CRL) or use OCSP in the verifier.
On the IP allowlist. A Rust gateway on a static IP gives Shopify’s IP allowlist a single address to trust. That is tighter, but not required: Workers meet Shopify’s rule today by allowlisting Cloudflare’s published ranges (see “Allowlisting an app that runs on Cloudflare”), at the cost of trusting all of Cloudflare’s address space rather than one machine.
In Rust, Axum with rustls 0.23 ends mTLS like this. Leave out .allow_unauthenticated(), which would let
callers without a certificate through. Tutorials written for rustls 0.21 (AllowAnyAuthenticatedClient,
with_safe_defaults()) no longer compile.
#![allow(unused)]
fn main() {
use std::sync::Arc;
use axum_server::tls_rustls::RustlsConfig;
use rustls::server::WebPkiClientVerifier;
// client_ca_roots: the CA that issued your partners' certificates.
let verifier = WebPkiClientVerifier::builder(Arc::new(client_ca_roots)).build()?;
let config = rustls::ServerConfig::builder()
.with_client_cert_verifier(verifier)
.with_single_cert(server_certs, server_key)?;
axum_server::bind_rustls(addr, RustlsConfig::from_config(Arc::new(config)))
.serve(app.into_make_service())
.await?;
}
RuBAC compared with perimeter login (SAP role login)
Perimeter login decides access once, at the door. An SAP GUI logon is the familiar example: the user enters a
client (the Client field, such as 400, chooses which company’s data set inside the system), a user name, a
password and a logon language. Once past that screen, the user’s roles (built in transaction PFCG) decide what
they can do. Each role carries authorization objects, such as S_TCODE for which transactions may run and field
values such as a company code, and ABAP programs test them with AUTHORITY-CHECK. The roles are loaded into the
user’s buffer at logon, so a role change generally takes effect at the next logon. The rest of the perimeter is the
network around it: the VPN or the corporate network the SAP system sits inside.
That is RBAC (role-based access control): access follows the job title. It works inside one system with a known set of employees. It strains when the people are customers, partners and agents, when the permission has to follow a purchase or a consent rather than a job, and when the same permission must hold across WordPress, AEM, Salesforce, Webflow and Shopify at once.
RuBAC (rule-based access control) decides every request against rules over the current facts, not against a role
handed out at login. A rule reads: this person may use pim.webflow if a license granting that term exists, hasn’t
expired or been revoked, and consent for this purpose is in force in their region. The login only establishes who the
person is; the entitlement register decides what they may do, each time they try.
| Perimeter login (SAP roles, RBAC) | RuBAC with an entitlement register | |
|---|---|---|
| Where access is decided | Once, at logon; then the session’s role buffer | On every request, by the Worker reading the register |
| What a permission is | A role assigned to a user by an administrator | A record: a license with its terms, granted by a purchase, an invitation or an admin, with a date and a proof |
| Who it’s for | Employees inside one system | Customers, partners, merchants and AI agents, across several platforms |
| A change takes effect | Generally at the next logon | On the next request |
| Revocation | Remove the role; open sessions keep the buffered authorizations | Delete or expire the record; the next request is refused |
| Inputs | User, role, authorization object values | Identity plus the license terms, expiry, consent, region and the destination asked for |
| Audit | Change documents on users and roles; security audit log | Grant is an insert, revoke is a delete, audit is a select, each row with a timestamp and a receipt |
| Trust after login | The session is trusted once it’s inside | Nothing is trusted on its own: not the token, not the page, not /auth/me |
| Across platforms | Each system keeps its own roles | One register; each platform renders and the Worker decides |
How the two meet. An enterprise keeps SAP’s roles for employees working inside SAP; nothing here replaces them.
What RuBAC adds sits outside the ERP: the permissions for people and agents who never get an SAP user, checked live
through the same gate that checks consent. On an account page this shows as a list of licenses, each with its
grant date, its terms (for example pim.sync, pim.webflow, pim.omnibus) and a proof link (a receipt that can be
verified), beside an activity log of consent decisions. The login screen offers email, Shopify and Google; whichever is
used, the same register answers.
One login, three ways in: email and password, Shopify, or Google. Any of them leads to the same person in the register.
The account page after sign-in. Each license row is a grant with its date, its terms and a verifiable proof; the activity log below records each consent decision and how it was made. A SAP logon screen has no equivalent of either: its roles are assigned behind the logon, and the user doesn’t see them.
The rule: perimeter login asks “are you inside?” once. RuBAC asks “may this person do this, now?” every time.
Which integrations the token rule reaches
The line that matters is public app or custom app, not how long a job runs.
| Integration | Usually connects as | Covered | Who acts |
|---|---|---|---|
| Bulk import and export (Matrixify and similar) | Public app | Yes | The vendor; the merchant may need to re-authorise |
| Fulfilment and warehouse (ShipHero, ShipBob and similar) | Public app | Yes | The vendor |
| Email and CRM (Klaviyo and similar) | Public app | Yes | The vendor |
| Loyalty and reviews apps | Public app | Yes | The vendor |
| Salesforce, SAP or NetSuite through middleware (Boomi, Celigo, MuleSoft, a custom connector) | Often a custom app in the merchant’s admin, its static token pasted into the middleware | No: exempt | No one is required to |
| The same middleware installed as a vendor’s public app | Public app | Yes | The vendor |
The ERP link is the surprise. A custom-app token feeding SAP or Salesforce is exempt from both rules, so it never expires, works from anywhere and often can write orders and customers: frequently the most exposed credential in the store. Keep it read-mostly (see Licensing penalties by flow), hold it in one place behind the gate, and rotate it even though Shopify doesn’t force it.
How tokens worked before
Until expiring offline tokens, background tokens did not expire. An app’s token lasted until the app was uninstalled or the merchant revoked it, and expiry was not something anyone managed. (The Dev Dashboard is Shopify’s newer app-management console, replacing app management in the Partners Dashboard; WebAssembly belongs to Shopify Functions, covered below.)
| Era | How an app got access | Expiry | How access ended |
|---|---|---|---|
| Private apps (deprecated around 2022) | Created in the merchant’s admin: an API key and password sent with every request | Never | Delete the private app |
| Public app, OAuth offline token | The merchant approves scopes once; the app stores a permanent token in its own database | Never, until uninstall, a revoke, or a scope change that needs re-approval | Uninstall or revoke |
| Public app, OAuth online token | Tied to one logged-in staff member | 24 hours, or when that person logs out of the admin, whichever comes first | Expires on its own |
| Custom app (replaced private apps) | The merchant creates the app and copies a static shpat_ token, shown once | Never | Uninstall the custom app |
| Embedded app, token exchange (from around 2024) | The app swaps the browser’s session token for an Admin API token, with no redirect | Offline tokens from the exchange were still non-expiring at first | Uninstall or revoke |
| Expiring offline token (required for public apps from Jan 1, 2027) | An offline access token plus a refresh token | Access token 1 hour; refresh token 90 days when issued, replaced on every refresh | Lapses if unused; uninstall or revoke |
The dates are approximate; Shopify phased each change in. What “management” meant before:
- Storage was the app’s job. Each app kept its offline token in its own database, with no lifetime or rotation tooling from Shopify.
- Rotation meant reinstalling. Rotating the app’s client secret changed signing (webhooks, for example), but stored offline tokens generally kept working. Replacing a token meant re-running OAuth or reinstalling.
- No network limits. Before the allowlist, a leaked offline token worked from anywhere, indefinitely.
- Monitoring was optional. Apps watched for
401s and deleted stored tokens on theapp/uninstalledwebhook.
Shopify Functions never held tokens. Functions run inside Shopify as WebAssembly (written in Rust or JavaScript), receive the data their input query asks for, and return a decision (a discount, a delivery option, a checkout validation). They make no network calls, so they were never part of the token problem, and they can’t ask the gate either: the gate’s decision has to be written beforehand where the Function reads it (see Parsing at the gate).
Why it matters now. Most long-running integrations were built when an offline token was permanent: they store one token and use it forever, with no refresh step. Moving to expiring tokens means each needs a refresh step, one place that refreshes, and a way to survive 90 quiet days. Custom-app ERP links skip all of it, because they are exempt, which is why they remain the most exposed credential in most stores.
Shopify and Google: both access tokens last one hour
The same design applies to both platforms, because both issue access tokens that last one hour:
| Shopify Admin API (expiring offline token) | Google APIs (OAuth 2.0: Ads, BigQuery, Merchant Center, YouTube) | |
|---|---|---|
| Access token | 1 hour (expires_in 3600) | 1 hour (expires_in about 3599) |
| Refresh token | 90 days when issued; replaced on every refresh | Long-lived and usually not replaced; it stops working when the user revokes access, after six months unused, when the user changes the password (for Gmail scopes), past the per-client limit of live refresh tokens, or after 7 days for an app whose consent screen is still in Testing |
| Server-to-server, no person present | Client credentials: a public app signs a JWT (RS256 or ES256) and gets a token of up to 1 hour, with no refresh token; a custom app on its own organization’s stores sends its client secret and gets 24 hours | A service account: the backend signs a JWT and gets a token of up to 1 hour, with no refresh token |
| A dead refresh token | 401 invalid_request; the merchant reopens the app | 400 invalid_grant; the user grants access again |
So a job that pulls from Shopify and writes to BigQuery or Google Ads holds two one-hour tokens with different refresh
rules. Give each its own owner in the job (the TokenOwner pattern below), refresh each before it expires, and never
assume one’s lifetime from the other’s. Shopify’s rotating refresh token is the stricter of the two: two workers
refreshing at once break it, which is not true of Google’s.
Signing in as the app: RS256 or ES256, not EdDSA
A background job with no merchant present (a nightly sync, a cron sweep) can get its own Admin token without a refresh token. Shopify has two versions of this, and which one an app gets depends on how it is distributed:
| Custom app, stores in its own organization | Public app, any store that installed it | |
|---|---|---|
| What the app sends | client_id and client_secret | client_id and a signed client_assertion (no secret) |
| Token lifetime | 24 hours (expires_in 86399) | Up to 1 hour (expires_in 3599); read the value, don’t assume it |
| Refresh token | None | None |
| Who can use it | Only when the app and the store belong to the same Shopify organization | Any store that has installed the app and approved its scopes |
Shopify accepts two signing algorithms for the assertion: RS256 (RSA, 2048 to 8192 bits) and ES256 (EC, P-256). EdDSA (Ed25519) is not on the list. A design that labels its fallback “Ed25519 signer” should use ES256 instead. ES256 is the nearest equivalent: small keys and fast signing, and Cloudflare Workers’ WebCrypto supports it.
The request is a form post to https://{shop}.myshopify.com/admin/oauth/access_token:
grant_type=client_credentials
client_id=<app client ID>
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion=<JWT signed with the app's private key>
The assertion is a short JWT that Shopify checks part by part:
| Part | Value |
|---|---|
alg (header) | RS256 or ES256, matching the registered key |
kid (header) | The ID of an active public key on the app |
iss, sub | The app’s client ID |
aud | https://{shop}.myshopify.com/admin/oauth/access_token, the store’s permanent domain |
iat, exp | Now, and at most 300 seconds later |
jti | Unique; Shopify accepts each one once per app, across all stores |
Because each jti is accepted once, sign a new assertion for every request, retries included. Don’t
send a client secret, an Authorization: Basic header or a scope in the same request. The public key
is registered as a JWK (with kid, alg and use: "sig") in the Dev Dashboard, under the app’s
Settings → Credentials → Public keys. The dashboard does not accept PEM.
Why it matters for long-running work. For a public app this replaces the refresh-token chain. Each time it needs Shopify, the job signs a new assertion and gets a new one-hour token: there is no refresh token to store, rotate or lose, no 90-day expiry, and no dead refresh token that waits on the merchant to reconnect. What remains is the install itself: the store has to keep the app installed with its scopes approved.
Keep it apart from other signing keys. A platform that already signs its own documents (license
certificates, attestations) with an Ed25519 key keeps that key for that purpose. The Shopify assertion
key is a separate ES256 key per app: the private half held as a secret in the Worker, the public half in
the Dev Dashboard, and a new kid on every rotation.
In Rust, with the jsonwebtoken, serde and uuid crates, the assertion is a few lines. shop is the
permanent domain (example.myshopify.com) and pem the PKCS#8 private key:
#![allow(unused)]
fn main() {
use jsonwebtoken::{encode, Algorithm, EncodingKey, Header};
use serde::Serialize;
#[derive(Serialize)]
struct Assertion<'a> { iss: &'a str, sub: &'a str, aud: String, iat: u64, exp: u64, jti: String }
fn client_assertion(client_id: &str, shop: &str, kid: &str, pem: &[u8], now: u64) -> jsonwebtoken::errors::Result<String> {
let mut header = Header::new(Algorithm::ES256); // RS256 also accepted; EdDSA is not
header.kid = Some(kid.to_string());
let claims = Assertion {
iss: client_id, sub: client_id,
aud: format!("https://{shop}/admin/oauth/access_token"),
iat: now, exp: now + 60, // at most 300 seconds
jti: uuid::Uuid::new_v4().to_string(), // new for every request, retries included
};
encode(&header, &claims, &EncodingKey::from_ec_pem(pem)?)
}
}
Migrating stored tokens: the options
An app built the old way holds a database of permanent offline tokens: one per shop, no expiry date, no refresh token. Before Jan 1, 2027 it has five ways forward (migration guide):
| # | Option | Merchant action | Best for |
|---|---|---|---|
| 1 | Exchange each stored token for an expiring pair: POST /admin/oauth/access_token with grant_type=urn:ietf:params:oauth:grant-type:token-exchange, the stored token as subject_token (type urn:shopify:params:oauth:token-type:offline-access-token), the same requested_token_type, and expiring=1 | None | Any app with working stored tokens: the main path |
| 2 | The template flag: future: { expiringOfflineAccessTokens: true } in shopify.server.ts, then shopify app deploy | None | Apps on Shopify’s Remix or React Router template, which then store and refresh the tokens itself |
| 3 | Application-only access (client credentials) | None | Background sync; no long-lived token stays in the database |
| 4 | Re-authenticate when the merchant opens the app (token exchange with the session’s ID token) | Opens the app | Shops whose stored token is already dead, or whose exchange returns invalid_subject_token |
| 5 | A merchant-created custom app | Creates it in the admin | Enterprise setups; custom apps are exempt |
Doing nothing: delisted with no new installs on Jan 1, 2027 (existing installs keep working); merchants warned on
Jan 15; from Apr 1, 2027 every Admin API call with the old token returns 403 (“Non-expiring access tokens are no
longer accepted for the Admin API”).
The database change behind option 1:
- New columns per shop:
access_token,access_expires_at(now plusexpires_in),refresh_token,refresh_expires_at(90 days when issued), and a lock or version column. - Delete the old token once the exchange succeeds: migration permanently invalidates it for Admin API calls.
- One shop at a time, never two workers on the same shop. If a response is lost, the same request within seven days returns the same pair.
- Refresh dormant shops at least once every 90 days, or the next job needs the merchant.
- Treat
401 invalid_requeston refresh as final: mark the shop “reopen the app” instead of retrying. - Shopify’s pages don’t give a rate limit for exchanging many shops, or say whether migration can be undone. Assume it can’t, and pace the batch.
By integration type: Klaviyo, Gorgias and Sprinklr, Attentive, Matrixify
The names describe the shape of each integration. They are not a statement about any vendor’s readiness; most will have migrated or will migrate before the deadline.
| Integration shape | What it does with the token | What breaks first | Path |
|---|---|---|---|
| Klaviyo-style (email, marketing) | Continuous background sync of customers, orders and catalog for thousands of shops; writes email consent back | Sync workers on many machines refresh the same shop at once and break each other’s refresh token | Option 1 in a paced batch with one token owner per shop, or option 3 so nothing is stored |
| Gorgias / Sprinklr-style (helpdesk, social care) | Agents look up orders and customers on demand and act (refund, cancel, change an address); background pulls too | A refund in the middle of a ticket fails on an expired token | Option 1; refresh before any action if under five minutes remain. Enterprise setups on per-merchant custom apps (option 5) are exempt |
| Attentive-style (SMS) | High-volume, two-way sync of SMS subscribers and consent | A compliance gap, not just an outage: a consent write that gets 403 or 401 means an unsubscribe never reaches Shopify, and another tool may keep texting the person | Option 1, plus a dead-letter queue for failed consent writes and a daily reconciliation of consent between the two systems |
| Matrixify-style (bulk import, export, platform migration) | Jobs of several hours; occasional use; scheduled feeds; bulk operations for exports and large numbers of mutations for imports; runs on the vendor’s servers | The 90-day refresh token lapses between uses, and a long job outlives several one-hour tokens | Option 1, plus a background refresh for dormant shops every 60 to 80 days, one token owner that import and export workers ask, and checkpoints with writes keyed by row. Option 3 for scheduled jobs |
For a merchant before a large migration with a Matrixify-style tool:
- Open the app shortly before the run, so a quiet connection gets a fresh token.
- Split very large imports by collection or date range, so a failure costs one batch.
- Keep the source files and a pre-import export, so a half-finished import can be rolled back.
- After Apr 1, 2027, a
403about non-expiring tokens means the vendor hasn’t migrated. - For a subscriber or customer migration, reconcile email and SMS consent afterwards: a partial failure can leave people with the wrong status.
The common point: the token change is a data-management change, not only an authentication change. Each shape needs one owner per credential, refresh before expiry, one shop at a time, writes that are safe to retry, and a list of shops that need the merchant. The Klaviyo- and Attentive-style shapes add reconciliation, so a consent withdrawal is never lost; the Matrixify-style shape adds refreshes for dormant shops and checkpoints, so a quiet connection or a long job isn’t.
Dead letters: when a write can’t land
Webhooks make a promise awkward to keep. The sender wants a quick 2xx; Shopify and Webflow retry a failure a few
times and then may switch the subscription off. So most handlers answer 200 whatever happens. The risk is that 200
also means “done” to the sender, which never sends it again: if the write behind it failed, the work is gone and
nothing records it.
A dead-letter queue closes that gap. Work that fails is set aside with its error, instead of being retried forever or dropped, and a scheduled job delivers it later. The name comes from the post office’s dead-letter office for mail that can’t be delivered.
| Step | What happens |
|---|---|
| 1. The write fails | A 401, rejected data (userErrors), a missing credential, or the other side unreachable. The write reports the failure; it doesn’t return quietly |
| 2. Save before answering | The work is stored with its error and the time of the first failure, keyed by what it is (the item, the person), so the same work failing twice is one entry. Then the handler answers 200 |
| 3. Retry on a schedule | A cron delivers what it can and deletes it; what still fails waits longer each time (15 minutes, doubling, up to 6 hours) |
| 4. Newer wins | A newer change that lands clears the older saved one; a change from the other system after the failure supersedes it, so old data never overwrites new |
| 5. Don’t hammer a dead credential | A shop waiting for the merchant to reconnect is skipped until it’s reconnected. A dead-letter refresh is the same idea for tokens: a refresh token that returns 401 invalid_request is final, so the shop is marked, the work waits, and it’s replayed after the merchant reopens the app |
| 6. Say what is late | Anything pending past a set time (24 hours here) is logged as overdue on every run, where someone will see it |
Applying it: two webhook fixes, test first
The same review that found the password gaps found this one in two public apps of this stack. Both answered 200 on a
failed write and kept nothing. Each fix was written test first: the tests failed against the live code, passed after
the change, and the fix was deployed and merged.
| Reviews app: privacy webhooks | PIM sync: Webflow to Shopify edits | |
|---|---|---|
| What was lost | A customer data request, a customer erasure or a shop erasure that failed to reach the worker doing it. The failure was logged; Shopify was told 200 and never resent | A Webflow CMS edit (description, tags, metafields, a collection’s title or publish state) whose Shopify write failed. Webflow was told {processed: true}; a failed collection was even recorded as synced |
| Why it matters | Legal: Shopify gives 30 days to answer a data request, and an erasure that silently didn’t happen reads like one that did | Data: the storefront and the CMS drift apart, and nobody knows which edits are missing |
| Saved as | dsr:pending:<type>:<shop>:<customer> | webflow_dlq:<itemId>, holding the newest version of the edit |
| Retried by | A new cron, every 30 minutes | The existing 15-minute cron, right after it refreshes tokens, so an edit waiting on a token goes out in the same run |
| Late | OVERDUE after 24 hours; PAST DEADLINE after 30 days | OVERDUE after 24 hours, noting when the shop needs the merchant to reconnect |
| Tests | 12 | 11 |
The rule from both: a 200 to the sender is a promise that the work is either done or saved. Answering 200
without either is how data drops between intervals: between one webhook and the next cron, between a token dying and a
merchant reconnecting, between a failure and someone reading the log.
Example: a nightly SAP load through a bulk loader, longer than an hour
A common pattern: SAP (ECC or S/4HANA) exports materials, prices and stock every night, and a Matrixify-style bulk loader writes them to Shopify as a bulk mutation. Shopify doesn’t name any loader in its announcements; the example is the shape, not a vendor. With 200,000 variants the load takes two to three hours, so it outlives at least two access tokens.
The point that makes it workable: a bulk operation runs on Shopify’s side. The token is needed only to start the job, to check on it, and to fetch the result; nothing calls the Admin API while Shopify is applying the rows. So the token has to be fresh at four moments, not for three hours straight.
| Time (UTC) | Step | Token needed? | What can go wrong |
|---|---|---|---|
| 01:00 | SAP extracts the night’s changes (change pointers on MATMAS, condition records for prices, stock by plant) to a CSV or IDoc file | No (SAP side) | The extract runs while users are still changing prices: take a consistent cut-off time and record it |
| 01:20 | The loader maps SAP fields to Shopify: MATNR to SKU and handle, MAKTX to title, KBETR and KONWA to price and currency; it writes a JSONL file, one line per product | No | Unit and currency conversions; a MATNR with leading zeros becoming a different SKU |
| 01:30 | stagedUploadsCreate, upload the JSONL, then bulkOperationRunMutation (for example with productSet) | Yes: refresh first if under five minutes remain | Since Nov 12, 2026, blocked if the call comes from a server outside the app’s IP allowlist |
| 01:30 to 03:45 | Shopify applies the rows. The loader waits for the bulk_operations/finish webhook, or polls the operation’s status | Yes, for each poll. The 01:30 token expired at 02:30 | Polling with the expired token gets 401. The poller must ask the token owner, not keep its own copy |
| 03:45 | Download the result file: one line per input line, with any errors | Only to read the operation’s result URL | Per-line errors (a missing option value, an invalid price) don’t fail the whole job; they have to be read |
| 04:00 | Retry only the failed lines as a second, smaller bulk operation; reconcile counts against SAP; save a checkpoint | Yes | A full rerun instead of a retry of the failures doubles the load and the risk |
What keeps the nightly load safe:
- One token owner for the shop, which the starter, the poller and the downloader all ask. Two of them refreshing at once breaks Shopify’s rotating refresh token.
- A nightly load keeps the refresh token alive. Each night’s refresh resets the clock, so the 90-day expiry is a risk only when the loads stop (a migration pause, a holiday freeze).
- Calls from the allowed network. Starting and polling must come from servers in the app’s allowlist: the loader vendor’s, or a Worker if you run the loader.
- Writes keyed by SKU or handle (
productSetwith an identifier), so retrying a line updates the same product instead of creating a second one. - No overlap. If last night’s operation is still running when tonight’s starts, wait or skip; check the operation’s status first. Shopify limits how many bulk operations a shop can run at once (check the current limit for your API version).
- A cut-off time and a checkpoint. Record which SAP extract each load applied, so the next night’s delta starts from the right point and an audit can say which SAP state the storefront showed.
- Bulk scopes. Shopify’s Nov 5, 2026 update says bulk queries and bulk mutations will each need their own access scope. Apps that ran a bulk operation in the last 180 days get them granted automatically; a loader that has been idle longer has to request them.
- The deadline. The same update’s summary says “November 11” for apps using bulk operations, while its body and table say November 12, 11:59 PM ET. Plan for the 11th.
Where it isn’t a bulk operation. Inventory by location, metafields written one at a time, or an importer that sends ordinary mutations row by row makes thousands of Admin API calls over the three hours. That load needs everything in Threads, tasks and async in a long-running Rust job: refresh during the run, a bounded queue, a cap on concurrent requests to stay inside Shopify’s rate limit, idempotent writes and checkpoints.
Shopify to Google Merchant Center: sync on change or morning updates
Once the night’s load reaches Shopify, the same products have to reach Google Merchant Center, which feeds Shopping ads, free listings and YouTube shopping. There are two ways to move them, and they fail differently.
| Sync on change | Morning updates | |
|---|---|---|
| How | A Shopify webhook (products/update, inventory_levels/update) reaches the Worker, which sends that one product to Google’s Merchant API | One scheduled batch after the night’s load finishes and reconciles: a feed file Google fetches, or a batch of Merchant API calls |
| How fresh Google is | Minutes after the change | Up to a day old by evening |
| A price or stock change at 14:00 | Reaches Google within minutes | Ads show the old price until tomorrow morning; Google can flag a mismatch with the landing page and disapprove the item |
| A 200,000-variant bulk load at 01:30 | Floods: each updated product can fire a webhook, so Google receives 200,000 single updates over three hours, against its API quotas | One batch after 04:00, built from the bulk operation’s result file |
| What Google sees mid-load | A half-loaded catalog: some products with new prices, some with old | Only the finished, reconciled state |
| Retries and order | Webhooks can arrive late, twice or out of order; each update needs a timestamp check so an older one doesn’t overwrite a newer one | One run, one checkpoint; easy to rerun |
| Tokens | The Worker holds a Google token (one hour) and refreshes it all day | One Google token for a short run |
| Best for | Price, sale price and availability: the fields that cause disapprovals and pricing-law problems when stale | Titles, descriptions, images, categories, product attributes: the fields that change with the catalog, not by the minute |
The usual answer is both, split by field:
SAP nightly ─▶ bulk load to Shopify (01:30–03:45) ─▶ reconcile ─▶ morning batch to Merchant Center (04:15)
all fields, from the result file
Shopify during the day ─▶ webhook ─▶ Worker (the gate) ─▶ Merchant API, price and availability only
ignores changes made by the bulk load itself
- During the bulk load, pause the on-change path (or let the Worker ignore updates tagged as coming from the load), then send one batch from the result file. Otherwise Google gets the catalog half-finished and the quota is spent three hours early.
- During the day, send only the fields that matter by the minute: price, sale price, availability. A merchandiser’s price change or a sell-out reaches Google in minutes.
- One record decides. The Worker sends Google what the system of record (Xano, behind the gate) says, keyed by the same product ID the crosswalk assigned, not whatever field arrived last.
- Keep every product refreshed within 30 days. Merchant Center lets products expire when nothing has updated them for 30 days, so a product that never changes still needs the morning batch to touch it.
- Two one-hour tokens. The day path holds a Google token as well as Shopify’s; each gets its own owner and its own refresh, as in Shopify and Google: both access tokens last one hour.
Where Shopify’s own Google channel fits. The Google & YouTube app syncs Shopify products to Merchant Center on its own schedule, and suits a store whose catalog lives in Shopify. Where SAP owns the catalog and Shopify is one destination, the split above gives control over timing: which fields are live within minutes, and when the catalog as a whole changes. Use one path per field, never two writers for the same field.
The data layer. Merchant Center performance and product status also come back to BigQuery through the Merchant Center transfer, once a day. That is reporting, not sync: it shows what Google held yesterday, which is the check that the morning batch and the day path are doing their jobs (see Extending the data: BigQuery transfers).
Where long-running work breaks with expiring tokens
| Failure | Why | What closes it |
|---|---|---|
| A long paginated pull fails partway | The access token lasts one hour, so a longer job outlives it | Refresh during the job; prefer bulk operations, which run on Shopify’s side and need the token only to start and poll |
| A seasonal job can’t run | A refresh token not used within 90 days expires (a quarterly reconciliation, a holiday fulfilment sync, a points-expiry run). Shopify then returns 401 with invalid_request, and the merchant has to reopen the app | Store sessions for the refresh token’s full life, refresh at least once before day 90, and test seasonal jobs before they’re needed |
| Two workers break each other | Every refresh returns a new refresh token. The old one stays usable only until the newer one is used, a new token is acquired, 30 days pass after its first use, or its 90-day expiry, whichever comes first. A worker still holding the old one then fails | One refresher per shop, with a lock; every other worker asks it for the current token and always stores the newest refresh token |
| Copies go stale | The token was copied into a warehouse, an iPaaS or Xano | One place refreshes; the others fetch from it, as every other decision goes through the gate |
| The refresh token is lost | A failed write, a wiped session store, a migration that went wrong | Shopify’s October 2026 update adds client credentials for public apps: the backend signs a short-lived JWT with the app’s private key (its public key registered in the Dev Dashboard) and gets an access token for a store that has the app installed, valid up to one hour, with no refresh token. The migration guide still treats an invalid refresh token as “the merchant must reopen your app”, so confirm which path applies before relying on it |
Where long jobs should run
A job that runs for more than an hour (a catalog load, an ERP reconciliation, a long import) raises two separate questions: where it runs, and how it keeps access. A server answers the first. It doesn’t answer the second: the access token still lasts one hour wherever the job runs, so a server job refreshes during the run like any other.
| Job | Best fit | Why |
|---|---|---|
| Large export or import of catalog or orders | Shopify bulk operations | Shopify runs the job; the token is needed only to start it, check on it and download the result |
| Hours of per-record work (transforms, ERP lookups, retries) | A server, container or queue worker | Runs as long as needed, keeps state in memory, and has a fixed outbound IP for the allowlist |
| A long job split into short steps | Cloudflare Workflows, or Queues with Durable Objects | Each step is short, retries on its own and gets the current token, so no run outlives a token |
| The gate, webhooks, the app proxy, short reads and writes | Cloudflare Workers | Requests take milliseconds to seconds; per-request CPU limits are in minutes, not hours |
| A vendor’s import tool you don’t control | The vendor’s servers | Ask how its long jobs refresh tokens and whether it uses bulk operations |
Cloudflare Worker (gate) ── starts the job, decides consent, issues the receipt
│
├─ small or medium: Workflow steps on Cloudflare (each step gets the current token)
├─ catalog-sized: a Shopify bulk operation (Shopify does the work)
└─ hours of custom work: a server or queue worker (fixed IP, one token owner, checkpoints)
│
└─ reports back to the gate → receipt in Xano
Threads, tasks and async in a long-running Rust job
On a server, the Rust core runs long loads on Tokio, Rust’s most widely used async runtime. Its model, briefly:
- Async tasks, not one thread each.
async fncode pauses at each.await(a network call, a channel send) and lets other work run. Tokio runs thousands of these tasks on a small pool of OS threads, about one per CPU core. tokio::spawnstarts a background task; aJoinSetcollects a group of them and reports each result, so a failure isn’t lost.- CPU-heavy work goes to
spawn_blocking. Parsing a large page or converting ECC records holds a thread for a while;spawn_blockingruns it on a separate pool so the async threads keep serving network calls. - Bounded channels give backpressure. If writing is slower than fetching, the producer waits instead of filling memory.
- A semaphore caps work in flight, which keeps the job under Shopify’s rate limits. Shopify limits GraphQL by query cost and reports the remaining budget in each response: slow down when it runs low.
- Ownership carries over. The token pair has one owner behind a lock; tasks borrow a copy of the current access token. The compiler rejects code that shares the pair without the lock.
- Cancellation is explicit. A
CancellationTokenlets a deploy or shutdown stop the job between pages, after the last checkpoint, instead of mid-write.
Shopify’s cursor pagination is sequential (each page gives the cursor for the next), so the fetch runs as one producer in order, and the parallel part is the transform and write. A sketch, compiled against Tokio, with the Shopify call, the Rust core and Xano left as stubs:
#![allow(unused)]
fn main() {
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::{mpsc, Mutex, Semaphore};
use tokio::task::JoinSet;
use tokio_util::sync::CancellationToken;
type Res<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
#[derive(Clone)]
pub struct AccessToken { pub value: String, pub expires_at: Instant }
pub struct Row { pub id: String, pub raw: String }
pub struct Batch { pub cursor: Option<String>, pub rows: Vec<Row> }
/// The one owner of a shop's tokens. Every task borrows the current access token through `current()`;
/// only the owner refreshes, under a lock, and it always keeps the newest refresh token.
pub struct TokenOwner { inner: Mutex<(AccessToken, String)> }
impl TokenOwner {
pub fn new(access: AccessToken, refresh_token: String) -> Self {
Self { inner: Mutex::new((access, refresh_token)) }
}
pub async fn current(&self) -> Res<AccessToken> {
let mut guard = self.inner.lock().await; // one refresher per shop
let left = guard.0.expires_at.saturating_duration_since(Instant::now());
if left < Duration::from_secs(5 * 60) {
let (access, refresh_token) = refresh(&guard.1).await?; // returns a new pair every time
*guard = (access, refresh_token);
}
Ok(guard.0.clone())
}
}
/// Long load: one producer walks Shopify's cursor pages in order (cursors are sequential),
/// a bounded channel applies backpressure, and a limited number of workers transform and write.
pub async fn run_load(owner: Arc<TokenOwner>, start: Option<String>, cancel: CancellationToken) -> Res<()> {
let (tx, mut rx) = mpsc::channel::<Batch>(8); // at most 8 pages waiting
let producer = {
let owner = owner.clone();
let cancel = cancel.clone();
tokio::spawn(async move {
let mut cursor = start;
loop {
if cancel.is_cancelled() { break; }
let token = owner.current().await?; // fresh token for every page
let (rows, next) = fetch_page(&token, cursor.as_deref()).await?;
tx.send(Batch { cursor: cursor.clone(), rows }).await?;
match next { Some(n) => cursor = Some(n), None => break }
}
Res::Ok(())
})
};
let limit = Arc::new(Semaphore::new(4)); // workers in flight, kept under the API's rate limit
let mut workers = JoinSet::new();
while let Some(batch) = rx.recv().await {
let permit = limit.clone().acquire_owned().await?;
workers.spawn(async move {
let _permit = permit; // released when this task ends
let records = tokio::task::spawn_blocking(move || parse(batch.rows)).await?; // CPU work off the async threads
write_idempotent(&records).await?; // keyed by record ID, so a replay is harmless
save_checkpoint(batch.cursor.as_deref()).await
});
}
while let Some(done) = workers.join_next().await { done??; }
producer.await??;
Ok(())
}
}
What each part closes from the failure table above:
| Part of the sketch | Failure it closes |
|---|---|
TokenOwner::current() refreshes under a lock, five minutes before expiry, and stores the new pair | A long pull failing partway; two workers breaking each other’s refresh token |
| One producer, cursor pages in order | Pages fetched out of order or twice |
mpsc::channel(8) | Memory filling up when writes are slower than fetches |
Semaphore::new(4) | Hitting Shopify’s rate limit with too many requests in flight |
spawn_blocking(parse) | Network calls stalling behind CPU-heavy parsing |
write_idempotent + save_checkpoint | A job that stops at hour two starting over, or writing records twice when it resumes |
CancellationToken | A deploy or shutdown cutting a write in half |
Rust’s non-blocking runners compared with useState in JavaScript
Rust adds code runners that don’t block: Tokio tasks (spawn, JoinSet), a separate pool for heavy work
(spawn_blocking), and coordination built into the runtime (channels, semaphores, cancellation). Together they
manage data while it moves: how much is in flight, who owns it, where to resume, and when to stop. React’s useState
does something else. It holds a value for one component on one screen, re-renders when the value changes, and loses it
when the page reloads or the tab closes.
| Rust with Tokio | JavaScript with React useState | |
|---|---|---|
| What it manages | Data in flight across a long job: pages, tokens, checkpoints | One component’s display state in one browser tab |
| Where it runs | A server, for hours if needed, on several threads | The shopper’s or merchant’s browser, for as long as the tab stays open |
| Doing work at once | Tasks run in parallel on a thread pool; CPU-heavy parsing moves to spawn_blocking so network calls keep moving | One event loop per tab. async/await interleaves waiting but doesn’t run in parallel; heavy work freezes the page unless it moves to a Web Worker |
| Limits and backpressure | Built in: a bounded mpsc channel and a Semaphore | None. Each fetch starts at once unless you write the limit yourself |
| Who may change the data | The compiler enforces one owner, or a lock; two writers changing the same value at once can’t compile | Any code holding the setter can change it; a stale value from an earlier render can overwrite a newer one |
| Surviving a failure | save_checkpoint and idempotent writes resume where the job stopped | State is gone on reload; nothing resumes |
| Stopping cleanly | CancellationToken finishes the current write, then stops | Closing the tab stops everything mid-request |
In business terms: useState is a note on one person’s desk, useful while they’re working on the screen in front
of them. The Rust runners are the operations floor behind it: a controlled intake queue, a work-in-progress limit, a
capacity cap on partner systems, a separate back office for heavy work, restart points, and an orderly close. The page
can show progress with useState; the record of what was loaded, and from where to continue, belongs to the server
and to Xano.
The two aren’t rivals. A merchant’s admin screen uses useState to show a load’s progress bar; the load itself runs in
Rust on a server and reports its checkpoint, which the screen reads. Keep anything that must survive a reload, a
retry or a deploy out of component state.
Inside a Cloudflare Worker there is no Tokio thread pool. A Worker runs one event loop per isolate; Rust compiled
for it is async (through wasm-bindgen-futures) but single-threaded, and each request has CPU-time limits. The same
crate’s logic (types, parsing, decide) runs there; the hour-long orchestration does not. Split it into Workflow
steps or queue messages, or run it on a server with Tokio.
Certification and authorization impact
The two rules reach further than the App Store listing. The Shopify side decides whether an app can be listed and installed. The merchant’s own certifications decide whether its auditors accept how integrations hold credentials.
On Shopify’s side
| What | Impact |
|---|---|
| App Store listing and review | An app missing either rule is delisted and can’t take new installs, and an app under review should meet both before it’s approved. Check the current App Store requirements before submitting |
| Built for Shopify status | Depends on being listed and meeting the App Store requirements, so delisting puts it at risk. Check the current Built for Shopify criteria |
| Protected customer data access | Approved per app and per level. The rules don’t change the approval itself, but a token that can be used from anywhere and never expires is hard to defend in the data-protection answers that approval asks for |
| Merchant authorization (OAuth) | Moving to expiring tokens can force a re-authorization. A refresh token that lapsed after 90 days does too. Plan it so merchants aren’t asked to re-approve scopes unexpectedly. Never widen scopes in the same change |
| Custom apps in the merchant’s admin | Exempt from both rules. The merchant’s admin staff own the token, the scopes and the rotation, so the merchant’s own controls have to cover them |
On the merchant’s certifications
The token and allowlist rules map onto access-control requirements most frameworks already have. The mapping below is a guide for preparing evidence; the auditor decides what counts.
| Framework | Requirement it touches | Evidence the rules provide | Gap the exempt custom-app token leaves |
|---|---|---|---|
| SOC 2 (Trust Services Criteria, CC6) | Logical access: restrict access, authenticate system accounts, limit access from outside the boundary | Expiring tokens; an allowlist limiting the networks a token can be used from; Dev Dashboard logs of client IPs | A static token in middleware, usable from anywhere, often with write scopes |
| ISO/IEC 27001:2022 (Annex A) | Authentication information, secure authentication, access rights (A.5.17, A.8.5, A.5.18) | Token lifetime and rotation; network restriction; one owner per credential | No forced rotation, and the credential is copied into several systems |
| PCI DSS v4.0 (Requirement 8) | Accounts used by systems and applications: managed, protected and changed periodically based on a risk analysis (8.6) | Expiring and rotating tokens for public apps | Custom-app tokens feeding order or payment-adjacent systems need their own rotation schedule. Card data itself stays out of Shopify app tokens |
| GDPR / UK GDPR (Art. 32) | Security of processing appropriate to the risk | Short-lived credentials, network limits, an audit trail per decision | A long-lived token with customer scopes, held by a processor, without its own limits |
| SAP’s own certification of an integration | SAP certifies the connector, not the Shopify side | — | The Shopify credential the connector uses is out of scope for SAP’s certification and has to be covered by the merchant’s controls |
What to put in the evidence pack
- Each public app’s allowlist and enforcement state, with the date it was turned on and the traffic test result.
- Proof that installs use expiring offline tokens, plus the session lifetime that keeps refresh tokens alive.
- An inventory of custom-app tokens: where each is stored, its scopes, its owner and its rotation date.
- A receipt for each export from the gate’s ledger (Function gating), so access can be traced per decision, not just per system.
Before Jan 1
- List the store’s installed apps and ask each vendor whether it has moved to expiring offline tokens.
- Find the custom apps whose tokens sit in ERP or middleware: exempt, but review their scopes and rotation, and allowlist them too where the platform allows.
- Run each seasonal job once, early, so a lapsed refresh token shows up before the season does.
- Treat the deadline as a review point: an app that stops on Apr 1 is the moment to decide whether to replace it with a build behind the same gate.
Terms
| Term | Stands for | What it means here |
|---|---|---|
| ASN | Autonomous System Number | The number identifying one network operator’s part of the internet: Cloudflare is 13335, Amazon Web Services 16509, Google 15169. Shopify’s allowlist can accept ASNs instead of addresses, meaning “any request from this operator’s network”. It depends on Shopify’s lookup (GeoLite) matching the request to an ASN, which failed for Cloudflare Workers egress |
| Short-lived token | (not an acronym) | An access token that expires quickly. Shopify’s expiring offline access token lasts one hour, so a stolen copy stops working on its own |
| Refresh token | (not an acronym) | The longer-lived token (90 days when issued) used to get a new access token. Shopify replaces it on every refresh |
| IP | Internet Protocol | An address such as 104.16.0.0 (IPv4) or 2606:4700:: (IPv6) |
| CIDR | Classless Inter-Domain Routing | The /16 or /32 notation for a block of IP addresses. A smaller number after the slash means a larger block |
| OAuth | Open Authorization | How a merchant approves an app’s access and the app receives its tokens |
| JWT | JSON Web Token | A signed token. In Shopify’s client credentials flow, the app’s backend signs one with its private key to get an access token |
| JWK | JSON Web Key | The public key, registered in the Dev Dashboard, that Shopify uses to check that JWT |
| GID | Global ID | Shopify’s identifiers, such as gid://shopify/Product/123 |
| Client assertion | (not an acronym) | A short JWT the app signs to prove it is the app, sent instead of a client secret when asking Shopify for a token |
| RS256 | RSA signature with SHA-256 | One of the two algorithms Shopify accepts for a client assertion (RSA keys of 2048 to 8192 bits) |
| ES256 | ECDSA on P-256 with SHA-256 | The other algorithm Shopify accepts; small keys and fast signing, the nearest equivalent to Ed25519 |
| EdDSA | Edwards-curve Digital Signature Algorithm | Signing with Ed25519 keys. Not accepted by Shopify for client assertions; fine for a platform’s own certificates |
kid | Key ID | The label in a signed token’s header saying which registered public key checks it; a new one on every key rotation |
jti | JWT ID | A unique ID per token. Shopify accepts each client assertion’s jti once per app, across all stores |
| mTLS | Mutual Transport Layer Security | TLS in which the caller also presents a certificate you issued, checked in the handshake; proves the machine, not the person |
| CA | Certificate authority | Whoever issues and signs certificates; for mTLS, the CA you trust for your callers’ certificates |
| API Shield | (Cloudflare product) | Cloudflare’s API protection; its mTLS rules require a valid client certificate on chosen hostnames or paths |
| CRL / OCSP | Certificate Revocation List / Online Certificate Status Protocol | The two ways to tell a verifier a certificate has been withdrawn before it expires |
| Dead-letter queue | (not an acronym) | Where work that failed is set aside with its error, to be retried on a schedule instead of being dropped or retried forever |
| Dead-letter refresh | (not an acronym) | A token refresh that can never succeed (401 invalid_request): stop retrying, mark the shop, keep its waiting work, and replay it after the merchant reconnects |
| Bulk operation | (not an acronym) | A job Shopify runs on its own side over a whole dataset, started with bulkOperationRunQuery (export to a JSONL file) or bulkOperationRunMutation (apply an uploaded JSONL file), then polled or reported by the bulk_operations/finish webhook. Not the same as mutations with “bulk” in their name, such as productVariantsBulkUpdate, which are ordinary single requests. The Nov 12, 2026 allowlist rule applies to bulk operations only |
| API | Application Programming Interface | The Admin API is how apps read and write store data |
| TLS | Transport Layer Security | The encryption behind https://. A TLS login keeps every step of sign-in encrypted in transit; it protects the connection, not the identity |
| Salt | (not an acronym) | A random value, different for every password, mixed in before hashing so identical passwords give different hashes. Stored beside the hash; not secret |
| PBKDF2 | Password-Based Key Derivation Function 2 | A slow, salted hash for passwords and for deriving keys from a secret; its iterations set how slow |
| AES-GCM | Advanced Encryption Standard, Galois/Counter Mode | Two-way encryption that also detects tampering; used here with 256-bit keys |
| JWE | JSON Web Encryption | A token whose contents are encrypted, not only signed; Xano’s built-in auth tokens use it |
| OIDC | OpenID Connect | The sign-in standard on top of OAuth that Google and Shopify’s Customer Account API use to say who a person is |
| Claims | (not an acronym) | The facts about who a signed-in person is and which accounts are linked to them, kept in Xano |
| Extras | (not an acronym) | Extra per-person data a signed-in page may show, kept apart from the claims |
/auth/me | (an endpoint) | Answers “who is signed in?”: verifies the token, then returns the user, claims, extras and entitlement |
| RBAC | Role-based access control | Access follows an assigned role, as with SAP roles built in PFCG and loaded at logon |
| RuBAC | Rule-based access control | Every request is decided by rules over current facts: a license and its terms, its expiry, consent and region |
| Perimeter login | (not an acronym) | Access decided once at the door (a logon screen, a VPN); inside, the session is trusted |
| Entitlement register | (not an acronym) | The record of who holds which license terms, read by the Worker on every request |
| BYO | Bring your own | A merchant running the stack on their own Cloudflare account or Xano instance |
References
- App security updates, October 2026 (Shopify changelog)
- IP allowlists are now required for public apps (Shopify changelog)
- App security updates: IP allowlist is now required (Shopify changelog: the enforcement dates)
- Offline access tokens
- Implement token exchange (migration and refresh)
- Google: Using OAuth 2.0 to access Google APIs (token lifetimes, refresh token expiration)
- Google: OAuth 2.0 for server-to-server applications (service accounts)
- Access tokens: lifetimes, refresh and rotation
- Use expiring offline access tokens
- Migrate to expiring offline access tokens
- Application-only access tokens (client credentials) (accepted algorithms: RS256, ES256)
- Authenticate an app for stores in your organization (client credentials grant)
- Cloudflare API Shield: mTLS
- Cloudflare Workers: mTLS binding
- rustls:
WebPkiClientVerifier - Restrict API access to your IP addresses
- IP allowlist (Dev Dashboard)
- App configuration:
network_access - Expiring offline access tokens required for new public apps starting April 1st (Shopify community)
Parsing at the gate: Shopify and Webflow
Shopify and Webflow apps send the same kinds of data (customers, products, content, events) in different shapes. When both share one Cloudflare Worker as the gating endpoint, the Worker does the same five things to every request before anything reaches Xano, BigQuery or Basin:
Shopify Webflow
webhooks · app proxy · Web Pixel webhooks · Data API · site custom code · Designer Extension
│ │
└───────────────┬─────────────────────┘
▼
Cloudflare Worker (one gating endpoint)
1. verify the signature (HMAC), the timestamp, the shop or site
2. parse into a typed Rust struct (compiled to WebAssembly)
3. normalise ISO 3166 codes, UTC timestamps, money as micros, IDs as GIDs
4. decide consent and purpose from the ledger, through the release gate
5. record an idempotency key and a receipt, then forward
│
▼
Xano (system of record) · Basin Pipelines (events) · BigQuery (Google joins)
The rule from Function gating across clouds applies: steps 2 to 4 are one Rust crate, not a parser per app. The ECC side of the book already works this way; Shopify and Webflow are two more inputs to it.
Where each app’s data comes in
| App surface | What arrives | How it’s verified | Parsing notes |
|---|---|---|---|
| Shopify webhooks | JSON for orders, customers, products, refunds; the GDPR topics (customers/data_request, customers/redact, shop/redact) | X-Shopify-Hmac-Sha256 over the raw body | Payloads are REST-shaped: a numeric id plus admin_graphql_api_id (the GID). Keep the GID. Delivery is at least once and can arrive out of order: deduplicate on the webhook ID |
| Shopify app proxy | Storefront requests forwarded from /apps/… to the Worker | A signature query parameter (HMAC over the other parameters) | Shopify strips cookies on the proxy; the shopper arrives as logged_in_customer_id and shop, not as a session cookie |
| Shopify Web Pixel | Standard customer events: page_viewed, product_viewed, product_added_to_cart, checkout_started, checkout_completed | Runs in Shopify’s sandbox; posts to the Worker | Shopify applies its Customer Privacy API before the pixel runs; the gate records the consent the pixel ran under, it doesn’t override it |
| Shopify Functions | Discount, delivery and checkout logic, in WebAssembly | Runs inside Shopify | No network calls. A Function can’t ask the gate; the gate’s decision has to be written beforehand (to a metafield the Function’s input query reads) |
| Shopify Admin GraphQL | Products, variants, markets, translations, on request | App access token | camelCase fields, GIDs, MoneyV2 (amount as a decimal string, currencyCode) |
| Webflow webhooks | Form submissions, CMS item changes, site publish | x-webflow-signature (HMAC) with x-webflow-timestamp; reject stale timestamps | Retries on failure: deduplicate on the item ID and timestamp |
| Webflow Data API | CMS items, locales, assets | Site or app token | fieldData is keyed by each field’s slug; option fields return option IDs, reference fields return item IDs, rich text is HTML, images are {fileId, url, alt}; isDraft, isArchived, lastPublished decide what’s live; each locale is its own item version (cmsLocaleId) |
| Webflow site custom code | One tag in the head that loads the islands and the consent check | Served by the Worker | Webflow has no consent API of its own: the edge banner and the Worker’s session decision are the consent layer |
| Webflow Designer Extension | The designer’s app inside the Designer | Webflow’s extension auth | Reads classes, data-* attributes and components: the same contract Beautiful Soup reads from an export (see What is ABAP?) |
One record from three shapes
The same product, as each source sends it, and as the gate writes it:
| Field | ECC | Shopify | Webflow CMS | After the gate |
|---|---|---|---|---|
| ID | MATNR 000000000000012345 | gid://shopify/Product/9001 (webhook: id: 9001) | Item ID 64f…, slug heated-mat-queen | Product key from the Xano crosswalk, with all three kept |
| Title | MAKT-MAKTX per language key | title, translations per locale | fieldData.name per cmsLocaleId | Text per BCP 47 locale |
| Price | KONP-KBETR 129.00, KONWA USD | MoneyV2 {"amount": "129.0", "currencyCode": "USD"} | A number field, currency implied by the site | {amountMicros: 129000000, currency: "USD"} |
| Updated | DATS + server local time | ISO 8601 UTC | lastUpdated ISO 8601 | UTC with a sequence number |
| Live? | LVORM deletion flag | status ACTIVE / DRAFT / ARCHIVED | isDraft, isArchived | One status enum |
Gaps the shared endpoint has to cover
| Gap | Why | What the gate does |
|---|---|---|
| Shopify Functions can’t call out | No network access inside a Function | Writes the decision ahead of time where the Function reads it; a stale decision expires |
| Out-of-order webhooks | Both platforms retry; an update can arrive after a newer one | Compare the source’s timestamp with the stored one; the newer wins, the older is receipted and dropped |
| Two sources of consent | Shopify’s Customer Privacy API on the storefront, the edge banner on Webflow | One ledger subject per person; both decisions recorded with their source and banner version |
| No cookie on the app proxy | Shopify strips it | Session tied by the signed logged_in_customer_id or a signed token, never a cookie |
| Webflow fields keyed by slug | A designer renaming a field’s slug breaks a parser that hard-codes it | Map slugs in one place (the crosswalk), fail the build or the request loudly on an unknown slug |
| Drafts and locales | Webflow and Shopify both hold unpublished and per-locale versions | Only published, current-locale versions forward; drafts never leave |
| Personal data in events | Form submissions and checkout events can carry names and e-mails | Pseudonymise before Basin; personal data goes to Xano only, under the gate |
The rule: one endpoint, one parser, one ledger. Shopify and Webflow keep their own surfaces; the Worker verifies, parses into the same typed record, and asks the same gate, so a product, a person or a consent decision means the same thing whichever app sent it.
One Rust crate, layered into WebAssembly: ownership, Javy and conditional loading
The gate’s rules live in one Rust crate (src/release_gate.rs: decide(destination, subject, rows) -> Decision). The
same crate can be compiled into each layer that has to apply them, including a Shopify Function, which can’t call the
gate itself. What makes that safe is Rust’s ownership model; what makes it cheap is loading each piece only where and
when it’s needed.
Ownership, in one paragraph
In Rust every value has exactly one owner. Other code can borrow it, either read-only (many at once) or to change it (one at a time), and the compiler checks both rules before the program runs. When the owner goes out of scope the value is freed. There is no garbage collector, so a WebAssembly module built from Rust carries no runtime to manage memory: it is small, starts fast and behaves the same on every run. Two classes of bug that matter when parsing untrusted input, reading freed memory and two writers changing the same data, can’t compile.
The model maps onto the gate. One owner per decision: the Worker owns it, writes it once, and every other layer only borrows a read-only copy. The same rule in the type system is the same rule in the architecture.
The layers
| Layer | Build target | Who loads it, and when | Network | What it does with the decision |
|---|---|---|---|---|
| Cloudflare Worker (the gate’s endpoint) | WebAssembly for Workers, through workers-rs / wasm-bindgen | Bundled at deploy; your code decides per request which routes instantiate it | Yes | Owns it: reads the ledger, calls decide, writes the result |
| Shopify Function (discount, delivery, checkout validation) | WebAssembly (WASI), built by the Shopify CLI | Shopify runs it, only when that function is active for the shop and the cart or checkout reaches it | None | Borrows it: reads the decision the Worker wrote to a metafield, through the Function’s input query |
| Browser island | WebAssembly, wasm-bindgen | The Worker adds its tag to the page only after the session’s consent decision | Through the Worker | Uses it for display only (a price preview, a converter); never decides |
| Native and Python | Native binary; Python extension (PyO3) | Batch jobs, the design pipeline | Yes | Reads it, never writes consent |
Rust or Javy for a Shopify Function
Shopify Functions can be written in Rust or in JavaScript. JavaScript Functions are compiled with Javy, a Bytecode Alliance project started at Shopify, which builds a WebAssembly module that runs your JavaScript inside an embedded JavaScript engine (QuickJS).
| Rust | JavaScript through Javy | |
|---|---|---|
| What’s in the module | Your compiled logic only | Your script plus a JavaScript engine to run it (Javy can link the engine separately to keep the module small) |
| Memory | Ownership, decided at compile time; no garbage collector | The engine’s garbage collector, inside the module |
| Size and speed | Smaller and faster for the same logic | Larger, and more instructions per run |
| Shopify’s limits | Further from Functions’ size, memory and instruction limits | Closer to them as the logic grows |
| Reuse in other layers | The same crate as the Worker and the batch tools | The same JavaScript can run in a Worker directly, but not in the Rust core |
| Best for | Rules shared with the gate; anything heavy (many cart lines, pricing, parsing) | Small, Function-only logic a JavaScript team owns |
Shopify publishes the current Function limits and recommends Rust where performance matters; check them before choosing. For this layer the deciding point is reuse: a Rust Function reads the decision with the same type the Worker wrote it with, so the two can’t drift.
The decision as a shared type
The Worker serialises a decision with an expiry; the Function deserialises it with the same struct and refuses one
that’s stale. A sketch, built on the crate’s existing Decision:
#![allow(unused)]
fn main() {
use serde::{Deserialize, Serialize};
/// Written once by the Worker (the owner) to an app metafield; read-only everywhere else.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PublishedDecision {
pub destination: String, // e.g. "member_price", "audience"
pub allowed: bool, // release_gate::Decision.allowed
pub reason: String, // release_gate::Decision.reason
pub rule_version: u32, // which version of the rules decided it
pub expires_at: i64, // Unix seconds; after this the decision is not trusted
}
impl PublishedDecision {
/// Borrows `self` read-only: checking a decision never changes it.
pub fn is_current(&self, now: i64) -> bool {
now < self.expires_at
}
}
}
In the Function, a missing, unreadable or expired decision falls back to the safe default for its purpose: deny for anything that grants a member price, a discount tied to consent or an audience; ignore (proceed normally) for anything that is part of fulfilling the order. The time the Function compares against has to come from its input, since a Function has no network and no clock of its own to trust.
Conditional loading, server side
Loading each piece only where it is needed keeps every layer small and keeps decisions where they belong:
- In the Worker, the module is bundled at deploy, but it doesn’t have to run on every request. Instantiate the Rust core only on routes that parse or decide (webhooks, the app proxy, exports), keep it for the isolate’s lifetime, and let static pages skip it.
- For the browser, the Worker decides on the server which island tags to add (HTMLRewriter), after the consent check. A visitor who hasn’t consented never downloads a module they aren’t allowed to run. That’s the same consent-first rule as What is ABAP? → islands, applied to WebAssembly.
- For Shopify Functions, Shopify does the loading: a Function runs only when it is active for the shop and the cart or checkout reaches it. What you control is its input: the input query asks only for the fields and the metafield the decision needs, so the Function reads less and runs fewer instructions.
The rule: one crate, one owner per decision. The Worker owns and writes; Shopify Functions, browser islands and batch tools borrow and read; each layer loads the module only when its route, its consent state or Shopify’s activation needs it.
Bringing security and data in house
Introduction: layers of security, not just login
SAP, WordPress and Magento all secure data the same way: at sign-in, by role. Once a user is signed in, their role decides what they can do, and nothing is checked again.
| System | Role model | Checked | What it doesn’t cover |
|---|---|---|---|
| SAP ECC / S/4HANA | Roles built in PFCG from authorization objects (S_TABU_DIS for tables, F_KNA1_BUK for customers by company code) | At login and when a transaction starts | Data read through RFC, IDoc or a direct database connection. A role with table access sees every row in clear text |
| WordPress | Roles and capabilities (administrator, editor, current_user_can('edit_posts')) | At login, then per action against the role | Any plugin with database access, and the wp_users / wp_usermeta tables in a database dump |
| Magento / Adobe Commerce | Admin roles with ACL resources (Magento_Customer::manage), plus integration tokens | At admin login and per controller | Customer and order tables are readable by any extension, any integration token with the resource, and any copy of the database |
Login is a door, not a vault. If one session is stolen, one token leaks, one plugin is compromised or one database dump is copied, every row that role could see is exposed. Penetration tests and breach reports on all three platforms come back to this point: the role was right, but nothing checked the request or the data after sign-in.
The layers in this chapter reinforce the login rather than replace it. Each one checks something different, so a failure in one is caught by the next:
1 Edge WAF rules, rate limits, Turnstile → is this a person, from a sane place, at a sane rate?
2 Request HMAC signature, session-token JWT → did Shopify / Webflow / our own app really send it?
3 Login + role SAP role, WP capability, Magento ACL, → who is this, and what may their role do?
CRM Sync entitlement
4 Rule RuBAC: consent, region, purpose, time → may THIS action happen to THIS record, right now?
checked on every change, not once
5 Row per-row encryption (kid), signature, → if the database leaks, is each row still unreadable,
hash chain and is any edit detectable?
- Rules (layer 4) are role-based access turned into rule-based access: the decision is made for each request and each record, using facts the role can’t know, such as this customer’s consent, this market’s law and this export’s purpose. See RuBAC compared with perimeter login.
- Row-based encryption (layer 5) means each sensitive row is encrypted with a data key named by its
kid, and signed and chained to the row before it. An administrator, an integration or a database dump without the key gets ciphertext. A changed row breaks the chain. Rotating a key re-encrypts rows a batch at a time, without taking the table offline. The Xano examples below (consent_records,entitlement_signing_keys, JWE) are this layer.
SAP, WordPress and Magento keep their own logins and roles. The layers sit in front of them (edge, request) and behind them (rule, row), so a stolen login alone no longer reaches the data.
Keys at every layer
Every gate in this book trusts one thing: a key. This chapter lists the keys in the CRM Sync stack and what each one signs or proves, along with where it is kept, how it is checked and how it rotates. It covers Xano’s working examples, the signing keys Shopify and Webflow use for apps and Designer Extensions, and the Cloudflare layer in front of them all (Workers, Turnstile and the WAF).
Visitor / bot Cloudflare edge Apps and systems of record
───────────── ───────────────────────────────── ──────────────────────────
browser form ──▶ WAF rules ─▶ Turnstile ─▶ Worker ──▶ Xano (env keys, signed ledger)
Shopify ──▶ webhook HMAC / session token JWT ──▶ Shopify Admin API (IP allowlist)
Webflow ──▶ webhook signature / Designer idToken ─▶ Webflow Data API (site token)
└── each hop checks a key; none of them reuses another's ──┘
Three rules hold throughout. A key is generated, not typed (openssl rand -hex 32 or the platform’s own
“create secret”). It lives in one secret store per runtime: Worker secrets, Xano environment variables, or the
platform’s dashboard. It is recorded by fingerprint only: no key value appears in this book, in a log or in chat.
Working examples in Xano
Each technique, and where it runs in the CRM Sync workspace (workspace 4).
| What it shows | Where |
|---|---|
| HMAC-SHA256 with a key from the environment | ads_export/record_conversion and rebuild_audiences (functions 122, 123): order_id|hmac_sha256:$env.ADS_HMAC_KEY |
| SHA-256 hashing for Google matching | ads_export/rebuild_audiences: $email|sha256 |
| A shared secret that fails closed, split by scope, with Basic auth decoded | ads_export/authorize (function 126): base64_decode, separate read and write keys, a 32-character minimum, refused if the two keys match |
| A rate-limited rebuild | POST /rebuild refuses a second run within 10 minutes with HTTP 429 |
| JWE decryption | API group SamsungPay (69): decrypts the wallet’s payment credential and never stores or logs the plaintext |
| EdDSA signing keys and rotation | Tables entitlement_signing_keys (192) and entitlement_keys (191) |
| Signed, hash-chained records | consent_records (183): record_hash, prev_hash, kid, and an EdDSA JWS signature on every new row |
| A secret-gated release check | release_gate (function 115, API group 76) using env RELEASE_GATE_SECRET |
The key matters more than the function. Xano’s
encrypt,decryptand JWE use a key you supply, so generate it withopenssl rand -hex 32or Xano’s “Create secret key” and keep it in an environment variable. Randomness and custody decide the strength, which is what the eMudhra certificate failure showed.Live and verified on 31 October 2026: the read key returns the CSV (HTTP 200) and the write key is refused on it (403). The read key is refused on a rebuild (403), the first rebuild runs (200), and a second within 10 minutes is refused (429). Consent-record signatures and the Samsung Pay JWE path are live.
Function, table and API group numbers are workspace identifiers, not credentials.
Which kind of key: platform-issued or in-house owned
Keys in this stack come from two places, and the difference decides who can rotate or revoke them.
| Kind | Examples | Who owns it | What it proves |
|---|---|---|---|
| Platform-issued | Shopify app client secret, Webflow app client secret, Webflow site API token, Turnstile secret key | The platform. It issues the key and can rotate or revoke it | That a request came from Shopify, Webflow or Cloudflare, or is allowed into their APIs |
| In-house owned: a Consulting Team Purchase / Attestation | The EdDSA entitlement signing key (entitlement_signing_keys, 192), the consent-ledger signature (consent_records, 183), ADS_HMAC_KEY, RELEASE_GATE_SECRET | You. Generated in your own Xano and Worker, never handed to a platform | That your system granted something: a capability, a consent, a release |
The signing key behind a capability is the in-house kind. When a team, such as a consulting team working for a
brand, buys a capability, the purchase is the grant. The Worker records it in the team’s entitlement and signs it with
the in-house EdDSA key, under a kid. That signed grant is an attestation: anyone holding the public key can check
it, and no platform can forge, rent or withdraw it. Rotating the key adds a new kid; grants already signed keep their
old kid and still verify (entitlement_keys, 191).
Example: Channel managers. Channel Publish is bought this way. Minting a tracked link or QR code requires a signed-in account that holds the Channel Publish capability. Every mint and every scan lands in the buyer’s own ledger, never a third party’s. The team’s channel managers publish under a grant the team owns, attested by an in-house key, not a key rented from a link or QR service.
Signing keys for Shopify apps and extensions
One Shopify app has one client secret (the “API secret key” in the Dev Dashboard), and Shopify uses it to sign four different things. Public apps that sign in as themselves add a second key pair, covered in Signing in as the app.
| What Shopify signs | Header or field | Algorithm and encoding | How the Worker checks it |
|---|---|---|---|
| Webhooks (orders, customers, GDPR topics) | X-Shopify-Hmac-Sha256 | HMAC-SHA256 over the raw body, base64 | verifyShopifyHmac: recompute over the body as received, then compare in constant time. Parse the JSON only after it passes |
| Session tokens from the admin, checkout and Thank you page UI extensions | Authorization: Bearer <jwt> | JWT, HS256, signed with the client secret; expires after one minute | verifyToken(tok, appSecret), then dest must equal the shop and aud the app’s client ID. A token proves the shop, not the buyer: the Thank you page handler reads the order’s own customer from Shopify (handleCheckoutAdsConsent) |
| OAuth install callback | hmac query parameter | HMAC-SHA256 over the other parameters, sorted, hex | Check before exchanging the code; reject a shop that isn’t *.myshopify.com |
| App proxy requests from the storefront | signature query parameter | HMAC-SHA256 over the sorted parameters joined with no separator, hex | Check on every proxied request; the proxy adds logged_in_customer_id, which is only trustworthy after this check |
| Client credentials assertion (public apps, no merchant present) | client_assertion | RS256 or ES256 key pair; Shopify holds the public key | Signed by the app, verified by Shopify; never EdDSA |
Rotation. Rotating the client secret in the Dev Dashboard gives a new secret before the old one is revoked. For
that window, hold both in the Worker (SHOPIFY_APP_SECRET and SHOPIFY_APP_SECRET_PREVIOUS), accept a signature that
matches either, then delete the old one once it’s revoked. A per-tenant secret in KV rotates the same way, one tenant at
a time.
The same check in Rust, for a gate compiled once and run in a Worker or a native service (see One Rust crate, layered into WebAssembly):
use base64::{engine::general_purpose::STANDARD, Engine};
use hmac::{Hmac, Mac};
use sha2::Sha256;
/// Shopify webhook: HMAC-SHA256 of the raw body, base64. Tries the current secret, then the
/// previous one while a rotation is in progress. `verify_slice` compares in constant time.
pub fn shopify_webhook_ok(raw_body: &[u8], header_b64: &str, secrets: &[&str]) -> bool {
let Ok(expected) = STANDARD.decode(header_b64.trim()) else { return false };
secrets.iter().filter(|s| !s.is_empty()).any(|secret| {
let mut mac = Hmac::<Sha256>::new_from_slice(secret.as_bytes()).expect("any key length");
mac.update(raw_body);
mac.verify_slice(&expected).is_ok()
})
}
Signing keys for Webflow apps and Designer Extensions
A Webflow Data Client app (OAuth) has a client ID and client secret. A Designer Extension runs inside the Designer as an iframe with no secret of its own, so anything it sends has to be proved some other way. A site API token is a bearer token for one site, and it signs nothing.
| Key | What it signs or proves | How the Worker checks it |
|---|---|---|
| App client secret | Webhooks from an OAuth app: x-webflow-signature is HMAC-SHA256 (hex) over `${x-webflow-timestamp}:${rawBody}` | verifyWebflowSignature: refuse a timestamp more than 5 minutes old (replay), recompute, compare in constant time |
| Designer Extension ID token | Which Webflow user is in the Designer: webflow.getIdToken() returns a short-lived JWT | Send it to the Worker; the Worker calls POST https://api.webflow.com/v2/token/resolve with the app’s access token and gets the user back. The extension never holds a reusable key |
| Site API token (Site settings → Apps & Integrations → API access) | Calls into the Data API for one site; signs nothing | Keep in Worker secrets, never in the extension or a page. Revoke any token that hasn’t been used recently |
| Site webhooks created with a site token | Not signed. No signature header is sent | Treat as unverified: re-read the item from the Data API by ID before acting, rather than trusting the payload |
The gap in the Design Auth extension today. It asks for an admin key or a crm_t_… tenant token and sends it as a
bearer token on every call. The token is scoped to one brand and isn’t saved when you sign out, but it is still a
long-lived key typed into a browser. Moving to webflow.getIdToken() plus /v2/token/resolve replaces it with a
token that expires within minutes and names the user. The Worker then maps that user to a tenant and its entitlements,
the same way the sign-in page does.
/// Webflow webhook: hex HMAC-SHA256 over "timestamp:body", refused if older than five minutes.
pub fn webflow_webhook_ok(raw_body: &str, sig_hex: &str, ts_ms: i64, now_ms: i64, secret: &str) -> bool {
if secret.is_empty() || (now_ms - ts_ms).abs() > 5 * 60 * 1000 { return false; }
let Ok(expected) = hex::decode(sig_hex) else { return false };
let mut mac = Hmac::<Sha256>::new_from_slice(secret.as_bytes()).expect("any key length");
mac.update(format!("{ts_ms}:{raw_body}").as_bytes());
mac.verify_slice(&expected).is_ok()
}
One Worker, the same for every platform
The Worker in front of a Webflow site is the same Worker as the one in front of a Shopify store, and the same one
in front of Magento, WordPress, Drupal or a Next.js, Astro or Vue app. It has the same code, deploy, secret store and
edge rules. The theme loads the same way too: the Worker is the route in front of the site, so it adds the same
consent, Turnstile and behaviour scripts to every page through HTMLRewriter, whatever the theme or CMS. No platform
plugin has to carry the security; the platform keeps its own login and roles (layer 3), and the Worker adds the rest.
| Platform | Where the Worker sits | How a request is proved | Tenant key | Theme |
|---|---|---|---|---|
| Shopify | Route in front of the storefront domain; app and webhook endpoints | Webhook HMAC, session token JWT, app proxy signature | Shop domain | Liquid theme or Hydrogen; scripts added at the edge |
| Webflow | Route in front of the published site; Webflow Cloud apps run on Workers | Webhook signature, Designer Extension ID token | Site ID | Webflow design output; scripts added at the edge |
| Magento / Adobe Commerce | Route in front of the storefront; webhooks and integration calls go to the Worker | Its webhook signature or a shared secret, checked in the Worker; the admin integration token stays in Worker secrets | Store / website code | Luma or Hyvä theme unchanged; scripts added at the edge |
| WordPress / WooCommerce | Route in front of the site; WooCommerce webhooks go to the Worker | WooCommerce’s webhook signature (HMAC-SHA256, base64), or a shared secret for custom hooks | Site domain | Any theme; scripts added at the edge, no security plugin required |
| Drupal / Drupal Commerce | Route in front of the site | A shared-secret HMAC from the sending module | Site domain | Any theme; scripts added at the edge |
| Next.js, Astro, Vue (Nuxt) | The app can run on Workers itself (OpenNext for Next.js, the Cloudflare adapter for Astro, Nitro for Nuxt), or the Worker sits in front | The app’s own session, plus the same signed-request check for anything machine-to-machine | Domain or app ID | The app’s components; the same scripts, loaded the same way |
What changes from one row to the next is only how the request is proved. That is one match arm in the gate. The
edge rules, the tenant config, the Xano release gate, the consent ledger and the in-house attestations are shared.
Adding a platform means adding one arm, not another security stack.
Same head and footer code, same function
In the browser, a Webflow page and a Shopify page are both just HTML. If the head and footer code is identical, the same script loads from the same Worker URL and runs in the same browser runtime, and the function behaves the same on either platform.
| Webflow | Shopify | |
|---|---|---|
| Head | Site settings → Custom code → Head code (or per page) | theme.liquid before </head>, or an app embed block |
| Footer | Site settings → Custom code → Footer code | theme.liquid before </body>, or an app embed block |
| The line (example path) | <script src="https://<your-worker>/stack.js" data-tenant="…" defer></script> | The same line |
Keep the head and footer to that one loader line. The Worker serves the code behind it, so a change ships once to every platform, with nothing to re-paste. WordPress, Magento, Drupal and a Next.js, Astro or Vue app load the same line in their own head and footer.
What still differs is what the script finds on the page. Each difference is a small check inside the same script, not a second script:
- Platform objects: Shopify has
window.Shopifyand the Customer Privacy API for consent; Webflow hasWebflowand no built-in consent API. - Markup: class names, form markup and where product data sits.
- Forms: a Webflow form posts to Webflow (with Turnstile built in), a Shopify form posts to Shopify. A form that posts to the Worker behaves the same on both.
Where identical head and footer code doesn’t reach:
- Shopify checkout doesn’t run theme head or footer code. There, the restricted blocks take over: checkout UI extensions for the screen, Shopify Functions for the decision (see Stack, heap and runtime).
- Server-side work, meaning signatures, keys, R2 and the ledger, stays in the Worker.
So there are three layers: the browser layer is one script, loaded the same way everywhere; the checkout layer is Shopify’s blocks; the server layer is the Worker.
Shopify and Webflow side by side
Compared layer by layer, the two differ only in the format each platform uses to sign a request, and both use HMAC-SHA256 checked in constant time.
| Layer | Shopify | Webflow | Same in the Worker? |
|---|---|---|---|
| Edge | WAF rules, rate limits, Turnstile | WAF rules, rate limits, Turnstile | Yes: one zone, one rule set |
| Request proof | X-Shopify-Hmac-Sha256, base64, over the raw body | x-webflow-signature, hex, over timestamp:body, 5-minute window | Yes: HMAC-SHA256 + timingSafeEqualHex; only the encoding differs |
| App user | Session token (JWT, HS256, app secret): dest = shop | Designer Extension ID token, resolved with Webflow | Yes: a short-lived token, mapped to one tenant |
| Tenant | Shop domain (*.myshopify.com) | Site ID | Yes: the same per-tenant KV config |
| Rule and row | Xano release gate, consent ledger, entitlement attestations | The same | Yes: one Xano system of record |
| Outbound | Admin API, from Cloudflare’s ranges (IP allowlist) | Data API, with the site token from Worker secrets | Yes: both calls leave from the Worker, never the browser |
In Rust, the difference fits in one match; everything after it is shared:
pub enum Platform { Shopify, Webflow /* Magento, WordPress, Drupal, App: one more arm each */ }
/// One gate for every platform. Only how the signature is read differs.
pub fn signed_by_platform(p: Platform, raw_body: &str, headers: &Headers, secrets: &[&str], now_ms: i64) -> bool {
match p {
Platform::Shopify => shopify_webhook_ok(raw_body.as_bytes(), headers.get("x-shopify-hmac-sha256"), secrets),
Platform::Webflow => {
let ts = headers.get("x-webflow-timestamp").parse().unwrap_or(0);
secrets.iter().any(|s| webflow_webhook_ok(raw_body, headers.get("x-webflow-signature"), ts, now_ms, s))
}
}
// Then, for both: resolve the tenant, ask the release gate, write the receipt.
}
Where it differs: stacks that own their compile, data load and encryption
The Worker can sit in front of anything. The difference is behind it. A Gadget app, a React Router 7 + Prisma app or a Firebase-hosted app may end up on the same kind of data store (Postgres, or a document store), but what can compile, load and encrypt that data depends on the file stack: the framework’s build, the ORM’s migrations and the host’s runtime. WordPress plugins work the same way: ACF and WooCommerce compile to their own PHP and write to their own SQL tables, released through their own update and publish system.
| Stack | Compiles with | Data store and how data loads | Encryption depends on | Changing the shape of data |
|---|---|---|---|---|
| Gadget (hosted Shopify app) | Gadget’s build and runtime | Gadget’s Postgres-backed models; Shopify data arrives through Gadget’s sync | Gadget’s field types and environment variables | Model changes are Gadget migrations, on Gadget’s platform |
| React Router 7 + Prisma (Shopify’s app template) | Vite / React Router build | Prisma schema → prisma migrate → the app’s own database | App code and the host’s secret store | ALTER TABLE migrations; rows rewritten in place |
| Firebase Hosting (with Functions or App Hosting) | The framework’s build, deployed by Firebase | Firestore or Cloud SQL, written by Functions | Google’s at-rest encryption, plus app code for fields | Documents overwritten; a new shape means a backfill script |
| WordPress: ACF | PHP, loaded by WordPress on each request | Field values in wp_postmeta; field groups as posts or JSON | The database server, if anything; no field encryption by default | update_field overwrites the previous value |
| WordPress: WooCommerce | PHP, released through plugin updates | Orders in its own tables (HPOS) or wp_posts; schema changes run on plugin update | The database server; payment data stays with the gateway | Plugin-update migrations, on the plugin’s schedule |
| Worker + Xano (in house) | Rust → WebAssembly, or TypeScript, compiled once for every platform | Xano as system of record; the Worker loads through the release gate | Your keys (kid), per row | New version, old one kept: append-only, signed, chained |
Non-destructive data fine-tuning isn’t possible in the first five. Tuning data means refining a field, a mapping, a translation, a consent wording or a price rule. In those stacks a change overwrites the row, or runs a migration that rewrites the table on the stack’s own release schedule. The old value is gone unless a backup is restored. Nobody can show which version a past export, order or decision used, and a migration that goes wrong can’t be undone row by row.
In house, every change is a new version. The Worker and Xano write a new row that names the rule version and the
kid. The old row still verifies, and its hash chain shows the order of edits. The release gate decides which version
each platform reads. Fine-tuning becomes a new version the gate points at, and rolling back means pointing it at the
old one, with no restore and no migration. The platform’s own store still holds its working copy for its pages, but
the record, the keys and the history stay with you.
Stack, heap and runtime: Shopify blocks vs the Worker
“Stack” above means the tech stack: framework, build, ORM and host. In memory terms, the stack and the heap are two areas inside the runtime, and neither is the logic itself:
| Term | What it is | In a Worker |
|---|---|---|
| Runtime | Runs the compiled code and provides its memory | The V8 isolate, with WebAssembly inside it (PHP for WordPress, Node for Firebase Functions) |
| Logic / function | The compiled instructions | verifyShopifyHmac, release_gate, the Rust .wasm |
| Stack | Short-lived memory per function call, freed when the call returns | The frame of shopify_webhook_ok while it runs: flags, lengths, timestamps |
| Heap | Memory that grows as needed and lives as long as its owner | Everything loaded: the request body, an R2 file, parsed CSV rows, a decrypted record |
A decrypted row or a loaded key sits on the heap. In Rust, ownership frees it the moment its owner goes out of scope,
and zeroize wipes the bytes first. In JavaScript or PHP the garbage collector frees it later, unwiped.
A Shopify block is a restricted slot in Shopify’s runtime. A Shopify Function (discounts, delivery and payment customisations, cart and checkout validation) is your logic compiled to WebAssembly and run by Shopify with a small, fixed memory and instruction budget. Theme app blocks and checkout UI extensions are the same idea for the screen: they render in a slot Shopify controls, from a limited set of components, in a sandbox.
| Shopify Function (a block) | The Worker | |
|---|---|---|
| Runtime | Shopify’s, running your .wasm | Cloudflare’s V8 isolate, deployed by you |
| Logic | One function, with a strict size limit | The whole gate: any number of routes and functions |
| Stack and heap | Small and fixed, with an instruction budget per run; exceed either and the function fails and Shopify falls back | Roughly 128 MB per isolate, CPU time you configure |
| Load | Only what the input query asks for; Shopify loads it and hands it in | Anything: R2, Xano, KV, Shopify, Webflow |
| Network | None | Yes |
| Output | Operations Shopify applies: a discount, hide this option, block this checkout | Any response, write or signed receipt |
| Keys | None inside the function | Your secrets and your kid |
The split: the block holds the small, fast decision that must happen inside checkout. The Worker holds everything that needs keys, network, files or history: signatures, the release gate, R2, the ledger. The same Rust crate compiles to both, so the rule is written once (see Rust or Javy for a Shopify Function). Shopify revises the Function limits; check the Shopify Functions reference for current figures before relying on one.
One store for every file type: R2 behind the same gate
Data is one half of bringing things in house; files are the other. Media, docs and Markdown, Rust books, video, responsive source sets, 3D models and any other MIME type can share one R2 resource, behind the same Worker and the same gate. R2 charges no egress fees, and the Worker that reads it runs on the same network, so serving a file to Shopify, Webflow, an app or a buyer adds no cross-cloud transfer charge. That is the egress gap closed for files.
Shopify storefront ─┐
Webflow site ───────┤ ┌─ media/ images, source sets (resized at the edge)
WordPress, Magento ─┼─▶ Worker (one gate) ─▶│ docs/ Markdown, PDFs, Rust books
Next / Astro / Vue ─┤ entitlement, │ video/ MP4, HLS segments (range requests)
Desktop / PWA app ──┘ consent, signature └─ 3d/ glTF / USDZ, encrypted, gated
one R2 bucket · no public access · no egress fee
| File type | Stored as | Served by the Worker as | Gate decides |
|---|---|---|---|
| Media (images) | One original per image | srcset variants resized at the edge (Cloudflare Images) | Public, or by entitlement for a gated asset |
| Source set | The original plus its widths, generated on request | image/avif, image/webp or image/jpeg, chosen by the browser’s Accept | Which widths and formats a page may ask for |
| Docs / Markdown | .md and PDF objects | Rendered HTML, or the raw file | Public docs, or a signed-in reader’s licence |
| Rust books | The built mdBook | Static HTML, CSS and search index | Public, or a client’s private edition |
| Video | MP4 or HLS segments | Range requests (206 Partial Content) | Who may stream, and from which country |
| 3D | glTF, GLB, USDZ, encrypted at rest | Decrypted per request for a buyer, never a copyable public file | The purchase attestation (see 3D Publisher) |
| Any MIME type | httpMetadata.contentType on the object | The stored Content-Type; never guessed from the name | The object’s own metadata, read by the gate |
One resource, one gate, for data and metadata alike. The bucket has no public access and no public r2.dev
URL. Every read goes through the Worker’s R2 binding, so the same check that guards an API call guards a file: the
tenant, the entitlement or purchase attestation, consent, and the signature of the request. Metadata is gated too.
An object’s custom metadata (owner, licence, kid, rule version, GTIN) is read by the gate and only shown to callers
the gate allows, so a file’s existence and its details don’t leak through a listing or a header.
Webflow and Shopify are consolidated. Neither platform keeps its own copy. Shopify Files and Webflow’s asset library each hold a separate copy with its own public URL and permissions, so a file uploaded to both is two files to revoke. Pointing both at the Worker’s URL leaves one file, with one permission and one delete:
| Separate platform stores | One R2 store behind the Worker | |
|---|---|---|
| Copies of a file | One per platform (Shopify Files, Webflow assets, the app’s bucket) | One |
| Who can read it | Anyone with each platform’s public CDN URL | Whoever the gate allows, checked on every read |
| Revoking access | Delete it in each platform, and hope nothing cached the URL | Change the grant once; the next read is refused |
| Egress | Each cloud’s own transfer pricing, plus copies between them | None from R2 |
| Changing a file | Re-upload to each platform | New object version; the gate decides which version each platform reads |
A Webflow image field copies the file into Webflow’s assets when it’s set, so use a link field or an embed pointing at the Worker’s URL to keep the file in R2. In Shopify, reference the Worker’s URL from a metafield or the theme rather than uploading to Files.
/// One gate for every file type: no public bucket, the Worker reads R2 only after the check passes.
async fn serve_file(req: &Request, env: &Env, key: &str) -> worker::Result<Response> {
let bucket = env.bucket("MEDIA")?;
let Some(head) = bucket.head(key).await? else { return Response::error("Not found", 404) };
let meta = head.custom_metadata()?; // owner, licence, kid, rule version
if !gate_allows(req, env, &meta).await? { // tenant, attestation, consent, signature
return Response::error("Not found", 404); // a refused file looks like a missing one
}
let Some(obj) = bucket.get(key).execute().await? else { return Response::error("Not found", 404) };
let ct = obj.http_metadata().content_type.unwrap_or_else(|| "application/octet-stream".into());
let mut res = Response::from_stream(obj.body().expect("body").stream()?)?;
res.headers_mut().set("Content-Type", &ct)?; // the stored MIME type, never guessed
Ok(res)
}
Tools that give you no key: Matrixify, Airtable, SAP and ERP exports
Some tools stay in use even after everything else is in house: a bulk importer, a shared spreadsheet-database, a nightly ERP export. None of them gives the merchant a key. The credentials they run on belong to the vendor or the platform, or there are none at all, as with a CSV file on an SFTP server. The question for each one is whose key it is, and what your own ledger can prove about what it did.
| Tool | Whose key | What is signed | What isn’t | What you can revoke |
|---|---|---|---|---|
| Matrixify (public Shopify app) | The vendor’s. Its client secret, a per-store access token, and its own IP allowlist, all held on its servers | Shopify signs its webhooks, admin session tokens and OAuth hmac with Matrixify’s secret; Matrixify checks them | The import file. A sheet uploaded or pulled from a URL, FTP, Dropbox or Google Drive carries no signature. Changes land in Shopify as overwrites | Uninstalling the app revokes its tokens. Nothing to rotate on your side |
| Airtable | Yours, but a bearer token. A personal access token or OAuth token, scoped to bases | Webhook notifications carry X-Airtable-Content-MAC, an HMAC-SHA256 keyed with the MAC secret returned when the webhook is created | The records. Anyone with edit access to the base changes the data, and the API returns the current value only | The token, in Airtable’s developer hub. Rotate it like any other secret |
| SAP / ERP export (CSV, flat file, IDoc file) | None. A file written to SFTP, a share or a bucket | Nothing, unless the transfer is AS2 (EDI), where S/MIME signs the message, or the SFTP key proves the sender’s server | The file’s content. Anyone who can write to the drop folder can change what gets loaded | The SFTP or share account. The file itself can’t be revoked once copied |
If you keep using them, wrap them. The tool and its key stay as they are. The Worker adds the in-house layers around each run, so your ledger can prove what went in:
- Land the file in R2 first, behind the gate (see One store for every file type), not on a public URL or a shared drive. For an ERP export, the SFTP drop becomes a Worker upload or an R2 bucket the ERP writes to with its own scoped token.
- Fingerprint it and sign the receipt. The Worker computes SHA-256 of the file and writes a ledger row: file
hash, source, job, row count, rule version, signed under your
kid. That is the attestation the tool can’t give. - Check before loading. The release gate checks the file against its schema, consent and market rules. A file that doesn’t match is held, not loaded halfway.
- Hand the tool a short-lived signed URL to that exact object for one run (Matrixify’s scheduled import from a URL, Airtable’s sync, the ERP’s pickup), instead of a standing link anyone could reuse.
- Record the result. The Worker records what the tool reports back (Matrixify’s job result, an Airtable webhook, the ERP’s acknowledgement) against the same receipt. Every value the tool changes can now be traced to one exact file.
| Tool used directly | Tool wrapped by the Worker | |
|---|---|---|
| The file | On a URL, drive or SFTP folder; anyone with access can change it | One R2 object behind the gate, hash recorded before the run |
| Who proves what was loaded | The vendor’s job log, in the vendor’s account | Your ledger: file hash, job, rule version, signed with your kid |
| A bad file | Loaded, then found later; Shopify values overwritten | Held at the gate before the tool reads it |
| Undoing a run | Re-import an older file, if someone kept it | The previous file is still in R2 under its hash; re-run it |
| Leaving the tool | Its history stays with the vendor | Your files and receipts stay with you |
For SAP and other ERPs specifically: an export with no key is the normal case, not a mistake. ECC was never designed to sign a CSV. AS2 adds a signature in transit, but nothing records it once the file lands. Signing the receipt at the gate gives the export the same proof as a signed webhook, without changing the ERP. See SAP to Google over EDI for the IDoc route and a nightly SAP load through a bulk loader for the token side of the same job.
Workers, Turnstile and the WAF
The keys above prove who sent a request. Nothing so far stops a bot from filling in a public form or hammering a sign-in route. Three layers at the Cloudflare edge do that, and they run before the Worker spends any time on a request.
| Layer | Stops | Doesn’t stop | Applies to |
|---|---|---|---|
| WAF (managed rules, custom rules, rate limiting) | Known attack patterns, floods, requests to admin paths from outside | A real browser driven by a script | Everything on the zone, before the Worker runs |
| Turnstile | Automated form posts: sign-up, contact, review, sign-in | A paid human solving it; a valid token replayed within 300 seconds if it isn’t checked server side | Pages a person fills in |
| Worker checks (signatures, session tokens, Siteverify) | Forged webhooks, calls from the wrong shop or site, tokens that don’t verify | Anything the WAF should have stopped first | Each route |
Never put a challenge in front of a machine path. Shopify and Webflow webhooks, the app proxy and Designer Extension calls cannot solve a challenge. Exempt them from Turnstile and challenge rules, and rely on their signatures instead.
Turnstile on a Webflow site
Webflow has Turnstile built in. Under Site settings → Apps & Integrations, the “Cloudflare Turnstile spam protection” switches turn on bot blocking and spam filtering for every native form on the site. No site key is needed, and the site must be republished after either switch changes.
What each setting on this screen does:
| Setting | State | What it means |
|---|---|---|
| Cloudflare Turnstile spam protection: bots | On | Native Webflow forms check a Turnstile token before accepting a submission |
| Turnstile: spam filtering | On | Submissions that pass the bot check are still scored, and spam is kept out of the form inbox. Turn this off if real submissions are being marked as spam |
| reCAPTCHA validation | Off, no keys | Leave off: Turnstile already covers the same forms. Turning it on makes every form without a reCAPTCHA field fail to submit |
| Restrict uploaded file access | On | Files uploaded through forms open only for people logged in to the site (you, a client, collaborators). Turn it off only for an integration that must fetch the file, and know that the files become public |
| API access: CRM-Base | Used within the last week | The site token the CRM Sync Worker uses. Keep it in Worker secrets |
| API access: Config Manager | Last used 4 months ago | An unused token is a key with no owner. Revoke it, or record why it is kept |
| Webhooks | (section below the tokens) | Webhooks added here use the site token and are not signed; see the table above |
Webflow’s built-in Turnstile covers native Webflow forms only. A form that posts straight to a Worker (a review form, the newsletter sign-up, a sign-in page served by the Worker) needs its own widget and its own Siteverify check.
Turnstile on a Worker route
- Create a widget in the Cloudflare dashboard under Turnstile → Add widget, listing the hostnames that will show it
(for example
crm-sync.dev). The dashboard gives a site key (public, goes in the page) and a secret key (private). - Store the secret as a Worker secret, never in a page or
wrangler.toml:npx wrangler secret put TURNSTILE_SECRET_KEY --config wrangler.toml --env="". - Add the widget to the form:
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>and<div class="cf-turnstile" data-sitekey="…" data-action="review-submit"></div>. The widget adds acf-turnstile-responsefield to the form. - In the Worker, call Siteverify before any other work and fail closed:
#[derive(serde::Deserialize)]
struct Siteverify { success: bool, hostname: Option<String>, action: Option<String> }
/// Turnstile Siteverify from a Worker (workers-rs). A token is single-use and valid for 300 seconds;
/// check the hostname and action too, so a token minted for another form or site is refused.
async fn turnstile_ok(token: &str, ip: Option<&str>, secret: &str, host: &str, action: &str) -> bool {
if token.is_empty() || token.len() > 2048 { return false; }
let mut form = vec![("secret", secret), ("response", token)];
if let Some(ip) = ip { form.push(("remoteip", ip)); }
let body = serde_urlencoded::to_string(&form).unwrap_or_default();
let mut init = worker::RequestInit::new();
init.with_method(worker::Method::Post).with_body(Some(body.into()));
let mut headers = worker::Headers::new();
let _ = headers.set("Content-Type", "application/x-www-form-urlencoded");
init.with_headers(headers);
let Ok(req) = worker::Request::new_with_init("https://challenges.cloudflare.com/turnstile/v0/siteverify", &init) else { return false };
let Ok(mut res) = worker::Fetch::Request(req).send().await else { return false };
match res.json::<Siteverify>().await {
Ok(v) => v.success && v.hostname.as_deref() == Some(host) && v.action.as_deref() == Some(action),
Err(_) => false,
}
}
- Test with Cloudflare’s published test keys first (a site key that always passes, one that always fails), then switch to the real keys.
Turnstile setup links: Get started · Client-side rendering · Server-side validation (Siteverify) · Testing keys · Pre-clearance for WAF challenges · Turnstile in the dashboard
WAF rules for the Worker’s zone
These are recommended rules, written in Cloudflare’s rule language; adjust paths to the Worker’s routes. Order matters: exemptions first.
| Rule | Expression | Action |
|---|---|---|
| Machine paths skip challenges | starts_with(http.request.uri.path, "/webhooks/") or starts_with(http.request.uri.path, "/apps/") | Skip: managed challenge and bot rules (signature checks run in the Worker) |
| Admin pages | starts_with(http.request.uri.path, "/admin") | Managed Challenge; the Worker still requires the crm_admin cookie |
| Sign-in and form posts | http.request.method eq "POST" and (starts_with(http.request.uri.path, "/auth/") or http.request.uri.path contains "/reviews") | Rate limit: for example 10 requests per minute per IP, then block for 10 minutes |
| Managed rules | Cloudflare Managed Ruleset (and the OWASP Core Ruleset on paid plans) | Log first for a week, then block |
| Wrong countries for a regime (optional) | ip.src.country in {"…"} and starts_with(http.request.uri.path, "/consent") | Block, only where a residency rule requires it |
Inside the Worker, the Rate Limiting binding ([[ratelimits]] in wrangler.toml) limits by any key the code knows,
such as the shop domain or tenant, not just the IP. That is what keeps one tenant from using up another’s Shopify or Xano
quota, which a per-IP WAF rule can’t do.
WAF links: Custom rules · Rate limiting rules · Managed rules · Workers Rate Limiting binding
The Shopify IP allowlist, seen from the Dev Dashboard
The allowlist is the outbound counterpart to the WAF. It limits where the app’s Admin API tokens can be used from, not who can reach the app. It is set per app in the Dev Dashboard under Settings → IP allowlist.
| Feature on this screen | What it does | For an app on Cloudflare Workers |
|---|---|---|
| Enforcement | Off: the policy is only tested. On: Admin API calls from anywhere else get 403 | Turn on only after Run test comes back clean |
| Always allowed | Dev previews on dev stores, and Direct API access from embedded admin pages | The embedded app’s own browser calls don’t need an entry |
| IP addresses or CIDR ranges | Up to 250 lines; IPv4 /16 or narrower, IPv6 /32 or narrower | Cloudflare’s published ranges, split to fit: 47 entries (see Allowlisting an app that runs on Cloudflare) |
| Networks (ASN) | Allow a provider’s whole network | Leave Cloudflare’s ASN 13335 out: Workers egress has no ASN in Shopify’s lookup, so it blocked every request in testing |
| Limit ASNs to countries | Narrows ASN entries to chosen countries; IP ranges aren’t affected | Not needed when no ASN is listed |
| Test against recent traffic | Replays the policy against 30 days of Admin API calls and lists what would be blocked | Run before each change; a Xano instance calling Shopify directly shows up here first |
This screen is for the dropship reader app, a custom app, which is exempt from the public-app requirement; it is shown disabled for that reason. UCP, Reviews and PIM Sync, the public apps, have the 47 Cloudflare ranges in place and enforcement on.
Where the code is
| Check | Code |
|---|---|
| Shopify webhook HMAC | workers/crm-sync/src/index.ts, verifyShopifyHmac |
| Webflow webhook signature | workers/crm-sync/src/index.ts, verifyWebflowSignature |
| Shopify session token (Thank you page) | workers/crm-sync/src/index.ts, handleCheckoutAdsConsent |
| Constant-time compare | workers/crm-sync/src/index.ts, timingSafeEqualHex |
| Design Auth extension (bearer token today) | extensions/design-auth/src/index.ts |
| Xano ads export, release gate, consent ledger | Workspace 4: functions 115, 122, 123, 126; tables 183, 191, 192; API groups 69, 76 |
Checklist
- Every secret generated, not typed; stored in Worker secrets or Xano env; recorded by fingerprint.
- Shopify: webhook HMAC, session token
dest/aud, OAuthhmacand app proxysignatureall checked in constant time; two secrets held during a rotation. - Webflow: webhooks from the OAuth app (signed), not site-token webhooks; Designer Extension moved to
getIdToken()+/v2/token/resolve; unused site tokens revoked. - Turnstile on every public form: Webflow’s switch for native forms, a widget plus Siteverify for Worker forms.
- WAF: machine paths exempt from challenges; admin challenged; sign-in and form posts rate limited.
- Shopify IP allowlist: Run test clean, then enforcement on, for every public app.
- Key-less tools (Matrixify, Airtable, ERP exports): file landed in R2, hashed and signed under your
kid, checked at the gate, handed over by a short-lived signed URL.
Data layer: ECC, Xano, Shopify and Google Cloud compared with Databricks, Snowflake and Fabric
The data layer in this book is ECC as the source, Xano as the system of record, Shopify as the storefront and Google Cloud (BigQuery, Merchant, Ads) for analytics and activation. Cloudflare Workers carry it at the edge. The usual alternative is a lakehouse or warehouse (Databricks, Snowflake or Microsoft Fabric) fed by ELT tools.
| ECC + Xano + Shopify + Google Cloud | Databricks | Snowflake | Microsoft Fabric | |
|---|---|---|---|---|
| Shopify in | Shopify webhooks to Google Cloud Pub/Sub, then a BigQuery subscription into a table. BigQuery Data Transfer Service also has a Shopify connector, in Preview since 2026-01-28. | Third-party ELT (Fivetran, Airbyte, Rivery, dlt), or Shopify → EventBridge → S3 → Auto Loader | Third-party ELT, or Shopify → EventBridge → S3 → Snowpipe | No native Shopify route: HTTPS webhooks into an Azure Function or Eventstreams, or ELT |
| Real time | Shopify webhooks reach the Worker and Xano in seconds; Pub/Sub reaches BigQuery in near real time | Near real time only through an AWS event route you build | Same as Databricks | Eventstreams, with an intake you build |
| Consent enforced in the pipe | Yes. The Worker verifies the webhook, checks consent and writes the ledger before anything lands. BigQuery gets only changed consent rows (crm_us.consent_log). | Not by default. ELT copies what the API returns; policies apply after the data lands. | Not by default. Masking and row-access policies apply after the data lands. | Not by default. Purview policies apply after the data lands. |
| One consent decision | The release gate in Xano, in front of every Google payload about a person | Built in notebooks or Unity Catalog policies, downstream of the copy | Built with masking and row-access policies, downstream | Built with Purview policies, downstream |
| ECC data in | The Rust converter in this book, from DD03L-shaped exports: typed and tested, no S/4HANA needed | SAP connectors exist; the strongest assume S/4HANA and SAP Business Data Cloud | SAP connectors through partners; the same S/4HANA bias | SAP mirroring and connectors; the same S/4HANA bias |
| Google activation (Merchant, Ads, Customer Match) | Native: Merchant API, Google Ads and BigQuery are all Google, behind the release gate | Reverse-ETL tools (Hightouch, Census) | Reverse-ETL tools | Reverse-ETL tools |
| System of record | Xano for customers, consent and products; the warehouse holds analytics only | The lakehouse tends to become the record | The warehouse tends to become the record | OneLake tends to become the record |
| Residency | Per-market BigQuery datasets (crm_us first); Xano instances per region | Per workspace region | Per account region | Per capacity region |
| Cost shape | Workers, a Xano plan, BigQuery storage and queries: small to start | Compute clusters plus ELT seats | Credits plus ELT seats | Capacity units plus ELT seats |
| Where it wins | Shopify and Google merchants, ECC shops without S/4HANA, consent-first commerce | Heavy ML, data science teams, large-scale Spark | Enterprise BI, data sharing, an existing Snowflake contract | Microsoft-standard enterprises: Power BI, Entra, Purview |
One typed record, any destination
The converter turns ECC rows into Rust types once, with Serde derives on every struct. After that, the destination is a
serializer, not a new integration: the same Product or customer record is written as whatever the target reads.
| Destination | Format | Today |
|---|---|---|
| Google Merchant API v1 | JSON (productInputs) | Built: src/merchant_api.rs, tests/merchant_api.rs |
| Merchant feed file | The specification’s names and text | Built: src/merchant.rs |
| Xano | JSON records and CSV uploads | Built: xano-buildout |
| GraphQL | schema.graphql from the same map | Built |
| BigQuery | JSON rows (insertAll) or Pub/Sub messages | Through the CRM Sync Worker |
| Databricks, Snowflake, Fabric | Parquet or Iceberg | Proposed: needs the Arrow / Parquet crates |
| Kafka, Pub/Sub, EventBridge | JSON or Avro messages | Proposed |
What stays fixed whatever the destination: names come from lib/naming.js, types from the DDIC (NUMC keeps its leading
zeros, DATS 00000000 is None, amounts keep their scale), and the tests fail if a field goes missing. What doesn’t
change either: any record about a person passes the release gate first. A new destination is a new output, never a way
around consent.
Feeding the other three, governed
None of the three gets a consent-checked Shopify feed out of the box: ELT tools copy whatever the Admin API returns, and EventBridge or Pub/Sub deliver every event whatever the person’s consent. The same Worker intake can feed them, so a Databricks, Snowflake or Fabric shop keeps its warehouse and gets a governed Shopify feed:
Shopify webhook ─▶ Cloudflare Worker (verify HMAC, enforce consent, write ledger) ─▶ Xano (system of record)
└─▶ Parquet / Iceberg in R2 or the client's S3
└─▶ Databricks · Snowflake · Fabric · BigQuery
Today the Worker streams to Xano and BigQuery only. The Parquet / Iceberg export is proposed, not built. Cloudflare R2 can serve Iceberg tables through its catalog, which Snowflake and Databricks both read, so the export needs no new storage.
Cloudflare Basin compared with BigQuery
Cloudflare’s lake (now Basin: Basin Pipelines, Basin Catalog and Basin SQL, formerly Pipelines, R2 Data Catalog and R2 SQL) is open storage and a catalog at the edge, with no egress fees and a read-only query engine. BigQuery and the three platforms above are compute platforms: they write, transform, run ML and apply fine-grained access rules.
| Cloudflare Basin (R2 + Iceberg) | BigQuery | |
|---|---|---|
| Storage | Parquet in R2, with an Iceberg REST catalog any Iceberg engine can read | Native storage; BigLake Iceberg tables and external tables as options |
| Ingest | Basin Pipelines: streaming events with SQL transforms, fed straight from Workers | Data Transfer Service connectors (Shopify, YouTube, Merchant Center, Ads), streaming, loads |
| Query | Basin SQL: distributed, read-only (Apache DataFusion); no Workers binding, queried by fetch() | Full SQL with DML, BigQuery ML, Gemini |
| Writes | Pipelines, or an external engine (PyIceberg, Spark) | INSERT, MERGE, UPDATE |
| Egress | None on R2 | Charged when data leaves Google Cloud |
| Fine-grained access | Token scope per bucket and catalog; no row-level security or column masking | Row-level security, policy tags, dynamic masking |
| Residency | Bucket jurisdiction (R2 has an EU jurisdiction); check the catalog and query engine follow it | Regional and multi-region datasets |
| Maintenance | You enable compaction and snapshot expiry; file count drives query time | Managed |
What each is for in this layer
| Job | Better fit |
|---|---|
| Edge events, consent and gate receipts, cheap long-term logs | Basin |
| Shopify, YouTube, Merchant and Ads joins, segments, BigQuery ML | BigQuery |
| One open copy of ECC extracts, read by several engines without egress | R2 and Iceberg |
| Heavy transforms and an enterprise catalog | Databricks or Snowflake |
Two consequences:
- Basin has no column or row policies, so the release gate does that job. Keep personal data out of Basin, or pseudonymise it before Pipelines writes it: cohorts, receipts and hashed keys, not identities. See Function gating across clouds.
- BigQuery doesn’t read R2 directly, as far as the current docs show (BigQuery Omni covers AWS S3 and Azure). Data for BigQuery is copied to Google Cloud Storage or loaded; Snowflake and Databricks read R2 through its S3-compatible API.
Basin was renamed recently and its docs are mid-migration: check pricing, limits and jurisdiction support on developers.cloudflare.com before quoting them.
Reading the table fairly
- “Not by default” is not “can’t”. Each of the three can enforce policies once data has landed. The difference is where: here the check runs before anything is copied, and the ledger records why.
- The ECC row is where this layer differs most. The other three platforms’ SAP paths mostly assume S/4HANA; this one works from ECC as it runs today. See An alternative to a full S/4HANA upgrade.
- BigQuery’s own Shopify connector is in Preview; Fivetran and others list generally available connectors on the Google Cloud Marketplace. Sources: Load Shopify data into BigQuery, BigQuery release notes.
ERP programmes in public: penalties and lessons
Six companies whose SAP programmes are on the public record, with what each cost where it was reported. Only one is a clean case of an SAP rollout hurting the business. The others are a non-SAP add-on, a supply-network merger, two licence disputes over how other systems reached SAP data, and a consent fine with no ERP failure. Each has a lesson for a layer like the one in An alternative to a full S/4HANA upgrade.
| Company | Where it failed | SAP programme | What happened | Penalty or cost (as reported) | Lesson for an ECC → Xano layer |
|---|---|---|---|---|---|
| Revlon | E-commerce and channels: orders the ERP couldn’t fill | SAP rollout at its Oxford, North Carolina plant, 2018 | Failure. Production and shipping were disrupted; a material weakness in financial reporting was disclosed, and the share price fell. | About $54M in expenses to remedy the disruption, including about $10M in incremental production and labour costs; a shareholder class action alleges about $64M of net sales went unfulfilled. | The ERP cutover reached customers. Keep commerce and feeds off the ERP’s critical path at go-live. |
| Nike | Global channels: demand forecast wrong, too much of some shoes and too little of others | SAP as the ERP backbone, with i2 for demand planning, 2000–2001 | Failure, in the i2 add-on, not SAP. Nike moved its short- and medium-range planning into SAP afterwards. | $80M to more than $100M in lost sales; the share price fell about 20%; class actions followed. | Often misquoted as an SAP failure. A rushed, customised layer beside the ERP can fail on its own: build the layer to fixed, tested rules. |
| Coty (Kylie Cosmetics) | Global: warehouses and planning consolidated across Europe and the US | Integrating about 40 P&G beauty brands, 2016–2019 | Supply-chain disruption. Coty attributed it to consolidating warehouses and planning centres; no source found blames SAP. | About $150M hit from the disruptions (reported 2019). | Kylie Cosmetics, launched on Shopify in 2015 and 51% bought by Coty for $600M in 2019, ran on its own. The trouble came when back-end operations were consolidated: keep the storefront’s record separate from the ERP merger. |
| Diageo | Governance: other channel systems reaching SAP data | RISE with SAP S/4HANA, a five-year programme with IBM from 2023 | In progress, not a failure. Earlier, in SAP v Diageo (2017), the UK High Court held that Diageo’s Salesforce-based systems accessing SAP data needed SAP licences (“indirect access”). | £54.5M in additional licence fees (2017 ruling). | The risk to check for this layer: non-SAP systems reading SAP data can carry licence fees. Read the client’s SAP contract terms on indirect or digital access before the exports start. |
| AB InBev | Governance: other systems reaching SAP data | SAP S/4HANA migration, prepared with Celonis process mining from 2018 | No reported migration failure; a licence dispute. In 2017 SAP claimed AB InBev breached its 2010 licence through unlicensed direct and indirect access to SAP systems and data, and underpaid fees. | SAP sought damages of more than $600M. Settled on 30 June 2017; terms not disclosed. | The same lesson as Diageo, at a larger claim: how other systems reach SAP data is a licence question. Settle it in the contract before any export or integration runs. Mapping processes before migrating (about 100 changes designed in) is the part that went well. |
| Honda | Governance: consent on the web channel and ad-tech vendors | Honda Australia: two divisions onto one S/4HANA core. Sundiro Honda (China): SAP Commerce Cloud, 2021 | No reported ERP failure; a consent penalty. In March 2025 California’s privacy regulator (CPPA) found American Honda’s cookie tool took two steps to opt out of advertising cookies and one to opt back in, asked for more information than needed to act on privacy requests, and had no compliant contracts with its ad-tech vendors. | $632,500 fine under the CCPA (2025), plus changes to its consent tool and request process. Honda did not admit most findings. | The penalty was in the consent layer, not the ERP. Opting out must be as easy as opting in, and every vendor that receives the data needs a contract: the banner and the release gate are where that is enforced. |
The common thread
None of these is an ERP failing on its own terms. Each broke where the ERP meets the channels around it: e-commerce and retail orders it had to fill, the same products planned and shipped across global markets, and the governance that has to hold across every channel (licences for the systems that read ERP data, and consent for the people the channels reach).
| Requirement | What it takes | Cases |
|---|---|---|
| E-commerce | Orders and feeds keep flowing while the ERP and the commerce APIs change underneath | Revlon, and the escalation below |
| Global | One product record, priced, planned and stocked per market | Nike, Coty |
| Governance | Licences settled for every system that reads ERP data; consent enforced the same way on every channel | Diageo, AB InBev, Honda |
That is the scope of the layer in this book: the record that faces the channels (products, customers, consent) lives in Xano, is carried at the edge by Cloudflare, and passes one release gate, so the ERP can change without the channels breaking and every channel answers to the same rules. See An alternative to a full S/4HANA upgrade.
The next escalation: e-commerce, then agentic commerce
The ERP-to-e-commerce integration is where the next failures are scheduled. The commerce side is changing its data shapes and its credentials on fixed dates, whatever the ERP is doing:
| Change | Date | What breaks in an SAP integration |
|---|---|---|
| Shopify’s REST Admin API is legacy; new public apps must use GraphQL only | Legacy since 2024-10-01; GraphQL-only for new public apps since 2025-04-01 | Every mapping written against REST payloads: IDs become global IDs (gid://shopify/...), amounts become money objects, lists become cursor-paged connections |
| Shopify replaces non-expiring offline tokens with expiring ones (1 hour, with a 90-day refresh token) | New public apps since 2026-04-01; all public apps by 2027-01-01; Admin API calls with the old tokens rejected from 2027-04-01 | Middleware that stored one token and never refreshed it stops: every call returns 403 |
| GA4 renames and reshapes: conversion events become key events; Google recommends the Data Manager API over the Measurement Protocol for new server-to-server integrations | Ongoing through 2026 | Revenue and conversion feeds built on the old event names and endpoints |
Agentic commerce is the bigger problem. When an AI agent places the order through Shopify and Google’s UCP or Stripe’s ACP, the ERP integration has to accept an order that carries who authorised it, under which consent, and with which limits, and every channel has to answer to the same rules for an agent as for a person. That is governance multiplied by every agent, on top of the data-shape and token changes above.
The layer in this book takes both off the ERP: the GraphQL shapes and token refresh live in the Worker and Xano, the converted ECC record stays the same, and the release gate decides for agents as it does for people.
Reading the table
- Penalties are as reported, not audited. Revlon’s $64M is an allegation in a shareholder suit; Nike’s loss is its own estimate, and sources give a range. Coty’s $150M is not attributed to an ERP.
- Consent fines and wiretap suits are separate. Honda’s fine came from the regulator under the CCPA. California’s wiretap law (CIPA) is a different route: private suits over tracking that runs before or despite consent, with statutory damages of up to $5,000 per violation. No CIPA suit against Honda was found; in 2026 one was filed against Toyota, alleging tracking continued after visitors chose “decline”. Both point at the same control: nothing loads or sends before the consent decision, and a refusal is honoured everywhere.
- The licence point applies to any layer. The exports in this book are batch extracts, not live users of SAP, but how a contract counts them is for the contract to say. SAP v Diageo and SAP’s claim against AB InBev, both in 2017, are why the question comes first. SAP changed its licensing model for indirect access in 2018 after customer pushback; which model a contract uses decides how exports are counted.
Licensing penalties by flow
Running SAP on external VMs carries no penalty of its own: SAP supports AWS, Azure and GCP. The costs come from four other places, and for a layer like this book’s, the first is the one that matters.
1. Other systems using SAP data. Under older user-based contracts, a non-SAP system reading or writing SAP data on behalf of people can be counted as needing SAP user licences: that is the Diageo and AB InBev lesson in the table above. SAP’s Digital Access model (2018) counts documents created in SAP by other systems instead, in nine types: sales, invoice, purchase, service and maintenance, manufacturing, quality management, time management, financial and material documents. Reading is generally not counted. Each flow in this book, under that model:
| Flow | Exposure under Digital Access |
|---|---|
| ECC → Rust → Google Merchant (read materials, prices, stock) | Low: a read |
| ECC → Xano for identity and blocking | Low: a read |
| ECC → BigQuery extracts | Low: a read |
Shopify order → ECC sales order (VBAK / VBAP) | Counted: a sales document, then deliveries and invoices follow |
| Returns and refunds posted to ECC | Counted: sales, financial and material documents |
| Consent written to ECC | Avoided by design: ECC never holds consent |
Which model a contract uses decides how any of these is counted; a customer still on user-based licensing, never moved to Digital Access, carries the most risk. Read the contract before any flow that writes to SAP.
2. Certified VMs. SAP supports HANA and S/4HANA only on certified instance types and sizes for each cloud. An uncertified VM costs no fee, but support can be declined until a problem is reproduced on a supported setup.
3. HANA memory. HANA licences are often sized by memory. A larger VM costs nothing by itself; giving HANA more memory than is licensed leads to a true-up.
4. Network, contract and maintenance.
- Egress. Moving SAP data between clouds or regions (S/4 on one cloud, BigQuery on another) incurs the provider’s data-transfer charges. Send deltas, not full extracts.
- RISE with SAP. SAP runs the infrastructure; your own VMs can’t sit inside it, but they can connect to it. Extensions are expected on BTP and paid for with BTP credits. Running them on your own VMs or Kubernetes is allowed; point 1 still applies.
- ECC maintenance. Mainstream maintenance ends in 2027; extended maintenance to 2030 costs about 2% a year more. Where the VMs run doesn’t change this; staying on ECC does. See An alternative to a full S/4HANA upgrade.
| Penalty | Trigger | How to avoid it |
|---|---|---|
| Indirect / Digital Access fees | Other systems creating SAP documents | Read-mostly flows; settle the licence model before writing orders back |
| Support declined | An uncertified VM type | Certified instance types only |
| HANA licence true-up | HANA memory beyond the licence | Size HANA to the licence |
| Egress charges | SAP data moved between clouds or regions | One region per regime; deltas, not full extracts |
| Extended maintenance (about 2% a year) | ECC past 2027 | Plan the move, or the alternative in this book |
These are general terms as publicly reported; every contract differs. Confirm with the customer’s SAP account team or a licensing adviser before quoting any of them.
Sources
- Revlon: TechTarget, Computer Weekly, Reuters via Yahoo Finance
- Shopify: REST to GraphQL for new public apps, expiring offline tokens for all public apps, access tokens
- GA4: Admin API changelog, Measurement Protocol
- Nike: CIO, eWeek
- Coty and Kylie Cosmetics: Business Insurance, Happi, Practical Dermatology, Wikipedia
- Diageo: Diageo press release, ERP Today
- AB InBev: E3 Magazine, Computer Weekly, Computerworld
- Honda consent fine: Kelley Drye, ZwillGen
- CIPA wiretap claims: Loeb & Loeb, National Law Review
- Honda SAP: iTnews, CX Today
SAP standard tables
Module abap_to_rust::sap.
| ABAP table | Rust | Fields | Description |
|---|---|---|---|
KNA1 | sap::Kna1 | 13 | General Data in Customer Master |
ADR6 | sap::Adr6 | 8 | E-Mail Addresses (Business Address Services) |
VBAK | sap::Vbak | 8 | Sales Document: Header Data |
KNVV | sap::Knvv | 9 | Customer Master Sales Data |
ADRC | sap::Adrc | 13 | Addresses (Business Address Services) |
VBAP | sap::Vbap | 10 | Sales Document: Item Data |
MARA | sap::Mara | 19 | General Material Data |
MAKT | sap::Makt | 4 | Material Descriptions |
CDHDR | sap::Cdhdr | 9 | Change document header |
CDPOS | sap::Cdpos | 10 | Change document items |
MARM | sap::Marm | 13 | Units of Measure for Material |
MARD | sap::Mard | 7 | Storage Location Data for Material |
MBEW | sap::Mbew | 8 | Material Valuation |
A004 | sap::A004 | 9 | Material (sales organization / distribution channel / material) |
KONP | sap::Konp | 9 | Conditions (Item) |
T001W | sap::T001w | 5 | Plants/Branches |
TCURX | sap::Tcurx | 2 | Decimal Places in Currencies |
T179T | sap::T179t | 4 | Materials: Product Hierarchies: Texts |
KNA1 → sap::Kna1
General Data in Customer Master
Key: MANDT + KUNNR
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client |
KUNNR (key) | kunnr | String | CHAR 10 | KUNNR | Customer Number |
LAND1 | land1 | String | CHAR 3 | LAND1_GP | Country Key |
NAME1 | name1 | String | CHAR 35 | NAME1_GP | Name 1 |
ORT01 | ort01 | String | CHAR 35 | ORT01_GP | City |
PSTLZ | pstlz | String | CHAR 10 | PSTLZ | Postal Code |
REGIO | regio | String | CHAR 3 | REGIO | Region |
SPRAS | spras | String | LANG 1 | SPRAS | Language Key |
ADRNR | adrnr | String | CHAR 10 | ADRNR | Address |
ERDAT | erdat | Option<chrono::NaiveDate> | DATS 8 | ERDAT_RF | Created On |
LOEVM | loevm | bool | CHAR 1 | LOEVM_X | Central Deletion Flag |
ZZ_MKT_OPTIN | zz_mkt_optin | bool | CHAR 1 | XFELD | Marketing opt-in (custom append) |
/ACME/GPC | acme_gpc | bool | CHAR 1 | XFELD | Global Privacy Control seen (namespaced append) |
Generated Rust
// abap_to_rust::sap::Kna1
/// `KNA1`: General Data in Customer Master
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Kna1 {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `KUNNR` CHAR 10 (key): Customer Number
#[serde(rename = "KUNNR")]
pub kunnr: String,
/// `LAND1` CHAR 3: Country Key
#[serde(rename = "LAND1", default)]
pub land1: String,
/// `NAME1` CHAR 35: Name 1
#[serde(rename = "NAME1", default)]
pub name1: String,
/// `ORT01` CHAR 35: City
#[serde(rename = "ORT01", default)]
pub ort01: String,
/// `PSTLZ` CHAR 10: Postal Code
#[serde(rename = "PSTLZ", default)]
pub pstlz: String,
/// `REGIO` CHAR 3: Region
#[serde(rename = "REGIO", default)]
pub regio: String,
/// `SPRAS` LANG 1: Language Key
#[serde(rename = "SPRAS", default)]
pub spras: String,
/// `ADRNR` CHAR 10: Address
#[serde(rename = "ADRNR", default)]
pub adrnr: String,
/// `ERDAT` DATS 8: Created On
#[serde(rename = "ERDAT", default, with = "crate::abap::dats")]
pub erdat: Option<chrono::NaiveDate>,
/// `LOEVM` CHAR 1: Central Deletion Flag
#[serde(rename = "LOEVM", default, with = "crate::abap::xflag")]
pub loevm: bool,
/// `ZZ_MKT_OPTIN` CHAR 1: Marketing opt-in (custom append)
#[serde(rename = "ZZ_MKT_OPTIN", default, with = "crate::abap::xflag")]
pub zz_mkt_optin: bool,
/// `/ACME/GPC` CHAR 1: Global Privacy Control seen (namespaced append)
#[serde(rename = "/ACME/GPC", default, with = "crate::abap::xflag")]
pub acme_gpc: bool,
}
impl Kna1 {
pub const TABNAME: &'static str = "KNA1";
pub const KEY: &'static [&'static str] = &["MANDT", "KUNNR"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("KUNNR", "kunnr"), ("LAND1", "land1"), ("NAME1", "name1"), ("ORT01", "ort01"), ("PSTLZ", "pstlz"), ("REGIO", "regio"), ("SPRAS", "spras"), ("ADRNR", "adrnr"), ("ERDAT", "erdat"), ("LOEVM", "loevm"), ("ZZ_MKT_OPTIN", "zz_mkt_optin"), ("/ACME/GPC", "acme_gpc")];
}
Sample record
As exported, with ABAP names and internal formats (fixtures/records/kna1.json, read by tests/convert.rs):
{"MANDT":"100","KUNNR":"0000012345","LAND1":"US","NAME1":"Example Retail Inc.","ORT01":"Los Angeles","PSTLZ":"90010","REGIO":"CA","SPRAS":"E","ADRNR":"0000098765","ERDAT":"20240115","LOEVM":"","ZZ_MKT_OPTIN":"X","/ACME/GPC":""}
ADR6 → sap::Adr6
E-Mail Addresses (Business Address Services)
Key: CLIENT + ADDRNUMBER + PERSNUMBER + DATE_FROM + CONSNUMBER
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
CLIENT (key) | client | String | CLNT 3 | MANDT | Client |
ADDRNUMBER (key) | addrnumber | String | CHAR 10 | AD_ADDRNUM | Address Number |
PERSNUMBER (key) | persnumber | String | CHAR 10 | AD_PERSNUM | Person Number |
DATE_FROM (key) | date_from | Option<chrono::NaiveDate> | DATS 8 | AD_DATE_FR | Valid From |
CONSNUMBER (key) | consnumber | String | NUMC 3 | AD_CONSNUM | Sequence Number |
FLGDEFAULT | flgdefault | bool | CHAR 1 | AD_FLGDFNR | Default Address |
FLG_NOUSE | flg_nouse | bool | CHAR 1 | AD_FLNOUSE | Do Not Use |
SMTP_ADDR | smtp_addr | String | CHAR 241 | AD_SMTPADR | E-Mail Address |
Generated Rust
// abap_to_rust::sap::Adr6
/// `ADR6`: E-Mail Addresses (Business Address Services)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Adr6 {
/// `CLIENT` CLNT 3 (key): Client
#[serde(rename = "CLIENT")]
pub client: String,
/// `ADDRNUMBER` CHAR 10 (key): Address Number
#[serde(rename = "ADDRNUMBER")]
pub addrnumber: String,
/// `PERSNUMBER` CHAR 10 (key): Person Number
#[serde(rename = "PERSNUMBER")]
pub persnumber: String,
/// `DATE_FROM` DATS 8 (key): Valid From
#[serde(rename = "DATE_FROM", with = "crate::abap::dats")]
pub date_from: Option<chrono::NaiveDate>,
/// `CONSNUMBER` NUMC 3 (key): Sequence Number
#[serde(rename = "CONSNUMBER")]
pub consnumber: String,
/// `FLGDEFAULT` CHAR 1: Default Address
#[serde(rename = "FLGDEFAULT", default, with = "crate::abap::xflag")]
pub flgdefault: bool,
/// `FLG_NOUSE` CHAR 1: Do Not Use
#[serde(rename = "FLG_NOUSE", default, with = "crate::abap::xflag")]
pub flg_nouse: bool,
/// `SMTP_ADDR` CHAR 241: E-Mail Address
#[serde(rename = "SMTP_ADDR", default)]
pub smtp_addr: String,
}
impl Adr6 {
pub const TABNAME: &'static str = "ADR6";
pub const KEY: &'static [&'static str] = &["CLIENT", "ADDRNUMBER", "PERSNUMBER", "DATE_FROM", "CONSNUMBER"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("CLIENT", "client"), ("ADDRNUMBER", "addrnumber"), ("PERSNUMBER", "persnumber"), ("DATE_FROM", "date_from"), ("CONSNUMBER", "consnumber"), ("FLGDEFAULT", "flgdefault"), ("FLG_NOUSE", "flg_nouse"), ("SMTP_ADDR", "smtp_addr")];
}
Sample record
As exported, with ABAP names and internal formats (fixtures/records/adr6.json, read by tests/convert.rs):
{"CLIENT":"100","ADDRNUMBER":"0000098765","PERSNUMBER":"","DATE_FROM":"00010101","CONSNUMBER":"001","FLGDEFAULT":"X","FLG_NOUSE":"","SMTP_ADDR":"orders@example.com"}
VBAK → sap::Vbak
Sales Document: Header Data
Key: MANDT + VBELN
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client |
VBELN (key) | vbeln | String | CHAR 10 | VBELN_VA | Sales Document |
ERDAT | erdat | Option<chrono::NaiveDate> | DATS 8 | ERDAT | Created On |
ERZET | erzet | Option<chrono::NaiveTime> | TIMS 6 | ERZET | Entry Time |
AUART | auart | String | CHAR 4 | AUART | Sales Document Type |
KUNNR | kunnr | String | CHAR 10 | KUNAG | Sold-To Party |
NETWR | netwr | rust_decimal::Decimal | CURR 15,2 | NETWR_AK | Net Value |
WAERK | waerk | String | CUKY 5 | WAERK | Document Currency |
Generated Rust
// abap_to_rust::sap::Vbak
/// `VBAK`: Sales Document: Header Data
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Vbak {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `VBELN` CHAR 10 (key): Sales Document
#[serde(rename = "VBELN")]
pub vbeln: String,
/// `ERDAT` DATS 8: Created On
#[serde(rename = "ERDAT", default, with = "crate::abap::dats")]
pub erdat: Option<chrono::NaiveDate>,
/// `ERZET` TIMS 6: Entry Time
#[serde(rename = "ERZET", default, with = "crate::abap::tims")]
pub erzet: Option<chrono::NaiveTime>,
/// `AUART` CHAR 4: Sales Document Type
#[serde(rename = "AUART", default)]
pub auart: String,
/// `KUNNR` CHAR 10: Sold-To Party
#[serde(rename = "KUNNR", default)]
pub kunnr: String,
/// `NETWR` CURR 15,2: Net Value
#[serde(rename = "NETWR", default)]
pub netwr: rust_decimal::Decimal,
/// `WAERK` CUKY 5: Document Currency
#[serde(rename = "WAERK", default)]
pub waerk: String,
}
impl Vbak {
pub const TABNAME: &'static str = "VBAK";
pub const KEY: &'static [&'static str] = &["MANDT", "VBELN"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("VBELN", "vbeln"), ("ERDAT", "erdat"), ("ERZET", "erzet"), ("AUART", "auart"), ("KUNNR", "kunnr"), ("NETWR", "netwr"), ("WAERK", "waerk")];
}
Sample record
As exported, with ABAP names and internal formats (fixtures/records/vbak.json, read by tests/convert.rs):
{"MANDT":"100","VBELN":"0000500123","ERDAT":"20261104","ERZET":"101500","AUART":"OR","KUNNR":"0000012345","NETWR":"258.00","WAERK":"USD"}
KNVV → sap::Knvv
Customer Master Sales Data
Key: MANDT + KUNNR + VKORG + VTWEG + SPART
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client |
KUNNR (key) | kunnr | String | CHAR 10 | KUNNR | Customer Number |
VKORG (key) | vkorg | String | CHAR 4 | VKORG | Sales Organization |
VTWEG (key) | vtweg | String | CHAR 2 | VTWEG | Distribution Channel |
SPART (key) | spart | String | CHAR 2 | SPART | Division |
KDGRP | kdgrp | String | CHAR 2 | KDGRP | Customer Group |
WAERS | waers | String | CUKY 5 | WAERS_V02D | Currency |
AUFSD | aufsd | String | CHAR 2 | AUFSD_V | Order Block for Sales Area |
LOEVM | loevm | bool | CHAR 1 | LOEVM_V | Deletion Flag for Sales Area |
Generated Rust
// abap_to_rust::sap::Knvv
/// `KNVV`: Customer Master Sales Data
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Knvv {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `KUNNR` CHAR 10 (key): Customer Number
#[serde(rename = "KUNNR")]
pub kunnr: String,
/// `VKORG` CHAR 4 (key): Sales Organization
#[serde(rename = "VKORG")]
pub vkorg: String,
/// `VTWEG` CHAR 2 (key): Distribution Channel
#[serde(rename = "VTWEG")]
pub vtweg: String,
/// `SPART` CHAR 2 (key): Division
#[serde(rename = "SPART")]
pub spart: String,
/// `KDGRP` CHAR 2: Customer Group
#[serde(rename = "KDGRP", default)]
pub kdgrp: String,
/// `WAERS` CUKY 5: Currency
#[serde(rename = "WAERS", default)]
pub waers: String,
/// `AUFSD` CHAR 2: Order Block for Sales Area
#[serde(rename = "AUFSD", default)]
pub aufsd: String,
/// `LOEVM` CHAR 1: Deletion Flag for Sales Area
#[serde(rename = "LOEVM", default, with = "crate::abap::xflag")]
pub loevm: bool,
}
impl Knvv {
pub const TABNAME: &'static str = "KNVV";
pub const KEY: &'static [&'static str] = &["MANDT", "KUNNR", "VKORG", "VTWEG", "SPART"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("KUNNR", "kunnr"), ("VKORG", "vkorg"), ("VTWEG", "vtweg"), ("SPART", "spart"), ("KDGRP", "kdgrp"), ("WAERS", "waers"), ("AUFSD", "aufsd"), ("LOEVM", "loevm")];
}
ADRC → sap::Adrc
Addresses (Business Address Services)
Key: CLIENT + ADDRNUMBER + DATE_FROM + NATION
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
CLIENT (key) | client | String | CLNT 3 | MANDT | Client |
ADDRNUMBER (key) | addrnumber | String | CHAR 10 | AD_ADDRNUM | Address Number |
DATE_FROM (key) | date_from | Option<chrono::NaiveDate> | DATS 8 | AD_DATE_FR | Valid From |
NATION (key) | nation | String | CHAR 1 | AD_NATION | Address Version |
NAME1 | name1 | String | CHAR 40 | AD_NAME1 | Name 1 |
CITY1 | city1 | String | CHAR 40 | AD_CITY1 | City |
POST_CODE1 | post_code1 | String | CHAR 10 | AD_PSTCD1 | Postal Code |
STREET | street | String | CHAR 60 | AD_STREET | Street |
COUNTRY | country | String | CHAR 3 | LAND1 | Country Key |
REGION | region | String | CHAR 3 | REGIO | Region |
LANGU | langu | String | LANG 1 | SPRAS | Language Key |
TEL_NUMBER | tel_number | String | CHAR 30 | AD_TLNMBR1 | Telephone |
DEFLT_COMM | deflt_comm | String | CHAR 3 | AD_COMM | Communication Method |
Generated Rust
// abap_to_rust::sap::Adrc
/// `ADRC`: Addresses (Business Address Services)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Adrc {
/// `CLIENT` CLNT 3 (key): Client
#[serde(rename = "CLIENT")]
pub client: String,
/// `ADDRNUMBER` CHAR 10 (key): Address Number
#[serde(rename = "ADDRNUMBER")]
pub addrnumber: String,
/// `DATE_FROM` DATS 8 (key): Valid From
#[serde(rename = "DATE_FROM", with = "crate::abap::dats")]
pub date_from: Option<chrono::NaiveDate>,
/// `NATION` CHAR 1 (key): Address Version
#[serde(rename = "NATION")]
pub nation: String,
/// `NAME1` CHAR 40: Name 1
#[serde(rename = "NAME1", default)]
pub name1: String,
/// `CITY1` CHAR 40: City
#[serde(rename = "CITY1", default)]
pub city1: String,
/// `POST_CODE1` CHAR 10: Postal Code
#[serde(rename = "POST_CODE1", default)]
pub post_code1: String,
/// `STREET` CHAR 60: Street
#[serde(rename = "STREET", default)]
pub street: String,
/// `COUNTRY` CHAR 3: Country Key
#[serde(rename = "COUNTRY", default)]
pub country: String,
/// `REGION` CHAR 3: Region
#[serde(rename = "REGION", default)]
pub region: String,
/// `LANGU` LANG 1: Language Key
#[serde(rename = "LANGU", default)]
pub langu: String,
/// `TEL_NUMBER` CHAR 30: Telephone
#[serde(rename = "TEL_NUMBER", default)]
pub tel_number: String,
/// `DEFLT_COMM` CHAR 3: Communication Method
#[serde(rename = "DEFLT_COMM", default)]
pub deflt_comm: String,
}
impl Adrc {
pub const TABNAME: &'static str = "ADRC";
pub const KEY: &'static [&'static str] = &["CLIENT", "ADDRNUMBER", "DATE_FROM", "NATION"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("CLIENT", "client"), ("ADDRNUMBER", "addrnumber"), ("DATE_FROM", "date_from"), ("NATION", "nation"), ("NAME1", "name1"), ("CITY1", "city1"), ("POST_CODE1", "post_code1"), ("STREET", "street"), ("COUNTRY", "country"), ("REGION", "region"), ("LANGU", "langu"), ("TEL_NUMBER", "tel_number"), ("DEFLT_COMM", "deflt_comm")];
}
VBAP → sap::Vbap
Sales Document: Item Data
Key: MANDT + VBELN + POSNR
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client |
VBELN (key) | vbeln | String | CHAR 10 | VBELN_VA | Sales Document |
POSNR (key) | posnr | String | NUMC 6 | POSNR_VA | Sales Document Item |
MATNR | matnr | String | CHAR 18 | MATNR | Material Number |
ARKTX | arktx | String | CHAR 40 | ARKTX | Short Text |
KWMENG | kwmeng | rust_decimal::Decimal | QUAN 15,3 | KWMENG | Order Quantity |
VRKME | vrkme | String | UNIT 3 | VRKME | Sales Unit |
NETWR | netwr | rust_decimal::Decimal | CURR 15,2 | NETWR_AP | Net Value |
WAERK | waerk | String | CUKY 5 | WAERK | Document Currency |
WERKS | werks | String | CHAR 4 | WERKS_EXT | Plant |
Generated Rust
// abap_to_rust::sap::Vbap
/// `VBAP`: Sales Document: Item Data
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Vbap {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `VBELN` CHAR 10 (key): Sales Document
#[serde(rename = "VBELN")]
pub vbeln: String,
/// `POSNR` NUMC 6 (key): Sales Document Item
#[serde(rename = "POSNR")]
pub posnr: String,
/// `MATNR` CHAR 18: Material Number
#[serde(rename = "MATNR", default)]
pub matnr: String,
/// `ARKTX` CHAR 40: Short Text
#[serde(rename = "ARKTX", default)]
pub arktx: String,
/// `KWMENG` QUAN 15,3: Order Quantity
#[serde(rename = "KWMENG", default)]
pub kwmeng: rust_decimal::Decimal,
/// `VRKME` UNIT 3: Sales Unit
#[serde(rename = "VRKME", default)]
pub vrkme: String,
/// `NETWR` CURR 15,2: Net Value
#[serde(rename = "NETWR", default)]
pub netwr: rust_decimal::Decimal,
/// `WAERK` CUKY 5: Document Currency
#[serde(rename = "WAERK", default)]
pub waerk: String,
/// `WERKS` CHAR 4: Plant
#[serde(rename = "WERKS", default)]
pub werks: String,
}
impl Vbap {
pub const TABNAME: &'static str = "VBAP";
pub const KEY: &'static [&'static str] = &["MANDT", "VBELN", "POSNR"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("VBELN", "vbeln"), ("POSNR", "posnr"), ("MATNR", "matnr"), ("ARKTX", "arktx"), ("KWMENG", "kwmeng"), ("VRKME", "vrkme"), ("NETWR", "netwr"), ("WAERK", "waerk"), ("WERKS", "werks")];
}
MARA → sap::Mara
General Material Data
Key: MANDT + MATNR
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
MATNR (key) | id | matnr | String | CHAR 18 | MATNR | Material Number |
ERSDA | ersda | Option<chrono::NaiveDate> | DATS 8 | ERSDA | Created On | |
LVORM | lvorm | bool | CHAR 1 | LVOMA | Deletion Flag at Client Level | |
MTART | mtart | String | CHAR 4 | MTART | Material Type | |
MATKL | google_product_category | matkl | String | CHAR 9 | MATKL | Material Group |
MEINS | meins | String | UNIT 3 | MEINS | Base Unit of Measure | |
BRGEW | shipping_weight | brgew | rust_decimal::Decimal | QUAN 13,3 | BRGEW | Gross Weight |
GEWEI | product_weight shipping_weight | gewei | String | UNIT 3 | GEWEI | Weight Unit |
NTGEW | product_weight | ntgew | rust_decimal::Decimal | QUAN 13,3 | NTGEW | Net Weight |
EAN11 | gtin identifier_exists | ean11 | String | CHAR 18 | EAN11 | International Article Number (EAN/UPC) |
NUMTP | gtin | numtp | String | CHAR 2 | NUMTP | Category of EAN |
MFRNR | brand | mfrnr | String | CHAR 10 | MFRNR | Manufacturer (vendor number) |
MFRPN | mpn identifier_exists | mfrpn | String | CHAR 40 | MFRPN | Manufacturer Part Number |
PRDHA | product_type | prdha | String | CHAR 18 | PRODH_D | Product Hierarchy |
WRKST | material | wrkst | String | CHAR 48 | WRKST | Basic Material |
SATNR | item_group_id | satnr | String | CHAR 18 | SATNR | Generic Article (IS-Retail) |
INHAL | unit_pricing_measure | inhal | rust_decimal::Decimal | QUAN 13,3 | INHAL | Net Contents (IS-Retail) |
INHME | unit_pricing_measure | inhme | String | UNIT 3 | INHME | Content Unit (IS-Retail) |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Mara
/// `MARA`: General Material Data
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Mara {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `MATNR` CHAR 18 (key): Material Number
#[serde(rename = "MATNR")]
pub matnr: String,
/// `ERSDA` DATS 8: Created On
#[serde(rename = "ERSDA", default, with = "crate::abap::dats")]
pub ersda: Option<chrono::NaiveDate>,
/// `LVORM` CHAR 1: Deletion Flag at Client Level
#[serde(rename = "LVORM", default, with = "crate::abap::xflag")]
pub lvorm: bool,
/// `MTART` CHAR 4: Material Type
#[serde(rename = "MTART", default)]
pub mtart: String,
/// `MATKL` CHAR 9: Material Group
#[serde(rename = "MATKL", default)]
pub matkl: String,
/// `MEINS` UNIT 3: Base Unit of Measure
#[serde(rename = "MEINS", default)]
pub meins: String,
/// `BRGEW` QUAN 13,3: Gross Weight
#[serde(rename = "BRGEW", default)]
pub brgew: rust_decimal::Decimal,
/// `GEWEI` UNIT 3: Weight Unit
#[serde(rename = "GEWEI", default)]
pub gewei: String,
/// `NTGEW` QUAN 13,3: Net Weight
#[serde(rename = "NTGEW", default)]
pub ntgew: rust_decimal::Decimal,
/// `EAN11` CHAR 18: International Article Number (EAN/UPC)
#[serde(rename = "EAN11", default)]
pub ean11: String,
/// `NUMTP` CHAR 2: Category of EAN
#[serde(rename = "NUMTP", default)]
pub numtp: String,
/// `MFRNR` CHAR 10: Manufacturer (vendor number)
#[serde(rename = "MFRNR", default)]
pub mfrnr: String,
/// `MFRPN` CHAR 40: Manufacturer Part Number
#[serde(rename = "MFRPN", default)]
pub mfrpn: String,
/// `PRDHA` CHAR 18: Product Hierarchy
#[serde(rename = "PRDHA", default)]
pub prdha: String,
/// `WRKST` CHAR 48: Basic Material
#[serde(rename = "WRKST", default)]
pub wrkst: String,
/// `SATNR` CHAR 18: Generic Article (IS-Retail)
#[serde(rename = "SATNR", default)]
pub satnr: String,
/// `INHAL` QUAN 13,3: Net Contents (IS-Retail)
#[serde(rename = "INHAL", default)]
pub inhal: rust_decimal::Decimal,
/// `INHME` UNIT 3: Content Unit (IS-Retail)
#[serde(rename = "INHME", default)]
pub inhme: String,
}
impl Mara {
pub const TABNAME: &'static str = "MARA";
pub const KEY: &'static [&'static str] = &["MANDT", "MATNR"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("MATNR", "matnr"), ("ERSDA", "ersda"), ("LVORM", "lvorm"), ("MTART", "mtart"), ("MATKL", "matkl"), ("MEINS", "meins"), ("BRGEW", "brgew"), ("GEWEI", "gewei"), ("NTGEW", "ntgew"), ("EAN11", "ean11"), ("NUMTP", "numtp"), ("MFRNR", "mfrnr"), ("MFRPN", "mfrpn"), ("PRDHA", "prdha"), ("WRKST", "wrkst"), ("SATNR", "satnr"), ("INHAL", "inhal"), ("INHME", "inhme")];
}
MAKT → sap::Makt
Material Descriptions
Key: MANDT + MATNR + SPRAS
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
MATNR (key) | matnr | String | CHAR 18 | MATNR | Material Number | |
SPRAS (key) | title | spras | String | LANG 1 | SPRAS | Language Key |
MAKTX | title | maktx | String | CHAR 40 | MAKTX | Material Description |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Makt
/// `MAKT`: Material Descriptions
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Makt {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `MATNR` CHAR 18 (key): Material Number
#[serde(rename = "MATNR")]
pub matnr: String,
/// `SPRAS` LANG 1 (key): Language Key
#[serde(rename = "SPRAS")]
pub spras: String,
/// `MAKTX` CHAR 40: Material Description
#[serde(rename = "MAKTX", default)]
pub maktx: String,
}
impl Makt {
pub const TABNAME: &'static str = "MAKT";
pub const KEY: &'static [&'static str] = &["MANDT", "MATNR", "SPRAS"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("MATNR", "matnr"), ("SPRAS", "spras"), ("MAKTX", "maktx")];
}
CDHDR → sap::Cdhdr
Change document header
Key: MANDANT + OBJECTCLAS + OBJECTID + CHANGENR
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDANT (key) | mandant | String | CLNT 3 | MANDT | Client |
OBJECTCLAS (key) | objectclas | String | CHAR 15 | CDOBJECTCL | Object Class (DEBI = customer) |
OBJECTID (key) | objectid | String | CHAR 90 | CDOBJECTV | Object Value |
CHANGENR (key) | changenr | String | CHAR 10 | CDCHANGENR | Change Number |
USERNAME | username | String | CHAR 12 | CDUSERNAME | User who changed it (a batch user shows here) |
UDATE | udate | Option<chrono::NaiveDate> | DATS 8 | CDDATUM | Date |
UTIME | utime | Option<chrono::NaiveTime> | TIMS 6 | CDUZEIT | Time |
TCODE | tcode | String | CHAR 20 | CDTCODE | Transaction |
CHANGE_IND | change_ind | String | CHAR 1 | CDCHNGINDH | Change Type (U / I / D) |
Generated Rust
// abap_to_rust::sap::Cdhdr
/// `CDHDR`: Change document header
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Cdhdr {
/// `MANDANT` CLNT 3 (key): Client
#[serde(rename = "MANDANT")]
pub mandant: String,
/// `OBJECTCLAS` CHAR 15 (key): Object Class (DEBI = customer)
#[serde(rename = "OBJECTCLAS")]
pub objectclas: String,
/// `OBJECTID` CHAR 90 (key): Object Value
#[serde(rename = "OBJECTID")]
pub objectid: String,
/// `CHANGENR` CHAR 10 (key): Change Number
#[serde(rename = "CHANGENR")]
pub changenr: String,
/// `USERNAME` CHAR 12: User who changed it (a batch user shows here)
#[serde(rename = "USERNAME", default)]
pub username: String,
/// `UDATE` DATS 8: Date
#[serde(rename = "UDATE", default, with = "crate::abap::dats")]
pub udate: Option<chrono::NaiveDate>,
/// `UTIME` TIMS 6: Time
#[serde(rename = "UTIME", default, with = "crate::abap::tims")]
pub utime: Option<chrono::NaiveTime>,
/// `TCODE` CHAR 20: Transaction
#[serde(rename = "TCODE", default)]
pub tcode: String,
/// `CHANGE_IND` CHAR 1: Change Type (U / I / D)
#[serde(rename = "CHANGE_IND", default)]
pub change_ind: String,
}
impl Cdhdr {
pub const TABNAME: &'static str = "CDHDR";
pub const KEY: &'static [&'static str] = &["MANDANT", "OBJECTCLAS", "OBJECTID", "CHANGENR"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDANT", "mandant"), ("OBJECTCLAS", "objectclas"), ("OBJECTID", "objectid"), ("CHANGENR", "changenr"), ("USERNAME", "username"), ("UDATE", "udate"), ("UTIME", "utime"), ("TCODE", "tcode"), ("CHANGE_IND", "change_ind")];
}
CDPOS → sap::Cdpos
Change document items
Key: MANDANT + OBJECTCLAS + OBJECTID + CHANGENR + TABNAME + TABKEY + FNAME + CHNGIND
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDANT (key) | mandant | String | CLNT 3 | MANDT | Client |
OBJECTCLAS (key) | objectclas | String | CHAR 15 | CDOBJECTCL | Object Class |
OBJECTID (key) | objectid | String | CHAR 90 | CDOBJECTV | Object Value |
CHANGENR (key) | changenr | String | CHAR 10 | CDCHANGENR | Change Number |
TABNAME (key) | tabname | String | CHAR 30 | TABNAME | Table Name |
TABKEY (key) | tabkey | String | CHAR 70 | CDTABKEY | Changed Table Record Key |
FNAME (key) | fname | String | CHAR 30 | FIELDNAME | Field Name |
CHNGIND (key) | chngind | String | CHAR 1 | CDCHNGIND | Change Type (U / I / E / D) |
VALUE_NEW | value_new | String | CHAR 254 | CDFLDVALN | New Value |
VALUE_OLD | value_old | String | CHAR 254 | CDFLDVALO | Old Value |
Generated Rust
// abap_to_rust::sap::Cdpos
/// `CDPOS`: Change document items
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Cdpos {
/// `MANDANT` CLNT 3 (key): Client
#[serde(rename = "MANDANT")]
pub mandant: String,
/// `OBJECTCLAS` CHAR 15 (key): Object Class
#[serde(rename = "OBJECTCLAS")]
pub objectclas: String,
/// `OBJECTID` CHAR 90 (key): Object Value
#[serde(rename = "OBJECTID")]
pub objectid: String,
/// `CHANGENR` CHAR 10 (key): Change Number
#[serde(rename = "CHANGENR")]
pub changenr: String,
/// `TABNAME` CHAR 30 (key): Table Name
#[serde(rename = "TABNAME")]
pub tabname: String,
/// `TABKEY` CHAR 70 (key): Changed Table Record Key
#[serde(rename = "TABKEY")]
pub tabkey: String,
/// `FNAME` CHAR 30 (key): Field Name
#[serde(rename = "FNAME")]
pub fname: String,
/// `CHNGIND` CHAR 1 (key): Change Type (U / I / E / D)
#[serde(rename = "CHNGIND")]
pub chngind: String,
/// `VALUE_NEW` CHAR 254: New Value
#[serde(rename = "VALUE_NEW", default)]
pub value_new: String,
/// `VALUE_OLD` CHAR 254: Old Value
#[serde(rename = "VALUE_OLD", default)]
pub value_old: String,
}
impl Cdpos {
pub const TABNAME: &'static str = "CDPOS";
pub const KEY: &'static [&'static str] = &["MANDANT", "OBJECTCLAS", "OBJECTID", "CHANGENR", "TABNAME", "TABKEY", "FNAME", "CHNGIND"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDANT", "mandant"), ("OBJECTCLAS", "objectclas"), ("OBJECTID", "objectid"), ("CHANGENR", "changenr"), ("TABNAME", "tabname"), ("TABKEY", "tabkey"), ("FNAME", "fname"), ("CHNGIND", "chngind"), ("VALUE_NEW", "value_new"), ("VALUE_OLD", "value_old")];
}
MARM → sap::Marm
Units of Measure for Material
Key: MANDT + MATNR + MEINH
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
MATNR (key) | matnr | String | CHAR 18 | MATNR | Material Number | |
MEINH (key) | meinh | String | UNIT 3 | LRMEI | Alternative Unit of Measure | |
UMREZ | umrez | rust_decimal::Decimal | DEC 5 | UMREZ | Numerator for Conversion to Base Unit | |
UMREN | umren | rust_decimal::Decimal | DEC 5 | UMREN | Denominator for Conversion to Base Unit | |
EAN11 | gtin | ean11 | String | CHAR 18 | EAN11 | International Article Number (EAN/UPC) |
NUMTP | gtin | numtp | String | CHAR 2 | NUMTP | Category of EAN |
LAENG | shipping_length | laeng | rust_decimal::Decimal | QUAN 13,3 | LAENG | Length |
BREIT | shipping_width | breit | rust_decimal::Decimal | QUAN 13,3 | BREIT | Width |
HOEHE | shipping_height | hoehe | rust_decimal::Decimal | QUAN 13,3 | HOEHE | Height |
MEABM | shipping_length shipping_width shipping_height | meabm | String | UNIT 3 | MEABM | Unit of Dimension |
BRGEW | brgew | rust_decimal::Decimal | QUAN 13,3 | BRGEW | Gross Weight | |
GEWEI | gewei | String | UNIT 3 | GEWEI | Weight Unit |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Marm
/// `MARM`: Units of Measure for Material
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Marm {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `MATNR` CHAR 18 (key): Material Number
#[serde(rename = "MATNR")]
pub matnr: String,
/// `MEINH` UNIT 3 (key): Alternative Unit of Measure
#[serde(rename = "MEINH")]
pub meinh: String,
/// `UMREZ` DEC 5: Numerator for Conversion to Base Unit
#[serde(rename = "UMREZ", default)]
pub umrez: rust_decimal::Decimal,
/// `UMREN` DEC 5: Denominator for Conversion to Base Unit
#[serde(rename = "UMREN", default)]
pub umren: rust_decimal::Decimal,
/// `EAN11` CHAR 18: International Article Number (EAN/UPC)
#[serde(rename = "EAN11", default)]
pub ean11: String,
/// `NUMTP` CHAR 2: Category of EAN
#[serde(rename = "NUMTP", default)]
pub numtp: String,
/// `LAENG` QUAN 13,3: Length
#[serde(rename = "LAENG", default)]
pub laeng: rust_decimal::Decimal,
/// `BREIT` QUAN 13,3: Width
#[serde(rename = "BREIT", default)]
pub breit: rust_decimal::Decimal,
/// `HOEHE` QUAN 13,3: Height
#[serde(rename = "HOEHE", default)]
pub hoehe: rust_decimal::Decimal,
/// `MEABM` UNIT 3: Unit of Dimension
#[serde(rename = "MEABM", default)]
pub meabm: String,
/// `BRGEW` QUAN 13,3: Gross Weight
#[serde(rename = "BRGEW", default)]
pub brgew: rust_decimal::Decimal,
/// `GEWEI` UNIT 3: Weight Unit
#[serde(rename = "GEWEI", default)]
pub gewei: String,
}
impl Marm {
pub const TABNAME: &'static str = "MARM";
pub const KEY: &'static [&'static str] = &["MANDT", "MATNR", "MEINH"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("MATNR", "matnr"), ("MEINH", "meinh"), ("UMREZ", "umrez"), ("UMREN", "umren"), ("EAN11", "ean11"), ("NUMTP", "numtp"), ("LAENG", "laeng"), ("BREIT", "breit"), ("HOEHE", "hoehe"), ("MEABM", "meabm"), ("BRGEW", "brgew"), ("GEWEI", "gewei")];
}
MARD → sap::Mard
Storage Location Data for Material
Key: MANDT + MATNR + WERKS + LGORT
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
MATNR (key) | matnr | String | CHAR 18 | MATNR | Material Number | |
WERKS (key) | werks | String | CHAR 4 | WERKS_D | Plant | |
LGORT (key) | lgort | String | CHAR 4 | LGORT_D | Storage Location | |
LABST | availability | labst | rust_decimal::Decimal | QUAN 13,3 | LABST | Unrestricted-Use Stock |
INSME | availability | insme | rust_decimal::Decimal | QUAN 13,3 | INSME | Stock in Quality Inspection |
SPEME | availability | speme | rust_decimal::Decimal | QUAN 13,3 | SPEME | Blocked Stock |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Mard
/// `MARD`: Storage Location Data for Material
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Mard {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `MATNR` CHAR 18 (key): Material Number
#[serde(rename = "MATNR")]
pub matnr: String,
/// `WERKS` CHAR 4 (key): Plant
#[serde(rename = "WERKS")]
pub werks: String,
/// `LGORT` CHAR 4 (key): Storage Location
#[serde(rename = "LGORT")]
pub lgort: String,
/// `LABST` QUAN 13,3: Unrestricted-Use Stock
#[serde(rename = "LABST", default)]
pub labst: rust_decimal::Decimal,
/// `INSME` QUAN 13,3: Stock in Quality Inspection
#[serde(rename = "INSME", default)]
pub insme: rust_decimal::Decimal,
/// `SPEME` QUAN 13,3: Blocked Stock
#[serde(rename = "SPEME", default)]
pub speme: rust_decimal::Decimal,
}
impl Mard {
pub const TABNAME: &'static str = "MARD";
pub const KEY: &'static [&'static str] = &["MANDT", "MATNR", "WERKS", "LGORT"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("MATNR", "matnr"), ("WERKS", "werks"), ("LGORT", "lgort"), ("LABST", "labst"), ("INSME", "insme"), ("SPEME", "speme")];
}
MBEW → sap::Mbew
Material Valuation
Key: MANDT + MATNR + BWKEY + BWTAR
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
MATNR (key) | matnr | String | CHAR 18 | MATNR | Material Number | |
BWKEY (key) | bwkey | String | CHAR 4 | BWKEY | Valuation Area | |
BWTAR (key) | bwtar | String | CHAR 10 | BWTAR_D | Valuation Type | |
VPRSV | cost_of_goods_sold | vprsv | String | CHAR 1 | VPRSV | Price Control (S standard / V moving average) |
VERPR | cost_of_goods_sold | verpr | rust_decimal::Decimal | CURR 11,2 | VERPR | Moving Average Price |
STPRS | cost_of_goods_sold | stprs | rust_decimal::Decimal | CURR 11,2 | STPRS | Standard Price |
PEINH | cost_of_goods_sold | peinh | rust_decimal::Decimal | DEC 5 | PEINH | Price Unit |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Mbew
/// `MBEW`: Material Valuation
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Mbew {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `MATNR` CHAR 18 (key): Material Number
#[serde(rename = "MATNR")]
pub matnr: String,
/// `BWKEY` CHAR 4 (key): Valuation Area
#[serde(rename = "BWKEY")]
pub bwkey: String,
/// `BWTAR` CHAR 10 (key): Valuation Type
#[serde(rename = "BWTAR")]
pub bwtar: String,
/// `VPRSV` CHAR 1: Price Control (S standard / V moving average)
#[serde(rename = "VPRSV", default)]
pub vprsv: String,
/// `VERPR` CURR 11,2: Moving Average Price
#[serde(rename = "VERPR", default)]
pub verpr: rust_decimal::Decimal,
/// `STPRS` CURR 11,2: Standard Price
#[serde(rename = "STPRS", default)]
pub stprs: rust_decimal::Decimal,
/// `PEINH` DEC 5: Price Unit
#[serde(rename = "PEINH", default)]
pub peinh: rust_decimal::Decimal,
}
impl Mbew {
pub const TABNAME: &'static str = "MBEW";
pub const KEY: &'static [&'static str] = &["MANDT", "MATNR", "BWKEY", "BWTAR"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("MATNR", "matnr"), ("BWKEY", "bwkey"), ("BWTAR", "bwtar"), ("VPRSV", "vprsv"), ("VERPR", "verpr"), ("STPRS", "stprs"), ("PEINH", "peinh")];
}
A004 → sap::A004
Material (sales organization / distribution channel / material)
Key: MANDT + KAPPL + KSCHL + VKORG + VTWEG + MATNR + DATBI
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
KAPPL (key) | kappl | String | CHAR 2 | KAPPL | Application (V = sales) | |
KSCHL (key) | price sale_price | kschl | String | CHAR 4 | KSCHA | Condition Type (PR00 = price) |
VKORG (key) | vkorg | String | CHAR 4 | VKORG | Sales Organization | |
VTWEG (key) | vtweg | String | CHAR 2 | VTWEG | Distribution Channel | |
MATNR (key) | matnr | String | CHAR 18 | MATNR | Material Number | |
DATBI (key) | price sale_price sale_price_effective_date | datbi | Option<chrono::NaiveDate> | DATS 8 | KODATBI | Valid To |
DATAB | price sale_price sale_price_effective_date | datab | Option<chrono::NaiveDate> | DATS 8 | KODATAB | Valid From |
KNUMH | knumh | String | CHAR 10 | KNUMH | Condition Record Number |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::A004
/// `A004`: Material (sales organization / distribution channel / material)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct A004 {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `KAPPL` CHAR 2 (key): Application (V = sales)
#[serde(rename = "KAPPL")]
pub kappl: String,
/// `KSCHL` CHAR 4 (key): Condition Type (PR00 = price)
#[serde(rename = "KSCHL")]
pub kschl: String,
/// `VKORG` CHAR 4 (key): Sales Organization
#[serde(rename = "VKORG")]
pub vkorg: String,
/// `VTWEG` CHAR 2 (key): Distribution Channel
#[serde(rename = "VTWEG")]
pub vtweg: String,
/// `MATNR` CHAR 18 (key): Material Number
#[serde(rename = "MATNR")]
pub matnr: String,
/// `DATBI` DATS 8 (key): Valid To
#[serde(rename = "DATBI", with = "crate::abap::dats")]
pub datbi: Option<chrono::NaiveDate>,
/// `DATAB` DATS 8: Valid From
#[serde(rename = "DATAB", default, with = "crate::abap::dats")]
pub datab: Option<chrono::NaiveDate>,
/// `KNUMH` CHAR 10: Condition Record Number
#[serde(rename = "KNUMH", default)]
pub knumh: String,
}
impl A004 {
pub const TABNAME: &'static str = "A004";
pub const KEY: &'static [&'static str] = &["MANDT", "KAPPL", "KSCHL", "VKORG", "VTWEG", "MATNR", "DATBI"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("KAPPL", "kappl"), ("KSCHL", "kschl"), ("VKORG", "vkorg"), ("VTWEG", "vtweg"), ("MATNR", "matnr"), ("DATBI", "datbi"), ("DATAB", "datab"), ("KNUMH", "knumh")];
}
KONP → sap::Konp
Conditions (Item)
Key: MANDT + KNUMH + KOPOS
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
KNUMH (key) | knumh | String | CHAR 10 | KNUMH | Condition Record Number | |
KOPOS (key) | kopos | String | NUMC 2 | KOPOS | Sequential Number of the Condition | |
KSCHL | kschl | String | CHAR 4 | KSCHA | Condition Type | |
KBETR | price sale_price | kbetr | rust_decimal::Decimal | CURR 11,2 | KBETR_KOND | Rate (amount) |
KONWA | price sale_price | konwa | String | CUKY 5 | KONWA | Rate Unit (currency) |
KPEIN | price sale_price | kpein | rust_decimal::Decimal | DEC 5 | KPEIN | Condition Pricing Unit |
KMEIN | kmein | String | UNIT 3 | KMEIN | Condition Unit | |
LOEVM_KO | price | loevm_ko | bool | CHAR 1 | LOEVM_KO | Deletion Indicator for Condition Item |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Konp
/// `KONP`: Conditions (Item)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Konp {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `KNUMH` CHAR 10 (key): Condition Record Number
#[serde(rename = "KNUMH")]
pub knumh: String,
/// `KOPOS` NUMC 2 (key): Sequential Number of the Condition
#[serde(rename = "KOPOS")]
pub kopos: String,
/// `KSCHL` CHAR 4: Condition Type
#[serde(rename = "KSCHL", default)]
pub kschl: String,
/// `KBETR` CURR 11,2: Rate (amount)
#[serde(rename = "KBETR", default)]
pub kbetr: rust_decimal::Decimal,
/// `KONWA` CUKY 5: Rate Unit (currency)
#[serde(rename = "KONWA", default)]
pub konwa: String,
/// `KPEIN` DEC 5: Condition Pricing Unit
#[serde(rename = "KPEIN", default)]
pub kpein: rust_decimal::Decimal,
/// `KMEIN` UNIT 3: Condition Unit
#[serde(rename = "KMEIN", default)]
pub kmein: String,
/// `LOEVM_KO` CHAR 1: Deletion Indicator for Condition Item
#[serde(rename = "LOEVM_KO", default, with = "crate::abap::xflag")]
pub loevm_ko: bool,
}
impl Konp {
pub const TABNAME: &'static str = "KONP";
pub const KEY: &'static [&'static str] = &["MANDT", "KNUMH", "KOPOS"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("KNUMH", "knumh"), ("KOPOS", "kopos"), ("KSCHL", "kschl"), ("KBETR", "kbetr"), ("KONWA", "konwa"), ("KPEIN", "kpein"), ("KMEIN", "kmein"), ("LOEVM_KO", "loevm_ko")];
}
T001W → sap::T001w
Plants/Branches
Key: MANDT + WERKS
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
WERKS (key) | werks | String | CHAR 4 | WERKS_D | Plant | |
NAME1 | name1 | String | CHAR 30 | NAME1 | Name | |
LAND1 | ships_from_country | land1 | String | CHAR 3 | LAND1 | Country Key |
REGIO | regio | String | CHAR 3 | REGIO | Region |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::T001w
/// `T001W`: Plants/Branches
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct T001w {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `WERKS` CHAR 4 (key): Plant
#[serde(rename = "WERKS")]
pub werks: String,
/// `NAME1` CHAR 30: Name
#[serde(rename = "NAME1", default)]
pub name1: String,
/// `LAND1` CHAR 3: Country Key
#[serde(rename = "LAND1", default)]
pub land1: String,
/// `REGIO` CHAR 3: Region
#[serde(rename = "REGIO", default)]
pub regio: String,
}
impl T001w {
pub const TABNAME: &'static str = "T001W";
pub const KEY: &'static [&'static str] = &["MANDT", "WERKS"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("WERKS", "werks"), ("NAME1", "name1"), ("LAND1", "land1"), ("REGIO", "regio")];
}
TCURX → sap::Tcurx
Decimal Places in Currencies
Key: CURRKEY
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
CURRKEY (key) | currkey | String | CUKY 5 | CURRKEY | Currency Key | |
CURRDEC | price sale_price | currdec | u8 | INT1 3 | CURRDEC | Number of Decimal Places |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::Tcurx
/// `TCURX`: Decimal Places in Currencies
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Tcurx {
/// `CURRKEY` CUKY 5 (key): Currency Key
#[serde(rename = "CURRKEY")]
pub currkey: String,
/// `CURRDEC` INT1 3: Number of Decimal Places
#[serde(rename = "CURRDEC", default)]
pub currdec: u8,
}
impl Tcurx {
pub const TABNAME: &'static str = "TCURX";
pub const KEY: &'static [&'static str] = &["CURRKEY"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("CURRKEY", "currkey"), ("CURRDEC", "currdec")];
}
T179T → sap::T179t
Materials: Product Hierarchies: Texts
Key: MANDT + SPRAS + PRODH
| ABAP field | Google Merchant | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client | |
SPRAS (key) | spras | String | LANG 1 | SPRAS | Language Key | |
PRODH (key) | product_type | prodh | String | CHAR 18 | PRODH_D | Product Hierarchy |
VTEXT | product_type | vtext | String | CHAR 40 | BEZEI40 | Description |
pink attributes are machine data: converted by a fixed rule, never rewritten. See Google Merchant Center.
Generated Rust
// abap_to_rust::sap::T179t
/// `T179T`: Materials: Product Hierarchies: Texts
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct T179t {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `SPRAS` LANG 1 (key): Language Key
#[serde(rename = "SPRAS")]
pub spras: String,
/// `PRODH` CHAR 18 (key): Product Hierarchy
#[serde(rename = "PRODH")]
pub prodh: String,
/// `VTEXT` CHAR 40: Description
#[serde(rename = "VTEXT", default)]
pub vtext: String,
}
impl T179t {
pub const TABNAME: &'static str = "T179T";
pub const KEY: &'static [&'static str] = &["MANDT", "SPRAS", "PRODH"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("SPRAS", "spras"), ("PRODH", "prodh"), ("VTEXT", "vtext")];
}
Customer namespace /ACME/
Module abap_to_rust::acme.
| ABAP table | Rust | Fields | Description |
|---|---|---|---|
/ACME/CONSENT | acme::Consent | 7 | Consent ledger (customer namespace /ACME/) |
/ACME/CONSENT → acme::Consent
Consent ledger (customer namespace /ACME/)
Key: MANDT + KUNNR + PURPOSE + RECORDED_AT
| ABAP field | Rust field | Rust type | DDIC | Data element | Description |
|---|---|---|---|---|---|
MANDT (key) | mandt | String | CLNT 3 | MANDT | Client |
KUNNR (key) | kunnr | String | CHAR 10 | KUNNR | Customer Number |
PURPOSE (key) | purpose | String | CHAR 20 | /ACME/PURPOSE | Purpose (analytics / ads / sale_share) |
RECORDED_AT (key) | recorded_at | Option<chrono::NaiveDateTime> | DEC 15 | TIMESTAMP | Recorded at (UTC, YYYYMMDDhhmmss) |
GRANTED | granted | bool | CHAR 1 | XFELD | Granted |
SOURCE | source | String | CHAR 10 | /ACME/SOURCE | Source (banner / dsr / gpc) |
SEQNO | seqno | i32 | INT4 10 | INT4 | Sequence within the second |
Generated Rust
// abap_to_rust::acme::Consent
/// `/ACME/CONSENT`: Consent ledger (customer namespace /ACME/)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Consent {
/// `MANDT` CLNT 3 (key): Client
#[serde(rename = "MANDT")]
pub mandt: String,
/// `KUNNR` CHAR 10 (key): Customer Number
#[serde(rename = "KUNNR")]
pub kunnr: String,
/// `PURPOSE` CHAR 20 (key): Purpose (analytics / ads / sale_share)
#[serde(rename = "PURPOSE")]
pub purpose: String,
/// `RECORDED_AT` DEC 15 (key): Recorded at (UTC, YYYYMMDDhhmmss)
#[serde(rename = "RECORDED_AT", with = "crate::abap::timestamp")]
pub recorded_at: Option<chrono::NaiveDateTime>,
/// `GRANTED` CHAR 1: Granted
#[serde(rename = "GRANTED", default, with = "crate::abap::xflag")]
pub granted: bool,
/// `SOURCE` CHAR 10: Source (banner / dsr / gpc)
#[serde(rename = "SOURCE", default)]
pub source: String,
/// `SEQNO` INT4 10: Sequence within the second
#[serde(rename = "SEQNO", default)]
pub seqno: i32,
}
impl Consent {
pub const TABNAME: &'static str = "/ACME/CONSENT";
pub const KEY: &'static [&'static str] = &["MANDT", "KUNNR", "PURPOSE", "RECORDED_AT"];
/// (ABAP name, Rust name), in DDIC position order.
pub const FIELDS: &'static [(&'static str, &'static str)] = &[("MANDT", "mandt"), ("KUNNR", "kunnr"), ("PURPOSE", "purpose"), ("RECORDED_AT", "recorded_at"), ("GRANTED", "granted"), ("SOURCE", "source"), ("SEQNO", "seqno")];
}
Sample record
As exported, with ABAP names and internal formats (fixtures/records/acme_consent.json, read by tests/convert.rs):
[{"MANDT":"100","KUNNR":"0000012345","PURPOSE":"ads","RECORDED_AT":20261104100200,"GRANTED":"X","SOURCE":"banner","SEQNO":0},
{"MANDT":"100","KUNNR":"0000012345","PURPOSE":"ads","RECORDED_AT":20261104100500,"GRANTED":"","SOURCE":"dsr","SEQNO":0}]
Field index
Every ABAP field in this book, A to Z. A field that maps to different Rust types in different tables is marked differs.
| ABAP field | Rust field | Rust type | Tables | Google Merchant |
|---|---|---|---|---|
/ACME/GPC | acme_gpc | bool | KNA1 | |
ADDRNUMBER | addrnumber | String | ADR6, ADRC | |
ADRNR | adrnr | String | KNA1 | |
ARKTX | arktx | String | VBAP | |
AUART | auart | String | VBAK | |
AUFSD | aufsd | String | KNVV | |
BREIT | breit | rust_decimal::Decimal | MARM | shipping_width |
BRGEW | brgew | rust_decimal::Decimal | MARA, MARM | shipping_weight |
BWKEY | bwkey | String | MBEW | |
BWTAR | bwtar | String | MBEW | |
CHANGENR | changenr | String | CDHDR, CDPOS | |
CHANGE_IND | change_ind | String | CDHDR | |
CHNGIND | chngind | String | CDPOS | |
CITY1 | city1 | String | ADRC | |
CLIENT | client | String | ADR6, ADRC | |
CONSNUMBER | consnumber | String | ADR6 | |
COUNTRY | country | String | ADRC | |
CURRDEC | currdec | u8 | TCURX | price sale_price |
CURRKEY | currkey | String | TCURX | |
DATAB | datab | Option<chrono::NaiveDate> | A004 | price sale_price sale_price_effective_date |
DATBI | datbi | Option<chrono::NaiveDate> | A004 | price sale_price sale_price_effective_date |
DATE_FROM | date_from | Option<chrono::NaiveDate> | ADR6, ADRC | |
DEFLT_COMM | deflt_comm | String | ADRC | |
EAN11 | ean11 | String | MARA, MARM | gtin identifier_exists |
ERDAT | erdat | Option<chrono::NaiveDate> | KNA1, VBAK | |
ERSDA | ersda | Option<chrono::NaiveDate> | MARA | |
ERZET | erzet | Option<chrono::NaiveTime> | VBAK | |
FLGDEFAULT | flgdefault | bool | ADR6 | |
FLG_NOUSE | flg_nouse | bool | ADR6 | |
FNAME | fname | String | CDPOS | |
GEWEI | gewei | String | MARA, MARM | product_weight shipping_weight |
GRANTED | granted | bool | /ACME/CONSENT | |
HOEHE | hoehe | rust_decimal::Decimal | MARM | shipping_height |
INHAL | inhal | rust_decimal::Decimal | MARA | unit_pricing_measure |
INHME | inhme | String | MARA | unit_pricing_measure |
INSME | insme | rust_decimal::Decimal | MARD | availability |
KAPPL | kappl | String | A004 | |
KBETR | kbetr | rust_decimal::Decimal | KONP | price sale_price |
KDGRP | kdgrp | String | KNVV | |
KMEIN | kmein | String | KONP | |
KNUMH | knumh | String | A004, KONP | |
KONWA | konwa | String | KONP | price sale_price |
KOPOS | kopos | String | KONP | |
KPEIN | kpein | rust_decimal::Decimal | KONP | price sale_price |
KSCHL | kschl | String | A004, KONP | price sale_price |
KUNNR | kunnr | String | KNA1, VBAK, /ACME/CONSENT, KNVV | |
KWMENG | kwmeng | rust_decimal::Decimal | VBAP | |
LABST | labst | rust_decimal::Decimal | MARD | availability |
LAENG | laeng | rust_decimal::Decimal | MARM | shipping_length |
LAND1 | land1 | String | KNA1, T001W | ships_from_country |
LANGU | langu | String | ADRC | |
LGORT | lgort | String | MARD | |
LOEVM | loevm | bool | KNA1, KNVV | |
LOEVM_KO | loevm_ko | bool | KONP | price |
LVORM | lvorm | bool | MARA | |
MAKTX | maktx | String | MAKT | title |
MANDANT | mandant | String | CDHDR, CDPOS | |
MANDT | mandt | String | KNA1, VBAK, /ACME/CONSENT, KNVV, VBAP, MARA, MAKT, MARM, MARD, MBEW, A004, KONP, T001W, T179T | |
MATKL | matkl | String | MARA | google_product_category |
MATNR | matnr | String | VBAP, MARA, MAKT, MARM, MARD, MBEW, A004 | id |
MEABM | meabm | String | MARM | shipping_height shipping_length shipping_width |
MEINH | meinh | String | MARM | |
MEINS | meins | String | MARA | |
MFRNR | mfrnr | String | MARA | brand |
MFRPN | mfrpn | String | MARA | identifier_exists mpn |
MTART | mtart | String | MARA | |
NAME1 | name1 | String | KNA1, ADRC, T001W | |
NATION | nation | String | ADRC | |
NETWR | netwr | rust_decimal::Decimal | VBAK, VBAP | |
NTGEW | ntgew | rust_decimal::Decimal | MARA | product_weight |
NUMTP | numtp | String | MARA, MARM | gtin |
OBJECTCLAS | objectclas | String | CDHDR, CDPOS | |
OBJECTID | objectid | String | CDHDR, CDPOS | |
ORT01 | ort01 | String | KNA1 | |
PEINH | peinh | rust_decimal::Decimal | MBEW | cost_of_goods_sold |
PERSNUMBER | persnumber | String | ADR6 | |
POSNR | posnr | String | VBAP | |
POST_CODE1 | post_code1 | String | ADRC | |
PRDHA | prdha | String | MARA | product_type |
PRODH | prodh | String | T179T | product_type |
PSTLZ | pstlz | String | KNA1 | |
PURPOSE | purpose | String | /ACME/CONSENT | |
RECORDED_AT | recorded_at | Option<chrono::NaiveDateTime> | /ACME/CONSENT | |
REGIO | regio | String | KNA1, T001W | |
REGION | region | String | ADRC | |
SATNR | satnr | String | MARA | item_group_id |
SEQNO | seqno | i32 | /ACME/CONSENT | |
SMTP_ADDR | smtp_addr | String | ADR6 | |
SOURCE | source | String | /ACME/CONSENT | |
SPART | spart | String | KNVV | |
SPEME | speme | rust_decimal::Decimal | MARD | availability |
SPRAS | spras | String | KNA1, MAKT, T179T | title |
STPRS | stprs | rust_decimal::Decimal | MBEW | cost_of_goods_sold |
STREET | street | String | ADRC | |
TABKEY | tabkey | String | CDPOS | |
TABNAME | tabname | String | CDPOS | |
TCODE | tcode | String | CDHDR | |
TEL_NUMBER | tel_number | String | ADRC | |
UDATE | udate | Option<chrono::NaiveDate> | CDHDR | |
UMREN | umren | rust_decimal::Decimal | MARM | |
UMREZ | umrez | rust_decimal::Decimal | MARM | |
USERNAME | username | String | CDHDR | |
UTIME | utime | Option<chrono::NaiveTime> | CDHDR | |
VALUE_NEW | value_new | String | CDPOS | |
VALUE_OLD | value_old | String | CDPOS | |
VBELN | vbeln | String | VBAK, VBAP | |
VERPR | verpr | rust_decimal::Decimal | MBEW | cost_of_goods_sold |
VKORG | vkorg | String | KNVV, A004 | |
VPRSV | vprsv | String | MBEW | cost_of_goods_sold |
VRKME | vrkme | String | VBAP | |
VTEXT | vtext | String | T179T | product_type |
VTWEG | vtweg | String | KNVV, A004 | |
WAERK | waerk | String | VBAK, VBAP | |
WAERS | waers | String | KNVV | |
WERKS | werks | String | VBAP, MARD, T001W | |
WRKST | wrkst | String | MARA | material |
ZZ_MKT_OPTIN | zz_mkt_optin | bool | KNA1 |
No field changes type between tables in this book.