Wednesday, May 30, 2018

Notes Series : LUW, Lock Objects & Memory


Logical Unit of Work
_________________________________________

Application programs/database transactions (sequence of actions belonging together) can change database tables. Time span in which one consistent state is transferred to another consistent state (or changes thrown back/rolled back) is called LUW.
It guarantees database integrity through locking mechanism to protect transaction integrity (as SAP is a multi-user system).

Types-

1.       DB LUW – Realized by database system with the help of database lock.
Data base transaction refers to non-separable sequence of database operations.
Database commit:
a.       Implicit
a.       Completion of a dialog step
b.       Synchronous or asynchronous function call
c.       Completion of a function module call
d.       Wait up to, wait for
e.       Sending errors , warnings
b.       Explicit
a.       Database specific native SQL  statements
b.       Between Exec-End exec statement
c.       Calling function module DB_COMMIT
d.       Using Open SQL statement Commit Work
Commit not allowed in AMDP methods.

2.       SAP LUW- Set of DB LUW(Several dialog steps combined, set of tasks combined).  Done using ABAP technique with help of SAP Lock.
a.       Using Bundling technique
                                                               i.      Update function call – All database operation executed in update work process
                                                             ii.      TRFC function call
                                                           iii.      Subroutine call using perform.. on commit.
b.       Commit work makes end of SAP LUW
c.       All changes are written to database in final DB LUW

Lock Objects
______________________________________

 Lock objects helps in integrity when there is simultaneous access of same data records by several users.
When a lock object(EZ_<LOCK>) is created it creates ENQUEUE_<LOCK>, DEQUEUE_<LOCK> function modules. These function modules/group are not transported, rather when lock object transported , it regenerates them in target system.

Lock Mode

1.       Shared or Read Lock
2.       Exclusive and cumulative or Write Lock
3.       Exclusive but not cumulative – only once per transaction

Lock Arguments

1.       Key fields form the lock arguments
2.       It defines which set of data records to be blocked

Lock Table

1.       In main memory of enqueue server records of current lock in the system with owner, lock mode, fields are saved.

Scope

1.       Dialog owner
2.       Update Owner
3.       Both Owners

Update
_________________________________________

 When time consuming changes are made to database, process is carried asynchronously by update work process.
Types
1.       Time critical V1 update -> primary changes (synchronous)
a.       Processed in single update work process in single DB LUW. Executed under SAP Lock.
2.       Non time critical (statistical or V1 dependent) V2 update (Asynchronous)
Update request is triggered from Dialog server and it decides which update server to use.

Work Processors(Screen processor, ABAP interpreter, DB Task handler)
_______________________________________________________________

 All requests that comes in from presentation server are written to a dispatcher queue. Then the dispatcher pulls them in FIFO to first available work process which handles one request at a time.

1.       Dialog WP handles online jobs, interactive request
2.       Update WP saves data in DB using V1 & V2 Update
3.       Background WP
4.       Spool WP
5.       Enqueue WP
6.       Message WP
7.       Gateway WP

Memory
__________________________________________

1.       ABAP Memory

a.       Import/Export
b.       Within a session
c.       Values stored in SPARAM
d.       Export<> to memory id<>
e.       Import<> to <> from memory id <>
f.        Useful when 2 reports use same top include, Parameter ID TPARA

2.       SAP Memory

a.       SET/GET
b.       Session to Session
c.       Can’t carry table data, only field values
d.       Remain until over written or deleted, so clear it before initial use
e.       Set parameter id <> field <>
f.        Get parameter id <> field <>


No comments:

Post a Comment