SAP TRANSACTION

Locking: Database Locking, SAP Locking
 
Database Locking
Lock Unit: Table line, Table, data pages, index pages
Lock mode: Read Lock(Shared Lock, Read locks allow the system to set other read locks, but prevent other transactions from setting write locks for the objects in question), Write Lock(Exclusive Lock, Write locks do not allow other transactions to set any locks for the objects in question.)
 
Case 1
 
DATA: SFLIGHT_WA TYPE SFLIGHT, SBOOK_WA TYPE SBOOK.

SELECT SINGLE * FOR UPDATE FROM SFLIGHT (Notes: For update here is the same as  CALL FUNCTION func IN UPDATE TASK, and PERFORM ... ON COMMIT
理解一: FOR UPDATE, IN UPDATE TASK, ON COMMIT 分别是把select-clause, Function module, Form拉进这个Transaction.
理解二:让这个 Select-clause或Function module或Forms在下一个commit work时执行。 )
       INTO SFLIGHT_WA
  WHERE
    CARRID   = 'LH'       AND
    CONNID   = '0400'     AND
    FLDATE   = '19960516'.
IF SY-SUBRC <> 0.
  MESSAGE E...
ENDIF.

IF SFLIGHT_WA-SEATSOCC < SFLIGHT_WA-SEATSMAX.
  SBOOK_WA-CARRID = 'LH'.
  SBOOK_WA-CONNID = '0400'.
  SBOOK_WA-FLDATE = '19960516'.
  ...
  INSERT SBOOK FROM SBOOK_WA.
  IF SY-SUBRC <> 0.
    MESSAGE E...
  ENDIF.
  UPDATE SFLIGHT
    SET
      SEATSOCC = SEATSOCC + 1
    WHERE
      CARRID   = 'LH '      AND
      CONNID   = '0400'     AND
      FLDATE   = '19960516'.
ELSE.
  MESSAGE E...
ENDIF.
COMMIT WORK.
 
 
 
 
Uncommitted read (or dirty read)
一个事务读取了被另一个未提交的并行的事务写的数据。
A program using an "uncommitted read" to read data does not set locks on data objects and does not obey them. For this reason, programmers must bear in mind that their programs might read data that has not yet been finally written to the database with a database commit and could thus still be deleted from the database by a database rollback. "Uncommitted read" is the
default setting in the R/3 system for the isolation level.
Committed read
A program using a "committed read" to read data obeys the locks on data objects. This means that programmers can be sure that their programs will read only data which has been finally written to the database with a database commit. You can set the isolation level in the R/3 system to "committed read" by calling the function module DB_SET_ISOLATION_LEVEL . The next database commit or rollback will reset the isolation level to its default setting, as will calling the function module DB_RESET_ISOLATION_TO_DEFAULT .
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值