ERPClimb logoERPClimb
BAPI
ABAP Developmentadvanced 9 min read

BAPI Part 9: BAPI Uploads — Idempotency and Safe Retry

Preview · a free account unlocks the full lesson

Key takeaway

Build reliable BAPI uploads and interfaces: one LUW per document, idempotency keys to prevent duplicates on reruns, status tables, locking, restart after failures, handling "success but unknown result" cases, and parallel processing considerations.

In this lessonShow sections

Visual overview

BAPI Part 9: BAPI Uploads — Idempotency and Safe Retry — learning sheetFlow: Create a status table as described (sandbox) → Implement the processing sequence (code example) and run a file twice → Kill the job midway and restart: no duplicates. Key ideas: WHY DUPLICATES HAPPEN; IDEMPOTENCY KEY; STATUS TABLE DESIGN; PROCESSING SEQUENCE PER DOCUMENT. Watch out: The dangerous case is "commit done, status not saved" (crash between them) — design the check so a rerun detects the existing document.ERPClimb.com / ABAP / LESSON 9/10 / LEARNING SHEETBAPI Part 9: BAPI Uploads — Idempotency and Safe Retry1 · HOW IT FLOWS1Create a status table asdescribed (sandbox)2Implement the processingsequence (code example)and run a file twice3Kill the job midway andrestart: no duplicates2 · KEY IDEAS EXPLAINEDWhy Duplicates HappenA job is restarted after a timeout.The same file is uploaded twice.Idempotency KeyUse a business key from the source: external orderID, file name + row, EDI reference.Store it in the SAP document where possible (e.g.customer PO number, reference field, custom field)and in a Z status table.Status Table DesignZUPL_STATUS: EXTKEY (key), STATUS (N new, Pprocessing, S success, E error), SAP_DOC, RUN_ID,MESSAGES reference (SLG1 log number)…Processing Sequence Per Document1. Lock the external key (ENQUEUE on the statustable) to avoid parallel duplicates.3 · REMEMBER · WATCH OUTRememberIdempotency: running the same input twice must not create twodocuments — store an external key per document and check it before…A status table (external key → status, SAP document, messages) makesreruns safe: skip done rows, retry failed ones.One LUW per document: BAPI → evaluate RETURN → commit/rollback →update status (in the same or next LUW deliberately).!Watch outThe dangerous case is "commitdone, status not saved" (crashbetween them) — design the check soa rerun detects the existingdocument.4 · IN A REAL PROJECTA nightly order upload job was cancelled by a system restart after 3,000 of 5,000 orders. Operations restartedit the next morning, creating 3,000 duplicate orders that customers received as double deliveries. Theredesigned upload stored the external order ID in the customer PO number and in a status table, checked both…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 2 through 8 covered calling BAPIs correctly; real uploads also fail midway, get restarted, and sometimes receive the same file twice, which is what this lesson addresses.

Idempotency means running the same input twice must never create two documents — the way to guarantee that is to store an external key per document and check it before ever calling the BAPI.

A status table mapping that external key to a status, the resulting SAP document, and any messages makes reruns safe, since done rows can be skipped and only failed ones retried.

Each document should be processed within one logical unit of work: call the BAPI, evaluate RETURN, commit or roll back, and update the status — deliberately, in the same or a carefully chosen next LUW.

The genuinely dangerous case is a crash between the commit succeeding and the status being saved; the check logic needs to be designed so that a rerun can detect the document that was already created, rather than blindly creating a second one.

Duplicates tend to happen for a few predictable reasons: a job gets restarted after timing out, the same source file gets uploaded twice, or middleware retries after a network error even though SAP had already committed the data on its side.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.