Skip to main content

ERPL Quick Start (On-Premise)

In this 5-minute tutorial, you'll connect to an on-premise SAP system and read your first table. By the end, you'll be querying SAP data directly from DuckDB.

Prerequisites
  • DuckDB installed (version 0.10.0+)
  • Access to an on-premise SAP system
  • SAP connection credentials (username/password)
  • Network access to SAP system (port 33xx)

Step 1: Install ERPL

-- Install ERPL extension
INSTALL 'erpl' FROM 'http://get.erpl.io';

-- Load the extension
LOAD 'erpl';
Success Check

If installation worked, you should see no errors. The extension is now loaded and ready to use.

Step 2: Connect to SAP

-- Store SAP credentials in a DuckDB secret of type sap_rfc
CREATE SECRET sap_system (
TYPE sap_rfc,
ASHOST 'your-sap-host',
SYSNR '00',
CLIENT '100',
USER 'your_username',
PASSWD 'your_password',
LANG 'EN'
);
Connection Details

Replace the connection details:

  • ASHOST - Your SAP application server hostname or IP
  • SYSNR - Your SAP system (instance) number, e.g. 00
  • CLIENT - Your SAP client (mandant), e.g. 100
  • USER / PASSWD - Your SAP username and password

The functions below pick up a single secret automatically; with several secrets, pass secret => 'sap_system' to any function.

What's Happening?

Step 3: Read Your First Table

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

Understanding the Result

The KNA1 table contains customer master data. You should see columns like:

  • KUNNR - Customer number
  • NAME1 - Customer name
  • LAND1 - Country
  • REGIO - Region

Step 4: Filter and Transform Data

-- Get German customers only
SELECT
KUNNR AS customer_id,
NAME1 AS customer_name,
LAND1 AS country,
REGIO AS region
FROM sap_read_table('KNA1')
WHERE LAND1 = 'DE'
LIMIT 100;

Step 5: Explore More Tables

Here are some common SAP tables you can explore:

-- Sales document header
SELECT * FROM sap_read_table('VBAK', MAX_ROWS => 5);

-- Material master data
SELECT * FROM sap_read_table('MARA', MAX_ROWS => 5);

-- Sales document items
SELECT * FROM sap_read_table('VBAP', MAX_ROWS => 5);

Common SAP Tables Reference

TableDescriptionKey Fields
KNA1Customer Master DataKUNNR, NAME1, LAND1
VBAKSales Document HeaderVBELN, ERDAT, KUNNR
VBAPSales Document ItemsVBELN, POSNR, MATNR
MARAMaterial Master DataMATNR, MTART, MEINS
LFA1Vendor Master DataLIFNR, NAME1, LAND1
BKPFAccounting Document HeaderBUKRS, BELNR, GJAHR

Troubleshooting

Connection Issues

Error: "Connection refused"

-- Check that ASHOST/SYSNR are correct, then ping the system
PRAGMA sap_rfc_ping;

Error: "Authentication failed"

-- Re-create the secret with the correct credentials
CREATE OR REPLACE SECRET sap_system (
TYPE sap_rfc,
ASHOST 'your-host',
SYSNR '00',
CLIENT '100',
USER 'correct_username',
PASSWD 'correct_password',
LANG 'EN'
);

Table Access Issues

Error: "Table not found"

-- Check table name (case-sensitive)
-- Verify table exists in your SAP system
SELECT * FROM sap_read_table('KNA1', MAX_ROWS => 1);

Next Steps

🚀 Ready for More?

🔧 Advanced Topics

💡 Examples

What You've Learned

Installed ERPL extension
Connected to SAP system
Read SAP tables
Filtered and transformed data
Explored common SAP tables

You're now ready to use ERPL for your SAP data analysis needs!


Need help? Check our troubleshooting guide or browse more examples.