Creating Tables in SAP ABAP

SAP ABAP Tables

Hello again and welcome to the next tutorial where we will learn how to create tables in SAP ABAP. Here we will also incorporate the concept of data elements from our previous tutorial.

Creating our first table

Let’s start with going to the TCODE SE11 again.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Make sure that you are on the Database Table radio button.

Let’s say we now create a table called ‘Customer Revenue’ with technical name ZCUST_REV.

Enter the name and click on the create button.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

You will reach the below screen where you need to fill in a description for this table and a delivery class. All the custom tables we create will be to hold master and transaction data and those are class ‘A’ objects. Fill in these values here

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

It should look like the below illustration

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES



Now switch to the Fields tab. This is the area where SAP expects us to fill in the field names, their data types or data elements and also specify if this field is a key for the table or not. A key field or a group of key fields uniquely identify a row of information in the table. It means that for if two fields are marked as key, for a unique value combination of those two fields, there should not be a duplicate rows in the table.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Let’s add the first field – Customer Number of length 6. As shown below, I give it a technical name ZCUST_NO but the Data Type field is greyed out. The only active field is Data Element which I don’t have in this case. To use an internal datatype, click on the “Predefined Type” button as marked below.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

On clicking this, we see that the data element column gets grayed out and the Datatype, Length, Decimal places and Short Description field have become active.

Here we enter the datatype NUMC and not CHAR because we assume that he customer number is a character string consisting only of numbers in this example. The length and description are also as specified.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Let’s add another field – Quantity Sold with technical name ZQUAN_SOLD. These are key figure values and hence have special data types available. Let’s do a F4 on the data type field to search for the right data type. As seen below, there is a data type by the name of QUAN specifically for Quantities.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Here we select QUAN and add a short description for it.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES



Now, if you sell something to someone, it must have a unit. A vendor can sell 6 boxes of something or 8 pieces or 100 Kgs but to say  X sold 6 to Y does not make sense. A value needs a unit to go with it. For example X sold Y Liters of something. Therefore we need a unit field. The data type for this field is also provided by SAP and is called UNIT. The usage is illustrated in the below screenshot.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

For the final field, we will use the data element “Recurring Customer First Name” that we created in the previous tutorial. To use a Data Element, we need to switch over using the button marked below

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Enter the technical name of the data element in the data element column ZREC_FNAME and press enter. As seen below, the data type and short description fields get filled automatically and that is why you should use more data elements in your design if you are planning to add the same fields across multiple tables. This saves a lot of time.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Add a field name to this row and also mark Customer Number as the key field using the check-box in front of it as shown below.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Now if you’ve noticed, we added a field called Quantity and one for units but how will the system know that the unit field is linked to this Quantity field? To make this link, switch to the Currency/Quantity Fields tab. Here you will see a blank area in front of the Quantity field asking for the reference table and reference field for the unit. In our case, the Reference table is ZCUST_REV itself since the unit field is here and the Ref field is ZUNIT_SOLD.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Fill up the required information as shown below.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

We are almost done here. There is a minor setting you need to specify to avoid getting warnings in activation. From the Menu bar as shown below, select the “Enhancement Category” option.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

You will get the pop-up like below. Press the tick button.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Mark the option shown below to allow future enhancements (field additions) to this table with Character or Numeric  fields. You can also choose the “Deep” option to allow all enhancement types to be applied to this table. For now, choose one and press the copy button.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Now, save and activate this table using the same steps as in the previous tutorial.

You should reach the below screen

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

Using F4 helps to understand the possible values for this field.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

In our case,  revenue is transaction data and hence we select APPL1.

Next, we fill out the size category which is the number of records expected in that table.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

I expect less data and hence choose Category 0 and then press the save button on top and then the green back button to go back.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

When back, activate the table and the table would now be ready to use.

CREATE TABLE SAP BI ABAP SAP ABAP SAP BW ABAP CREATE TABLES

I hope this tutorial to create custom tables in SAP ABAP was clear to you. Stay tuned for our next tutorials on SAP BI ABAP. Please show your support for this free website by sharing this tutorial on social media and also makes sure you subscribe to our newsletter for the latest updates.

Happy Learning.

<<Previous Tutorial                                                                                                               Next Tutorial>>

Content Protection by DMCA.com
Tagged , , , , , , , , , , , , , , , , , , , .

Leave a Reply