Creating a table in SAP ABAP

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).

Keep learning abap tutorials.

Comments