Professional Documents
Culture Documents
TABLE Types of Internal
TABLE Types of Internal
- logical structures of the objects used in
application development and shows how they are mapped to the relational
database in tables/views.
c
-
Domains:central object for describing the technical characteristics of an
attribute of an business objects .It describes length of data type for the
field.
c
- Indexes are described as a copy of a database table
. This data exists in sorted form. This sorting
form ease fast access to the field of the tables.
Pooled tables in the dictionary have a many-to-one relation
with the table in database. Table in the database has the different name as
in the dictionary.Pooled table are stored in table pool at the database
level.
i)check functions which check that user input is complete,
correct,and plausible. ii)Meaningful data selection. iii)central
authorization checks for database accesses. iv)good read access performance
while retaining the hierarchical data view determined by the application
logic.
i)If you donot specify a logical database in the program
attributes,the GET events never occur. ii)There is no ENDGET command,so the
code block associated with an event ends with the next event statement (such
as another GET or an END-OF-SELECTION).
Internal table is a dynamic sequential dataset in which all records have the
same data structure and a key
Internal tables are used for fetching large volume of data from the database,
storing in ABAP working memory line-by-line and processing within a program
- The line type may be any data type or another internal table.
Generally the data type will be a structure and each component of a structure
is a column in this local table.
# - Key is used to identify table rows. You may specify whether the key is
UNIQUE or NON-UNIQUE. As the name indicates UNIQUE key cannot contain
duplicate entries whereas NON-UNIQUE can.
$
"
Standard tables have a linear index ( numeric value assign to word ). 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.
$
"
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.
"#'$.,''./
c"6(.(!7("87'#'*
!
9:-:!9:6:
!952! 9:;222:
"($',"(.'
'-"(./%
1* '%
5* '%
'(./
"#''./%
<"#'
.0"4'$
!19!
!59!
==5
'(.
!19!
!59!
==0
'(.<
'(.
"($',"('$./"(.<"('+1
.. <"(.
c,"' !%!1%!5
'(..
6
"
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 7("87' 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. 6
.
"
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
Example: As long as your records has unique key(s), using hash table will
give you a huge performance gain when dealing with large dataset. assuming in
your case, 10000 record , and if the key is unique, use hash table. The main
use of hash tables is for looking up fixed information from a key. So if you
have a report that has personnel number and you want to display their name,
you could use a hash table.
Code:
'
$(,'
TYPES ITAB_SalesORD TYPE STANDARD TABLE OF SalesOrd WITH DEFAULT KEY.
$.,''
TYPES ITAB_SORD_St TYPE SORTED TABLE OF SalesOrd WITH UNIQUE KEY VBELN.
6$6''
TYPES ITAB_SalesOrd TYPE HASHED TABLE OF SalesOrd WITH UNIQUE KEY VBELN.
"
You can use the following statement to find the attributes of an Internal
Table at Runtime.
loop at itab.
read table lt_pernr with table key pernr = itab-pernr
into ls_pernr.
write: ls_pernr-ename, itab-data.
endloop.
c
Whereas work area is a variable declared with the TYPE of an internal table
or a database table. It can store only one record at a time. It is like a
structure declaration in C. You can refer individual columns in the work
area with the names.
If you declare an internal table with "WITH HEADER LINE" clause the internal
table itself acts as a work area. For example, your ITAB is a work area and
ITAB[] is the internal table.
If you are familiar with ORACLE PLSQL, work area is similar to %ROW_TYPE and
internal is similar to TABLE TYPE.
A work area is nothing more than a structure which serves as a header line
for an internal table. When you read an internal table (without header line)
the line which you read must be moved somewhere, it is moved into a work
area.
The area where this record is kept is called as work area for the internal
table. The area must have the same structure as that of internal table. An
internal table consists of a body and an optional header line.
Header line is a implicit work area for the internal table. It depends on how
the internal table is declared that the itab will have the header line or
not.
Work areas are used for processing data from n into internal table. as work
area is a structure which can hold only one record at a time i.e to be
inserted into internal table populated from internal table.
Work areas generally used for reusability purpose. i.e a internal table with
header line is only used for storing data from a single data base table where
as internal table without header line can be used in other internal table.
for this purpose we'll create a explicit work area for processing data.
e.g.
data: begin of itab occurs 10,
ab type c,
cd type i,
end of itab. " this table will have the header line.
data: wa_itab like itab. " explicit work area for itab
data: itab1 like itab occurs 10. " table is without header line.
The header line is a field string with the same structure as a row of the
body, but it can only hold a single row. It is a buffer used to hold each
record before it is added or each record as it is retrieved from the internal
table. It is the default work area for the internal table.
Sample code:
DATA : it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE INITIAL SIZE
10.
INITIALIZATION.
it_test-code = 300.
it_test-name = 'Ramesh'.
it_test-amount = 5500.
APPEND it_test.
wa-code = 207.
wa-name = 'Prem'.
wa-amount = 5000.
APPEND wa TO it_test.
it_test-code = 117.
it_test-name = 'James Bond'.
it_test-amount = 9900.
INSERT it_test INDEX 3.
it_test-code = 217.
it_test-name = 'Sivaraman'.
it_test-amount = 9900.
INSERT it_test INDEX 3.
it_test-code = 201.
it_test-name = 'Saravanan'.
it_test-amount = 1000.
APPEND it_test.
it_test-code = 210.
it_test-name = 'Shanmugam'.
it_test-amount = 6000.
APPEND it_test.
END-OF-SELECTION.
CLEAR : it_test-code, it_test-name.
WRITE : / 'this from end of selection'.
*&--------------------------------------------------------------------*
*& Form DISP1
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM disp1.
WINDOW STARTING AT 15 10
ENDING AT 80 15.
DO.
CLEAR chk1.
READ LINE sy-index FIELD VALUE chk1.
IF sy-subrc NE 0.
EXIT.
ELSE.
CHECK chk1 NE space.
WRITE : / it_test-code, it_test-name.
MODIFY CURRENT LINE :
FIELD VALUE chk1 FROM ' '
FIELD FORMAT chk1 INPUT OFF.
ENDIF.
ENDDO.
ENDFORM.
"DISP1
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ULINE.
SKIP.
SKIP.
WRITE : / 'Below from Get Cursor Field...'.
GET CURSOR FIELD fldname VALUE fldval.
CONDENSE fldname.
CONDENSE fldval.
WRITE : / 'You have clicked ', fldname, ' & its value is ', fldval.
*AT USER-COMMAND.
* CASE SY-UCOMM.
* WHEN 'STOP' OR 'CANCEL'.
* LEAVE TO SCREEN 0.
* WHEN 'TESTME'.
* PERFORM DISP1.
* ENDCASE.