TABLES, DATA ELEMENT & DOMAIN


Tables
Tables can be defined independently of the database in the ABAP Dictionary. The fields of the
table are defined with their (database-independent) data types and lengths.

           When the table is activated, a physical table definition is created in the database for the table
definition stored in the ABAP Dictionary. The table definition is translated from the ABAP
Dictionary to a definition of the particular database.
Table Fields
You must define the following for a table field in the ABAP Dictionary:
1 Field name: The field name can have a maximum of 16 places and may contain letters,
digits and underscores. The field name must begin with a letter.
2 Key flag: determines whether the field should belong to the table key.
3 Field type: data type of the field in the ABAP Dictionary.
4 Field length: number of valid places in the field.
5 Decimal places: number of places after the decimal point, specifying numeric data
types.
6 Short text: short text describing the meaning of the field.

Technical requirement to create the table: -
1. Name of the table starts with ‘y’ or ‘z’ because a x reserved for SAP.
2. Provide list of fields, data types and lengths.
3. Provide the delivery class.
4. Provide the Technical settings.

Delivery class: - It defines the owner of the table as well as it controls the transport of the data from one table to another table.

Technical setting is nothing but combination of DATA CLASS & SIZE OF THE CATEGORY.

Data class: - Data class defines the physical area of the database in where our table is logically stored. Some of the important data classes are:-

APPL 0:- Master data class
APPL 1:-Transaction data class
APPL 2:- Organization data class 

Master data class: - Master data class is the data, which data we can access frequently as well as update rarely.
Ex: - customer master data, employee master data

Transaction data: - It’s the data, which data we can access frequently as well as updated frequently.
Ex: - Sales order data, purchase order data

Technical data is dependent data. 

Organizational data: - It’s the data, which data we can access frequently & updated rarely. Organizational data is created at the time system configures.
Ex: - Company data, branches data

Size category: - The size category defines the expected space required for the table in the database. You can choose a size category from 0 to 4 for your table. Each category is assigned a certain fixed
memory size in the database, which depends on the database system used.

Steps to create the table: -

1. In the initial screen of the ABAP Dictionary, select object class Database table, enter the
table name and choose Create.
The maintenance screen for the table is displayed.
2. Enter an explanatory short text in the field Short text.
You can for example find the table at a later time using this short text.
3. On the Attributes tab page, enter the delivery class of the table.
4. On the Fields tab page, enter the table fields. Perform the following steps for each table field:
Enter a name for the table field in the column Fields.
Select the Key column if the field should be part of the table key.
Enter the name of a data element in field Field type.
5. Maintain the technical settings for the table. The corresponding maintenance
screen is displayed with
 Goto _ Technical settings.
6. Save the table.
A dialog box appears in which you have to assign the table a development class.
7. ACTIVATE your table Ctrl + F3.

As Example below
Field       Key       Data type      Length       Short Description
Eid                        CHAR            10                Employee ID
Ename                  CHAR             25                Name of the employee

Eadd                     CHAR             35                Address of employee 


Steps to provide the data to the table directly: -
In the menu bar click on utilities - table contents - provide the data. Click on save. Repeat same steps for all employees.

Steps to display the data from table: -
In the menu bar click on utilities - Table contents display. Click on execute.


Data Elements & Domain
Data element is the collection of domain with short description or
A data element describes either an elementary type or a reference type.

An elementary type is defined by the built-in data type, length and possibly the number of
decimal places. These type attributes can either be defined directly in the data element or copied
from a domain.

Domain
Domain is the collection of data types & lengths.
A domain is assigned to a data element. All table fields or
structure components that use this data element then have the value range defined by the
domain. The relationship between the field or component and the domain is thus defined by the
data element of the field or component.

Steps to create the domain: -

1. Select object type Domains in the initial screen of the ABAP Dictionary, enter the name of the
domain and choose Create.
The maintenance screen for domains appears.
2. Enter an explanatory short text in the field Short text.
You can for example find the domain at a later time using this short text.
3. On the Data type tab page, choose the data type, number of places (valid
positions without editing characters such as comma or period) and number of decimal places
(only needed for data types DEC, FLTP, QUAN and CURR).
Note that some data types have a fixed length. For example, the data type CLNT (client)
always has 3 places. If you enter an invalid number of places for such a data type, the
system corrects this automatically after issuing a warning.
4. If only certain input values are valid for the domain, you can enter them in the Value range
tab page as fixed values.
You can also define a value table as proposed value for foreign key checks
on this tab page.
5. Save the domain.
You are asked to assign the domain a development class.
6. Choose ACTIVATE or Ctrl + F3.


Steps to create the data element: - 

1. Select the radio button data type enter the data element name and choose Create.
2. Select the data element and enter.
The maintenance screen for data elements appears.
3. Enter an explanatory short text in the field Short text.
The short text appears as title in the F1 help for all the screen fields referring to this data
element.
4. On the Definition tab page, define the data type, number of places and
possibly the number of decimal places of the data element. You can define these
attributes by specifying a domain or by direct type entry.
If the data element should have the type attributes of a domain, you only have to select
Domain and enter the domain name in the corresponding field. You can also define a
new domain and create it by navigating to the domain maintenance screen by double-clicking
(see Creating Domains).
If you want to enter the type attributes directly, select Direct type entry. Entries are now
possible in the fields Data type, Number of places and Decimal places.
If the data element should be a reference to a class or an interface, select Reference
type. Enter the name of the class or interface in the Reference field. You can also enter
OBJECT or DATA if the data element should implement a generic reference to objects or
data objects.
5. On the Field label tab page you can (optionally) maintain text information
(short, medium, and long field labels and the title) for the data element.
You can use this text information in input templates to represent fields that refer to this
data element.
6. Save the data element.
You are asked to assign the data element a development class.
7. Choose ACTIVATE or Ctrl + F3.

No comments:

Post a Comment