Skip to Content
0
Former Member
Jul 16, 2011 at 10:21 AM

What scenario is suitable to test a lock object?

15 Views

Dear experts,

I'm studying about lock objects and I want to create a scenario that shows a fail access to a table row since the row is locked. Any idea how to do this?

I've created 2 identical programs that lock the same table row, update it, but not unlock it. Both programs update the same locked row successfully. Any better idea?

DATA:
  csubrc TYPE c LENGTH 5,
  wa_zscarr TYPE zscarr.

CALL FUNCTION 'ENQUEUE_EZSCARR'
  EXPORTING
    mandt = '000'
    carrid = '01'.

IF sy-subrc > 0.
  WRITE sy-subrc TO csubrc.

  MESSAGE csubrc TYPE 'I'.
ELSE.
  MESSAGE 'Lock successful' TYPE 'S'.
ENDIF.

wa_zscarr-mandt = '000'.
wa_zscarr-carrid = '01'.
wa_zscarr-carrname = sy-uzeit.

UPDATE zscarr CLIENT SPECIFIED FROM wa_zscarr.

IF sy-subrc > 0.
  WRITE sy-subrc TO csubrc.

  MESSAGE csubrc TYPE 'I'.
ELSE.
  MESSAGE 'Update successful' TYPE 'S'.
ENDIF.

Thanks in advance.

Regards,

Haris