SAP ABAP Data Elements
Data elements are the object of the data dictionary in ABAP, which are used to define the particular fields of the table. These are used to specify the types of the columns in the databases. The data elements are of unstructured types that are used to provide the semantic information of the database table. It can be referenced as TYPE in the ABAP programs.
The data elements are reusable in the database table. The following diagram shows the relationship between the table, data element, and domain:
A data element consists of the description, data type, and length. In ABAP, there are two types of data elements:
- Elementary Type:
Elementary type refers to the data type that contains semantic attributes, such as data type, length, and the number of decimal places. These data types can be assigned in two ways to a data element:
- By assigning a predefined ABAP Dictionary type: A data element can be assigned using the predefined types such as CHAR, NUMC, etc.
- By assigning a domain: It specifies that a data element inherits the properties or technical attributes of the predefined domain. A domain can be used with multiple numbers of data elements.
- Reference Type:
The reference type describes the single field that has references for global classes and interfaces with the multiple numbers of data elements.
Note: After creating a data element, we can provide the documentation or text information to it. This documentation appears as the online aid to the end-user when a user clicks the F1 button, and if no documentation is provided, then only the short description will be displayed.
Field Labels in Data Element
The field labels are used to provide the text information to the data element. We can provide the meaning of a table field or structure component, and this information is automatically available to all the screens that contain that particular data element.
Creating a Data Element in ABAP
Below are the steps for creating the ABAP data element in SAP:
- Go to the command field and enter the T-Code SE11, which will open the data dictionary initial screen.
- Select the Data Type object from the available options or click on the radio button in front of the Data Type.
- Enter the name for the data type, here we can enter any name, but it must start with the letter z, such as "ZCUSTN."
- After entering the name, click on the Create button. It will open the new pop window, where we need to click on the Data element
- After selecting the Data element option, a new window will open, where we need to enter the details in order to create it. The snap of the new window is shown below:
Here, we need to enter the Short description of the data element. It can be a simple description of the data element.
- As we can see in the above image, there are various tabs given, but first, we will enter the fields in the Data Type In this tab, there are two options given: Elementary Type and Reference Type, which we have already discussed above.
- For this example, we will choose the Elementary Type option, and if we have other data element so we can give the reference of that in the Reference Type option.
- Next, we will click on the predefined type, as to select the data types that are already defined in the SAP system. Here, we will enter the CHAR in the data type field and press the dropdown key. All the available options will be shown in the new window. Consider the below image:
- Next, we will enter the other options, such as Length and Decimal Places. Consider the below image:
- Next, move to the next tab, which is Field Label. Here we need to enter the Field Labels, and corresponding lengths will automatically be filled. Consider the below image:
- Now click on the Save button in the menu bar, and our data element will be saved. When we click the save button, a new pop window will appear, where to save it as the local object. Consider the below image:
- Now we need to activate it, so for this, we need to click on the activate(ctrl+F3) option from the menu bar, which will open a new window to show all the local objects created till now. Consider the below image:
Hence our data element is successfully created, which we can use further in the database tables.