So here we are with our SAP GUI opened.
The first thing we're going to do is find the Data Dictionary in the SAP menu.
So, open up the Tools menu, choose the ABAP Workbench.
Under Development, you will then see SE11 for the ABAP Dictionary.
Double click it, and you'll then be presented with the first screen for the ABAP Dictionary.
So, let'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, followed by a Display, probably look
at the technical components of the table.
Then we have Views.
A view is similar to a table but all it is is a table structure.
It doesn't contain any data.
Then we have Data types.
Data types are what can make up our database tables, and we'll have a look at those soon.
We have 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 in this exercise, we are going to 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 know about those just now.
All we want to do is create a transparent table.
And when we create our table, we need to ensure our table name adheres to the customer-defined
name space.
And 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.
So, for our example, we're going to create a table that will list employees within a
company.
In the Database tables field, enter ZEMPLOYEES and click the Create button.
This new screen appears, and the cursor is on the Short text field.
All we need to de here is enter description for our table.
Just type in Employees.
Now, under the Short text you can see various tabs and the one that's highlighted at the
moment is the Delivery and Maintenance tab.
For the Delivery Class, click on the field, and click the dropdown button.
This shows you a list of delivery classes that you can choose for your table.
Have a read through but the one we want to choose is Application table because we're
going to hold master data or transaction data in the table that we are creating.
And in the Data Browser/Table View Maintenance field click the dropdown again and choose
Display/Maintenance Allowed.
This will allow us later on to enter data directly inside the table.
And before we go any further, click the Save button.
Now this window pops up, Create Object Directory Entry.
Now what this is all about is any development we do within the SAP system.
Quite often, we do the development in our development environment and we have to move
the development through to our quality insurance environment and then through to production.
And this window allows us to choose the development class which has configure behind it actual
transport roots that we want to use for our development.
But in our case, we're just running through this example scenario and we don't want to
move our developments into another system.
So, what we need to do is click Local object, and what will happen is you will see $TMP
appear as the development class.
And that means to the system this object is only to exist in our development environment
and we do not wish to transport it any further.
So, click the Local object button, and we can see down at the status bar at the bottom
of the screen our table has been saved.
And if you go to the Go To menu and choose Object directory entry, we can then see the
Change Object Directory Entry pop-up box is very similar to the previous one and we can
see that the Development class has been changed to $TMP.
Close that window.
So the next thing that we want to do is 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, our 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.
Our tables 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 can assign an initial value to a field.
Let's say now, the example, we had an employee class.
Let's say the majority of our employees are going to be regular staff.
So let's say we have an initial value of S for Staff.
But we do have some employees that are directors.
Maybe they have a code of D. So we can say our initial value would always
be an S but allow the user to change the value to a D later on.
Every field that we use in our table is made up of what we call a data element.
A data element defines a specific attributes of each field.
One word of warning here, data elements must adhere to the customer name space again so
they must for anything new that we create begin with the letter Z or Y.
So let's start off with entering our first field.
And 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, and the data element, we will enter MANDT.
Now, the data elements already exist in the data system.
And when I 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 elements itself.
Now, very important, we need to ensure that the Client field is made a key field within
our table.
The next field we are going to enter is going to be our own created field and this is going
to be EMPLOYEE.
Again, we're going to make this field a key field and we're going to use a brand new data
element called ZEENUM.
Once you have done this, click the Save button.
I always like to save the table as we go along.
Now, the next thing is ZEENUM does not exist so we have to create the data element.
So even though it's letters entry here, if we try to activate the table, I'll just check
the table, you should see an error message and we do.
So basically because we haven't got a data element called ZEENUM already existed in the
system, it's telling us we cannot activate this table and use it within our system.
So, press F3 or the Back button and then we are going to use forward navigation to create
the data element.
Another way of doing it is to open up a brand new session.
Go to SE11 again and start creating the individual objects this way.
But we don't want to do that.
We want to use forward navigation and we do this just by double clicking our brand new
data element.
So we get this window that appears for Create Data element and it's telling us the element
does not exist, do we want to create it?
Answer YES, then we get taken to Maintain Data element window, similar to the first
screen that we saw when we created our table.
The data element window is asking us for some Short text.
So I enter in here Employee Data Element.
Now, under the Short text you can see four tabs and the one that is highlighted says
Data Type.
We can see here the Elementary data type, called the Domain, needs to be defined for
our data element.
Now, this is important: Domains must adhere to the customer name space.
And we are going to create a brand new domain using the same name that we used for the data
element.
Now, don't get confused.
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.
So, enter ZEENUM, and once again, we are going to use forward navigation to create the domain.
So double click the entry.
It's telling us our data element has changed and do we want to save it before creating
our domain?
Choose YES.
We get the Create Object Directory Entry window appearing again.
And just as before, we want to save this development to the $TMP development class.
So you can either just click the Save button or just click the Local object button.
So now because we've used forward navigation, it's telling us that the new domain that we
are trying to create does not exist.
Choose YES to create the domain.
And once again, enter some Short text that describes what the domain is going to be used
for.
So we will just enter Employee Domain.
Under the Short text, we can see three tabs and the one that's highlighted says Definitions.
The fields available to us, the first one says Data type.
Click the dropdown on Data type, you will see lots of generic data types already exist
within the ABAP dictionary and we can use one of these for our Employee field or domain.
We're going to choose NUMC, which is a character string with only digits.
So double click the entry and that fills in the data type field for us.
And, the number of characters, enter 8.
This means that this field is going to contain a maximum of 8 characters, and we want 0 for
decimals which is the default anyway for a NUMC field.
So put an Output length of 8 and just hit the Enter key.
We can see here that where we have entered the NUMC, it has brought back the description
of this field which tells us it's a valid entry.