SAFTCheck
Blog

4 min read

SAF-T (PT) from SAP rejected by AT: what to check

Why SAF-T files exported from SAP get rejected by AT and what to check: encoding and the XML declaration, customer tax IDs, documents outside the period, and ATCUD.

Why SAP exports need extra care

In SAP, the Portuguese SAF-T is produced by the localization for Portugal, configured by your SAP team or implementation partner. It is one export among hundreds in a system built for many countries, so the details AT is strict about are easy to get slightly wrong, and they tend to stay wrong every month until someone fixes the configuration.

AT usually answers with a generic "ficheiro inválido". These are the points to check, in order.

1. Encoding and the XML declaration

SAP systems store text in Unicode, and depending on how the export is set up the file can come out as UTF-8. AT expects Windows-1252, and the declaration on the first line has to match the bytes that follow. A file that says encoding="Windows-1252" but contains UTF-8 characters (or the other way round) is rejected, typically on names with accents such as João or Conceição. How to fix the UTF-8 error.

Also check for a byte order mark (BOM) before <?xml: some file transfer and download steps add one.

2. Customer tax IDs

  • Portuguese customers need a NIF with a valid check digit. Typos in customer master data are the most common NIF error. Check a NIF.
  • Foreign customers carry their own country's tax ID, and their billing country must be right: a foreign tax ID on a customer marked as PT looks like an invalid NIF.
  • Consumers without a NIF, including sales booked on a shared one-time customer account, are reported with the generic NIF 999999990 (Consumidor final).

3. Documents outside the period

The header states the period the file covers, and every invoice date must fall inside it. If the export selects documents by one date (for example the posting date) while InvoiceDate carries another, an invoice dated 31 August but posted on 1 September ends up in the September file with an August date.

4. ATCUD

Every document needs an ATCUD built from the validation code AT issued for its series, a dash and the document number. Check that each series was communicated to AT and that the code is stored exactly as issued, in uppercase. Check an ATCUD.

A workflow that fixes it once

  1. Export the file a few days before the deadline.
  2. Validate it: you get every error with its line number, in plain language you can forward to your SAP team.
  3. For the urgent month, use the auto-fix for encoding and the inline editor for a wrong NIF or ATCUD, then submit.
  4. Fix the cause in the SAP configuration or master data, so next month's export is clean.

Files up to 20 MB can be validated; the first validation is free and needs no account.

Other posts