HAERGI

Incoming invoices from KSeF in SAP. Automation of processing incoming invoices from KSeF in SAP.

Incoming invoices from KSeF in SAP. Automation of processing incoming invoices from KSeF in SAP.

The introduction of the National e-Invoicing System (KSeF) in Poland is associated with a revolution in the approach to electronic invoicing and data exchange between taxpayers and the tax administration. While much attention is focused on sending invoices to KSeF, considerably less is devoted to the subject of handling incoming invoices. Incoming invoices from KSeF in SAP — for companies operating on SAP systems, effective automation of their receipt and processing is key to cost optimization, reducing the risk of errors, and ensuring compliance with new regulations.

In this article, we present a practical approach to integrating KSeF with SAP for incoming invoices, analyze the solution architecture, describe automation possibilities, and highlight best practices worth implementing.

Incoming invoices from KSeF in SAP. Architecture of SAP integration with KSeF for incoming invoices

From a technical perspective, the process of receiving purchase invoices from KSeF into SAP is based on REST API communication between the ERP system and the Ministry of Finance’s gateway. Secure authorization using access tokens generated in the KSeF application is crucial, as it allows SAP to retrieve XML documents and metadata.

In the approach presented by HAERGI, integration takes place entirely within SAP, without the need for external intermediary servers. The solution is based on ABAP, which ensures:

Incoming invoices from KSeF in SAP – retrieval and classification mechanism

Document retrieval is carried out based on a query to the KSeF API using a certificate and a token linked to a specific tax ID (NIP). Invoices are imported into SAP and classified in a dedicated interface according to status:

The process can be fully automated (background job) or partially interactive – depending on the organization’s preferences.

Incoming invoices from KSeF in SAP – automatic assignment of operators and posting

The system enables automatic assignment of responsible operators based on:

Posting can be carried out based on predefined rules configured per company. For more complex scenarios, the system can trigger an approval workflow or send data to external tools (e.g., document circulation systems).

Extension possibilities and solution flexibility

In HAERGI’s product, extension points (BAdI) play a key role, allowing the logic of data mapping and posting to be tailored to specific companies and data sources. Each client receives a template implementation that is then adjusted during deployment to meet individual needs:

Verification, visualization, and error management

Each invoice, once retrieved, can be visualized in SAP based on the FA(3) structure, including header data, line items, and metadata. The system enables:

Further processing and inter-system integration

After booking or preliminary approval, the invoice can be forwarded:

Integration formats include XML, JSON, RFC, IDOC, SOAP/REST API, and saving to an FTP/SFTP server. Depending on the organization’s IT maturity, it is possible to implement full automation or remain with semi-automated solutions.

Incoming invoices from KSeF in SAP. Implementation recommendations and best practices

Integration of SAP with the National e-Invoicing System for incoming invoices is not just a regulatory obligation—it’s also a significant opportunity to streamline accounting processes. Thanks to HAERGI’s solution, it is possible to implement a fully internal, secure, and flexible solution that supports automation, reduces operational risks, and increases data transparency.

Well-designed processing of invoices from KSeF in SAP provides an organizational advantage – shortens document turnaround time, facilitates controlling, and paves the way for further digitalization of the finance domain.