Tables in DD
Tables in DD
ABAP DICTIONARY
Abap Dictionary is a central repository where we define and maintain the objects which are
related to database.
Define means creation of objects
Maintenance means changing and deleting the objects.
Database table:
It is an object which stores data in the form of rows and columns.
Domain:
It is an object which specifies technical information such as data type and length for a field.
It also specifies sign, lower case, conversion routine, fixed values, and value table.
Data element:
It is an object which specifies semantic information such as field description, field labels (short,
medium, long and heading) for a field.
• These are also used in creating foreign key relationship, search help, ale-idoc’s.
Key field: A field which is used to identify the record uniquely is called a key field. In a table
there should be at least one key field. We can create number of key fields.
2. Select Domain
4. Click on Create
7. Press enter
3. Click on create
4. Provide description
9.
10. Click on save
12. Provide the details as data class -> APPL0, size category -> 0
Note: Sometimes we may get unpredictable errors in a table, due to adding or deleting the fields in a
table. To solve the error follow the below steps.
Components of a TABLE :
Delivery class:
It specifies the type of the data that stored in a table.
Display maintenance:
It specifies whether the data should only be displayed or it can also be maintained.
• Display maintenance not allowed: Data is not displayed and not maintained
• Display maintenance allowed with restrictions: Data is displayed, but maintenance is given
only for some users based on restrictions.
Data class: It specifies the physical area of a table inside the database
Depending on the table we are supposed to select the required option. The options available are,
Master data: The data which never changes or which changes very rarely is called master data.
Ex: cno, cname, city etc.
Transaction data: The day to day business data or the data which changes every day is called
transaction data.
Organization data: The data which is related to organization or company like how many company
codes, plants, sales organization etc, is called organization data.
Size category: It specifies the max. Number of records that can be stored in a table.
The possible options are available as below.
In the real time we always set size category as ‘0’ OR ‘1’, because we have to use small amount of
memory.
Suppose if the memory is not sufficient the system will automatically assign the same memory area as
per the size category mentioned above.
Buffer/cache memory: It is a temporary memory to store the data. It is mainly used to increase
the system performance.
• The system will check whether the data is available in cache/buffer memory
• If it is available the data will be immediately given back to the table, thereby increasing the
system performance
• Suppose if the data is not available, the request will be sent to database, and the response wil
be given back to buffer or cache memory to store a copy for future references
• After the copy is stored then the data will be given back to the table
Buffering options:
• Buffering not allowed: Data is not stored in buffer
Buffering types:
• Single record buffer: Only first record or records which are read will be stored in the buffer
• Generic Area: The key field’s data is called generic area. Only generic area data i.e. key fields
data will be stored in the buffer
Log Data Changes: This Checkbox would define whether changes to the data records of the table
are to be logged/recorded or not.
If checkbox is selected, then every change (Update/Delete) to an existing data record is recorded in
the Standard Database Log table DBTABLOG.
CLIENT NUMBER
It is a unique number which is used to provide security to the data at the database level.
In the real time, Based on the client no only, usernames will be created and the access will be given.
In the real time, normally we use the client number (100,120), (200,220), (300,320).
The field name, data element, and domain for client number is ‘MANDT’.
2.
STRUCTURES IN ABAP
• It is a container of reusable fields
Include structure
Append structure
Ex on include structure:
Step 1: Create a structure by name ‘zaddr’ with fields city, country, postal code
4.
2. Provide the field name as ‘.include’, data element as structure name zaddr(which is
created above)
3. Enter
Add a custom field ‘MNAME’ (middle name) to the standard SAP table ‘KNA1’ .
1. Open the table kna1 in display mode
• So, for every currency and quantity field we have to specify the corresponding unitslike INR or
USD or EURO etc or KGS or EA or PC etc .
• CURR: It is the data type which is used to store the currency amount or price fields.
• CUKY: It is the data type which is used to store the corresponding units(INR or USD or EURO )
for the currency fields.
• QUAN: It is the data type which is used to specify the quantity for a material or stock.
• UNIT: It is the data type which is used to specify the units(KGS or EA or PC) for the quantity
fields.
Ex on currency/quantity fields:
1. Open any table which is already created.
a.
4. Save and activate the table
Check table:
A table which stores master data is called a check table.
Step 2: Create another table by name zcustomers_bank with fields cno, bankid and
bankname.
• We have to maintain some fixed values at the domain, so that all the table fields will
be referring to this domain will be checked against with the fixed values
• If, suppose we enter a wrong value for a field which refers this domain, then the system will
check your value with fixed values. If the value is not available, then the system will raise
the error message
• This option is only used whenever the number of values are less than 10 or 15
• If the values are more than 15, we go for foreign key relation
2. Add an extra field by name ‘gender’ with data element and domain as ‘zgender’
a.
6. Save and activate the domain and the table
7. Go to unit testing
VALUE TABLE:
A table name defined at the domain level so that all the table fields will be referring to
the domain will be checked or validated with a single table called as value table.
The main advantage of value table is to automate the system for foreign key relation
i.e. the system will automatically display check table name to generate foreign key
proposal.
We should just click on YES button, so that value table is converted as check table.
STEP1 : Create a table zzcustomer with field cno and cname, also create some records
STEP2 : Define the check table name at domain level as below. Nowcheck table is called as value
table
STEP3 : Create another table by name zzcustomer_bank with fields cno, bankid, bankname
• A pop-up displayed as below with value table to be proposed for check table
Domain properties:
• SIGN: It is used to store the sign of a number, whether it is positive sign or negative sign
• Lower Case: This option is used to store a value in the combination of capital and small letters
• If we don’t want to convert all letters into capital letters, please select lower case option
It is also used for validating the table data using the concept of events.
1. Create any table by name ‘zcust’ with mandt, cno, cname and land1
Activating TMG:
• Go to SE80
Unit testing:
• Go to SM30
• Enter customer number, name and country for a single record or bulk amount of records.
Inside the routine we have to write the ABAP code for validating the data
Events in TMG:
• Open the table
• Provide the routine name for above event in the second column and press enter
5. Select the event ‘05’ (creating a new record) and provide sub-routine name (sub-program
name)
6.
7. Click on editor icon
Form znew_rec.
If zkna1_land1 = ‘ ’.
Message ‘please enter country’ type ‘E’.
Endif.
Endform.
Assignment
Create a table by name ‘zlfa1’ with vendor number, name, date and user name. Create
TMG and validate the TMG so that date and username automatically saved.