‎2007 Jun 23 8:35 AM
1 ) give me brief explanation about internal tables and its types
2 ) what is the effect of defining work area while defining internal table.....
regards basavaraj
‎2007 Jun 23 3:31 PM
hi
just refer to the link below
http://www.sapmaterial.com/?gclid=CN322K28t4sCFQ-WbgodSGbK2g
hope it may help u.
regards
ravish
<b>plz dont forget to reward points if helpful</b>
‎2007 Jun 23 3:42 PM
Hello Basavraj,
An internal table is one of two structured data types in ABAP. It can contain any number of identically structured rows, with or without a header line.
The header line is similar to a structure and serves as the work area of the internal table. The data type of individual rows can be either elementary or structured.
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.
Fields of Internal Tables
SY-TABIX
Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.
SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
SY-TLENG
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the length of the lines in the relevant internal table.
SY-TOCCU
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the initial amount of memory allocated to the relevant internal table.
try this links....
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
Internal table declaration
Declaring internal tables is an essential part of writing ABAP code as this is where most of the data retrieved
from database tables will be stored. During the select statement you retrieve data from a database table into
an internal table (multiple rows) or a work area or header line (single row).
&----
*& Report ZTYPES *
*& *
&----
REPORT ZTYPES .
Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0, "itab with header line
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF tab_ekpo.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo. "work area (header line)
Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0, "old method
wa_datatab LIKE LINE OF tab_ekpo.
Build internal table and work area from existing internal table,
adding additional fields
TYPES: BEGIN OF t_repdata.
INCLUDE STRUCTURE tab_ekpo. "could include EKKO table itself!!
TYPES: bukrs TYPE ekpo-werks,
bstyp TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0, "itab
wa_repdata TYPE t_repdata. "work area (header line)
sy-tabix will give you the no of table entries in the table .... you can see the structure in the SE11 syst which has all the fields of the system ....
Thanks
Seshu
‎2007 Jun 25 6:34 AM
Hi!
Internal tables are of 4 types
1) Standard table
2) Sorted table
3) Hashed table
4) Index table
<u>Standard table</u>
Defines the table as a standard table. This will always strore the data into internal table in the sorting order on Key Field using Linear search. This means that the time taken for searching records would be based on no. of records we are reading from the database. You should use index operations to access standard tables.
Syntax:
data : itab type standard table of vbak.
<u>Sorted table</u>
Always defines the table in a sorted order. The records stored in this table will always be sorted using binary saerch on Key Field. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries. You can also access sorted tables by index operations.
Syntax:
data : itab type sorted table of dfkkop with unique key vkont.
(or)
data : itab type sorted table of dfkkop with non-unique key vkont.
<u>Hashed table</u>
Defines the table as one that is managed with an internal hash procedure. You can imagine a hashed table as a set, whose elements you can address using their unique key. Unlike standard and sorted tables, you cannot access hash tables using an index. All entries in the table must have a unique key. Access time using the key is constant, regardless of the number of table entries.
Syntax:
data : itab type hashed table of dfkkop with unique key vkont.
(or)
data : itab type hashed table of dfkkop with non-unique key vkont.
<u>Index table</u>
An index table is one that you can access using an index. Hashed tables are not index tables, and cannot therefore be passed to parameters defined as INDEX TABLE.
I think this will solve your problem.
Regards,
Venkat.
‎2007 Jun 25 8:57 AM
<b>Internal table declaration </b>
Declaring internal tables is an essential part of writing ABAP code as this is where most of the data retrieved from database tables will be stored. During the select statement you retrieve data from a database table into an internal table (multiple rows) or a work area or header line (single row).
REPORT ZTYPES .
* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0, "itab with header line
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF tab_ekpo.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo. "work area (header line)
* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0, "old method
wa_datatab LIKE LINE OF tab_ekpo.
* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
INCLUDE STRUCTURE tab_ekpo. "could include EKKO table itself!!
TYPES: bukrs TYPE ekpo-werks,
bstyp TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0, "itab
wa_repdata TYPE t_repdata. "work area (header line)
reward points if it is usefull ...
Girish