‎2007 Jan 02 5:04 AM
plz send differences between all internal tables with coding part to understand clearly ?
thank u.
‎2007 Jan 02 5:09 AM
it is ur choice....based on requirement u can create it....Say, u have an internal table which needs to be used as a LOOP or READ then internal table needs to be created with header line...
Now, u have just selected data and used to print, then internal table can be declared as without header line.
‎2007 Jan 02 6:21 AM
HI
First you should know about With Header line and With out Header line.
a)Operations without header line
b) Operations with header line
OPERATIONS FOR ALL TABLES:
a1 )INSERT <wa> INTO TABLE <itab>.
b1) INSERT TABLE ITAB.
a2) COLLECT <wa> INTO <itab>.
b2) COLLECT <itab>.
a3) READ TABLE <itab> ... INTO <wa>.
b3) READ TABLE <itab> ...
a4) MODIFY TABLE <itab> FROM <wa> ...
b4) MODIFY TABLE <itab> ...
a5) MODIFY <itab> FROM <wa> ...WHERE ...
b5) MODIFY <itab> ... WHERE ...
a6) DELETE TABLE <itab> FROM <wa>.
b6) DELETE TABLE <itab>.
a7) LOOP AT ITAB INTO <wa> ...
b7) LOOP AT ITAB ...
OPERATIONS FOR INDEX TABLES:
1) APPEND <wa> TO <itab>(Operations without header line).
1) APPEND <itab>(Operations with header line).
2) NSERT <wa> INTO <itab> ...
2) INSERT <itab> ...
3) MODIFY <itab> FROM <wa> ...
3) MODIFY <itab> ...
Regards,
Gunasree.
‎2007 Jan 02 11:16 AM
An internal table is fully specified by the following information:
<i><b>*Line type</b></i>
The line type of an internal table can be any ABAP data type. It is generally a structured data type.
<i><b>*Key sequence</b></i>
The key fields and their sequence determine the criteria by which the system identifies table lines.
<i><b>Uniqueness attribute</b></i>
You can define the key of an internal table as either UNIQUE or NON-UNIQUE. If the key is unique, there can be no duplicate entries in the internal table.
<i><b>Table type</b></i>
The table type defines how ABAP access individual table lines. This can be either by table index (access by row ID) or by the key (access by key fields).
The following statement creates an internal table with type <tabkind> and line type <linetype>:
DATA <itab> TYPE <tabkind> OF <linetype>
[WITH [UNIQUE | NON-UNIQUE] <keydef>] [INITIAL SIZE <n>]
Normally, you also specify a user-defined key in the form <f1> <fn>. All of the fields in the key must have a flat structure. The addition DEFAULT KEY allows you to set the standard key (all non-numerical fields) as the table key, as required by the definition of internal tables before Release 4.0.
You can use the UNIQUE or NON-UNIQUE addition to specify whether the table should be allowed to contain entries with duplicate keys.
If you know that your internal table will be smaller than 8KB, you can use the INITIAL SIZE <n> addition to reserve its initial memory space.
The table type defines how ABAP access individual table lines. There are three types of internal tables:
In a <i><b>standard table</b></i>, you can access data using either the table index or the key. If access proceeds via the primary key, the response time is linearly related to the number of table entries. The key of a standard table is always non-unique.
<b><i>Sorted tables</i></b> are always stored sorted in ascending order according to their key. You can access them using either the table index or the key. If you use the key, the response time is in logarithmic relation to the number of table entries, since the system uses a binary search to access the table. The key of a sorted table can be either unique or non-unique.
Standard tables and sorted tables are generically known as index tables, since their values can be accessed via an index.
<b><i>Hashed tables</i></b> can only be accessed via the primary key. The response time is constant, regardless of the number of table entries, since access proceeds via a hash algorithem.. The hash algorithm is determined internally. The key of a hashed table must be unique. You can neither implicitly nor explicitly access hash tables through indexes.
At runtime, you can find out the type of an internal table (ITAB) using the statement
<b>"DESCRIBE TABLE <ITAB> KIND <k>".</b>
Internal table operations can be classified as follows:
*By their access method, as either index operations or key operations.
*By the scope of their access, as either single record processing or mass processing.
Single record processing accesses one line in each operation, while mass processing accesses n lines.
*By the operation type, as Read, Append, Insert, Change, or Delete.
*Index operations cannot be used for hashed tables. For index tables, index operations are faster than key operations
Rows can be identified either via the work area from which the key values are taken (in an implicit key access); or via an explicit key specification using WITH [TABLE] KEY. Key accesses are possible for all table types, but they show different levels of performance for each table type.Hashed tables are useful for reading a single data record via the table key, since the resulting access time is independent of the number of table entries. The location of the data record to be read is determined using the hash function. The time required is independent of the number of table entries.INSERT for a standard table or hashed table using the key has the same effect as an APPEND statement. For hashed tables, however, the address of the data row to be entered must also be calculated. For inserts in sorted tables, the sort sequence must be strictly observed, which means the access costs grow with increasing table size. With a COLLECT for standard tables, a hash function is created internally. Using this hash function results in good performance. The hash function for standard tables is, however, non-persistent, since it is destroyed by each INSERT, DELETE, and so on; after which performance is reduced with a COLLECT all fields that are not part of the key must have a numeric type.With the key operations MODIFY and DELETE, the location of the table entry must be determined.Evaluating the costs of the various access types shows that index operations provide the most efficient accesses.
Regards,
Balaji Reddy G
**rewards if answers are helpful
‎2007 Jan 02 11:22 AM
Hai Prasad,
>>>You should use internal tables whenever u 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.
>>>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 can use the TYPES statement to construct a new local internal table in your program.
Syntax is:
TYPES <t> TYPE|LIKE <tabkind> OF <linetype> [WITH <key>]
[INITIAL SIZE <n>].
You can use the DATA statement to construct new internal tables as well as using the LIKE or TYPE addition to refer to existing types or objects. The table type that you construct does not exist in its own right; instead, it is only an attribute of the table object. You can refer to it using the LIKE addition, but not using TYPE. The syntax for constructing a table object in the DATA statement is similar to that for defining a table type in the TYPES statement.
DATA <itab> TYPE|LIKE <tabkind> OF <linetype> WITH <key>
[INITIAL SIZE <n>]
[WITH HEADER LINE].
Hope it is helpful
Cheers,
Prasanthi.
‎2007 Jan 02 11:36 AM
An internal table is fully specified by the following information:
*Line type
The line type of an internal table can be any ABAP data type. It is generally a structured data type.
*Key sequence
The key fields and their sequence determine the criteria by which the system identifies table lines.
Uniqueness attribute
You can define the key of an internal table as either UNIQUE or NON-UNIQUE. If the key is unique, there can be no duplicate entries in the internal table.
Table type
The table type defines how ABAP access individual table lines. This can be either by table index (access by row ID) or by the key (access by key fields).
The following statement creates an internal table with type <tabkind> and line type <linetype>:
DATA <itab> TYPE <tabkind> OF <linetype>
[WITH [UNIQUE | NON-UNIQUE] <keydef>] [INITIAL SIZE <n>]
Normally, you also specify a user-defined key in the form <f1> <fn>. All of the fields in the key must have a flat structure. The addition DEFAULT KEY allows you to set the standard key (all non-numerical fields) as the table key, as required by the definition of internal tables before Release 4.0.
You can use the UNIQUE or NON-UNIQUE addition to specify whether the table should be allowed to contain entries with duplicate keys.
If you know that your internal table will be smaller than 8KB, you can use the INITIAL SIZE <n> addition to reserve its initial memory space.
The table type defines how ABAP access individual table lines. There are three types of internal tables:
In a standard table, you can access data using either the table index or the key. If access proceeds via the primary key, the response time is linearly related to the number of table entries. The key of a standard table is always non-unique.
Sorted tables are always stored sorted in ascending order according to their key. You can access them using either the table index or the key. If you use the key, the response time is in logarithmic relation to the number of table entries, since the system uses a binary search to access the table. The key of a sorted table can be either unique or non-unique.
Standard tables and sorted tables are generically known as index tables, since their values can be accessed via an index.
Hashed tables can only be accessed via the primary key. The response time is constant, regardless of the number of table entries, since access proceeds via a hash algorithem.. The hash algorithm is determined internally. The key of a hashed table must be unique. You can neither implicitly nor explicitly access hash tables through indexes.
At runtime, you can find out the type of an internal table (ITAB) using the statement
"DESCRIBE TABLE <ITAB> KIND <k>".
Internal table operations can be classified as follows:
*By their access method, as either index operations or key operations.
*By the scope of their access, as either single record processing or mass processing.
Single record processing accesses one line in each operation, while mass processing accesses n lines.
*By the operation type, as Read, Append, Insert, Change, or Delete.
*Index operations cannot be used for hashed tables. For index tables, index operations are faster than key operations
Rows can be identified either via the work area from which the key values are taken (in an implicit key access); or via an explicit key specification using WITH [TABLE] KEY. Key accesses are possible for all table types, but they show different levels of performance for each table type.Hashed tables are useful for reading a single data record via the table key, since the resulting access time is independent of the number of table entries. The location of the data record to be read is determined using the hash function. The time required is independent of the number of table entries.INSERT for a standard table or hashed table using the key has the same effect as an APPEND statement. For hashed tables, however, the address of the data row to be entered must also be calculated. For inserts in sorted tables, the sort sequence must be strictly observed, which means the access costs grow with increasing table size. With a COLLECT for standard tables, a hash function is created internally. Using this hash function results in good performance. The hash function for standard tables is, however, non-persistent, since it is destroyed by each INSERT, DELETE, and so on; after which performance is reduced with a COLLECT all fields that are not part of the key must have a numeric type.With the key operations MODIFY and DELETE, the location of the table entry must be determined.Evaluating the costs of the various access types shows that index operations provide the most efficient accesses.
REWARD POINTS...
‎2007 Jan 02 12:33 PM
‎2007 Jan 03 5:32 AM
Hi,
Read This One
1 Internal Tables
Definition of Internal table:
Internal table is a temporary table on Application server. Once you will execute the program then it will fill up the rows of the internal table. Once you will discard the program then it will remove the contents of the internal table.
Declaration of Internal table:
With header line:
Data: begin of itab occurs 0,
-
,
-
,
end of itab.
Data: Itab like table name occurs 0 with header line.
Without Header line:
Types: begin of st, structure name
-
,
-
,
end of st.
Data: Itab type standard table of st,
Wa like line of itab.
Header line:
Header line will occupy the space into memory. With header line records will come one by one into internal table and user will clear the header line.
Work Area:
Work area will not occupy the space into memory. With work area records will come one by one into internal table and no need to clear the Wa because it will auto clear.
Commands of Internal Table:
Append
With header line
It-co1 = a.
It-co2 = 1.
Append Itab.
With Work area
wa-co1 = a.
wa-co2 = 1.
Append wa to itab.
Read
Syntax of Read statement:
Read table itab index x.
Read table itab into wa index x.
Read table itab into wa with key <field name> = X.
Read table itab into wa index X comparing <Y> <Z>.
Modify
Syntax of Modify statement:
Modify itab index X.
Modify itab from Wa.
Delete
Syntax of Delete statement:
Delete itab index X.
Delete itab from X to Y.
Delete itab where ITAB-COL = A.
Sort
Syntax of Sort statement:
Sort itab.
Sort itab descending.
Sort itab by carrid.
Clear
Syntax of Clear statement:
Clear itab[ ]. clear internal table
Clear itab. clear header line
Refresh
Syntax of Refresh statement:
Refresh Itab.
Free
Syntax of Free statement:
Free itab.
Control Break Event
It should work under loop.
Sorting Should required
At new
Create groups of the character field in internal table.
Syntax of At new statement:
Loop at Itab.
At new character field name.
Write: character filed name.
Endat.
Endloop.
At first
Create grand total top of the internal table.
Syntax of At first statement:
Loop at Itab.
At first.
Sum.
Write: intergar filed name.
Endat.
Endloop.
At last
Create grand total end of the internal table.
Syntax of At last statement:
Loop at Itab.
At last.
Sum.
Write: intergar filed name.
Endat.
Endloop.
At End of
Create sub total according to the groups of the internal table.
Syntax of At end of statement:
Loop at Itab.
At end of character field name.
Sum.
Write: interger filed name.
Endat.
Endloop.
Sum
Creating total of interger field.
Collect
Creating subtotal and groups of the internal table.
Syntax of collect statement:
Data: begin of itab occurs 0,
c1,
c2 type i,
end of itab.
itab-c1 = 'a'.
itab-c2 = 10.
collect itab.
itab-c1 = 'a'.
itab-c2 = 10.
collect itab.
loop at itab.
write:/ itab-c1,
itab-c2.
endloop.
Insert
Inserting new lines into internal table.
Difference between Loop and Read statement
Loop Read statement
Read multiple rows of internal table Read single row of internal table
Check Internal table Empty or not
If itab[ ] is initial.
---
endif.
Select Statement
Syntax of Select Statement with Internal table
Select * from table name into table internal table. Body
Select * from table name into internal table-field name. Header line
Select * from table name into corresponding field of table internal table. Body
Select * from table name into corresponding field of internal table-field name. HL
Transporting
Syntax of transporting command
Overwrite the Internal table
Output of internal table
1 a
2 b
3 c
4 e
5 e
Transporting command
Itab-f2 = X.
Modify itab transporting f2 where f2 <> e.
After command output
1 X
2 X
3 X
4 E
5 E
Determine rows of internal table
Count the rows, size and occurs value of the internal table
SY-TFILL no of rows
SY-TOCCU current value of occurs clause
ST-TLENG length of a row in byte
Describe table internal table lines N(integer variable)
Copy one internal table to another internal table
Condition: Structure should be same of both internal table
Target internal table [ ] = Source internal table [ ].
Mover-corresponding Source internal table to Target internal table
If is useful then let me know
Regards,
Rajneesh Gupta