Skip to content

XRechnung – Example

Many ERP and inventory programs can print invoices but cannot create an XRechnung. With RUNOS it is enough that the printed invoice contains a few extra lines. RUNOS reads them, creates the XRechnung, validates it with the KoSIT validator and sends it.

ERP prints invoice ──▶ RUNOS PDF printer saves PDF to the pool ──▶ RUNOS File trigger
│
script blocks in the PDF text ◀─┘
│
create XRechnung + KoSIT check + ZUGFeRD PDF
│
mail to the customer (SMTP / MAPI / Microsoft 365)

In RUNOS under Printer, create a PDF printer with the folder C:\RUNOS\Invoices that saves every document automatically there, and select it in the ERP for invoices. How to do that is described under PDF printer.

The PDF must contain real text (not a scanned image) so RUNOS can read the script blocks.

2. Write the invoice data into the printout

Section titled “2. Write the invoice data into the printout”

Add lines in the shorthand of script blocks to your ERP’s invoice form. Each line sets one field of the invoice. XR is the name of the XRechnung action in the workflow (step 3):

#RUNOS XR.Invoice.BT1=INV-2026-0001 #RUNOS
#RUNOS XR.Invoice.BT2=2026-10-08 #RUNOS
#RUNOS XR.Invoice.BT9=2026-11-07 #RUNOS
#RUNOS XR.Invoice.BT10=04011000-12345-03 #RUNOS
#RUNOS XR.Invoice.BG7.BT44=Customer GmbH #RUNOS
#RUNOS XR.Invoice.BG7.BT49=invoice@customer.de #RUNOS
#RUNOS XR.Invoice.BG7.BG8.BT50=Beispielweg 2 #RUNOS
#RUNOS XR.Invoice.BG7.BG8.BT52=München #RUNOS
#RUNOS XR.Invoice.BG7.BG8.BT53=80331 #RUNOS
#RUNOS XR.Invoice.BG25.BT126=1 #RUNOS
#RUNOS XR.Invoice.BG25.BT129=2 #RUNOS
#RUNOS XR.Invoice.BG25.BT130=HUR #RUNOS
#RUNOS XR.Invoice.BG25.BG29.BT146=50.00 #RUNOS
#RUNOS XR.Invoice.BG25.BG30.BT151=S #RUNOS
#RUNOS XR.Invoice.BG25.BG30.BT152=19 #RUNOS
#RUNOS XR.Invoice.BG25.BG31.BT153=Consulting #RUNOS
#RUNOS XR.Invoice.BG25.BT126=2 #RUNOS
#RUNOS XR.Invoice.BG25.BT129=1 #RUNOS
#RUNOS XR.Invoice.BG25.BT130=C62 #RUNOS
#RUNOS XR.Invoice.BG25.BG29.BT146=120.00 #RUNOS
#RUNOS XR.Invoice.BG25.BG30.BT151=S #RUNOS
#RUNOS XR.Invoice.BG25.BG30.BT152=19 #RUNOS
#RUNOS XR.Invoice.BG25.BG31.BT153=Setup #RUNOS
#RUNOS SendMail.To=invoice@customer.de #RUNOS
#RUNOS SendMail.Subject=Invoice INV-2026-0001 #RUNOS
  • Every line item starts with BT126 (line number). Another BT126 starts the next item. Write each item completely before the next one starts.
  • Per item: quantity (BT129), unit (BT130), net price (BG29.BT146), VAT category and rate (BG30.BT151, BG30.BT152) and name (BG31.BT153).
  • Amounts with a dot as decimal separator and no thousands separator.
  • The lines may be printed small (e.g. 4-point at the bottom of the page, even white on white), but they must be in the PDF’s text. Don’t let a line wrap.
  • The last two lines set the recipient and subject of the mail action SendMail.

Which fields exist is listed under Structure. In the E-invoice (XRechnung) view of the activity bar you can try out an invoice first.

The fixed data (your company, bank details, payment terms) is in the Invoice parameter of the XRechnung action once. The values from the PDF are laid over it.

{
"Name": "ERP invoice as XRechnung",
"Autostart": true,
"Trigger": {
"Type": "File",
"Name": "InvoicePrint",
"Parameters": {
"Pool": "C:\\RUNOS\\Invoices",
"Filter": "*.pdf",
"CronExpression": "0/10 * * * * ?"
}
},
"Actions": [
{
"Type": "XRechnung",
"Name": "XR",
"Parameters": {
"AutoCalculateTotals": true,
"EnableZugferd": true,
"PdfSourcePath": "{{FilePath}}",
"SaveToFolder": true,
"OutputFolder": "C:\\RUNOS\\Archive\\%yyyy%",
"Invoice": {
"BT3": "380",
"BT5": "EUR",
"BT20": "Payable within 30 days without deduction.",
"BG4": {
"BT27": "Muster GmbH",
"BT31": "DE123456789",
"BT34": "invoice@muster.de",
"BT34-1": "EM",
"BG5": { "BT35": "Musterstraße 1", "BT37": "Berlin", "BT38": "10115", "BT40": "DE" },
"BG6": { "BT41": "Accounting", "BT42": "+49 30 1234567", "BT43": "invoice@muster.de" }
},
"BG7": {
"BT49-1": "EM",
"BG8": { "BT55": "DE" }
},
"BG16": {
"BT81": "58",
"BG17": [ { "BT84": "DE89370400440532013000", "BT85": "Muster GmbH" } ]
}
}
}
},
{
"Type": "SMTP",
"Name": "SendMail",
"Parameters": {
"SmtpServer": "smtp.example.com",
"SmtpUser": "{{connector.Mailserver.Username}}",
"SmtpPassword": "{{connector.Mailserver.Password}}",
"From": "invoice@muster.de",
"FromName": "Muster GmbH",
"To": "",
"Subject": "Your invoice",
"Body": "Hello,\n\nplease find attached our invoice as a ZUGFeRD PDF.",
"Attachments": "{{XR.Response.Results.Zugferd.ZugferdPath}}"
}
}
]
}

AutoCalculateTotals calculates line amounts, VAT breakdown and totals, so the ERP doesn’t have to print them. The mail server credentials are in a Basic connector named Mailserver.

  1. Open the workflow in the editor and click Listen.
  2. Print an invoice from the ERP to the RUNOS PDF printer.
  3. The log shows the file found, the script blocks read (ScriptShorthandParsed), the validation result and the sending.

If validation fails, the message names every missing or wrong field with the rule from the standard. The PDF is then in C:\RUNOS\Invoices\Spooler\Failed\. Correct the form or the data and print again.

  • XML only instead of a ZUGFeRD PDF: leave out EnableZugferd and attach {{XR.Response.Results.FilePath}}. Public authorities usually require the pure XRechnung with the Leitweg-ID in BT10.
  • Filing instead of mail: SaveToFolder: true with OutputFolder keeps the XML and ZUGFeRD PDF; the mail action is not needed.
  • Data as a JSON block: instead of many shorthand lines the ERP can print one JSON block: #RUNOS {"Actions":{"XR":{"Invoice":{"BT1":"INV-2026-0001", …}}}} #RUNOS.
  • Data from a file: if the ERP writes the invoice as a JSON file, the File trigger takes *.json and the action "InvoiceJsonFile": "{{FilePath}}".
  • Templates: under New, the template Gedruckte Rechnung als XRechnung contains exactly this workflow, XRechnung per E-Mail a workflow that creates, validates and mails an XRechnung from data in the workflow.