Overview
The pipeline layers on top of existing SAP primitives (read_table, execute_rfc, get_table_schema). No additional Java connector endpoints are needed — all operations use standard RFC calls.
Agent workflow
When a user asks the agent to execute a migration, the system prompt enforces this sequence. The agent cannot skip steps 3, 4, or 6 — even if the user asks it to.Field Mapping
Agent calls
generate_field_mapping to compare source and target schemas. Returns coverage stats, type conflicts, and unmapped fields.Transform Suggestions
Agent calls
suggest_transforms which fetches live schemas from both systems and compares field types/lengths. Returns deterministic suggestions based on schema diffs (NUMC padding, date conversion, currency shifts, etc.). The agent reviews suggestions and asks the user about ambiguous cases — currency shift direction, UOM mapping tables, target client number.Pre-Validation (mandatory)
Agent calls
validate_migration. Six checks run against the live systems: source/target readability, target field existence, key field coverage, source data availability, transform type validity. If any error-severity check fails, the agent stops.Dry Run Preview (mandatory)
Agent calls
extract_transform_load with dry_run=true. Extracts and transforms data but writes nothing. Returns 5 sample rows showing source vs transformed values. The agent presents these to the user and waits for confirmation.Execute ETL
After user confirms the preview, agent calls
extract_transform_load with dry_run=false. Data is loaded in batches via BAPI calls with per-batch commit/rollback.Tools
suggest_transforms
Fetches schemas from both live SAP systems, compares field types and lengths for each mapped field, and suggests typed transformation rules. Parameters:| Param | Type | Description |
|---|---|---|
source_table | string | Source SAP table name |
target_table | string | Target SAP table name |
source_system | 's4' | 'ecc' | Source system identifier |
target_system | 's4' | 'ecc' | Target system identifier |
field_mapping | array | Field mapping from generate_field_mapping output |
- Target field is
MANDTorCLIENT→mandt_set - Target type is
NUMCand lengths differ →numc_pad(left zero-padding) - One side is
DATS, other isn’t →dats_format - One side is
TIMS, other isn’t →tims_format - Both
CURRbut lengths differ →currency_shift - One side is
UNITand types differ →uom_map - Both
CHAR, source longer →truncate - Both
CHAR, target longer →char_pad - Any other type mismatch →
custom_expression(flagged for manual review)
char_pad with numc_pad for known numeric fields, add transforms the tool missed, or flag issues the heuristics don’t catch.
Approval required: No
validate_migration
Runs 6 pre-flight checks against the live SAP systems before any data moves. Parameters:| Param | Type | Description |
|---|---|---|
source_table | string | Source SAP table name |
target_table | string | Target SAP table name |
source_system | 's4' | 'ecc' | Source system identifier |
target_system | 's4' | 'ecc' | Target system identifier |
field_mapping | array | Field mapping with optional transform rules per field |
| Check | Severity | What it does |
|---|---|---|
| Source table readable | Error | Calls get_table_schema on source system |
| Target table readable | Error | Calls get_table_schema on target system |
| Target fields exist | Error | Verifies every mapped target field exists in the live target schema |
| Key fields covered | Error | Ensures all key fields in the target table (except MANDT) are included in the mapping |
| Source has data | Warning | Reads 1 row from source to check the table isn’t empty |
| Transform types valid | Error | Validates every specified transform type against the 12 known types |
blocking_failures count. If > 0, the agent refuses to proceed.
Approval required: No
extract_transform_load
The core ETL tool. Reads from source, transforms, writes to target via BAPI. This is the only ETL tool that requires user approval before execution. Parameters:| Param | Type | Default | Description |
|---|---|---|---|
source_table | string | Source SAP table name | |
target_table | string | Target SAP table name | |
source_system | 's4' | 'ecc' | Source system identifier | |
target_system | 's4' | 'ecc' | Target system identifier | |
field_mapping | array | Field mapping with optional transform rules | |
target_bapi | string | BAPI function module for loading (e.g., BAPI_MATERIAL_SAVEDATA) | |
bapi_import_template | object | {} | Static import parameters for the BAPI |
bapi_table_param | string | BAPI table parameter that receives row data | |
batch_size | number | 200 | Rows per batch |
source_filters | string[] | WHERE clauses for source extraction | |
dry_run | boolean | false | Preview only — no writes |
Extract
Extract
Paginated
read_table calls against the source SAP system. Reads batch_size rows at a time until fewer rows return than requested, or the 10,000 row safety cap is hit. Source filters pass through as WHERE clauses.Transform
Transform
Every source row is transformed field-by-field using the mapping. Fields with a
transform rule run through the converter function (pure string-to-string). Fields without a transform copy the value to the target field name.Dry run gate
Dry run gate
If
dry_run=true, returns 5 sample source and transformed rows and stops. No data is written.Load
Load
For each batch:
- Build BAPI call — transformed rows go into
tables_params[bapi_table_param] - Call
execute_rfcon the target system’s connector - Check
RETURNtable forTYPE: 'E'(Error) or'A'(Abort) - If clean →
BAPI_TRANSACTION_COMMITwithWAIT: 'X' - If errors →
BAPI_TRANSACTION_ROLLBACK - If exception → catch, attempt rollback, record error
completed, partial, or failed.
Approval required: Yes
reconcile_migration
Post-migration verification. Reads from both systems and compares. Parameters:| Param | Type | Default | Description |
|---|---|---|---|
source_table | string | Source SAP table name | |
target_table | string | Target SAP table name | |
source_system | 's4' | 'ecc' | Source system identifier | |
target_system | 's4' | 'ecc' | Target system identifier | |
key_fields | string[] | Key fields to compare | |
sample_size | number | 10 | Number of keys to spot-check |
- Reads key fields from both source and target (parallel calls, up to 10,000 rows each)
- Compares row counts
- Samples N evenly-spaced keys from source, builds composite key strings, checks each against a Set of target keys
- Reports status:
match— counts equal AND all spot-checked keys foundmismatch— none of the spot-checked keys foundpartial— some found, some not
Transform engine
The transform engine (src/tools/etl/transformers.ts) is a set of pure functions with no side effects and no connector calls. Each converter takes a string value and a config object, returns a string.
| Transform | What it does | Config |
|---|---|---|
numc_pad | Strip non-digits, left-pad with zeros | { target_length: 40 } |
dats_format | Convert between SAP YYYYMMDD and ISO dates | { source_format, target_format } |
tims_format | Convert between SAP HHMMSS and HH:MM:SS | { source_format, target_format } |
currency_shift | Shift decimal places left or right | { shift: 2, direction: 'left' } |
uom_map | Map unit of measure codes via lookup table | { mapping: { 'EA': 'ST' } } |
truncate | Cut string to max length | { max_length: 40 } |
char_pad | Right-pad with spaces | { target_length: 20 } |
uppercase | Force uppercase | {} |
default_value | Fill empty values | { value: '0000' } |
lookup | Static value map | { table: { 'A': '01' } } |
mandt_set | Override with target client number | { target_mandt: '100' } |
custom_expression | Pass-through (safety placeholder) | {} |
Agent safety behaviors
The system prompt enforces several safety rules that the agent follows regardless of user input:- Ambiguity detection — If the user doesn’t explicitly state source and target systems, the agent asks for clarification before proceeding.
- Mandatory validation — The agent always runs
validate_migrationbefore any ETL execution, including dry runs. It will not proceed if any error-severity check fails. - Mandatory dry run — The agent always runs
extract_transform_loadwithdry_run=truefirst and presents the preview. It waits for user confirmation before the actual write. - Mandatory reconciliation — The agent always runs
reconcile_migrationafter execution, even if the migration failed. - execute_rfc guardrail — The agent may use
execute_rfcfor BAPI interface discovery or verification, but never for bulk data writes. All data loading goes throughextract_transform_load. - BAPI verification on target — The agent always verifies BAPIs exist on the target system using the target
connection_id(for examplesap_simulate_rfc(connection_id="<target>", ...)).
Common BAPIs
| Use case | BAPI | Table param |
|---|---|---|
| Material master | BAPI_MATERIAL_SAVEDATA | Uses import structures (HEADDATA, CLIENTDATA), not table params — requires per-material calls |
| Sales orders | BAPI_SALESORDER_CREATEFROMDAT2 | ORDER_ITEMS_IN |
| Accounting docs | BAPI_ACC_DOCUMENT_POST | ACCOUNTGL, CURRENCYAMOUNT |
| Purchase orders | BAPI_PO_CREATE1 | POITEM |
| Business partners | BAPI_BUPA_CREATE_FROM_DATA | — |
Some BAPIs (like BAPI_MATERIAL_SAVEDATA) use import structures rather than table parameters, which means they process one record per call instead of bulk table input. The agent detects this by verifying the BAPI interface via
simulate_rfc before attempting migration.