Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

hi

Former Member
0 Kudos

hi,m very new to abap i want to knw the entire process of database table and internal table..we create a table using se11,is it database table or internal table, if it is a database table den y do v need an internal table...

say i have created a table zsample in se11 ,den how do u create an internal table,

can u plz giv me the syntax for the db table and internal table process......and what is work area doing inbetween....how is the data fetsched...plz giv me the code

7 REPLIES 7

Former Member
0 Kudos

hi,

genarally we can create tables in SE11. where as we can create internal table in declaration part of the application, but in few senarios there is a necessity to define the internal table by using SE11.

we can create tbale in SE11 for that one we select TABLES object, where as we create internal table in SE11 by selecting LINE TYPE and ROW TYPE object.

suppose you are working with object oriented programming in that cases it doesn't allow internal table with header and required global presence in taht case we create internal table with LINE TYPE and ROW TYPE objects.

we create internal table in two types.

1) internal table with header line.

2) internal table without header line.

<b>syntax for creating internal table with header-line.</b>

DATA: begin of itab occurs 0,
          field1  type <refarencefield>,
          field2  type <refarencefield>,
         end of itab.

<b>syantax for creation of internal table without header line.</b>

TYPES: begin of itab.,
                    field1  type <refarencefield>,
                    field2  type <refarencefield>,
            end of itab.

DATA: itab_wa type itab,                 " internla table work area
           itab_body type table of itab.  "internal table body

for more information on internal table follow this link.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm

One common kind of interface work area are table work areas, which you declare using the

<b>TABLES <dbtab>.</b>

statement. This statement creates a structure with the same data type and the same name as a database table, a view, or a structure from the ABAP Dictionary.

regards,

Ashok reddy

Former Member
0 Kudos

<b>Steps to Creating domains, Data Elements, Tables</b>

<b>To give you the steps for creating table:.</b>

There are two approach in creating a table.

<b>1. Bottom-up approach

2. Top-down approach. </b>

Both are valid and you can choose which approach is suitable for you. I always use the bottom-up approach. Here are the steps to create the tables with this approach.

1. SE11 will take you to the DDIC and enter the name of the new table to be created. Let us say Zname. Click create.

2. Enter the short discription of the table and enter the field of the table. If it is primary key and you have to check the box.

3. Enter the data element and double click it, you will be asked to save and will take you to data element discription page. Enter the short discription of the data element and enter the information of domain like the length of field and type of field.

4. If you wanted to use the existing domain then its fine, or else, you have to create one. Enter the domain name in the data element page and double click it. Page will ask to save and jump to domain creation page.

5. In the domain page, you have to save the information which you have already given in the data elements page and check it. Before going to data element page, you have to activate the domain.

6. Go to data element page and save, check and activate.

7. Go to main table page and save, check, and activate.

8. Also, you have to save the technical settings of the table.

The table is now ready for operation. You can use it in your program or you can use it to enter information.

Check table: It is the table which will have all the information about the Foreign keys which are the primary keys in the check table.

It can be created by creating the foreign key from the main table. Click foreign key in the main table and it will take you to a page which will ask for table name and field to which foreign key relation has to be associated. Enter the information and you can create the check table automatically.

SM30 is used for maintenance of the table, that is to realease the errors occured during the creation of the table.

<b>

Internal tables</b>

Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.

Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.

<b>Internal table in ABAP</b>

An internal table is a run time instance. It get created when program starts execution.

It get destroyed when program terminates. it has two different parts. HeaderLine(optional) & Body(Compulsory). Any value that comes to or goes from interanal table , that travels through headerline.\

*A related program is . 

*declaration. 
data: begin of inernaltable occurs 0, 
         x type c, 
         y type i, 
      end of itab. 

*initializing headerline 
   internaltable-x = 'd'. 
   internaltable-y = 34. 
   
*storing value into internal table 

appene internaltable .  
appene internaltable . 
appene internaltable . 

*reading internal table 
loop at itab . 
   write: / internaltable-x, internaltable-y.  "writes to output list 
endloop.

<b>Different Types Of Internal Tables and Their Usage</b>

<b>1.Standard Internal Tables</b>

Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.

This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to

the number of table entries.

<b>2.Sorted Internal Tables</b>

Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.

This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.

3.Hashed Internal Tables

Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.

This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and using internal tables that are similar to database tables.

4.Index Tables

Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX.

Internal tables are not DB tables. Standard and Sorted tables in combined are basically called as Index tables and there nothing else. Here is the hierarchy

         ANY TABLE 
                                            | 
                    ------------------------------------ 
                     |                                                    | 
             Index Tables                                    Hashed Table 
                     |           
    ------------------------------------  
    |                                                     | 
Standard Table                      Sorted Table

reward points if it is usefull ...

Girish

Former Member
0 Kudos

Hi,

Database table is used to store the data perminently in database.This is seperate server.

Internal table is the temporary table in Application server.It will active till your session run.

If you want to do some changes in data based on some conditions you have to extract the data from database table to internal table and do the changes and can display output as you required, but you should not change the database.

So you can say internal table is a intermediate temporary table in between user and database table.

Work Area:

It is the intermediate work place for internal table body and user.If you want pass the data to internal table you should have work area from where you can move your data into internal table.This is compulsory.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

Don't forget to reward if useful.....

Former Member
0 Kudos

Internal tables

Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.

Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.

Internal table in ABAP

An internal table is a run time instance. It get created when program starts execution.

It get destroyed when program terminates. it has two different parts. HeaderLine(optional) & Body(Compulsory). Any value that comes to or goes from interanal table , that travels through headerline.\

Reward points if useful

Former Member
0 Kudos

HI ANGEL,

What types of objects can be created in the ABAP Dictionary?

Tables

Views

Data Elements

Structures

Table Types

Type Groups

Domains

Search Helps

Lock Objects

What types of tables can be created in the ABAP Dictionary?

Transparent Tables

Pooled and Clustered Tables

Which field differentiates a table from client-dependent and client-independent?

The MANDT field of the table specifies whether the table is client independent or not.

What is the difference between Pooled tables and Cluster tables?

Cluster tables and Pooled tables have many to one relationship with the underlying database.

A table pool corresponds to a table in the database in which all records from the pooled tables assigned to it are stored.

Several logical data records from different cluster tables can be stored together in one physical record in a table cluster.

A pooled table cannot have the name having more than 10 characters.

All the key fields of the pooled table must be of character data type.

In pooled tables, the maximum length of the key field/data fields should not exceed the length of varkey/vardata of the pool respectively.

In cluster table the records having the same key are stored in a single key in the cluster.

If there is an overflow of the data records a continuation record is created with the same table key.

What is the difference between Database tables and Views?

The Table has a physical storage of data whereas views do not have physical storage of data.

The view is derived from one or more tables which is created only with the required fields from the database table(s). It can also be created with table inner joins and specifying conditions for data retrieval.

What are the different types of Views?

Projection view - Just retrieves some fields from a single table.

Help View - This is used for search help.

Database View - This is inner join view of one or more tables

Maintenance View - Helps in creating maintaining data of the application object. The data can be distributed among several tables.

Can I use all the views in the ABAP program ?

No. You can use only projection view or database view in your ABAP program.

What is Table Maintenance Generator?

The Table Maintenance Generator is used to create table maintenance program to add, modify or delete records in the database table. This can be accessed using transaction SE54 or in SE11 using the menu Utilities->Table Maintenance Generator.

What is One step, two step in Table Maintenance Generator?

This specifies the screens to be created in the Table Maintenance Program.

Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.

Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.

How do you activate the database table after making changes to it?

After making changes to the table, inorder to reflect the changes go to transaction SE14 and Choose Edit and then choose Activate and Adjust Database.

OR

You can directly activate it from the SE11.

In which table are the programs stored in?

The programs are stored in the table TADIR and the development class packages in TDEVC.

I have recently added a few fields to a custom table. But I don't get these fields in the table maintenance program?

You have to delete and recreate your own existing table maintenance program to see your new fields.

What is the difference between INSERT and MODIFY?

Whenever you need to create new records in the database table use INSERT. Whenever using INSERT be sure that a duplicate entry having the same values for the primary key fields are not present. Else it may throw a dump.

When you use MODIFY it makes a check for the matching key field values. If present it modifies the matching record, else it creates a new record in the database table.

How do I create index on a database table?

Go to transaction SE11, open your database table. Choose the menu, Goto->Indexes to create index. Give your index name and choose the fields of the table. Be careful, an additional index may vanish with the next upgrade or hotpackage.

What is the difference between Check Table and Value Table?

The Check Table is the dependent table to which the relationship is defined using foreign keys. The contents of the check table field are shown in the input help for the referenced field.

The Value table is the table attached to a field at the domain level, where the entry to the field can be only from the value table. They are not used in the Input Help.

What is the difference between Domain and Data Elements?

The Domain specifies the Technical attributes of the field such as the data type, length and the value range.

The data element is an elementary type defining the description/text for the field when displaying on the screen and Parameter ID.

When I create new entries in the table the field values are always in Uppercase. How do I get the data with mixed case?

The reason for this is that the Domain for the field in the table might have Lowercase checkbox unchecked. Check the Lowercase checkbox to preserve the case of your data.

What is the need of reference table and reference field in Currency/Quantity fields?

The reference table and reference field are the fields which specify the currency key or Unit of Measure. Suppose if the user specifies a currency amount say 1000$, the currency amount field would indicate the amount 1000 and the currency key indicates that the currency specified is in Dollars.

Where to find the table of tables?

DD02L and DD02T for short text

please refer wiki page for more details

<b>

Reward pts if u found usefull</b>

Regards,

Sathish:)

former_member235056
Active Contributor
0 Kudos

Hi,

When we create new table then its the internal table as it comes under user namespace or creates in program(itab) and database.

Database table is one which is already present in database like mara, makt,.... and has its own database.

Internal table includes pooled,cluster and transparent table.

Syntax:

select * from <standard table> into <internal table> where <condition>

select * from <mara> into <itab> where <condition>

Pls reward points,

Regards,

Ameet

former_member196299
Active Contributor
0 Kudos

hi ,

Got a nice name ..... !

In SE11 we can create DB table as well as Internal table . In simple words we create DB table for storing the data permanently and internal table stores the data temporarily during runtime .

Though we have database tables, we need internal tables for performing the various operations during runtime in your program ..like you select the data from the database table in your program and store it temporarily in your current program inside an internal table ( so u can say internal table is a temporary data container during runtime ) and perform many operations like displaying them with various formats or something similar .

You retrieve the data from the database table ( Transparent table ) using the SELECT * .... Statements ...( please see the additions of these select statements in SAP HELP Documents ) .

You retrieve the data from the internal tables using the READ TABLE or LOOP ...ENDLOOP statements ... ( Please see the details from SAP Help ) ..

Hope the above details given above are easy to understand ..

Reward if helpful !

Regards,

Ranjita