Fields: - Fields are nothing but columns.
Domain: - Domain consists of the technical characteristics of a field such as field length and data type.
Data Element: - A table is composed of fields to create a field you need a data element. The data element contains the field labels and documentation (F1 help) for the field. It contains the semantic characteristics for the field and it works like a interface between Field and Domain.
Domain and data elements are reusable. A domain can be used in more than one data element and data elements can be used in more than one field and in more than one table.
Delivery Class: - Delivery class comes under attributes. The value in the delivery class field identifies the “OWNER” of the data in this table. The owner is responsible for maintaining the table contents. In customer tables we always enter ‘A’ Here which indicates that the table contains application data owned by the customer only.
Ex: - A –Application table (Master and Transaction data).
Data Class: It comes under technical settings. It defines the physical address of the database in which the table uses creates and logically stored or it’s a physical place where the actual data is to be stored.
Categories of data class: APPLO – Master data, transparent tables.
Size Category: It also comes under technical settings. It defines the probable space requirement for a table in the database.
Categories:
0:- 0 to 30,000.
1:- 30,000 to 1, 20,000.
2:- 1, 20,000 to 4, 90,000.
3:- 4, 90,000 to 1,9,00,000
Table Maintenance allowed: Its also comes under attributes. By enabling table maintenance allowed user can be able to enter the data, change and display manually.
Approaches for creating tables:- There are two approaches you can use when creating tables.
Top-down-approach: In top down approach first we create the field then data element then domain.
Bottom-up-approach: In the bottom-up-approach first we create the domain, then data element and then field.
Direct Method: Do not have data element or domain.
Primary key: Primary key is a field or combination of fields that uniquely identify a row in the database table.
Foreign Key: Foreign Key is a key which is a primary key of another table.
Naming convention for database tables:
1. The tables we are creating are generally called as Z-tables or customizing tables.
2. The name of a table should be started with Y or Z that a user creates.
3. SAP has used A to X for its own use, Z or Y in the beginning means that the program or table is user defined.
So it avoids the redundancy between predefined and customizing tables.
Steps to Create Database Tables
To create tables, Go to transaction SE11 and select database table radio button: Give Database table name for example ZKA_EMP. All user-created tables must start with Y or Z.
Eg: ZKA_EMP. Then click on the CREATE button.
Eg: ZKA_EMP. Then click on the CREATE button and you will get the below screen.
In the Attributes (tab) screen,
Enter the short description as EMPLOYEE DETAILS.
Delivery class: Under multiple entries, select A-Application table (Master and transaction data).
Check the box for the Table maintenance allowed.
Now select the fields (tab), Field name EMPNO and field type ZKA_EMPNO and check the primary key check box. Field name EMPNO and field type ZKA_EMPNO and check the primary key check box and click on save button.
When you click on save button you will get one pop-up box as shown below.
Click on the LOCAL OBJECT button.
Now double click on the field type and u will get CREATE DATA ELEMENT SCREEN, click on YES.
Enter the short text EMPLOYEE NO and the domain name ZKA_EMPNO.
Now double click on the domain name ZKA_EMPNO and enter the following details.
Short text : EMPLOYEE NO.
Data Type : NUMC(Click on the RIS button and select NUMC from that)
No. of characters: As per the requirement. ( Eg. 10 ).
Note: If the field is employee name then u need to select the data type to be CHAR and required no of characters.
Now SAVE (CTRL + S) ,
Click on the CHECK button or (CTRL + F2), and should get NO INCONSISTENSIES FOUND in the status bar.
Then click on the ACTIVATE button (CTRL + F3).
Now click on the BACK button and then,
SAVE(CTRL+S), CHECK(CTRL+F2) & ACTIVATE(CTRL+F3).
Click the BACK button and u will be in the main dictionary screen.
Now click on the NEW ROWS button to enter as many fields u would prefer.
Once all the fields with the data element and the domain is set up, the table need to be activated as a whole. To activate the table the technical settings should be saved.
Before u activate, u need to set up the technical settings by clicking on the TECHNICAL SETTINGS button.
Where the data class is APPL0 (Master data, Transparent tables).
Size category is 0(0-30000).
SAVE or (CTRL+S) the technical settings.
Click BACK to get to the main screen and SAVE, CHECK AND ACTIVATE the table.
In order to give the input values(new entries), click on Utilities->Table contents->Create Entries
Enter and SAVE the values and click RESET to give the new values.
Once the values are saved, click the BACK button and click on the CONTENTS, then the EXECUTE button to see the output.
So when we click on the EXECUTE button, we get the output in the table format.
Thus the table is created.
Database Views
A view is a logical window to a table or more than one table, the data from a view is not actually physically stored instead being derived from one or more tables. A view can be used to summarize data which is distributed among several tables. It does not contain memory space. During runtime it contains memory after the execution the memory will be released
Types of Views 1. Projection View 2. Database View 3. Maintenance View 4. Help View
Projection View: This view is used to display data’s from only one table i.e. view can draw upon only one table, this means that only the data that actually required is exchanged when the database is accessed. Selection conditions cannot be specified for projection view.
Database View: This view is used to display data’s from more than one table.
Database views are implement an inner join, that is, only records of the primary table for which the corresponding records of the secondary tables also exist are fetched. In database views, the join conditions can be formulated using equality relationships between any base fields. Inconsistencies between primary and secondary table could, therefore, lead to reduced selection set
Maintenance View: This view is used to for data manipulation like insert, update, delete, modify etc. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is the data is entered via the view and then distributed to the underlying tables by the system.
Help View: This view is used to displaying possible values of field from one or more than one table i.e. used to output additional information when the online help system is called or when F4 is pressed on the field.