sap-bapi-integrationlisted
Install: claude install-skill williamcorrea23/sap-router-skill
# SAP BAPI Integration — 9 Modules, 29 BAPIs
> **Prerequisites:** SAP RFC connection, ZROUTER_DISPATCH_FM (or direct BAPI), Python 3.8+.
> Full BAPI tables: [reference.md](reference.md)
## When to use
- Create/modify materials, orders, FI docs via BAPI
- Map CSV/XLS fields to BAPI parameters
- Debug BAPIRET2 -- the real error message is never in sy-subrc
- Create ZROUTER handler for a new functional module
- Replace batch input/BDC with BAPI (ex: MB01 → BAPI_GOODSMVT_CREATE)
## Golden Rule
```
1. BAPI_<OBJECT>_<ACTION> → call with parameters by VALUE
2. Check BAPIRET2-TYPE → NEVER trust sy-subrc
3. E or A in TYPE? → BAPI_TRANSACTION_ROLLBACK
4. Otherwise → BAPI_TRANSACTION_COMMIT EXPORTING wait = 'X'
```
## Step by step
### 1. Discover BAPI
```bash
python scripts/sap_router.py route --action CREATE_MATERIAL --module MM
# → "ZROUTER RFC"
# List BAPIs of a module
grep -A1 "CREATE_MATERIAL\|CREATE_PO\|CREATE_ORDER\|POST_DOCUMENT" scripts/xls_to_bapi.py
```
### 2. Convert CSV → BAPI payload
```bash
# Generate template
python scripts/xls_to_bapi.py template --output tmpl.csv --module MM --action CREATE_MATERIAL
# Convert data
python scripts/xls_to_bapi.py convert --input data.csv --module MM --action CREATE_MATERIAL
# Expected: JSON with BAPI_MATERIAL_SAVEDATA payload
```
### 3. Call BAPI (ABAP)
```abap
DATA: ls_header TYPE bapimathead, ls_ret TYPE bapiret2, lv_matnr TYPE matnr,
lt_desc TYPE TABLE OF bapi_makt.
ls_header-materia