Latest posts Visit blog

A B2B shop can handle customer groups, tiered pricing and approval workflows and still fail on a single question: which customers received batch C-2609-114? Anyone who cannot answer that inside the B2B shop ends up searching the warehouse, then the ERP system, and finally a folder of printed delivery notes. Batch and serial numbers are no longer a special case for two industries; they are a data field that has to travel the whole way from goods receipt to the outgoing document. This article shows which rules demand which number, what the underlying data model looks like, where the chain breaks in daily operation, and in what order a retrofit actually pays off.

What a batch is and where the shop loses it

A batch is not an invention of software vendors but a legal term with a fixed meaning. EU law describes it as a set of sales units produced, manufactured or packaged under practically the same conditions (Directive 2011/91/EU) - same raw materials, same line, same period. For the shop this has an uncomfortable consequence: two packs of the same article are different things from a traceability point of view as soon as they come from different batches. An article record that only knows part number, price and total stock cannot represent that difference. It loses it at the latest where the basket is served from a single stock figure without knowing which unit actually went into the box.

A serial number goes one step further. It identifies not a quantity but the individual item, and it is therefore the finest resolution a supply chain knows at all. For prescription medicines the EU makes it mandatory; for capital goods, tools, measuring devices and electronics it has long been standard practice, because warranty handling, maintenance history and spare part matching would otherwise be guesswork. Inside the shop the difference means two distinct data models: a batch is a property of a stock portion, a serial number is a record of its own covering exactly one unit. Put both into the same free text field and you lose the ability to query them on the day it matters.

For the purposes of this Directive, a lot means a batch of sales units of a foodstuff produced, manufactured or packaged under practically the same conditions.

Directive 2011/91/EU, Article 1(2)

The number is rarely lost in the warehouse; it is lost at the handovers. Goods receipt books batches cleanly, the shop knows only a total stock figure, picking decides at the shelf which unit goes into the box, and the delivery note is generated from the order rather than from the actual withdrawal. What remains is a document that states the quantity ordered but not the batch delivered. If something is flagged later, the recipient list can only be estimated. That estimate is exactly why recalls regularly turn out larger than necessary: if you do not know who is affected, you have to inform everyone - and you carry the cost of every unit included as a precaution.

Batch or serial: two models, not two labels

A batch number describes a quantity, a serial number a single item. The batch gives you a one-to-many link from a stock portion to many units; the serial gives you a one-to-one link from a record to exactly one unit. Both need their own tables in the shop, their own stock logic and their own display in the customer account. Putting them into a shared free text field saves a week of development and repays it with interest at the first serious traceability request.

The obligation to keep a number rarely comes from commercial law; as a rule it comes from the product law of the specific goods category - and those rules differ considerably in level, format and timing. For cosmetic products the batch number or an equivalent marking is part of the mandatory labelling on container and packaging (Regulation EC 1223/2009, Article 19(1)(e)). Anyone supplying such goods to resellers therefore has to keep it in the data as well, not just print it, because the buyer continues the record on their own side. The same logic applies to assortments sold through customer groups and tiered pricing in a B2B shop: the number is part of the goods, not part of the label.

Goods categoryMandatory markingLegal basisGranularity
Foodstuffs in generalLot marking, usually preceded by the letter LDirective 2011/91/EU, Article 1Lot
Food of animal originReference identifying the lot, batch or consignment in accompanying dataRegulation EU 931/2011, Article 3Consignment
Cosmetic productsBatch number on container and packagingRegulation EC 1223/2009, Article 19Batch
Prescription medicinesSerial number, randomised, at most 20 charactersRegulation EU 2016/161, Article 4Pack
Tobacco productsUnique identifier, at most 50 charactersRegulation EU 2018/574, Article 8Pack

The strictest format requirements sit in pharmaceutical law, and they are instructive for any shop creating a number field. The serial number is a numeric or alphanumeric sequence of a maximum of 20 characters (Regulation EU 2016/161) - that is the upper limit a database column has to carry, and at the same time the reason a field sized for 12 characters becomes expensive later. The second requirement is just as notable: the number must not be a counter. The probability that it can be guessed has to be negligible and in any case lower than one in ten thousand (Regulation EU 2016/161). An auto-increment sequence does not meet that; a random generator with a collision check does.

None of this is new. Serialisation for prescription human medicines has applied since 9 February 2019 (Regulation EU 2016/161), so for merchants in that field the question has not been whether for years, but how cleanly. Outside pharmaceuticals the EU also prescribes character lengths: for tobacco products the unique identifier consists of a sequence of alphanumeric characters that is as short as possible and no longer than 50 characters per pack (Regulation EU 2018/574). Two legal acts, two upper limits, one pattern: the legislator sets the field length, not the shop. Anyone carrying both categories sizes the column to the larger figure and enforces the smaller limit in the business logic.

  • Size the field by the rule, not by the sample data: 50 characters of column width cost nothing, a later migration across millions of document lines does.
  • Alphanumeric, not numeric: as soon as one supplier uses letters, an integer field fails at the first goods receipt.
  • Fix case handling up front: two batches that differ only in capitalisation are either the same one or not. That has to be decided before the first record exists.
  • Preserve leading zeros: a number here is a string, not an integer. A spreadsheet export that converts it into a numeric value destroys it silently.
  • Uniqueness per article, not globally: two suppliers may legitimately use the same batch label. The key is the pair of article and number.

The data model: three levels instead of one field

Technically, traceability is not a field but a graph. It has three kinds of nodes: the goods receipt with the supplier batch, your own batch with its units, and the document line through which a quantity leaves the building. Only the edges between those nodes make the chain provable, and those edges are exactly what most grown systems lack. The shop is rarely the leading system here: goods receipt and stock live in the ERP, the shop displays and orders. Which interfaces to the ERP system carry that data decides whether a batch enquiry takes seconds or days.

batch-model.sql
-- Drei Ebenen: Charge, Seriennummer, Belegposition
CREATE TABLE charge (
  id BIGINT PRIMARY KEY,
  artikel_id BIGINT NOT NULL,
  nummer VARCHAR(50) NOT NULL, -- Obergrenze aus der Tabakverordnung
  lieferant_id BIGINT,
  wareneingang DATE NOT NULL,
  mhd DATE,
  UNIQUE (artikel_id, nummer)
);

CREATE TABLE serie (
  id BIGINT PRIMARY KEY,
  charge_id BIGINT NOT NULL REFERENCES charge(id),
  nummer VARCHAR(20) NOT NULL, -- Obergrenze aus der Arzneimittelverordnung
  status ENUM('frei','reserviert','geliefert','retour') NOT NULL,
  UNIQUE (charge_id, nummer)
);

CREATE TABLE belegposition_charge (
  beleg_id BIGINT NOT NULL,
  position INT NOT NULL,
  charge_id BIGINT NOT NULL REFERENCES charge(id),
  serie_id BIGINT NULL REFERENCES serie(id),
  menge DECIMAL(12,3) NOT NULL,
  PRIMARY KEY (beleg_id, position, charge_id, serie_id)
);

Three details in this model matter more than they look. First, the batch hangs off the goods receipt, not off the article alone: without the supplier link the step backwards in the chain is missing. Second, the serial number is subordinate to the batch rather than a peer - otherwise you create units without origin. Third, the assignment hangs off the document line, not off the document: one line can be served from two batches when the first one runs short, and that case is the norm rather than the exception. Attaching the assignment to the order header produces an enquiry that answers incorrectly for partial deliveries. In projects with an existing ERP system it is worth checking the model there first; the article on ERP integration between Shopware and SAP shows what such a coupling looks like in practice.

  • Stock per batch, not per article: available stock is the sum of batch stocks, not the other way round.
  • Reservation at batch level: if the batch is only decided when packing, the enquiry stays incomplete until then.
  • Best-before date as picking order: withdrawing without sorting by expiry produces write-offs and confusing documents.
  • Block flag per batch: a blocked batch has to disappear from sale without deactivating the article.
  • History instead of overwriting: batch assignments are not corrected but reversed and rebooked. That is the only way the sequence stays readable.
The number belongs on the line, not on the order

The most common design mistake is a single batch field on the order or the delivery note. It works exactly until one line is served from two batches - and for stocked goods that is the normal case, not an edge case. The robust structure assigns each document line a list of batch and quantity. The sum of those quantities has to match the quantity delivered; this check is the most effective guard against silent gaps in the chain.

The path through the shop: from goods receipt to delivery note

A chain is only as strong as its weakest link, and in shop operations that link is rarely the database but a work step nobody perceives as data capture. Goods receipt books a pallet as a lump because the supplier note lists three different batches and typing them costs time. Picking grabs two cartons from the front of the shelf without scanning. The result is stock that adds up numerically and says nothing substantively. How closely stock management and sales channels are tied together shows up even with plain quantities: the article on real-time inventory sync across channels describes the same breaking point without batches.

For food of animal origin the EU requires that the accompanying data include a reference identifying the lot, batch or consignment (Regulation EU 931/2011, Article 3(g)); that obligation has applied since 1 July 2012 (Regulation EU 931/2011). In practice this means the number belongs on the delivery note and in the electronic order confirmation, not only in an internal table. A buyer who is subject to record keeping in turn cannot book in a delivery without that reference - and will reject it or ask for it afterwards. The proof travels with the goods, not separately from them.

Goods receipt

Every delivery is recorded with supplier batch, quantity and shelf life. Book it as a lump here and there is nothing to trace later - no downstream step can close that gap.

Picking

The withdrawal writes back which batch was actually taken. A scan at this point replaces any later reconstruction and costs a few seconds per line.

Documents

Delivery note, invoice and order confirmation carry the number per line. The document is the proof a commercial buyer may have to present to their own authority.

Returns

A return without a batch assignment creates stock without origin. The number has to be captured again when putting it back, otherwise it dilutes the verified stock.

Anyone running a branch or a collection counter alongside the shop has the same break at a second point: a sale at the till removes stock without creating the batch assignment. That is precisely why the point-of-sale connection belongs in the same analysis as the shop connection - the article on connecting a POS system to the online shop describes how stock and receipt come together there. For traceability one simple rule applies: every route by which goods leave the building has to write the number along. A single channel without capture makes the enquiry uncertain for the entire stock.

EDI and shop carry the same number

In B2B the shop is often thought of as the digital channel. The figures disagree: in the EU, 11.07 percent of total turnover of enterprises with ten or more employees comes from orders placed via EDI-type messages, but only 8.39 percent from orders via websites or apps (Eurostat). The electronic ordering route between businesses therefore carries more turnover than the web shop - and that route has to carry the batch identifier too, otherwise the enquiry has a blind spot exactly where the volume is largest. The same applies to catalogue-side connections; how closely ordering and catalogue routes are tied is shown in the article on PunchOut catalogues via OCI and cXML.

Pure EDI operation is the exception: only 2.9 percent of EU enterprises handle electronic sales exclusively via EDI-type messages (Eurostat). The shop is the normal case - 17.99 percent of EU enterprises sell electronically via websites or apps only, and just 2.7 percent use both channels (Eurostat). For that smaller group, completeness of the enquiry depends on both digital routes carrying the same batch identifier in the same format; otherwise the answer varies with the channel the order came through. In total, 23.59 percent of enterprises with ten or more employees in the EU sold electronically, compared with 18.93 percent ten years earlier (Eurostat). The share grows slowly but steadily - and with it the share of records that have to be created by machine, because nobody adds them by hand any more.

The own shop remains the main route for web sales: 85.65 percent of EU enterprises with web sales use their own website or app for it (Eurostat). Among large enterprises with 250 or more employees, the share selling electronically is 48.48 percent (Eurostat) - these are the buyers who do not ask for batch records but assume them in the ordering process. And turnover from web sales to other businesses and public authorities amounts to 4.34 percent of total turnover, above the share from sales to private consumers (Eurostat). The B2B web channel is not a side stage, then, but the place where the record chain becomes visible.

Terminal
$ curl -s /api/traceability/batch/C-2609-114/recipients
customer 4711 DN-9931 120 2026-08-04 customer 4809 DN-9947 240 2026-08-06 customer 5102 DN-9952 122 2026-08-11
$ curl -s /api/traceability/serial/S-0311
batch C-2609-114 receipt GR-2418 supplier L-88 document DN-9947

A dependable enquiry consists of two queries running in both directions: from the batch to all recipients, and from a single unit back to goods receipt and supplier. Both should exist as an interface rather than a spreadsheet export somebody assembles by hand. The reason is mundane: in a serious case it is not one person asking but several at once, and the answers have to match. If you are integrating your ERP system anyway, plan both endpoints into the same project; what such a coupling looks like day to day is described in the article on connecting the ERP system to Shopware.

Retention: the number outlives the shop

Traceability is not a question of current operations but of deadlines. Under German tax law, books, records and annual financial statements must be kept for ten years and accounting vouchers for eight years (German Fiscal Code, section 147(3)); commercial law sets the same periods in section 257(4) and adds six years for other documents (German Commercial Code). A delivery note carries that period only for as long as it is an accounting voucher: for received delivery notes the retention period otherwise ends when the invoice arrives, for dispatched ones when the invoice is sent (German Fiscal Code, section 147(3) sentences 3 and 4). The long period therefore rests on the accounting voucher itself - on the invoice carrying the batch reference. Keep batch data only in the shop and replace the shop every five years, and it is gone long before the period ends. Which data has to stay and which has to go is sorted out in the article on a deletion concept with retention periods.

The longer clock runs in liability law. Claims under the German product liability regime expire ten years after the point in time at which the producer put the product causing the damage into circulation (German Product Liability Act, section 13(1)). Ten years is an eternity in the shop world: two platform changes, several data migrations, usually a change of hosting. The batch assignment has to survive that time, and experience says it only does when it does not live in the shop alone but in the leading system plus an immutable document archive. A PDF archive of delivery notes is not a luxury here but the simplest insurance against a system change.

A platform change is the most common breaking point

During migrations, articles, customers and orders are carried over - batch assignments regularly drop out, because they sit in secondary tables no standard export knows about. Before any change, one question therefore belongs in the acceptance list: after the migration, can the batch still be named for any given historical document line? Ask that question only after the old system has been switched off and the answer can no longer be produced.

Recall: from the batch to the recipient

The serious case differs from daily business mainly in pace. A supplier reports an issue, and from that moment what counts is how quickly a batch number turns into a dependable recipient list. Operations that have maintained their chain need one query; operations without assignments need days and end up with a list that is too large. The difference is not only organisational but pays out immediately: every unit included as a precaution costs transport, credit notes and trust. With bulky or freight-bound goods this gets expensive fast - the article on freight shipping for bulky goods shows which routes come together there.

  1. Block the batch before communicating. Sales of the affected units have to stop at once, including in channels that do not run through the shop.
  2. Pull the recipient list per document line. The basis is quantities delivered, not ordered - partial deliveries and cancellations change the picture considerably.
  3. Notify processors first. Anyone who builds the goods in or repacks them passes the chain on and needs the lead time most urgently.
  4. Separate the stock physically in the warehouse. A blocked batch left in the same bin ends up in a carton the next day.
  5. Book returns with a batch reference. Without this step you create stock without origin, and the block becomes ineffective.
  6. Log the sequence and the timestamps. The log is the evidence towards buyers and authorities - it is created during the process or not at all.

Two metrics are worth measuring, and in quiet times rather than in the serious case: the time from a batch number to a complete recipient list, and the share of document lines with a valid batch assignment. The first figure describes responsiveness, the second the data quality it rests on. If the share sits at 82 percent, the enquiry is incomplete in one out of five cases - and you do not learn that beforehand but in the hour when it counts. A monthly report on both values costs little and makes measurable a chain that otherwise exists only as an assumption.

What 2026 and 2027 add in record keeping

The direction of European product law is unambiguous: more and more goods categories need data down to the individual consignment. For large and medium operators the deforestation regulation applies from 30 December 2026, for micro and small operators from 30 June 2027 (European Commission). Covered are cattle, wood, cocoa, soy, palm oil, coffee and rubber as well as derived products - which also means packaging, furniture parts and food ingredients that travel unnoticed in many assortments. The information system through which due diligence statements are submitted per consignment went live on 4 December 2024 (European Commission).

The scale of this regulation is no formality: it is meant to reduce emissions from EU consumption and production of the covered commodities by at least 32 million tonnes per year (European Commission). A target of that order can only be reached with a record chain operating at consignment level - which is exactly the level at which batches are kept. For merchants this means less a new technology than a second use for the same data: anyone already keeping batch, origin and consignment cleanly has the basis, and adds geolocation data and statement references rather than reinventing the structure.

Running in parallel is the ecodesign regulation, which entered into force on 18 July 2024 (European Commission) and prepares the digital product passport for nearly all physical products; which product groups come first is set out in the Commission's first working plan of April 2025 (European Commission). The batteries regulation, from which the battery passport follows, entered into force on 17 August 2023 (European Commission). All three initiatives lead to the same place: a product instance needs an identifier that data can hang off. What that means for shop data is put in context in the article on the digital product passport.

Batch handling belongs in the architecture, not in an extra field

The technical basis for all of this is a system that shares data between purchasing, warehouse and sales - and not even every second enterprise in the EU has one: 46.45 percent of enterprises with ten or more employees used ERP software in 2025 (Eurostat). Among small enterprises with 10 to 49 employees the figure is 41.08 percent (Eurostat) - so it is thinnest exactly where B2B business is subject to the same record keeping as at large suppliers. Anyone working without a leading system therefore needs clean ownership of article data and attributes first; the article on product data sovereignty through a PIM describes the step before this one.

  • Define field lengths and character sets per goods category before the first table exists.
  • Separate batch stock from article stock and reserve at batch level.
  • Attach the assignment to the document line, with the quantity sum as a validation rule.
  • Enforce capture at every outbound route: shop, EDI, till, collection, returns.
  • Provide two queries as an interface: batch to recipients, unit to origin.
  • Build a document archive outside the shop, designed for ten years.
  • Measure monthly: coverage of the assignment and time to the recipient list.

The commercial core is unspectacular: batch handling does not raise turnover, it lowers risk and effort in the serious case. That is why it pays off in reverse order - first the document that carries the number, then capture at the outbound routes, and only last the display in the customer account. Start the other way round and you build a pretty surface on top of data that does not exist. For assortments with variants, assemblies or spare parts it is also worth looking at the catalogue structure, because the batch question hangs off the line there rather than off the article. Where standard features fall short, the missing part is built as custom development inside the existing system rather than as a second tool next to it.

Sources and studies

This article draws on Eurostat surveys of business and e-commerce statistics (data sets on ERP use in 2025 and the 2024 e-commerce survey, in each case enterprises with ten or more employees in the EU), on Delegated Regulation EU 2016/161 on the safety features appearing on the packaging of medicinal products for human use, Implementing Regulation EU 2018/574 on the traceability system for tobacco products, Implementing Regulation EU 931/2011 on the traceability requirements for food of animal origin, Regulation EC 1223/2009 on cosmetic products and Directive 2011/91/EU on lot marking. The retention periods come from section 147 of the German Fiscal Code, section 257 of the German Commercial Code and section 13 of the German Product Liability Act as currently in force; the application dates for the deforestation, ecodesign and batteries regulations come from the topic pages of the European Commission. Percentages refer to the population stated in the respective source and not to the German market alone.

As soon as one goods category in the assortment is subject to a record keeping obligation, or a commercial buyer expects the reference on the document. Typically this covers food, cosmetics, medicines, chemicals, construction products and safety-relevant technology. Independently of that, it pays off as soon as a recall would be more than a theoretical case - the cost usually comes not from capturing the data but from the missing boundary in the serious case. For an assessment of your own assortment a short conversation helps; we look at the goods categories and classify them, see request advice.

Usually not. A field on the article only describes the batch booked in last and loses its meaning as soon as two batches are in the warehouse at the same time - which is the normal case with ongoing procurement. The assignment becomes dependable only when stock is kept per batch and every document line carries a list of batch and quantity. The extra effort lies mainly in capture at the outbound routes, not in the database structure.

The rules set the upper limit: at most 20 characters for the serial number on prescription human medicines (Regulation EU 2016/161) and at most 50 characters for the unique identifier on tobacco products (Regulation EU 2018/574). Anyone carrying several goods categories sizes the column to the larger value and enforces the smaller limit in the business logic. Alphanumeric as the data type, leading zeros preserved, case handling decided up front.

For documents the commercial and tax periods apply: ten years for books and financial statements, eight years for accounting vouchers, six years for other documents (German Commercial Code). In practice the decisive clock is usually product liability, whose claims expire only ten years after the product was put into circulation (German Product Liability Act). As a planning rule of thumb: the batch assignment should survive a platform change, so it has to be archived outside the shop.

If the ordering route is electronic, yes - otherwise a gap opens exactly where the volume is largest. In the EU, 11.07 percent of total turnover comes from orders via EDI-type messages compared with 8.39 percent via websites and apps (Eurostat). The number belongs in the same fields as in the shop document so that the enquiry gives the same answer across both routes. Otherwise completeness depends on which channel a customer happened to use.

With assemblies and spare parts the traceability question hangs off the line, not the article: the same part number can come from several production lots, and the link to the installed device is typically only created during installation. A catalogue that models assemblies cleanly is therefore the precondition for a dependable assignment - what such a structure looks like is described in the article on the spare parts catalogue in a B2B shop.