Skip to main content

How to Read an SAP Table

In this guide, you'll learn how to extract data from SAP ERP tables. By the end, you'll be able to query any SAP table directly from DuckDB.

What You'll Need
  • ERPL extension installed
  • SAP connection credentials
  • 5 minutes

Step 1: Connect to SAP

-- Install and load ERPL
INSTALL 'erpl' FROM 'http://get.erpl.io';
LOAD 'erpl';

-- Store your SAP credentials in a secret
CREATE SECRET sap_system (
TYPE sap_rfc,
ASHOST 'hostname',
SYSNR '00',
CLIENT '100',
USER 'your_username',
PASSWD 'your_password',
LANG 'EN'
);

Step 2: Read Your First Table

-- Read customer master data
SELECT * FROM sap_read_table('KNA1', MAX_ROWS => 100);

Common SAP Tables

TableDescription
KNA1Customer Master Data
VBAKSales Document Header
MARAMaterial Master Data

Next Steps