4.table creation

31
TABLE CREATION In Order to create tables go to the T-Code SE11. Database table Tables can be defined independently of the database in the ABAP Dictionary. The fields of the table are defined together with their (database-independent) data types and lengths. A table definition in the ABAP Dictionary has the following components: Table fields: The field names and the data types of the fields contained in the table are defined here. Foreign keys: The foreign keys define the relationships between this table and other tables. Technical settings: The technical settings define how the table is created on the database.

Upload: solankikavita

Post on 08-Nov-2014

21 views

Category:

Documents


4 download

DESCRIPTION

4.Table Creation

TRANSCRIPT

Page 1: 4.Table Creation

TABLE CREATION

In Order to create tables go to the T-Code SE11.

Database table

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

A table definition in the ABAP Dictionary has the following components:

Table fields: The field names and the data types of the fields contained in the table are defined here.

Foreign keys: The foreign keys define the relationships between this table and other tables.

Technical settings: The technical settings define how the table is created on the database.

Indexes: Indexes can be defined for the table to speed up data selection from the table.

There are three categories of database tables in the ABAP Dictionary.

Page 2: 4.Table Creation

Transparent table

There is a physical table on the database for each transparent table. The names of the physical tables and the logical table definition in the ABAP/4 Dictionary correspond.

All business data and application data are stored in transparent tables.

A physical table definition is created in the database for the table definition stored in the ABAP Dictionary for transparent tables when the table is activated. The table definition is translated from the ABAP Dictionary to a definition of the particular database.

On the other hand, pooled tables and cluster tables are not created in the database. The data of these tables is stored in the corresponding table pool or table cluster. It is not necessary to create indexes and technical settings for pooled and cluster tables.

Pooled table

Pooled tables can be used to store control data (e.g. screen sequences, program parameters or temporary data). Several pooled tables can be combined to form a table pool. The table pool corresponds to a physical table on the database in which all the records of the allocated pooled tables are stored.

Page 3: 4.Table Creation

Cluster table

Cluster tables contain continuous text, for example, documentation. Several cluster tables can be combined to form a table cluster. Several logical lines of different tables are combined to form a physical record in this table type. This permits object-by-object storage or object-by-object access. In order to combine tables in clusters, at least parts of the keys must agree. Several cluster tables are stored in one corresponding table on the database.

Page 4: 4.Table Creation

STEPS TO CREATE A TABLES:

1) For creating a table it always starts with Z or Y.

2) Give Short Description, Delivery Class and Data Browser/Table View Maintance.

Delivery Class contains

Page 5: 4.Table Creation

Delivery class

The delivery class controls the transport of table data when installing or upgrading, in a client copy and when transporting between customer systems. The delivery class is also used in the extended table maintenance.

There are the following delivery classes:

A: Application table (master and transaction data).

C: the customer maintains Customer table, data only.

L: Table for storing temporary data.

G: Customer table, SAP may insert new data records, but may not overwrite or delete existing data records. The customer namespace must be defined in table TRESC. (Use Report RDDKOR54 here).

E: System table with its own namespaces for customer entries. The customer namespace must be defined in table TRESC. (Use Report RDDKOR54 here.)

S: System table, data changes have the same status as program changes.

Page 6: 4.Table Creation

W: System table (e.g. table of the development environment) whose data is transported with its own transport objects (e.g. R3TR PROG, R3TR TABL, etc.).

Behavior during client copy

Only the data of client-specific tables is copied.

Classes C, G, E, and S: The data records of the table are copied to the target client.

Classes W, L: The data records of the table are not copied to the target client.

Class A: Data records are only copied to the target client if explicitly requested (parameter option). Normally it does not make sense to transport such data, but is supported to permit you to copy an entire client environment.

Behavior during installation, upgrade and language import

The behavior differs here for client-specific and cross-client tables.

Client-specific tables

Classes A and C: Data is only imported into client 000. Existing data records are overwritten.

Classes E, S and W: Data is imported into all clients. Existing data records are overwritten.

Class G: Existing data records are overwritten in client 000. In all other clients, new data records are inserted, but existing data records are not overwritten.

Class L: No data is imported.

Cross-client tables

Classes A, L and C: No data is imported.

Classes E, S, and W: Data is imported. Existing data records with the same key are overwritten.

Classe G: Data records that do not exist are inserted, but existing data records are not overwritten.

Page 7: 4.Table Creation

Behavior during transport between customer systems

Data records of tables of delivery class L are not imported into the target system. Data records of tables of delivery classes A, C, E, G, S and W are imported into the target system (this is done for the target client specified in the transport for client-specific tables).

Use of the delivery class in the extended table maintenance

The delivery class is also analyzed in the extended table maintenance (SM30). The maintenance interface generated for a table makes the following checks:

You cannot transport the entered data with the transport link of the generated maintenance interface for tables of delivery classes W and L.

When you enter data, there is a check if this data violates the namespace defined for the table in table TRESC. If the data violates the namespace, the input is rejected.

Flag if Maintenance with Standard Tools is allowed

Definition

Page 8: 4.Table Creation

This indicator specifies whether it is possible to display/maintain a table/view using the maintenance tools Data Browser (transaction SE16) and table view maintenance (transactions SM30 and SM31).

The indicator can be set for database views, projection views, maintenance views, maintenance view variants, and tables (called 'Table/ View' below) using transaction SE11.

Note: The indicator is not available for help views since they are not relevant to SE54 and are used for search functions.

Usage

The indicator can have the following values:

Display/maintenance not allowed

The usage of standard table maintenance tools is not allowed.o Maintenance and display of this table/view is not possible

in transaction SE16.

o Transaction SE54 does not allow the generation of a maintenance dialog, which means automatically that calling transactions SM30/SM34 for this table/view is no longer possible.

Display/maintenance allowed to limited extent

Usage of standard table maintenance tools is allowed to a limited extent:

o Transaction SE16 allows the display function for this table/view, but no maintenance.

o Generation of a maintenance dialog for this table/view is possible through transaction SE54.

o Transaction SM30 does not allow maintenance and display functions for this table/view.

Note: The generated dialog can be included in view clusters (data maintenance through transaction SM34) or called within a program through the function module View_Maintenance_Call.

Display/maintenance allowed

Page 9: 4.Table Creation

The usage of standard table maintenance tools is allowed:o Transaction SE16 allows the maintenance and display

functions for this table/view.

Note: If an SM30 maintenance dialog exists, this is called.

o Transaction SE54 allows the generation of a maintenance dialog for this table/view.

o Transaction SM30 allows the display and maintenance functions for this table/view.

Note: The generated dialog can be included in view clusters (data maintenance through transaction SM34) or called through the function module View_Maintenance_Call in the same way as the transaction call SM30.

CommentOnly the last two options are offered for maintenance views and maintenance view variants. 'Display/maintenance not allowed' does not apply since maintenance views and maintenance view variants serve exclusively to generate a user interface. This is rejected in the option 'Display/maintenance not allowed'.

When the standard maintenance tools are used, the system checks the corresponding authorizations of the user

3) Click on Fields Tab and enter fields.

Page 10: 4.Table Creation

4) Click on save and click on Technical settings

It contains Data class and size category.

Page 11: 4.Table Creation

Data class in technical settings

The data class defines the physical area of the database (for ORACLE the TABLESPACE) in which your table is logically stored. If you choose a data class correctly, your table will automatically be assigned to the correct area when it is created on the database.

The most important data classes are (other than the system data):

APPL0    Master data

APPL1    Transaction data

APPL2    Organizational and customizing data

Master data is data, which is frequently read, but rarely updated. Transaction data is data, which is frequently updated. Organizational und customizing data is data, which is defined when the system is initialized and then rarely changed.

There are two more data classes available, USR and USR1. These are reserved for user developments. The tables assigned to these data classes are stored in a table space for user developments.

Note: The data class only has an effect on table storage for the database systems ORACLE and INFORMIX.

Size category

Page 12: 4.Table Creation

The size category determines the probable space requirement for a table in the database.

You can select the categories 0 to 4 for your table. Each category is assigned a specific fixed storage area value in the database. When you create a table, initial space is saved for it in the database. If more space is required later as a result of data that has been entered, the storage space is increased in accordance with the category selected.

Press F4 on the field Size category to see the number of data records that can be maintained for the individual categories of your table without complications ensuing. These complications could be for example a reorganization becoming necessary because the maximum space to be reserved for the table was exceeded due to the maintained size category.

5) Then Click on Save and back

Page 13: 4.Table Creation

6) Then Click on Save, Check and Active

7) If we want to enter the values into this table go to utilities -> Table Content -> Create Entries.

Page 14: 4.Table Creation

8) Give entries here and then save. If you are not save then those are saved in the database. If you want give 2nd entry save and then click on Reset tab.

Page 15: 4.Table Creation

9) If we want to see the data in that table which we are created then

Or click on Contents tab on menu bar.

Page 16: 4.Table Creation

Then click on Execute Button on menu bar, it displays all the records, which you are created.

If we want to create more entries click on create tab.

Page 17: 4.Table Creation

CREATING FOEIGN KEY RELATIONSHIP

1) Create two tables as above, some conditions are

a) But there must be a common field in those two tables.

b) And also there must be Data Element.

See the creation of data element

Data element

A data element (elementary type) describes the technical attributes and the contents of a table or structure field. Fields with the same contents refer to the same data element.

A data element is a type and can be referenced in ABAP programs with TYPE. For example, variables taking on the type attributes of a data element can be defined in an ABAP program.

The type attributes of a data element (built-in data type in the ABAP Dictionary, field length and possibly decimal places) are copied from the domain of the data element.

Write data element name and double click on that data element. Then it ask like this

Page 18: 4.Table Creation

Click on YES, SAVE and Continue

Page 19: 4.Table Creation
Page 20: 4.Table Creation

It asks Data element not available create the data element? Click on YES.

Give Short Description and Domain name. And double click on Domain

Object class domains

A domain (technical domain) describes the value range and formal attributes of a field.

The domain is used to define the value range of a field with formal specifications, such as format and length, by defining fixed values or a value table.

Page 21: 4.Table Creation

Note

Different fields, which are technically the same, can be combined to form a domain. Fields, which is linked by a reference to the same domain, cannot be changed independently of each other.

Page 22: 4.Table Creation

Give Short description, Data type and No. Of Char.

In Abap there are 24 Data type. 90% of the field contains data type as CHAR.

Page 23: 4.Table Creation

Then Click on save, check and Activate

Page 24: 4.Table Creation
Page 25: 4.Table Creation
Page 26: 4.Table Creation

And come back. Domain values automatically stored. Ok in this screen also click on save, check and activate. And come back

Page 27: 4.Table Creation

Create the same field with same data element in the 2nd table also. If we want to give foreign key relationship then click on foreign key in 2nd

table by placing cursor on common field.

Give Check table name (i.e. 1st table name) and click on Generate Proposal.

Page 28: 4.Table Creation

Then click on Copy it generates foreign key relationship. In same way give technical settings and activate again.

While creating the entries it shows the possible entries to the common field (those can created already while creating the 1st table).

Give values like this save and come back. Now the output is like this

Page 29: 4.Table Creation