SAP System Setup Training Course
Reveals How To Setup A Free SAP Developer System.
Learn SAP & Practice For Certification. Developer Tips Included:

Beginners Guide To ABAP – Module 2 – Data Dictionary – Create A Table Part 1

In this lesson we are going to start creating our first SAP table. With your SAP GUI open and logged in, the first thing we’re going to do is find the Data Dictionary in the SAP menu.

Expand the Tools menu and choose the ABAP Workbench. Under the Development option you will see SE11 – ABAP Dictionary. Double click it, and you’ll then be presented with the first screen for the ABAP Dictionary.

Create A Sap Table - Part 1Let’s go through the different options that we see on the screen.

  • The first one we see is Database tables. This is where we can enter an existing table name and view the technical components of any SAP table.
  • Then we have Views. A View is similar to a table but it does not contain data. It brings together fields from 1 or more other tables by defining relationships between fields of these tables.
  • Then we have Data types. Data types are what can make up our database tables, and we’ll have a look at those soon.
  • The other options available are Type groups, Domains, Search help and Lock objects.

Let’s focus on creating a table, first of all. So, what we want to do is click on the Database table option and we will focus on creating a transparent table. There are other types of tables such as Cluster Tables and Pool Tables, but you don’t need to concern yourself with those just now.

When you create a transparent table you need to ensure the table name adheres to the customer-defined name space. This means we need to start our tables with the letter Z or the letter Y. Most commonly, you’ll see the letter Z being used.

For this example I am going to create a table that will list employees within a company. Follow these steps:

  1. In the Database Tables field, enter ZEMPLOYEES and click the Create button. A new screen appears, and the cursor is placed on the Short Text field. All we need to do here is enter a description for the table. Just type in the word ‘Employees’.
  2. Now, under the Short text field you can see various tabs. The one that’s highlighted first is the Delivery and Maintenance tab. For the Delivery Class, click the drop down button. You will see a list of delivery classes that you can choose for your table. Have a read through the descriptions. The one we want to choose is Application table because we are going to hold master data in the table that we are creating.
  3. For the Data Browser/Table View Maintenance field click the drop down button again and choose Display/Maintenance Allowed. This will allow us later on to enter data directly inside the table later on.
  4. Before you go any further, click the Save button.
  5. A window will appear called Create Object Directory Entry. Any development we do within the SAP system can potentially be moved into other systems within our landscape such as the quality insurance environment and production environment. This window allows us to choose the development class which has been which allows us to move our developments to the systems mapped out by the transport routed configures for a particular development class. As we are only creating an example table we don’t want to move our developments into another system. So, what you need to do is click the Local object button which will assign your table object to the $TMP development class. This is a special development class that tells the SAP system that any object assigned to this development class will not be transported through to another system. The object is just LOCAL to this system. Once you click the button check the status bar at the bottom of the screen to ensure our tables have been saved successfully.

If you select the GoTo menu and choose Object directory entry, you will see the Change Object Directory Entry pop-up box is very similar to the previous window and you will see the Development Class has been changed to $TMP. Close that window.

Create Your First Field

Next we want to start entering the field names for our table. There are few guidelines that we need to keep in mind when creating fields within our table.

  • Firstly, a field names can start with any letter at all. They do not have to begin with a Z or a Y like our table names themselves.
  • Field names can have a maximum of 16 characters.
  • Your table must have at least one key field. This is used later on for searching and sorting of data and they identify each record as being a unique record.
  • You have the option of assigning an initial value to a field. For example, let’s say for a field called Employee Class the majority of our employees have a value of ‘R’ meaning Regular Staff. You can also have employees that are Directors. For these employees you assign a code of ‘D’. As 99% of staff are ‘Regular Staff’ we can set the initial value of the field to ‘R’ and allow the system to automatically enter this value for us meaning we would only have to set it to the letter ‘D’ for the very few Directors that work within the company.
  • Every field that we use in our tables is made up of what we call a Data Element. A data element defines the specific attributes of each field. One word of warning here, data elements must adhere to the customer name space which means they must begin with the letter Z or Y.

Let us start off with entering our first field. The field we are going to create is a very important field within an SAP system. It’s the field that identifies the client that our records are associated with. So in the field name, enter CLIENT MANDT (edit made see comment). Then enter MANDT in the Data Element. This special data element already exists in the system. When you press Enter after entering it you can see the system automatically filled in the Data type, the Length, number of Decimals, Short text for the actual data element itself. Very important – we need to ensure that the MANDT field is made a key field within our table.

The next field we are going to enter is we create from scratch. This field is called EMPLOYEE. Again, you want to make this field a key field and we’re going to use a brand new Data Element called ZEENUM. Once entered, click the Save button. It is always good practice to save the table as we go along.

The system does not know what type of Data Element ZEENUM is, so you have to create the data element. Use forward navigation to create the new Data Element by double clicking its name. A new window will appear ‘Create Data element’ and it’s telling us the element does not exist, do we want to create it? Answer YES. The screen then displays the Maintain Data Element window. Similar to the first screen that we saw when we created our table. The Maintain Data Element window is asking waiting for some Short Text to be entered. So enter the text Employee Data Element.

Under the Short Text you will see four tabs and the one that is highlighted says Data Type. You can see here the Elementary Data Type called the Domain and we need to be define this for our Data Element. This is important: Domain’s must adhere to the customer name space. Create a brand new Domain using the same name that we used for the Data Element ZEENUM.

Don’t read anything into the same name. This doesn’t mean there’s some sort of magical relationship between the names. There isn’t. We’re just using the same name because that’s what I have decided when I created this guide J. Once you enter ZEENUM use forward navigation to create the Domain. So double click the entry. The system will tell you the Data Element has changed and do we want to save it before creating our Domain? Choose YES. Next you will see the Create Object Directory Entry window appearing again. Just as before, save this development to the $TMP development class. Either just click the Save button or just click the Local Object button.

The system will show another prompt explaining the new Domain that we are trying to create does not exist. Choose YES to create the domain. Enter some Short Text that describes what the domain is going to be used for. In this example I have entered ‘Employee Domain’.

Located under the Short text, you will see three tabs and the one that’s highlighted says Definitions. The first field available to us is Data Type. Click the dropdown button on Data Type. You will see a list of generic data types already existing within the ABAP Dictionary and we can use one of these for our Employee field / Domain. Choose ‘NUMC’, which is a character string with only digits.

Double click the entry and that fills in the data type field for us. For the number of characters, enter 8. This means that this field is going to contain a maximum of 8 characters. Enter 0 for decimals which is the default for a NUMC field. Enter an Output Length of 8 followed by the Enter key. We can see here that where we have entered NUMC, it has brought back the description of this field which tells us it’s a valid entry.

Watch the next video in the series to where we discus Values Ranges and Activating your objects: Create A SAP Table Part 2

About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon

  • safronov

    think there is an inaccuracy when you named the first fiald as “CLIENT”. You should name it as “MANDT” in order to make your table mandant dependent.

    • http://www.saptraininghq.com Pete

      Hi Safronov,

      You are quite right. Thanks for highlighting it. I will edit the text in the post and change the video shortly.

      A Note to all: when the MANDT (Client) field is used in a table it allows the table to hold records for multiple Clients that have been setup in the system. So always name you client field MANDT as highlighted by Safronov.

      Thanks again.
      Pete

x

Free SAP Training Course

d
c