sap.sync-open-items
Iterate every page of SAP AR/AP open items as of a key date via sap.fetch-open-items and persist each page into commerce_entity (entity_type=receivable or payable, keyed by side).
Iterate every page of SAP AR/AP open items and persist into commerce_entity.
Overview
| Property | Value |
|---|---|
| Workflow type | Linear |
| Library | App-sap |
| Version | 1.0 |
Input Schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
organization_uuid | uuid | Yes | — | Authenticated organization UUID injected by the workflow boundary |
connection_uuid | uuid | Yes | — | Organization-scoped SAP CloudConnection UUID |
workflow_run_id | string | No | — | Engine-stamped parent DAG run id |
key_date | string | Yes | — | YYYY-MM-DD key date; each page reads items open AS OF this date, forwarded unchanged to every sap.fetch-open-items call this run |
side | string | Yes | — | Ledger side to sync; exactly 'receivable' or 'payable', compared without case folding, forwarded unchanged to every fetch and used to pick the commerce_entity entity_type |
company_code | string | No | — | Optional SAP CompanyCode filter forwarded to each page; absent reads every company code the connection can see |
skip | integer | No | — | Starting OData $skip offset for the first page this run; non-negative integer, defaults to 0 |
top | integer | No | — | OData $top page size passed to sap.fetch-open-items; 1..1000, defaults to 100 |
max_pages | integer | No | — | Safety cap on pages fetched this run; defaults to 20 |
actor | string | No | — | Optional actor stamp forwarded to commerce persist/cursor workflows |
Output Schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
organization_uuid | uuid | Yes | — | — |
connection_uuid | uuid | Yes | — | — |
workflow_run_id | string | No | — | — |
key_date | string | Yes | — | — |
side | string | Yes | — | — |
company_code | string | No | — | — |
skip | integer | No | — | — |
top | integer | No | — | — |
max_pages | integer | No | — | — |
actor | string | No | — | — |
current_skip | integer | No | — | — |
pages_fetched | integer | No | — | — |
synced_count | integer | No | — | — |
persisted_count | integer | No | — | — |
created_count | integer | No | — | — |
updated_count | integer | No | — | — |
rejected_count | integer | No | — | — |
has_next_page | boolean | No | — | — |
sap_environment | string | No | — | — |
started_at | string | No | — | — |
completed_at | string | No | — | — |
failure_reason | string | No | — | — |
failure_type | string | No | — | — |
failed_action | string | No | — | — |
failed_step | json | No | — | — |
failed_layer | integer | No | — | — |
failed_at_state | string | No | — | — |
error | string | No | — | — |
error_type | string | No | — | — |
failed_at | string | No | — | — |
provider_request_ref | string | No | — | — |
retryable | boolean | No | — | — |
States
| State | Initial | Terminal | Success | Auto-advance | Description |
|---|---|---|---|---|---|
initiated | Yes | No | — | start | — |
fetching | No | No | — | — | — |
finalizing | No | No | — | complete | — |
planning | No | No | — | fetch_page | — |
completed | No | Yes | Yes | — | — |
failed | No | Yes | No | — | — |
State Diagram
Transitions
| From | Action | To | Description |
|---|---|---|---|
initiated | start | planning | — |
planning | fetch_page | fetching | — |
fetching | fetch_page | fetching | — |
fetching | finish_pages | finalizing | — |
finalizing | complete | completed | — |
* (any state) | fail | failed | — |
Business Errors
| Code | Message Template |
|---|---|
SAP_ORGANIZATION_CONTEXT_INVALID | Authenticated organization context is missing or does not match the workflow input |
SAP_CONNECTION_NOT_FOUND | SAP connection {connection_uuid} was not found in the authenticated organization |
SAP_CONNECTION_WRONG_PROVIDER | Connection {connection_uuid} is not a SAP connection |
SAP_CONNECTION_SERVICE_UNAVAILABLE | The shared cloud connection service is unavailable |
SAP_PROVIDER_CAPABILITY_MISSING | The installed SAP provider does not expose the required API operation |
SAP_AUTHENTICATION_FAILED | SAP rejected the connection credentials or API key |
SAP_PROVIDER_REQUEST_FAILED | The SAP OData request failed |
SAP_RESPONSE_SHAPE_INVALID | The SAP OData API returned an invalid response |
SAP_PAGINATION_INVALID | skip must be a non-negative integer and top must be between 1 and 1000 |
SAP_WINDOW_INVALID | Dates must use YYYY-MM-DD and be ordered |
SAP_SIDE_INVALID | side must be exactly 'receivable' or 'payable' |
SAP_ENVIRONMENT_INVALID | The connection's SAP environment must be exactly 'sandbox' or 'live' |
SAP_SYNC_PAGE_FETCH_FAILED | SAP sync child fetch failed: |
SAP_SYNC_PERSIST_FAILED | SAP sync persist-batch failed: |
API Usage
bash
POST /api/workflows/start
Content-Type: application/json
{
"workflow_type": "sap.sync-open-items",
"initial_data": {
"organization_uuid": "value",
"connection_uuid": "value",
"key_date": "value",
"side": "value"
}
}