SAP ABAP Interview Questions (51 - 55)
51. What is SY-SUBRC and how is it used?
SY-SUBRC is a system field that stores the return code of the last ABAP operation.
Usually 0 means success, and a non-zero value means something different happened, like no record found or an error condition.
Developers check SY-SUBRC after statements like READ TABLE, SELECT SINGLE, AUTHORITY-CHECK, and function module calls.
* SY-SUBRC example
READ TABLE it_scarr INTO wa_scarr WITH KEY carrid = 'AA'.
IF sy-subrc = 0.
WRITE: / 'Record found'.
ELSE.
WRITE: / 'Record not found'.
ENDIF.
52. What is COMMIT WORK and ROLLBACK WORK?
COMMIT WORK permanently saves database changes made during the current logical unit of work. ROLLBACK WORK cancels those changes if something goes wrong. These commands are important when our program inserts, updates, or deletes data and we need to control data consistency.
UPDATE zemp SET salary = 50000
WHERE empid = '1001'.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
53. What is Authority Check?
Authority Check is used to verify whether a user has permission to perform a specific action (like display, create, or change data). It ensures security and access control in SAP applications.
AUTHORITY-CHECK OBJECT 'Z_EMP'
ID 'ACTVT' FIELD '03'. "03 = Display
IF sy-subrc <> 0.
MESSAGE 'Not Authorized' TYPE 'E'.
ENDIF.
Authority Check ensures that only authorized users can perform specific operations in SAP.
54. What is Lock Object (ENQUEUE/DEQUEUE)?
Lock Object (ENQUEUE/DEQUEUE) is used to control concurrent access to data so that multiple users don’t update the same record at the same time. It ensures data consistency and prevents conflicts during updates.
How it works:
- ENQUEUE → Locks the record (no other user can change it).
- DEQUEUE → Unlocks the record after processing is done.
- SAP generates lock function modules automatically (like ENQUEUE_..., DEQUEUE_...).
* Lock object example
CALL FUNCTION 'ENQUEUE_EZEMP'
EXPORTING
emp_id = '100'.
IF sy-subrc = 0.
"Safe to update data
ENDIF.
CALL FUNCTION 'DEQUEUE_EZEMP'
EXPORTING
emp_id = '100'.
55. What is the difference between BDC and LSMW?
BDC (Batch Data Communication) is a programming technique used to transfer data into SAP by simulating user input on screens. It requires ABAP coding and is commonly done using CALL TRANSACTION or SESSION method.
LSMW (Legacy System Migration Workbench) is a tool provided by SAP to migrate data from legacy systems into SAP. It is mostly configuration-based (less coding) and provides step-by-step data migration processes. It is easier to use for functional users compared to BDC.
* CALL transaction example
CALL TRANSACTION 'VA01' USING bdcdata MODE 'A'.