ERPClimb logoERPClimb
Modularization
ABAP Developmentadvanced 8 min read

Modularization Part 5: Update Function Modules and IN UPDATE TASK

Preview · a free account unlocks the full lesson

Key takeaway

Understand SAP's classic update technique: logical units of work, update function modules (V1/V2), CALL FUNCTION … IN UPDATE TASK, COMMIT WORK and ROLLBACK WORK, PERFORM ON COMMIT, SM13 — and why RAP and BAPIs rely on it.

In this lessonShow sections

Visual overview

Modularization Part 5: Update Function Modules and IN UPDATE TASK — learning sheetFlow: Create update FM Z_FLIGHT_LOG_UPD (update module, start immediately) inserting into a custom log table → Register it in a report IN UPDATE TASK, then COMMIT WORK AND WAIT → Force an error in the FM and check SM13. Key ideas: DATABASE LUW VS SAP LUW; UPDATE FUNCTION MODULES; THE FLOW; PERFORM … ON COMMIT. Watch out: Never COMMIT WORK inside an update function module or in code called from BAdIs/user exits of standard transactions.ERPClimb.com / ABAP / LESSON 4/10 / LEARNING SHEETModularization Part 5: Update Function Modules and INUPDATE TASK1 · HOW IT FLOWS1Create update FMZ_FLIGHT_LOG_UPD (updatemodule, start…2Register it in a reportIN UPDATE TASK, thenCOMMIT WORK AND WAIT3Force an error in the FMand check SM132 · KEY IDEAS EXPLAINEDDatabase LUW vs SAP LUWDatabase LUW: changes between two databasecommits. Every dialog step (screen change)triggers an implicit database commit.SAP LUW: a business transaction spanning severaldialog steps (e.g. VA01 screens). To keep itatomic, changes are collected and executed…Update Function ModulesProcessing type "Update module" in SE37(start immediately = V1, start delayed = V2).Only IMPORTING and TABLES parameters (by value),no EXPORTING — they run later, in the update workprocess.The FlowCOMMIT WORK AND WAIT — waits until the update isfinished (synchronous) — use when the next stepneeds the data (e.g. read the new document).ROLLBACK WORK — discards all registered updatecalls.Perform … On CommitRegisters a FORM to be executed at COMMIT WORK (inthe dialog process), e.g. to collect data beforethe update. ON ROLLBACK for cleanup.3 · REMEMBER · WATCH OUTRememberAn SAP LUW groups all database changes of a business transaction —they are written together or not at all.CALL FUNCTION 'Z_UPD' IN UPDATE TASK only registers the call; it runsat COMMIT WORK.V1 = critical, synchronous-with-commit updates; V2 = statistical,lower priority.!Watch outNever COMMIT WORK inside an updatefunction module or in code calledfrom BAdIs/user exits of standardtransactions.4 · IN A REAL PROJECTA developer added a COMMIT WORK into a user exit during sales order save "to make sure the Z table iswritten". Occasionally, the order save later failed; the Z table already contained data for orders thatdid not exist, and some orders were partially saved. The fix wrote the Z table via an update function module…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Earlier parts covered units of logic; this part explains how SAP transactions save data consistently — a mechanism you will meet in every standard transaction, every BAPI, and in RAP's save phase.

It starts with the distinction between a database LUW and an SAP LUW. A database LUW is the set of changes between two database commits, and every dialog step (every screen change) triggers an implicit database commit. An SAP LUW, by contrast, is a whole business transaction spanning several dialog steps — think of the several screens of VA01.

To keep that business transaction atomic even though it crosses multiple database LUWs, SAP collects the changes and executes them together at COMMIT WORK, inside the update task. An SAP LUW groups all the database changes of a business transaction so they are written together or not at all.

The actual work happens in update function modules. These have the processing type "Update module" in SE37, which can be set to start immediately (V1) or start delayed (V2): V1 covers critical, synchronous-with-commit updates, while V2 covers statistical, lower-priority updates. Update function modules only have IMPORTING and TABLES parameters passed by value, with no EXPORTING parameters, because they run later, in a separate update work process. They contain the actual INSERT, UPDATE and DELETE statements.

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.