SAP Data Dictionary

Introduction

This article will focus specifically on the Data Dictionary. This is the main tool used to look at, understand and enhance the Database and Database tables which are used by the SAP system. You can view standard tables delivered by SAP using this tool, create new tables and enhance the existing tables delivered by SAP with new fields. There are many other features involved in the Data Dictionary, but the focus here will be on the basic ones so as to build on this later on when creating ABAP programs.

First, a database table will be created, involving the creation of fields, data elements and domains. An explanation of what each of these is, and why they are necessary to the tables built will be given. During the building of the tables, the tools used to check for errors will be shown. Once these errors are eradicated, the tables can be activated so that they can be used within the system.

After this, a look will be taken at maintaining the technical settings of the table created, which will allow the entry of data, before finally looking at the data which has been entered using standard SAP transactions available in the SAP system.

Creating a Table

With the SAP GUI open, you will be able find the Data Dictionary in the SAP menu tree. This is done via the Tools menu. Open the ABAP Workbench and click the ‘Development’ folder, where the ABAP Dictionary can be found and double-clicked. Alternatively, use the transaction code SE11:

Now, the initial screen of the ABAP Dictionary will appear:

image

To create a table, select the ‘Database table’ option. In this exercise a transparent table will be created. Other types of table do exist (such a cluster tables and pool tables), but at this early stage the transparent table variety is the important one to focus upon.

The table name must adhere to the customer-defined name space, meaning that the name must begin with the letter Z or Y, most commonly this will be Z. In this example, the table will show a list of employees within a company, so, in the ‘Database table’ area, type ‘ZEMPLOYEES’ and click the ‘Create’ button.

Once this is done, a new screen will appear:

image

image

In the ‘Short text’ field, a description for the table must be included, enter ‘Employees’:

image

In the ‘Delivery and Maintenance’ tab (which opens by default), look at the ‘Delivery class’ section, select the field and then click the drop-down button, where a list of Delivery classes will be shown and selected:

image

For the table being created here, choose ‘Application table’, as the data held in the table fits the description ‘master and transaction data’.

In the field below this, labelled ‘Data Browser/Table View Maint.’, choose the ‘Display/Maintenance allowed’ option, which will allow for data entry directly into the table later on. It should look like this:

image

Before going any further, click the ‘Save’ button: image

A window appears titled ‘Create Object Directory Entry’.

Nearly all development work done with SAP is usually done within a development environment, before being moved on to, for example, a quality assurance environment and on further to production. This window allows you to choose the appropriate Development class which is supported by other systems where the work may be moved on to. In this example scenario, though, developments will not be moved on to another system, so click ‘Local object’, so as to indicate to the system (via the phrase ‘$TMP’ which appears) that the object is only to exist within the development system and not to be transported elsewhere. Once this is done, the status bar at the bottom will show that the object has been saved:

image

To check everything has worked as we want, select the ‘Go to’ menu and selects the ‘Object directory entry’ option, a similar pop-up box to the previous one will appear, where the ‘Development class’ field will show ‘$TMP’, confirming this has been done correctly.

Creating Fields

The next step is to begin creating Field names for the table, in the ‘Fields’ tab:

image

Fields, unlike the name of the table, can begin with any letter of the alphabet, not just Z and Y and can contain up to 16 characters.

Tables must include at least one Key field, which is used later for the searching and sorting of data, and to identify each record as being unique.

An Initial value can be assigned to each field, for example, in the case of a field called Employee Class you could say the majority of employees are Regular Staff (‘S’), but some are Directors, with a code of ‘D’. The standard initial value would be ‘S’, but the user could change some of these to a ‘D’ later on.

Data Elements

Every Field in the table is made up of what is called a Data Element, which defines specific attributes of each field.

The first Field to be created here is an important one within an SAP system, and identifies the client which the records are associated with. In the Field name, enter ‘Client’, and in the Data Element, type ‘MANDT’. This Data Element already exists in the system, and after entering it, the system automatically fills in the Data Type, the Length, Number of Decimals and Short text for the Data Element itself. Ensure that the ‘Client’ field is made a Key field in the table by checking the ‘Key’ box.

The next field will be called ‘Employee’. Again, check the box to make this a Key field, and enter the new Data Element ‘ZEENUM’ (Data Elements broadly must adhere to the customer name space by beginning with Z or Y). Once this is done, click the save button.

Next, because the Data Element ‘ZEENUM’ does not yet exist, it must be created. If you try to activate or even check the table (via the ‘Check’ button), an error message is displayed:

image

Until the Data Element ‘ZEENUM’ is created, it cannot be used within the system. To do this, forward navigation is used. Double-click the new Data Element, and a window labelled ‘Create Data element’ appears. Answer ‘Yes’ to this, and the ‘Maintain Data Element’ window comes up.

image

image

In the ‘Short text’ area, enter ‘Employee Data Element’. Next, the Elementary data type, called the ‘Domain’, must be defined for the new Data element. Domains must adhere to the customer name space, so in this instance the same name as the Data element will be given: ‘ZEENUM’, (though giving both the same name is not imperative). Again, forward navigation will be used to create the Domain.

Data Domains

Double-click the entry (‘ZEENUM’) in the Domain area, and agree to save the changes made. Now, the ‘Create Object Directory Entry’ window will re-appear and again it is important to save this development to the ‘$TMP’ development class, via the ‘save’ or ‘local object’ button visible in this window.

After doing this, a window will appear stating that the new Domain ‘ZEENUM’ does not exist. Choose ‘Yes’ to create the Domain, and in the window which appears, type into the ‘Short text’ box a description of the Domain. In this example, ‘Employee Domain’:

image

The ‘Definition’ tab, which, as shown above, opens automatically. The first available field here is ‘Data type’, click inside the box and select the drop-down menu, and a number of generic data types already existing within the ABAP dictionary will appear.

The ‘NUMC’ type is the one to be used here for the Employee data, a “character string with only digits”. Once this selection is double-clicked, it will appear in the ‘Data type’ area in the ‘Definition’ tab.

Next, in the ‘No. characters’ field, enter the number 8, indicating that the field will contain a maximum of 8 characters, and in the ‘Decimal places’ area, enter 0. An Output length of 8 should be selected, and then press Enter.

The ‘NUMC’ field’s description should re-appear, confirming that this is a valid entry.

Next, select the ‘Value range’ tab, which is visible next to the ‘Definition’ tab just used:

image

This is where you set valid value ranges for the Domain created. Once this is set, any subsequent user entering values outside the valid value range will be shown an error message and be requested to enter a valid entry. Here, there are three options.

· First, where you can see ‘Single values’, it is possible to enter a list of individual valid values which can be entered by the user.

· Second, ‘Intervals’, where you can enter a lower and upper limit for valid values, for example 1 and 9, which saves the effort of entering 9 individual single values in the ‘Single values’ section.

· Last, the ‘Value table’ box visible at the bottom. When there are a large number of possible entries, this is a common method (to do this you must specify a complete valid value table entry list, in which case it is also necessary to introduce foreign keys to the table, to ensure the user’s entries are tested against the value stored in the value table created).

This example Domain, however, does not require any Value range entry, so just click the save button and, again, assign it as a ‘Local object’.

The next step is to Activate the object, allowing other Data elements to use this domain going forward. In the toolbar click the small matchstick icon (also accessible by pressing CTRL +F3).

A pop-up window appears, listing the 3 currently inactive objects:

image

It may be possible to activate all of the objects together, but this is not advised. In a typical development environment, a number of people will be creating developments simultaneously, and quite often, others’ objects will appear in this list.

At this point, it is only the Domain which is to be activated, the top entry labelled ‘DOMA’, with the name ‘ZEENUM’. When this is highlighted, click the green tick continue button. The window should disappear, and the status bar will display the message ‘Object(s) activated’

Now it is possible to proceed with the creation of the table. Forward navigation was used for generating the Domain, so click the ‘Back’ button, or press F3 to return to the ‘Maintain Data Element’ screen. As the domain is active, the description entered previously should appear by the area where ‘ZEENUM’ was typed, along with other Domain properties which have been created:

image

Next, the Field labels must be created, so click that tab. The Field labels entered here will appear as field labels in the final table. In this example they should read ‘Employee’, or better, ‘Employee Number’. If this does not fit within the area given, just tailor it so that it still makes sense, for example typing ‘Employee N’ into the ‘Short’ Field label box. Once the text has been put into the Field label spaces, press enter, and the ‘Length’ section will automatically be filled in:

image

Once this is complete, Save and Activate the element via the toolbar at the top. The inactive objects window will reappear, where two inactive objects will remain. Highlight the Data element (labelled ‘DTEL’) and click the green tick Continue button at the bottom.

Again, the status bar should display ‘Object(s) activated’.

Press the back button to return to the Table maintenance screen. Here you will now see that the ‘EMPLOYEE’ column has the correct Data Type, Length, Decimals and Short text, thus indicating the successful creation of a Data element and Domain being used for this Field.

image

Next, the same practices will be used to create four additional fields.

The next field to create should be titled ‘SURNAME’. This time it should not be selected as a Key field, so do not check the box. The Data element, in this instance, is labelled ‘ZSURNAME’:

image

Now, forward navigation will again be used. Double-click ‘ZSURNAME’; choose ‘Yes’ to save the table and ‘Yes’ again to create the new Data element. The ‘Maintain Data Element’ window will appear which will be familiar from the previous steps.

In the ‘Short text’ box this time type ‘Surname Data Element’ and title the new domain ‘ZSURNAME’:

image

Double-click the new domain and save the Data element, assigning it a ‘Local object’ and then choose ‘Yes’ to create the new Domain.

The Domain maintenance screen will reappear. Enter the short text ‘Surname’ and, this time; the Data type to select is ‘CHAR’, a Character string.

The number of characters and output length should both be set to 40, then press enter to be sure everything has worked, and click the Activate button.

image

Note that the Save button has not been pressed this time, as the Activate button will also save the work automatically. Ensure you assign the object to the $TMP development class as usual.

In the Activate menu, select the object (the domain (labelled ‘DOMA’) named ‘ZSURNAME’) to be activated, and click the green tick continue button. The status bar should read ‘Object saved and activated’.

Following this, click Back or F3 to return to the Maintain Data element screen. Ensure the domain attributes have appeared (Short text, Data type, Length and so on). In the Field Label tab, enter ‘Surname’ in each box and press Enter to automatically fill the ‘Length’ boxes and then activate the Data element (in the Activate menu, the ‘DTEL’ object named ‘ZSURNAMES’), checking the status bar to ensure this has occurred with any errors:

image

Again, press Back to return to the Maintain Table screen, where the new Data element will be visible:

image

The next field to be created is titled ‘FORENAME’, and the data element ‘ZFORENAME’. Click to create the Data element and follow the steps above again.

In the Maintain Data Element screen, the Short text should read ‘Forename Data Element’ and the domain ‘ZFORENAME’. Save this and choose ‘Yes’ to create the domain.

The domain’s short text should read ‘Forename’. Use the CHAR data type again and a Length and Output length of 40. Next, Activate the Domain as before.

Return to the Maintain Data Element screen. Type ‘Forename’ into the four Field label boxes. Press enter to fill the length boxes and then Activate the Data Element named ‘ZFORENAME’ as before. Go back again to see the table:

image

The next field will be called ‘Title’ and the Data Element ‘ZTITLE’, follow the steps above again to create this field with the following information:

The Data element short text should read ‘Title Data Element’ and the domain should be named ‘ZTITLE’.

The Domain Short text should be ‘Title’ and the Data type is again ‘CHAR’. This time the Length and Output length will be 15.

The Field labels should all read ‘Title’.

Activate all of these and go back to view the new, fifth field in the Table.

The final field which will be created for this table is for Date of Birth. In the Field box type ‘DOB’ and create the Data element ‘ZDOB’ using the steps from the previous section and this information:

The Data element short text should read ‘Date of Birth Data Element’ and the domain should be named ‘ZDOB’.

The Domain Short text should be ‘Date of Birth’ and the Data type is, this time, ‘DATS’, after which an information box will appear to confirm this. Click the green tick to continue:

image

image

For the DATS data type, the Length and Output lengths are set automatically at 8 and 10 (the Output length is longer as it will automatically output dividers between the day, month and year parts of the date).

The Field labels should all read ‘Date of Birth’, except the ‘Short’ label where this will not fit, so just type ‘DOB’ here. Activate the Domain and Data element, and return to the table.

image

Technical Settings

Once this has been saved, the next step is to move on to maintaining the technical settings of the Table. Before creating the final Database table, SAP will need some more information about the table being created.

Select ‘Technical settings’ via the toolbar above the table, through the ‘Go to’ menu, or with the shortcut CTRL+SHIFT+F9.

Here, it is important to tell the system what Data class is to be used, so select the drop down button. There are five different options, with accompanying descriptions. For this table, select the first, labelled ‘APPL0’, and double-click it:

image

image

For the ‘Size category’ field, again click the drop-down button. Here, you have to make an estimate as to the amount of data records which will be held within the table so that the system has some idea of how to create the tables in the underlying database. In this instance, it will be a relatively small amount of information, so select the first size category, labelled 0:

image

Below this are the Buffering options. Here, ‘Buffering not allowed’ should be selected:

image

This prevents the table contents from being loaded into memory for reading, stopping the table from being read in advance of the selection of the records in the program. You may, correctly, point out that it may be advantageous to hold the table in the memory for speed efficiency, but in this example, this is not necessary. If speed was an issue in a development, buffering would then be switched on, ensuring the data is read into memory. In the case of large tables which are accessed regularly but updated infrequently, this is the option to choose.

Nothing else on the ‘Maintain Technical Settings’ screen needs to be filled at this point, so click Save and then go back to the table itself. If all of this is successful, then the table should now be in a position to be activated and the entry of records can begin. Click the Activate icon to activate the table and check the status bar, which should again read ‘Object Activated’.

 

Entering Records into a Table

Now that the table has been created, data can be entered. To do this, enter the ‘Utilities’ menu, scroll to ‘Table contents’, and then ‘Create Entries’:

image

A Data-entry screen will appear which has automatically been generated from the table created. The field names correspond here to the technical names given when we created them. To change these to the Field labels which we set up, enter the ‘Settings’ menu and select ‘User Parameters’. This facility allows you to tailor how tables look for your own specific user ID. Select the ‘Field label’ radio button and click ‘Continue’:

image

The Field labels created will now appear as they were defined when creating the table:

image

The Employee Number field is limited to 8 characters, and the data type was set to NUMC, so only numerical characters can be entered. Create a record with the following data:

· Employee Number: ‘10000001’

· Surname: ‘Brown’

· Forename: ‘Stephen’

· Title: ‘Mr’

· Date of Birth: ‘16.02.1980’:

image

Press Enter and the system will automatically put the names in upper case, and validate each field to ensure the correct values were entered:

image

Click Save and the status bar should state ‘Database record successfully created’. Next, click the ‘Reset’ button above the data entry fields to clear the fields for the next entry.

Create another record with the following data:

· Employee Number ‘10000002’

· Surname ‘Jones’

· Forename ‘Amy’

· Title ‘Mrs’

· Date of Birth ‘181169’.

Note that this time the Date of Birth has been filled in without the appropriate dividers. When Enter is pressed, the system automatically validates all fields, correcting the Date of Birth field to the correct formatting itself:

image

image

 

Save, Reset, and then further records can be entered following the same steps:

image

 

Note that if dates are entered in the wrong format, an error message will appear in the status bar:

Viewing the Data in a Table

Now that data has been entered into the table, the final few steps will allow this data to be viewed.

Having entered several data records in the manner discussed previously, click the Back key to return to the ‘Dictionary: Display Table’ screen. To view the table created with the data entered, from the ‘Utilities’ menu, select ‘Table contents’ and then ‘Display’:

image

A selection screen will then appear, allowing you to enter or choose filter values for the fields you created. The selection screen is very useful when you have lots of data in your table. In this case, though, only five records have been entered, so this is unnecessary. However, for example if you were to only want to focus on a single employee number, or a small range, these figures can be selected from this screen:

image

To view all of the records, do not enter any data here. Just click the ‘Execute’ button, which is displayed in the top left corner of the image above, or use the shortcut F8. You will now see a screen showing the data records you entered in the previous section:

image

If further fields were to exist, the screen would scroll further to the right, meaning not all fields could be displayed simultaneously due to field size properties.

If you want to see all of the data for one record, double-click on the record and this will be shown. Alternatively, several records can be scrolled through by selecting the desired records via the check-boxes to the left of the ‘Client’ column and then clicking the ‘Choose’ icon on the toolbar: image

These can then be individually viewed and scrolled through with the ‘Next entry’ button: image

image

 

To return to the full table then, simply click the Back button, or press F3.

Experiment with the table created, using the toolbar’s range of options to filter and sort the information in a number of ways:

image

For example, to organise alphabetically by forename, click to select the ‘Forename’ field, and then click the ‘Sort ascending’ button: image

There are a number of things which can be achieved in this table view, and it can be a useful tool for checking the data within an SAP system without going through the transaction screens themselves.

Categories

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

2 Comments
  1. Ibrahim

    Hello Peter,
    Could you explain please what ist the difference between pool and cluster tables.
    thank you.