Thursday, February 21, 2013

How to create a database table in SAP ABAP or Steps to create a database table

Creating a Database Table in SAP ABAP:

1.Enter Transaction Code : SE11 and press Enter.

(ABAP Dictionary Initial Screen will appear)

2.Select radiobutton Database Table and provide name for the database table you want to
    create.  Database Table :  Zstudenttable.
(lets create a student table , The table name can be 16 characters in length.)

3. Press on CREATE .

4.  Provide Short Description : Table to store  students yearly marks.

Delivery and Maintenance Tab
5. Delivery Class : C Customizing Table.
     {A  Application Table(master and transaction data) These are client specific table.}


The delivery class controls the transport of table data for installation, upgrade, client copy and
when transporting between customer systems. The delivery class is also used in the extended
table maintenance.

6. Data Browser/ Table view maint. :  Display/ Maintenance allowed.

7. Save it .and it will ask for Package : $TMP. and save it.

8.Click on Fields Tab

9. Field        Key        Initial               DataElement
 StudentId. (a tick mark will appear).    Zstudentid
     

              ( This is nothing but Primary Key , which ensures the uniques values for that field. every table should atleast have 1 Primary key field. )


              All the key fields of a table must be stored together at the beginning of the table. A non-key
field may not occur between two key fields.
            A maximum of 16 key fields per table is permitted. The maximum length of the table key is
255.
            If the key length is greater than 120, there are restrictions when transporting table entries.
             The key can only be specified up to a maximum of 120 places in a transport. If the key is
larger than 120, table entries must be transported generically.
            A table may not have more than 249 fields. The sum of all field lengths is limited to 1962
(whereby fields with data type LRAW and LCHR are not counted).
              Fields of types LRAW or LCHR must be at the end of the table. Only one such field is
allowed per table. There must also be a field of type INT2 directly in front of such a field. The
actual length of the field can be entered there by the database interface.


Initial : If we select it , it will take the respective values as below. otherwise the value is null.


Data type
Initial Value
ACCP, CHAR, CUKY, LANG, UNIT
” ”  space
CURR, DEC, FLTP, INT1, INT2, INT4, QUAN
0
CLNT
000
TIMS
000000
DATS
00000000
NUMC
00000... for field length <= 32
no initial value for field length > 32
LRAW, LCHR, RAW, VARC
no initial value

10.STEPS TO CREATE A DATA ELEMENT and DOMAIN

11. Double click on the Data Element that is : Zstudentid..

It will ask to save the table, Click on YES.

It will ask to create  Data Element. Click on YES.

Short Description : Data element for student id.

Domain : zstudentid. 

In order to  create DOMAIN Double click on Zstudentid.

it will ask to save the table , click on yes. and package : $Tmp  and Save.

and it will ask to create the Domain , Click on Yes.

Short Description : Domain for Zstudentid.

Data type : Char.
No. of chars : 3.

Now save, check Activate the domain.

Go back and save, check ,activate the data element.

Go back , Click on Technical Settings.

Data class : APPLO (depends on type of data)
Size Category : 0     ( this predefines the no. of records the table can hold).

Save. go back,  and    check. 

it will show error enhancement category

for this go back 
and Click on Extras----> enhancement category

and select radiobutton  can be enhanced.      and press enter.

now save, check and activate.

like this add additional fields and again save , check , and activate.

now if you want to add entries to the database table.

go to Utilities------> Table Contents-----> Create Entries.

provide the values and save

and go back.

go to   Utilities------> Table Contents----> display

it will display the data.

we have successfully created a database table.


















ENHANCEMENT CATEGORY FOR TABLE MISSING ERROR

when this error occurs go to  EXTRAS---Enhancement category
 and then choose options like  " can be enhanced"  you will not get the error.