0% found this document useful (0 votes)
21 views22 pages

Tables in DD

tables

Uploaded by

Rakesh Pani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views22 pages

Tables in DD

tables

Uploaded by

Rakesh Pani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

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.

The objects are,

Database table:
It is an object which stores data in the form of rows and columns.

Each row is called as record, and each column is called as field.

So, to define a table we have to define the fields first.

So, to define a field, we have to specify the below things:

FIELD = DATA ELEMENT + DOMAIN

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 1


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

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.

Advantages of data element and domain:


• Reusability: The same data element and domain can be reused by multiple table
fields, instead of creating again and again.

• 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.

Steps to create domain:


1. Go to SE11

2. Select Domain

3. Give a name, ex – ‘zcno’

4. Click on Create

5. Provide short description

6. Provide data type as CHAR and length as 10 .

7. Press enter

8. Save, check and activate

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 2


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Steps to create data element:


1. Go to SE11
2. Select data type
3. Give a name, ex – ‘zcno’
4. Create -> select data element
5. Provide short description
6. Provide domain name as ‘zcno’
7. Press enter
8. Click on field label tab, specify short, medium, long and heading labels
9. Save, check and activate

Steps to create a table:


1. Go to SE11

2. Provide the table name ‘zcust_table’

3. Click on create

4. Provide description

5. Specify delivery class as ‘A’

6. Specify display maintenance allowed

7. Click on fields tab

8. Provide the field name, data element name as below

9.
10. Click on save

11. Click on technical settings button

12. Provide the details as data class -> APPL0, size category -> 0

13. Click on save and click on back

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 3


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

14. Save and activate the table

Creating records into the table:


• Go to SE11

• Give the table name and click on change

• Click on utilities -> table contents -> create

• Provide the cno, cname, city

• Repeat the same procedure and create the records

Displaying the table contents:


• Click on utilities -> table contents -> display

• Click on execute button

• The records will be displayed

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.

• Go to SE14 Provide the table name

• Click on edit button

• Click on ‘activate and adjust database button

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 4


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Components of a TABLE :

Delivery class:
It specifies the type of the data that stored in a table.

The data can be business data or system data.

Business data means application data (master and transaction data).

The following options are available.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 5


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Display maintenance:
It specifies whether the data should only be displayed or it can also be maintained.

Data maintenance means creation, deletion, and changing.

There are 3 options available.

• Display maintenance allowed: Data is displayed and 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.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 6


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Transaction data: The day to day business data or the data which changes every day is called
transaction data.

Ex: customer bank 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 functionality of buffer is defined as below.

• The Tables request for the data

• 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

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 7


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Buffering options:
• Buffering not allowed: Data is not stored in buffer

• Buffering allowed but not switched off: Used by SAP

• Buffering switched on: Data is stored in buffer

By default buffering not allowed will be selected.

Buffering types:
• Single record buffer: Only first record or records which are read will be stored in the buffer

• Fully buffered: All the records 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.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 8


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

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’.

Types of tables based on client number

Ex on Client dependent table:


1. Create a table by name zcust_table_dp with below fields.

2.

3. Create some records in the table and display them.


4. Now login to another client. Ex 810 client
5. Open the table and display the data
6. The data will not be available, because it is a client dependent table

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 9


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

STRUCTURES IN ABAP
• It is a container of reusable fields

• Structures are defined in data dictionary

• Once the structures are defined we must include them in tables

• There are two options for including the structures in tables

 Include structure

 Append structure

Difference between include structure and append structure:

Ex on include structure:
Step 1: Create a structure by name ‘zaddr’ with fields city, country, postal code

1. Go to SE11 Selectdata type provide a name ‘zaddr’

2. Click on create and provide the description

3. Specify the fields and data elements

4.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 10


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

5. Save and activate

Steps 2: Include the structure in a table as below

1. Open any table which is already created

2. Provide the field name as ‘.include’, data element as structure name zaddr(which is
created above)

3. Enter

4. The fields will be automatically copied

Ex on append structure: Business requirement:

Add a custom field ‘MNAME’ (middle name) to the standard SAP table ‘KNA1’ .
1. Open the table kna1 in display mode

2. Click on ‘append structure’ button

3. A pop-up is displayed, click on create icon

4. Provide the append name ‘zapp1’ and press enter

5. Provide the field name as ‘mname’ and data element as ‘zmname’

6. Save, activate and click on back

7. Check the field in the table, it will be available at the bottom

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 11


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Currency and Quantity fields


• Currency and quantity fields are used to store currency amounts data and quantity data
respectively.

• 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.

2. Add the below fields


3. Click on Currency/Quantity fields tab and specify Ref Tab Name and Ref Field Name.

a.
4. Save and activate the table

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 12


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Foreign key relation


The relation between two tables for validating the data is called foreign key relation.
Validation means checking whether the value is correct or not.

Check table:
A table which stores master data is called a check table.

Foreign Key Table :


A table which is linked with check table for validating its own data is called foreign key table

Foreign key relation :


A relation between two or more tables for validating the data is called foreign key relation.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 13


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Steps for foreign key relation:


Step 1: Create a table by name ‘zcustomers’ with field’s customer number and customer
name, also create some records.

Step 2: Create another table by name zcustomers_bank with fields cno, bankid and
bankname.

Step 3: Create the foreign key relation as below

1. Open the table zcustomer_bank

2. Select cno field

3. Click on foreign keys button or Icon

4. Provide the check table name as zcustomer(master data table)

5. Click on generate proposal button

6. Click on copy button

7. Save and activate

Step 4: Unit testing

• Click on utilities -> table contents -> create

• Enter the invalid customer number and click on save

• The error message will be displayed

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 14


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Real time ex on foreign key relation:

Domain with field values:


• It is an option to maintain some Fixed values inside the domain for validation

• It is used for validation at the domain level

• 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

• The main advantage of domain with fixed values is reusability

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 15


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Ex on Domain with field values


1. Open the table zcustomer_bank

2. Add an extra field by name ‘gender’ with data element and domain as ‘zgender’

3. Now go to the domain ‘zgender’.

4. Click on value range tab

5. Maintain the fixed values as below

a.
6. Save and activate the domain and the table

7. Go to unit testing

8. Enter the invalid value for gender

9. The error will be displayed

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.

Steps for value 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

1. Go to the domain zcno

2. Click on value range tab

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 16


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

3. Provide the value table as zzcustomer

4. Save and activate, domain and table

STEP3 : Create another table by name zzcustomer_bank with fields cno, bankid, bankname

STEP4 : Maintain the foreign key relation as below

• Open zzcustomer_bank table

• Select cno field and click on foreign key button

• A pop-up displayed as below with value table to be proposed for check table

• If we click on ‘yes’, foreign key relation will be automatically displayed

• If we click on ‘no’, it will not be displayed

Differences between check table and value table

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 17


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

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

• By default SAP will convert all letters into capital letters

• If we don’t want to convert all letters into capital letters, please select lower case option

• Conversion Routine: It is a sub-program or function module which is used to converta value


from internal format to external format and vice versa

Conversion routine function modules:


• Go to any domain, ex: MATNR

• The conversion routine will be displayed, ex: MATN1

• Double click on MATN1

• Two function modules will be displayed as below

• CONVERSION_EXIT_MATN1_INPUT: This function module is used to convert material number


from external format to internal format.

• CONVERSION_EXIT_MATN1_OUTPUT: This function module is used to convert material


number from internal format tot external format.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 18


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Table Maintenance Generator (SM30):


It is a standard SAP program created in the form of function modules to maintain mass or bulk
amount of data instead of maintaining each and every record.

Maintenance means creation, deletion and modification.

It is also used for validating the table data using the concept of events.

Steps for TMG:

1. Create any table by name ‘zcust’ with mandt, cno, cname and land1

2. Save and activate the table

3. Click on utilities -> select table maintenance generator

4. Provide the details as below

5. Authorization group = &NC&


6. Function group = zcust(table name)
7. Maintenance type as one step

8. Click on find screen number button

9. A pop-up is displayed, just press enter

10. The screen number will be automatically proposed

11. Click on create icon

12. The TMG will be created in the form of function modules

Activating TMG:

• Go to SE80

• Select function group from the list

• Provide function group name (table name) and press enter

• Right click on function group name and select activate

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 19


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

Unit testing:

• Go to SM30

• Provide the table name

• Click on ‘maintain’ button

• Enter customer number, name and country for a single record or bulk amount of records.

• Click on save, the data will be saved

Validations with TMG:


 Sometimes we want to validate the data by writing programlogic.
 In such cases we use events in TMG and validate the data

 The validation are possible using the concept called events

 There are around 39 events available

 For each event we need to provide a routine name (sub-program name )

 Inside the routine we have to write the ABAP code for validating the data

Events in TMG:
• Open the table

• Click on utilities and select TMG

• Click on environment -> modification -> events

• A new screen will be displayed

• Click on ‘new entries’ button

• Click on ‘help’ button on the first row, first column

• The 39 events will be displayed

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 20


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

• Double click on any Event Name. Ex : 05

• Provide the routine name for above event in the second column and press enter

New sub-program which will be created for writing the logic

Ex on validation: Business Requirement:

Raise an error message whenever a new record or customer is created without


providing the country or land1.

1. Create a table by name ‘zkna1’ with kunnr, land1, name1 fields

2. Create a TMG as discussed above

3. Click on environment -> modifications -> events

4. Click on ‘new entries’ button

5. Select the event ‘05’ (creating a new record) and provide sub-routine name (sub-program
name)

6.
7. Click on editor icon

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 21


A B A P&W E B D Y N P R O A B A P @ A R J U N IGROWSOFT

8. Press enter 2 times (sub-program will be created automatically)

9. Write the below ABAP code

Form znew_rec.
If zkna1_land1 = ‘ ’.
Message ‘please enter country’ type ‘E’.
Endif.
Endform.

10. Save and activate

11. Click on back, save

12. Click on back, save

13. Click on save

14. An information message will be displayed as ‘function group can’t be processed’

15. Click on back -> back -> back

16. Go to SE80 and activate function group

17. Got SM30 and test it

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.

ARJUN…….LEARN REAL TIME SCENARIOS DONE BY ME Page 22

You might also like