Examples OPEN SQL Statements in SAP ABAP

+ -

Below is the example program on INSERT, UPDATE, DELETE examples using lock objects.


REPORT ZSAN_LOCKOBJECT.
DATA : IT_STUDENT TYPE TABLE OF ZSTUDENT,
       WA_STUDENT TYPE ZSTUDENT.
WA_STUDENT-STUDENTID = '10'.
WA_STUDENT-NAME = 'SAPNuts'.
WA_STUDENT-LASTNAME = 'SAPNuts'.
WA_STUDENT-FATHER = 'SAP'.
WA_STUDENT-DOB = '25/09/2013'.
WA_STUDENT-GENDER = 'Male'.
WA_STUDENT-COURSE = 'SAP ABAP'.
WA_STUDENT-EMAIL = 'admin@sapnuts.com'.
WA_STUDENT-FEE = '0000'.
CALL FUNCTION 'ENQUEUE_EZSTUDENT' "add lock
  EXPORTING
    MODE_ZSTUDENT = 'E'
    MANDT         = SY-MANDT
    STUDENTID     = WA_STUDENT-STUDENTID.
IF SY-SUBRC = 0.
  INSERT ZSTUDENT FROM WA_STUDENT. "insert record
  IF SY-SUBRC = 0.
    WRITE:/ 'Record inserted'.
  ENDIF.
  UPDATE ZSTUDENT FROM WA_STUDENT. "update record
  IF SY-SUBRC = 0.
    WRITE:/ 'Record updated'.
  ENDIF.
  DELETE ZSTUDENT FROM WA_STUDENT. "delete record
  IF SY-SUBRC = 0.
    WRITE:/ 'Record deleted'.
  ENDIF.
ENDIF.

CALL FUNCTION 'DEQUEUE_EZSTUDENT' "release lock
  EXPORTING
    MODE_ZSTUDENT = 'E'
    MANDT         = SY-MANDT
    STUDENTID     = WA_STUDENT-STUDENTID.

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 16 People out of 17 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Lesson → SAP memory and ABAP memory