Wednesday, 4 October 2017

ABAP: Database Table

Database table is a collection of records, where each record is a collection of fields. You can define database tables using built-in types (or) by using data elements.

I am going to show you how to create below tables.

ZStudent
student_id
first_name
last_name
primary_email
secondary_email
phone_number
date_of_join








ZParent
parent_id
first_name
last_name
primary_email
secondary_email
phone_number







ZTeaching_Faculty
faculty_id
first_name
last_name
primary_email
work_email
phone_number
date_of_join
Salary









ZNon_Teaching_faculty
non_teaching_faculty_id
first_name
last_name
primary_email
work_email
phone_number
date_of_join
Salary









ZFaculty_student
faculty_id
student_id
Year




        
ZFtudent_parent
student_id
parent_id


        
ZFaculty_rating
faculty_id
student_id
faculty_rating




ZStudent_rating
student_id
faculty_id
student_rating



I am going to define the above tables using the data elements that I defined in my previous post.

Create Student table
Field
Data Element
student_id
ZSTUDENT_ID
first_name
ZSTUDENT_FIRST_NAME
last_name
ZSTUDENT_LAST_NAME
primary_email
ZSTUDENT_PRIMARY_EMAIL
secondary_email
ZSTUDENT_SECONDARY_EMAIL
phone_number
Z_PHONE_NUM
date_of_join
ZSTUDENT_DATE_OF_JOIN
                                                  
Use the transaction ‘SE11’ to open ABAP dictionary.

Select the radio button ‘Database table’ and give the table name as ZSTUDNT.
Click the button ‘Create’.

It opens below screen.
Update the ‘Short Description’ as ‘Student information’.

Click on the button ‘Delivery Class’ and choose ‘Application Table’.
Select the option ‘Delivery/Maintenance Allowed’.
Go to the Fields section by clicking on the tab ‘Fields’.

Specify the fields and data elements here.
Press Enter after updating the fields and data elements. While working with application tables, Your table first field must be MANDT. Since Application tables are client dependent, we require to add the field ‘MANDT’.

What is client dependent?
The date inserted into the table from one client can be accessed from that client only. Suppose if you inserted student details with id ‘12345’,  from the client 234, then the data with id ‘12345’ can be accessed from the client 234 only.
Mark the MANDT, STUDENT_ID as primary key by selecting the checkbox under the section Key.
Save the data.

Set the enhancement category to this table
Extras -> Enhancement Category.
Press Ok button.
Select the option ‘Can be Enhanced (Deep)’ and press the button Copy.

Save the settings.

Updating Technical Settings
Click on the button ‘Technical Setting’ on tool bar.

Click on Data Class section, and select the class ‘APPL0’.
Select the size category. I choose the size category as 1.
Save the settings and activate the table.

Create table ZTEACHINGFACULTY
faculty_id
first_name
last_name
primary_email
work_email
phone_number
date_of_join
salary









Field
Data Element
faculty_id
ZFACULTY_ID
first_name
ZFACULTY_FIRST_NAME
last_name
ZFACULTY_LAST_NAME
primary_email
ZFACULTY_PRIMARY_EMAIL
work_email
ZFACULTY_WORK_EMAIL
phone_number
Z_PHONE_NUM
date_of_join
ZFACULTY_DATE_OF_JOIN
salary
ZSALARY


Procedure is same like creating ZSTUDNT.

In my next post, I am going to show you how to define ZFaculty_rating and ZStudent_rating tables by maintaining foreign key constraint.

Previous                                                 Next                                                 Home

No comments:

Post a Comment