Creating a table in SAP ABAP

0

Here are the steps required to create a table in SAP ABAP.

Step 1: Go to transaction SE11 and input a table name.

Step 2: Involves setting up attributes for the table

In the Dictionary menu: Select the Database table option and enter the name of the table to be created (for our example, use ZWAL1). Click on the Create option. It will take you to the screen shown below
Short text: Short description of the table. (Test Table)
Delivery Class: Indicates who is responsible for maintaining the table, whether it is a parameterization table, etc. (We shall specify type A, = Application).
Table maintenance allowed: Enable/disable modifications to the table while its contents are being viewed. (If this is not marked, the table registers cannot be modified during a display transaction). (Mark this with an X)

Step 3: Enter the fields/column names for the table

Fields: The name of the field.
Key: Indicates whether the field is part of the primary key for the table.
A field or group of fields form a key for a table if they identify one unique register in the table. Every table must have a primary key.
Field type: The name of the data element that describes the field. (*)
Data & Length: The type and length of the data. (*)
Check table: A ‘*’ will appear in this table when the data element introduced refers to a domain which has a table of permitted values or when it is associated with a foreign key (See later).
Short text: Description of the field. (*)
(*) It is possible to define table fields that are not linked to data elements. We can define their type, length, and description directly. To create these fields use the Data Element/Direct type button. To return to using data elements, click on this button a second time. (Although this possibility exists, it is not recommended).
On the Currency/quant. fields tab.
Reference table & Ref. Field:
Only monetary fields (CURR) and quantity fields (QUAN) need to be referenced to other fields in the dictionary. Both the table and the field must be specified for these reference fields. The reference fields must be of type Currency Key (CUKY) for currency fields and type UNIT for quantity fields. This means that when the data is displayed its format will include the value in the field to which it is referenced.

Step 4: Maintain Technical Settings

Once all the entries all completed, press the “Technical Settings” button on the application toolbar or select Goto à Technical Settings from the menu.
The Data Dictionary will prompt to save the table and the provide an development class (and request number, if applicable). The development class and request are exactly the same as explained with relation to the ABAP editor and programs.
Data Class: The data class is used to provide a logical definition of the physical location in the database where the table will be saved. The physical location of the table will be determined by the use to which it will be put, e.g., mainly for updating, or for consulting the data. For example, tables that contain master data will not be updated often but will be consulted frequently(For our example, use APPL0)
Size category: This indicates approximately the number of registers that the table will hold. (Select size 3)
When finished, click on the check button  (Ctrl + F2), the save button  (F11) and then activate  (Ctrl + F3). Return to the initial screen by clicking on the  button (F3), then check   (Ctrl + F2) and finally activate the table  (Ctrl + F3).

Steps to Create an Index for the Tables

An index involves ordering the registers in a table according to the values in one or more of its fields. Consequently, defining an index consists in indicating the fields used for it. Check  (Ctrl + F2), save  and activate   (Ctrl + F3) the table before creating an index. If no indexes have been defined for the table, a popup dialog box will appear asking you if you want to create an index. When you click the “Yes” button in the popup, a window will appear asking for an identifier for the index. (We shall use Z01).
This takes us to the screen shown above where we introduce the fields that compose the index.
Short text: Description of the index. (Index by Company code.)
Unique Index / Non-unique: If we mark the unique index option, we shall create a unique index, i.e., no more than one entry is allowed in the table having the same values for the index fields.
Field name: The fields that form the index. We can type in the names of the fields or select them by clicking on the  button. (In our case, select the MANDT and BUKRS fields).
When the index fields have been defined, save the definition  (F11), check it  (Ctrl + F2) and activate it  (Ctrl + F3).

 

Understanding ABAP Data Dictionaries

Data definitions also called as metadata are managed and created in the ABAP Dictionary. It allows maintaining a huge volume of data without data redundancy. The ABAP Dictionary describes the logical structure of all the dictionary objects used in Application development. It also provides you with the flexibility of accessing the data on the screen and allows you to maintain manage and create without any programmers intervention.

data-dictionary

The data dictionaries can be categorized into the following.

  • Database table
  • Views
  • Data types
  • Domain
  • Search Help
  • Lock Objects

Database tables:

Tables can be defined independently in the database in the ABAP Dictionary. The fields of the table are defined together with their data types and lengths.
A table definition has the following components:
Table fields
Foreign keys
Technical settings
Indexes

Views

A View is a logical representation of tables. This is just a way of organizing the data by combining more than one table by comparing the common fields which are called a join.

Data types:

It’s an attribute to tell as to what kind of data is it going to hold like numbers, characters, integers etc. A data type can be an elementary data type or a reference data type.

Domain:

A domain contains the technical attributes of the data type. Like the length, the actual data type ( like char, integer), The output characteristics and the value range which tells us as to what kind of data can be accepted as a valid input.

A Domain describes the value range of a field and is assigned to a data element. All fields that use the data element will have the value range of the domain. The value range is defined by specifying the type and length of the domain. Fixed value intervals can also be defined for the domain and are automatically used as check values on screen entries.

Data Element:

A Data element describes the business meaning of a domain. Information about the meaning of a field such as its label is assigned to the data element and is accessible from all screen fields that use the data element.

Search Help:

A search help is simply what you see in SAP when you key in the F4 button. It provides you with the list/range of values. A search help can be categorized into three types:

  1. Elementary Search help
  2. Collective Search Help
  3. Append Search Help

Lock Object:

A lock object is the virtual link of a sap table which is used to synchronize the data when more than one user attempts to write to the Database table. These lock objects are called and handled inside the program based on the requirement.

What is a Logical Database?

A Logical Database is a special data-retrieval program delivered by SAP, with its own dynamic Selection Screens. You need to code only the processing logic (GET, CHECK, etc., statements). The logical database consists of a reading program in which the structure of the local database is reproduced with a selection screen.

Advantages:

  • Check functions to validate that user input is complete and correct.
  • Meaningful data selection.
  • Central authorization checks for database accesses.
  • Excellent read access performance while retaining the hierarchical data view determined by the application logic.

Table Buffering

SAP stores the content in tables (Every data except start and stop logs are stored in the DATABASE, no prog/ no data is available in the file system)

There are four different types of table buffering options as specified by SAP.  SAP stores the content in tables and buffering defines how the data is accessed.
1. FULL Buffering
2. Generic Buffering
3. Single Record Buffering
4. No Buffering

Table Buffering Options

Full Buffering:

The tables which are frequently used and rarely modified are eligible for buffering. (Also which are small in size)
Eg: T000 have all the clients and required to create a client copy. (This is fully buffered)

Generic Buffering:

Tables which are relatively large, frequently used, rarely modified using a set of keys (Fields)
Eg: USR02; T001 Company info

Single Record Buffering:

The tables which are large in size, frequently used and rarely modified are buffered using a primary key.

No Buffering:

The tables which are large frequently used, and frequently modified are not eligible for buffering. for example: VBAK (SALES), EKKO (PURCHASE)

Keep learning abap tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: