Create Lock Object, Auth Object & Application Log in SAP ABAP

SAP ABAP Objects Guide: How to Create Lock Object, Authorization Object, Application Log & Text Object
Learn the fundamental SAP ABAP development skills including the creation of a lock object using SAP ABAP to building authorization objects, application logs as well as text-based objects. This guide takes you through each idea step-by-step.
Table of Contents
- Introduction to SAP ABAP Objects
- How to Create an Object in SAP ABAP
- How to Create a Lock Object in SAP ABAP
- How to Create a Lock Object for a Table in SAP ABAP
- How to Create an Authorization Object in SAP ABAP
- How to Create an Authority Check Object in SAP ABAP
- How to Create an Application Log Object in SAP ABAP
- How to Create a Text Object in SAP ABAP
- Best Practices & Tips
- Conclusion
1. Introduction to SAP ABAP Objects
SAP ABAP (Advanced Business Application Programming) is the core of SAP's enterprise-level application development platform. If you're a novice developer who is just beginning or an experienced consultant in the process of planning upgrading, knowing what it takes to create objects using SAP ABAP will provide you with essential knowledge that is not to be missed.
In this article we go over four essential object types that each ABAP developer must be aware of:
- Lock objects — to manage simultaneous data access
- Authorization objects — used to manage the permissions of users
- Application Log Objects — used to store messages during runtime
- Text objects — for managing translatable text components
Each of them contributes to developing secure, reliable and durable SAP applications. Let's get started.
2. How to Create an Object in SAP ABAP
Before tackling specific types of objects it is important to know the general procedure for creating objects using SAP ABAP. SAP offers the Workbench ABAP (Transaction SE80) and various dedicated transactions to create various repository objects.
General Steps to Create an Object in SAP ABAP
- Open the transaction SE80 (Object Navigator) or the appropriate transaction for the type of object you have.
- Choose your package (development class) or make use of
$TMPto access local objects. - Select the type of object you want to use from the dropdown menu.
- Choose a relevant technical name according to your organization's naming conventions.
- Add a description of the item.
- Click Save and Activate.
$TMP objects) to make them visible through the landscape of your system — DEV → QAS → PRD.
The object types mentioned in this article have the same workflow for creation but utilize separate transactions for accuracy.
3. How to Create a Lock Object in SAP ABAP
The lock object in SAP ABAP can be utilized to implement the enqueue/dequeue lock — a method which prevents multiple users from simultaneously altering the same data entry and thereby avoiding data inconsistencies.
What is a Lock Object?
When a user accesses an editable record, SAP sets a logical lock on the record via an Enqueue server. The other user cannot modify this record until the lock has been removed. This is accomplished through function modules that are automatically generated by the creation of a lock object using SAP ABAP.
Transaction: SE11
Step-by-Step: How to Create a Lock Object in SAP ABAP
- Go to Transaction SE11 (ABAP Dictionary).
- Choose the radio button "Lock Object" and then enter a name beginning with
EZorEY(for customer objects). Example:EZLOCK_EMPLOYEE. - Click Create.
- Add a short description such as: "Lock Object for Employee Table".
- On the Tables tab, enter the table that you wish to secure (e.g.,
ZEMPLOYEE). - Select the Lock Mode:
E— Exclusive Lock (only one person can write)S— Shared Lock (multiple users are able to read)X— Exclusive but not cumulative
- Go to the Lock Parameters tab. SAP automatically populates lock parameters from the key fields in your table.
- Click Save, assign a transport request, and then click Activate.
Generated Function Modules
Once activated, SAP automatically generates two function modules:
| Function Module | Purpose |
|---|---|
ENQUEUE_EZLOCK_EMPLOYEE |
Locks the record (called before editing) |
DEQUEUE_EZLOCK_EMPLOYEE |
Lock is released (called after saving or cancelling) |
Sample ABAP Code
" Set Lock
CALL FUNCTION 'ENQUEUE_EZLOCK_EMPLOYEE'
EXPORTING
emp_id = lv_emp_id
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE 'Record is locked by another user.' TYPE 'E'.
ENDIF.
" Release Lock
CALL FUNCTION 'DEQUEUE_EZLOCK_EMPLOYEE'
EXPORTING
emp_id = lv_emp_id.
4. How to Create a Lock Object for a Table in SAP ABAP
Making a lock object for a particular table follows the same method as described previously, however here are some additional suggestions for managing several tables as well as secondary tables.
Adding Secondary Tables
Within the Tables tab of your lock object (SE11), you can include multiple tables:
- The initial table is the primary (master) table.
- Additional tables are secondary tables connected via foreign key relationships.
- SAP incorporates the key fields of all linked tables as lock parameters automatically.
When to Use Table-Level Locks
- When you update the header and item tables together (e.g., Sales Order Header + Items)
- When you alter configuration tables that impact many downstream processes
- When your custom Z-table has been changed by several applications or transactions
5. How to Create an Authorization Object in SAP ABAP
Authorization objects in SAP regulate what users can view and do in the SAP system. They are at the core of the role-based access control (RBAC) model.
Transaction: SU21
Step-by-Step: How to Create an Authorization Object in SAP ABAP
- Go to Transaction SU21 (Maintain Authorization Objects).
- Navigate to your Authorization Object Class (create one if required via the menu: Edit → Object Classes → Create).
- Choose your class then click Create Object (or navigate to Edit → Authorization Objects → Create).
- Fill in the Authorization Object name (max 10 characters, beginning with
Zfor custom objects). Example:ZHRLEAVE. - Enter a Description: "Authorization for HR Leave Management".
- In the Authorization Fields section, add a maximum of 10 fields. The most common fields are:
ACTVT— Activity (standard SAP field used for actions such as 01=Create, 02=Change, 06=Delete)- Custom fields that are specific to the business object you are working with
- Click Save.
Sample Usage in ABAP Code
AUTHORITY-CHECK OBJECT 'ZHRLEAVE' ID 'ACTVT' FIELD '02' ID 'ZLEAVE_TYPE' FIELD lv_leave_type. IF sy-subrc <> 0. MESSAGE 'You are not authorized to perform this action.' TYPE 'E'. ENDIF.
6. How to Create an Authority Check Object in SAP ABAP
An authority check within SAP ABAP is a runtime verification performed in code using the AUTHORITY-CHECK statement against an authorization object. This is the way to apply the authorization object you have created.
Key Points About Authority Checks
- The
AUTHORITY-CHECKstatement examines whether the profile of the user currently in use has the authorization values that are required. SY-SUBRC = 0means that the user has been granted permission.SY-SUBRC <> 0indicates that the individual is not authorized.- It is possible to check multiple fields within a single statement.
Best Practices for Authority Checks
- Always run authority checks prior to displaying sensitive information or performing critical operations.
- Place checks at the beginning of the program or prior to any critical operation.
- Utilize
ACTVTin conjunction with standard activity codes (01=Create, 02=Change, 03=Display). - Log failed authorization checks using the Application Log (covered in the following section) for audit purposes.
- Test using Transaction SU53 to display unsuccessful authorization checks.
How to Test Authority Checks
- Utilize Transaction SU53 to view the most recent unsuccessful authorization check for a user.
- Utilize Transaction ST01 to track authorization checks in real time.
7. How to Create an Application Log Object in SAP ABAP
The SAP Application Log (also known as BAL — Business Application Log) is a standard framework used for recording messages, errors, warnings and other entries during program execution.
Transaction: SLG0
Step-by-Step: How to Create an Application Log Object in SAP ABAP
- Go to Transaction SLG0 (Application Log: Define Objects).
- Click New Entries.
- Enter the Object Name (max 20 characters, beginning with
Z). Example:ZPAYROLL_LOG. - Enter a Short Description: "Payroll Processing Application Log".
- Optionally, create Sub-Objects (Transaction SLG0 → Sub-Objects tab) to sort log entries further. Example sub-object:
ZPAYROLL_RUN. - Click Save and assign the transport request.
How to Write to the Application Log in ABAP
DATA: lv_log_handle TYPE balloghndl,
ls_log TYPE bal_s_log,
ls_msg TYPE bal_s_msg.
" Step 1: Create Log Header
ls_log-object = 'ZPAYROLL_LOG'.
ls_log-subobject = 'ZPAYROLL_RUN'.
ls_log-extnumber = 'Payroll Run - 05/2026'.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = ls_log
IMPORTING
e_log_handle = lv_log_handle.
" Step 2: Add a Message
ls_msg-msgty = 'E'. " E=Error, W=Warning, I=Info, S=Success
ls_msg-msgid = 'ZHR_MSG'.
ls_msg-msgno = '001'.
ls_msg-msgv1 = 'Employee 12345'.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = lv_log_handle
i_s_msg = ls_msg.
" Step 3: Save Log to Database
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_log_handle = lv_log_handle.
Viewing Application Logs
Utilize Transaction SLG1 to review and analyze the application logs that have been saved according to object, sub-object, date and user.
8. How to Create a Text Object in SAP ABAP
Text objects in SAP ABAP are used to handle translatable text such as descriptions, messages, labels as well as UI strings that can be translated into a variety of languages. This is crucial for global SAP deployments.
Types of Text Objects in SAP
| Type | Transaction | Purpose |
|---|---|---|
| Message Classes | SE91 | Reusable messages across programs |
| Text Symbols | SE38/SE80 | Program-level translatable texts |
| Domain Fixed Values | SE11 | Texts for dropdown field values |
| Search Help | SE11 | Description texts for value helps |
How to Create a Text Object (Message Class) in SAP ABAP
- Go to Transaction SE91 (Message Maintenance).
- Enter a message class name (starting with
Z). Example:ZLEAVE_MSG. - Click Create.
- Enter a Short Description: "Messages for Leave Management Application".
- In the Messages tab, add individual messages:
- Enter the message number (3-digit, e.g.,
001) - Enter the message text (use
&1,&2,&3,&4as placeholders for dynamic values)
- Enter the message number (3-digit, e.g.,
- Click Save and Activate.
Example Messages
| No. | Message Text |
|---|---|
| 001 | The request for leave &1 was created successfully. |
| 002 | Employee &1 is not eligible for leave type &2. |
| 003 | The leave balance for &1 is insufficient. |
Using Text Objects in ABAP Code
" Using MESSAGE statement MESSAGE e001(ZLEAVE_MSG) WITH lv_leave_id. " Using in Selection Screen SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001. " TEXT-001 is a text symbol defined in the program SELECTION-SCREEN END OF BLOCK b1.
9. Best Practices & Tips
Here's a brief overview of top best practices to follow when you create objects within SAP ABAP:
Naming Conventions
- Always label customer objects with either
ZorYto avoid conflict with SAP standard objects. - Make use of descriptive names that represent the intended business function (e.g.,
ZLOCK_SALESORDERnotZLOCKSO1). - Be sure to follow your company's naming guidelines to ensure uniformity.
Transport Management
- Never store production-relevant objects within the
$TMPlocal package. - Make sure that all items are assigned to the appropriate package and transport request.
- Utilize SE10 to monitor and manage transport requests.
Security
- Always use
AUTHORITY-CHECKprior to any sensitive database operations. - Combine authorization objects with SAP roles (Transaction PFCG) to ensure proper user assignment.
- Regularly examine authorization objects using Transaction SU24.
Application Log
- Utilize the BAL framework instead of custom log tables — it includes built-in retention policies, archiving and the standard display transaction (SLG1).
- Always define sub-objects to classify log entries for easier filtering.
Lock Management
- Always pair ENQUEUE with DEQUEUE — a missing dequeue can cause lock table overflow over time.
- Set appropriate lock timeouts in the system parameters to auto-release stale locks.
10. Conclusion
Knowing the techniques to create objects within SAP ABAP — from lock objects and authorization objects to application logs and text objects — is a crucial career skill for anyone who is an SAP developer or consultant. These objects are the basic building blocks for secure, flexible and easily adaptable SAP applications.
Here's a quick overview of the transactions that you'll need to keep track of:
| Object Type | Transaction |
|---|---|
| Lock Object | SE11 |
| Authorization Object | SU21 |
| Authority Check (in code) | SE38 / SE80 |
| Application Log Object | SLG0 |
| Application Log Viewer | SLG1 |
| Text Object (Message Class) | SE91 |
| Text Translation | SE63 |
If you're in the process of preparing for SAP ABAP Certification, working on a customized development task, or converting your existing software into SAP S/4HANA, the information provided in this guide will give you the foundation you need to create professional-grade SAP applications.
Frequently Asked Questions (FAQs)
Q: What's the difference between a lock object and a database lock within SAP ABAP?
A: A lock object is an application-level logical lock that is managed by SAP's Enqueue server, and a database lock is an entry-level lock managed at the RDBMS level. SAP suggests using lock objects since they give more control, better visibility and compatibility with SAP's distributed structure.
Q: Can I include greater than 10 fields within one authorization object?
A: No. SAP limits authorization objects to a maximum of 10 authorization fields. If you require more, consider dividing the logic into several authorization objects.
Q: How long are application log entries kept?
A: By default, log entries are saved until deleted. You can define retention intervals and create archiving jobs with Transaction SLG2 to manage storage.
Q: What is the naming limit for a lock object within SAP ABAP?
A: Lock object names may be up to 16 characters long. They must start with E, followed by Y or Z for customer-defined objects (e.g., EZLOCK_TABLE).
Related SAP Training Courses
Tags
Share this article
Help others discover this valuable SAP content


