All skills
secondsky avatar

/sap-abap

@620a19a
by Eddiesecondsky/sap-skills456 stars
120

Comprehensive ABAP development skill for SAP systems. Use when writing ABAP code, working with internal tables, structures, ABAP SQL, object-oriented programming, RAP (RESTful Application Programming Model), CDS views, EML statements, ABAP Cloud development, string processing, dynamic programming, RTTI/RTTC, field symbols, data references, exception handling, or ABAP unit testing. Covers both classic ABAP and modern ABAP for Cloud Development patterns.

Use this Skill: https://skilld.dev/gh/secondsky/sap-skills/sap-abap

This session only. Nothing lands on disk.

referencessap-luw.md

≈947 tokens on demand. Your agent reads this file only when SKILL.md points to it.

SAP Logical Unit of Work (LUW) - Complete Reference

Source: https://github.com/SAP-samples/abap-cheat-sheets/blob/main/17_SAP_LUW.md


Overview

SAP LUW ensures transactional consistency through all-or-nothing commits: either all changes commit together or all rollback.


COMMIT and ROLLBACK

COMMIT WORK

COMMIT WORK.              " Asynchronous - returns immediately
COMMIT WORK AND WAIT.     " Synchronous - waits for completion

Effects:

  • Closes current SAP LUW, opens new one
  • Commits all change requests
  • Processes registered update function modules
  • Triggers database commit

ROLLBACK WORK

ROLLBACK WORK.

Effects:

  • Closes current SAP LUW, opens new one
  • Undoes all changes within current SAP LUW
  • Removes previous registrations
  • Triggers database rollback

Update Function Modules

Calling Update Functions

" Asynchronous (default)
CALL FUNCTION 'Z_UPDATE_FUNC' IN UPDATE TASK
  EXPORTING values = data.

COMMIT WORK.  " Returns immediately

" Synchronous
CALL FUNCTION 'Z_UPDATE_FUNC' IN UPDATE TASK
  EXPORTING values = data.

COMMIT WORK AND WAIT.  " Waits for completion

" Local update
SET UPDATE TASK LOCAL.

CALL FUNCTION 'Z_UPDATE_FUNC' IN UPDATE TASK
  EXPORTING values = data.

COMMIT WORK.  " Executes immediately in current work process

Update Function Implementation

FUNCTION z_update_func
  IMPORTING
    VALUE(values) TYPE some_dbtab.

  MODIFY some_dbtab FROM @values.

ENDFUNCTION.

Background RFC (bgRFC)

CALL FUNCTION 'Z_REMOTE_FUNC' IN BACKGROUND UNIT
  EXPORTING param1 = value1.

Enables asynchronous execution in same or different ABAP systems.


Subroutines (Deprecated)

" Register for commit
PERFORM some_subroutine ON COMMIT.

" Register for rollback
PERFORM some_subroutine ON ROLLBACK.

" Data transfer via ABAP memory
EXPORT data_var TO MEMORY ID 'KEY'.
IMPORT data_var FROM MEMORY ID 'KEY'.

Implicit Database Commits

Triggered automatically by:

  • Dialog step completion (dynpro PAI/PBO)
  • Synchronous/asynchronous RFC calls
  • HTTP/HTTPS/SMTP communication
  • WAIT statements
  • Sending messages (error, information, warning)

ABAP Cloud Behavior

" Both behave identically in ABAP Cloud
COMMIT WORK.
COMMIT WORK AND WAIT.

In ABAP Cloud:

  • Local updates always enforced implicitly
  • Updates occur in same work process
  • Always synchronous

RAP Integration

" RAP-specific commit
COMMIT ENTITIES.        " Implicitly triggers COMMIT WORK

" RAP-specific rollback
ROLLBACK ENTITIES.      " Resets all changes

Controlled SAP LUW

Enhanced transactional phase management:

" Activate modify phase
cl_abap_tx=>modify( ).

" Database modifications NOT allowed here
" Would throw BEHAVIOR_ILLEGAL_STMT_IN_CALL

" Activate save phase
cl_abap_tx=>save( ).

" Database modifications allowed here
MODIFY zdemo_table FROM TABLE @itab.

Transactional Phases

Phase Database Modifications
Modify Not allowed
Save Allowed

Lock Objects

" Enqueue (lock)
CALL FUNCTION 'ENQUEUE_EZLOCK'
  EXPORTING
    mode_table = 'E'
    key = value
  EXCEPTIONS
    foreign_lock = 1.

" Dequeue (unlock)
CALL FUNCTION 'DEQUEUE_EZLOCK'
  EXPORTING
    mode_table = 'E'
    key = value.

Best Practices

  1. Use COMMIT WORK AND WAIT when immediate confirmation needed
  2. Avoid implicit commits in transaction-critical code
  3. Use RAP for modern transactional scenarios
  4. Bundle modifications for consistency
  5. Handle locks appropriately
  6. Test rollback scenarios thoroughly

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    A comprehensive reference for SAP ABAP development, providing documentation and code examples for both classic ABAP and modern ABAP Cloud patterns. No security issues were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    3/32 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 620a19a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 months ago
Other metadata
metadata
{
  "maintainer": "Eduard Jiglau",
  "maintainer_email": "hello@sap-ai-skills.com",
  "website": "https://sap-ai-skills.com",
  "version": "2.4.1",
  "last_verified": "2026-04-02",
  "abap_release": "7.40 SP08+ / 7.50+ / ABAP Cloud",
  "sources": [
    "https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm",
    "https://github.com/SAP-samples/abap-cheat-sheets"
  ]
}

README badge

README badge for secondsky/sap-skills/sap-abap