Debugging Part 7: Update Task Debugging
Debug code that runs in the update task: CALL FUNCTION … IN UPDATE TASK, V1/V2 updates, PERFORM ON COMMIT, why normal breakpoints don't stop there, activating update debugging, analysing failed updates in SM13 and update dumps in ST22.
Explanation
📌 KEY POINTS
✅ CALL FUNCTION … IN UPDATE TASK only registers the call; the update function runs after COMMIT WORK in an update work process — not in your dialog session.
✅ To stop there, activate "Update Debugging" in the debugger settings before the COMMIT (then the update runs in a new debugger session).
✅ Failed updates appear in SM13 (status ERR) with the terminated function module; the dump is in ST22 for the update user/work process.
⚠️ An error in the update task rolls back the whole LUW's V1 updates — the user saw "saved", but nothing was written.
━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE
Part 6 read dumps. Some errors happen after the user already saw a success message — in the update task.
━━━━━━━━━━━━━━━━━━━━
▶ 1. HOW THE UPDATE TASK WORKS
- Dialog program registers update FMs (IN UPDATE TASK) and forms (PERFORM … ON COMMIT).
- COMMIT WORK: ON COMMIT forms run, then update records (VBHDR/VBMOD/VBDATA) are processed by an update work process.
- V1 (critical, e.g. document tables) processed first, V2 (statistics) later; V1 errors cancel the LUW.
- COMMIT WORK AND WAIT: dialog waits for V1 completion.
━━━━━━━━━━━━━━━━━━━━
▶ 2. WHY BREAKPOINTS DON'T STOP
The update FM runs in another work process; session breakpoints don't apply.
━━━━━━━━━━━━━━━━━━━━
▶ 3. UPDATE DEBUGGING
- In the debugger: Settings → Update Debugging (on).
- Continue to COMMIT WORK; after it, a new debugger window opens for the update task; set breakpoints in the update FM there.
- For PERFORM ON COMMIT: breakpoints work in the same session (they run in dialog at commit), no update debugging needed.
━━━━━━━━━━━━━━━━━━━━
▶ 4. FAILED UPDATES
- SM13: records with status ERR (error), INIT (waiting), per user/date; details show the FM and the error; in test systems they can be re-processed after fixing (careful in production).
- ST22: dump in the update work process.
- SM21: system log entries about update terminations.
━━━━━━━━━━━━━━━━━━━━
▶ 5. TYPICAL CAUSES
Duplicate keys (INSERT of existing record), data type conversions, locks not held, missing mandatory fields, custom update FMs with MESSAGE E/A.
━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP
- Run the code example; activate update debugging before COMMIT WORK.
- Force a duplicate key insert and find the error in SM13 and ST22.
- Fix the logic (MODIFY or existence check) and rerun.
✅ CHECKPOINT: you can debug update-task code and analyse update terminations.
Code example
* ===== Update function module (attribute: Update module, start immediately = V1) =====FUNCTION z_log_save.*" IMPORTING VALUE(IS_LOG) TYPE ZSO_LOG INSERT zso_log FROM is_log. " duplicate key -> update termination (SM13) IF sy-subrc <> 0. MESSAGE a001(zso). " abort -> whole LUW rolled back ENDIF.ENDFUNCTION. * ===== Caller =====REPORT zdebug_update. DATA ls_log TYPE zso_log. START-OF-SELECTION. ls_log-vbeln = '0000012345'. ls_log-ernam = sy-uname. ls_log-erdat = sy-datum. CALL FUNCTION 'Z_LOG_SAVE' IN UPDATE TASK " only registered here EXPORTING is_log = ls_log. PERFORM after_commit ON COMMIT. " runs in dialog at commit * Activate: Debugger -> Settings -> Update Debugging, then continue past COMMIT COMMIT WORK AND WAIT. " update FM runs now in the update work process IF sy-subrc <> 0. WRITE: / 'Update failed - check SM13 / ST22'. ELSE. WRITE: / 'Saved'. ENDIF. FORM after_commit. " e.g. trigger follow-up actions after successful registrationENDFORM. * ===== Diagnosis =====* SM13 : update records with status ERR, function module, error text* ST22 : dump in the update task* SM21 : system log entriesReal project scenario
Users confirmed that sales orders were "saved", but some did not exist. SM13 showed update terminations in a custom log FM called from USEREXIT_SAVE_DOCUMENT: it inserted a record with a key that already existed for reprocessed orders, and the abort message rolled back the whole order.
Changing INSERT to MODIFY for the log and removing the abort message fixed the lost orders. SM13 monitoring for ERR records became part of daily checks.
Common mistakes
- Expecting session breakpoints in update FMs.
- MESSAGE A/E in custom update FMs.
- INSERT without duplicate handling.
- Not monitoring SM13.
- Reprocessing failed updates in production without analysis.
Best practices
- Use update debugging for IN UPDATE TASK code.
- Robust update FMs (MODIFY, no dialog messages).
- COMMIT WORK AND WAIT when results are needed.
- Monitor SM13/ST22.
- Analyse before reprocessing updates.
Interview angle
Questions: "How do you debug a function module called IN UPDATE TASK?", "Where do you see update errors?", "V1 vs V2?"
Strong answer: IN UPDATE TASK registers, runs after COMMIT WORK in update work process; enable update debugging before commit; PERFORM ON COMMIT runs in dialog; V1 critical first, V2 later, V1 error rolls back LUW; SM13 ERR records, ST22 dumps, SM21; common causes duplicate keys, messages in update FMs.
Practice this lesson
Quick check
1. A document is saved but an entry written by an update function module is missing. Where do you look first?
2. To debug an update task function module, use:
3. A function module is called IN UPDATE TASK. What is needed to debug it?
Interview questions
1. A custom update function module (registered as V1 update) is supposed to insert a record into a Z table on sales order save, but the record never appears. How would you use update debugging to find the cause?
Answer it in your own words first, then compare.
2. A user exit is supposed to update a custom field during sales order save, but the field is coming up blank in production. Walk through how you would debug this.
Answer it in your own words first, then compare.
Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.
More lessons in this topic
- Debugging Part 1: How to Approach an ABAP Problem
- Debugging Part 10: Production Debugging — Evidence First
- Debugging Part 2: ABAP Debugger Essentials
- Debugging Part 3: External Breakpoints — Why They Are Not Hit
- Debugging Part 4: Watchpoints, Layers and Static Checks (ATC)
- Debugging Part 5: Debugging Internal Tables and Field Symbols
- Debugging Part 6: ST22 Short Dump Analysis
- Debugging Part 8: Background Job Debugging with SM37, JDBG and SM50