In this tutorial, I will explain How to Create Table in SAP ABAP environment. And I will explain how to create a data element and domain for the SAP table creation.
Before creating the table, we will see the important terms in the SAP ABAP for table creation.
Important Keywords in SAP ABAP Table
There are many important keywords in the SAP ABAP Table. Below is the main term we should know to create a table.
- Data Element – It is used to describe the type of field. This information is available on all the screens in the SAP ABAP.
- Domain – A domain is one of the basic objects of the ABAP data dictionary, which is used to specify the technical character of the fields such as data type, length, and value in a field. Initially, if we are creating an ID, we need to give a short description along with what kind of field it is.
- Data Type – This defines we can store information on different data types like characters, integers, floating points, etc. Based on the data type we are given; the SAP database will take in the particular data type.
Also, Read: How to Install ABAP Development Tools
Create a Table in SAP ABAP
Here we will see how to create a table in the SAP ABAP environment. Follow the steps below to do so:
Step – 1: [Getting into ABAP Dictionary]
There are two ways to get the SAP ABAP Database table. Such as:
- Through transaction code
- Through SAP Menu
- Through Transaction Code:
Open SAP ABAP. On the Home page, Type and enter SE11 in the search box -> We will redirect to ABAP Dictionary Screen.
- Below represents the ABAP Dictionary page. This is one way to get into the Database table.
2. Through SAP Menu:
- Another way of getting se11 TCODE (ABAP Dictionary) is through SAP Menu. Go to the Home page -> Click on the SAP Menu (from left navigation) -> Click Tools -> ABAP Workbench -> Development -> ABAP Dictionary.
- The ABAP Dictionary page will appear. Since the first method is the direct method to get the initial screen for the table creation in SAP ABAP.
This is the method to get into the ABAP Dictionary page to create a table in SAP ABAP.
Step – 2:
- Once the initial page opens, Provide a unique table name (Zcomp_employer) in the Database table.
- The important thing here is the table name should start with either Z or Y. Since it is a customized table, we cannot give the table name without Z or Y.
- Click on Create.
Step – 3: [Table Creation]
- Once we click on Create, we will see the page with the table name. Also, you can provide the below field values:
- Short Description: Short descriptions are for the user to understand what type of table it is and what are all the information is carried. Since I have taken the employer table, so I was given a short description as Employer Detail.
- Delivery Class: It represents what type of data will be carried. Generally, we will declare either A or C. Here I chose A. A represents the application table (master and transaction data) whereas C represents customizing, maintained only by customers.
- Data Browser/Table View Editing: we should give Display/Maintenance as allowed.
- Display/Maintenance is Allowed – A user can view and make modifications in the data browser and maintain and display in TCODE SM30.
- Display/Maintenance is Allowed with Restrictions – In this also a user can view and make changes with some restrictions.
- Display/Maintenance is not Allowed – A user can not view and make modifications in the data browser.
- Only display allowed – In this option, a user can only view and can’t do any changes.
Step – 4: [Adding Columns in the SAP ABAP Table]
- Now, we have to give respective fields for the table in the SAP ABAP dictionary. Click on Fields on the same page to give the details. The first field should be always a CLIENT field which is a mandatory field. So we will give MANDT in the data element.
- By double click on MANDT under the data element, it will ask for saving. Click Yes to save.
- Now, by default, the data length will be taken as 3, and a Short Description will be taken as a Client.
Step – 5: [Declaring Primary Key in Table]
- After providing the mandatory field as a client, now we have to declare ID as a primary key element. For every table one primary key is mandatory. The second field we have taken is employer id (EMID). We have enabled the checkbox to show the primary key field.
- Give ZEMID under the Data element and double-click the field.
- Since the data element is not created, it will ask for creating, click Yes to create.
Step – 6:
- Now, the Change Data Element page will appear to give a short description of the employer Id and domain name. The domain name can be the same as the data element.
- Double-click on the domain name ZEMID to save and Click Yes. Once clicked yes, the below image will appear.
Step – 7: [Activating the fields]
- The next step is to create a domain for the employer id. Give a short description of a domain as an Employer ID, Data type chosen from the list, then the number of characters is by default it will be taken as 3.
- Save the function by CTRL+S then Create Object Directory Entry page will open and click the Local object to proceed next step.
- Save the field labels by CTRL+S once it took the default value and activate by clicking CTRL+F3.
- Once activated the domain in the SAP table, the below image will appear with the word Active. Once we created, saved, and activated the data element and domain, the screen will show the word ACTIVE, and the data type we declared will be visible.
Check out: Operators in SAP HANA Cloud
Create a Column in the SAP ABAP Table
Similarly, we will see, how to create a Column in the SAP ABAP Table.
Let’s say I will create a column as Employer Name in the SAP ABAP table with a data element and domain.
- Here we will take the employer’s name as EMNAME in the field and ZEMNAME in the data element. Since it is not created already by anyone, it will show as a blank. If it is created already, automatically the values will be taken.
- Double-click on the ZEMNAME to create a data element for the table. Before that it will ask for saving, Click Yes to move next step.
- Now, again click Yes to create the Data element in the SAP ABAP Table for the employer name field in the employer table.
- The data element page will open. Give a short description of the Employer name and domain name same as a data element name. We can copy and paste the same name or we can give as per our wish. Since the below field is not activated so it showing as empty near the data type.
- Again Double-click on the ZEMNAME near Domain to create a domain. Before that, it will ask for saving, click Yes to create a domain in the table.
- Now give the data type as CHAR from the dropdown list, then give the required characters.
- It is mandatory to do the activation for the domain and data element. Else we will face an error. Click CTRL+F3 for activation and click on the DOMA with ZEMNAME then click the tickmark at the end of the page.
- Go back to the data element page, save the screen, and click the activation icon at the top to get the data element to be activated.
- Now for the data element activation for employer name, it will show like DTEL with the field name ZEMNAME then click the tickmark at the end of the page.
- Now after activating the screen, the value will be added to the fields automatically. In the same way, we can add more fields as per our requirements. But make sure to activate it immediately.
In this method, we will create data element and domain in the SAP ABAP Table.
Read: How to manage roles and privileges for users in SAP HANA Cloud?
Technical Settings in SAP ABAP Table
After activating everything, we have to give the technical settings values. The main purpose of technical settings is to declare data class and size.
- Go to Technical Settings at the top of the table we created and click on it to give the required inputs.
- Now give the Data class as APPL0 which denotes master data, and transparent table.
- While for Size Category we can give it as 0 because it will hold up to 6000 records. By default, the buffering is taken as Buffering not allowed but that doesn’t impact anything in the SAP Table, and click Save.
This is the standard method to give technical settings in SAP ABAP.
How to Create an Enhancement Category in SAP ABAP Table
Next, we will see How to Create an Enhancement Category in SAP ABAP Table. Refer to the instructions below:
- Go to More (from top) in the same SAP table created page with the fields -> Click Extras -> simultaneously click Enhancement Category…
- Select the enhancement category based on our user choice, and also depends upon user functionality. Here we can choose Can be Enhanced (Deep) and click the Tickmark down.
A pre-existing R/3 object’s functionality can be improved or modified through the use of enhancements, and the R/3 object’s enhancement or modification is ruled by the enhancement category. We can choose any of the options below.
- This table/structure can be enhanced (deeply) with a deep structure, reference fields, or any other legitimate field type.
- Fields that are solely character or numeric kinds, such as C, N, D, T, and I, can be added to the tables or structure to enrich them.
- Character Type Can Be Enhanced – Character types can be improved by only
- Cannot Be Enhanced – Limiting Post-Creation Enhancement of the Table/Structure.
- Not Classified – This Enhancement Category’s default choice generates the warnings that are frequently discussed. It merely signifies that the table has no defined enhancement categories.
This is how we should create Enhancement Category in the SAP ABAP Tabl.
Create Entries in SAP ABAP Table
After adding the fields in the table, we have to create entries or add values to the table.
- Expand More in the same table page -> Utilities -> Click Table Contents -> Create Entries.
- Now fill in the required fields and save by Table Entry -> Save or directly click Ctrl+S. Click Reset to add more entries and save.
By this method, we should give entries in the SAP ABAP table.
View Entries in SAP ABAP Table
After entries are added to the table, view the output in SAP ABAP by displaying the entries.
- Go to More-> Utilities -> Table contents -> Display to view the created entries for the table.
- To execute the output, click More -> Program -> Execute to see the final output.
- The final output of the table will be displayed in the below image.
This is how we will see how to view entries in SAP ABAP Table.
Check out: What is SAP BTP Cockpit?
View Particular Entries in SAP ABAP Table
If we want to see the particular records or entries in the output table, then we can give the specific values or entries to see as a result.
- Go to More -> Utilities -> Table Contents -> Display to view the created entries for the table.
- Now give any values like ID, name, phone number, or country. I am here giving the name from Jenifer to John. So, it will show Jenifer to John entries which I have created already.
- The required output for the entries we have chosen is displayed below.
This is how to view Particular Entries in SAP ABAP Table.
What happens when we are not Activate the Data Element and Data Domain?
If we forget to activate the data element or data domain or forget to give technical settings or enhancement categories the below error will occur.
Sometimes, we will receive an error like data element and data domain not active. The table will not be activated until the data element and the domain will be activated.
Conclusion
This tutorial explained each and every step to create a table in SAP ABAP. Make sure to activate the data element and domain to avoid errors. Below are the topics covered in this tutorial.
- Important Keywords in SAP ABAP Table
- How to create a table in SAP ABAP
- Creating a Column name in the SAP ABAP table
- Technical settings in the SAP ABAP Table
- Create an Enhancement category in SAP ABAP
- Create Entries in SAP ABAP Table
- View the entries in the SAP ABAP table
- View particular entries in the SAP ABAP table
Additionally, you may like some more SAP tutorials:
- How to Create Table Maintenance Generator in SAP ABAP
- What is SAP HANA Cloud Data Lake
- How to Create Lock Object in SAP ABAP?
- What is SAP HANA Cloud & How it Works [With Features]
- How to Create a Database Instance in SAP HANA Cloud
- How to Create a Package in SAP ABAP
I am Chris Waldron, working as a Senior SAP HANA Consultant at Halliburton, Houston, Texas, United States. I have been working in SAP for more than 15 years, especially in SAP IT consulting and business consulting. I worked in various industries in Sales & Distribution, Customer Relationship Management, banking, Risk Management, etc. And I am an SAP Certified Development Specialist – ABAP for SAP HANA 2.0 and SAP HANA Modeling Certified consultant. Read more