You are on page 1of 9

c 



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

Data Element: It is used to describe description the field. Data element


describes how a field can be displayed to end-user.

c     - A relationship which can be defined


between tables and must be explicitly defined at field level. Foreign keys
are used to ensure the   
.

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.

    


 
-
   Transparent tables in the dictionary has a one-to-one
relation with the table in database. Table in the database has the same name
as in the dictionary. Transparent table holds application data.


 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.

c    


c   
 
!
 
  
- To read data from a database tables we use logical
database. A logical database provides read-only access to a group of related
tables to an ABAP/4 program.


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

"  are local tables.

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.

 - Table type specifies the behavior of Internal table while


accessing the individual entries. There are three types of table.

$

" 

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.

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.  

%
 & '()
*  
 
%


    
&"('+
      
). 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 &"(,*), the response time is in logarithmic
relation to the number of table entries.

$ 
" 

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.

        



   

   You fill the table using the


&"($',) statement, according to the sort sequence defined in the table key.
Table entries that do not fit are recognized 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   .
Sorted tables are appropriate for partially sequential processing in a LOOP,
as long as the WHERE condition contains the beginning of the table key.
'-"(./%

&0)* ' %
&12)* ' %
* '%
 * ''3"4Œ$5%
'(./

Œ"#'$.,'Œ'./
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

i) Standard Internal Tables


ii)Sorted Internal Tables

So Both Standard and Sorted Internal Tables Can be accessed


by Indexes. Whereas Hashed Internal Tables Can be accessed
By Only Key Fields. For Hashed Tables System automatically
maintain a Hash Algorithm to retrieve the records with one
time hit. For sorted Tables system automatically uses Binary
Search to retrieve the records. For Standard Tables System
Follows Linear Search.

sorted table and Hash table are table types of internal


table.
Sorted internal table requires index and key. it retrieves
data based on index or key.

Hashed internal tables requires only unique key. they dont


need indexes. it retrieves data by unique key. key is
mandatory.
Hashed table is useful when your have to work with very big internal table
and to read it with
"READ TABLE WITH KEY ..."

Definition of a Hashed Table:


"Defines the table as one that is managed with an internal hash procedure.
è  

    
        

  . Unlike standard and sorted tables, you cannot access hash
tables using an index.    
   
   .

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: BEGIN OF SalesOrd,


VBELN LIKE VBAK-VBELN,
KUNNR LIKE KNA1-KUNNR,
MATNR LIKE MARA-MATNR,
END OF SalesOrd.

$(,Œ'
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.


 " 

Appending a Single Line

To add a line to an index table, use the statement:


APPEND <line> TO <itab>.

$ " 

Internal Tables are sorted as follows.

SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].

  " 

You can use the following statement to find the attributes of an Internal
Table at Runtime.

DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].

types: begin of typ_pernr,


pernr like pa0001-pernr,
ename like pa0001-ename,
end of typ_pernr.
data: ls_pernr type typ_pernr,
lt_pernr type hashed table of typ_pernr with unique key pernr.

select pernr ename into table lt_pernr from pa0001.

loop at itab.
read table lt_pernr with table key pernr = itab-pernr
into ls_pernr.
write: ls_pernr-ename, itab-data.
endloop.

c  
   
  

 
  

Internal table is a temporary two dimensional memory structure similar to


database table. We can store multiple records in the internal table and also
using record pointers we can do the activities such as reading, appending,
deleting, modifying etc.

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.

While adding or retrieving records to / from internal table we have to keep


the record temporarily.

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:

TYPES : BEGIN OF ty_test,


code TYPE i,
name(10) TYPE c,
amount TYPE p DECIMALS 2,
END OF ty_test.

DATA : it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE INITIAL SIZE
10.

DATA : wa TYPE ty_test,


chk1 TYPE c,
fldname(30), fldval(50).

*set pf-status 'PF01'.


*set titlebar 'PF01'.
*

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.

WRITE : / 'Loop Display ( Appended rows ) :-'.


LOOP AT it_test.
WRITE : / chk1 AS CHECKBOX,
sy-tabix, sy-vline, it_test-code, it_test-name, it_test-amount.
HIDE : it_test-code, it_test-name.
ENDLOOP.
SKIP.

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

***line double click ****


AT LINE-SELECTION.
CHECK sy-lsind = 1.
WINDOW STARTING AT 5 4
ENDING AT 85 20.
WRITE: / 'THE USER DOUBLE-CLICKED A LINE IN THE REPORT'.
WRITE: / sy-lisel.
WRITE : / 'Sometime ',it_test-name, ' is good '.
WRITE : / 'Sometime ',it_test-name, ' is bad '.
WRITE : / 'Sometime ',it_test-name, ' is rich '.
WRITE : / 'Sometime ',it_test-name, ' is poor '.
WRITE : / 'Who knows, who is ',it_test-name, ' ? '.
WRITE : /, / 'we can also use this in SELECT statement'.
CLEAR : it_test-code, it_test-name.

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

***function key press F6 ****


AT PF06.
PERFORM disp1.

*AT USER-COMMAND.
* CASE SY-UCOMM.
* WHEN 'STOP' OR 'CANCEL'.
* LEAVE TO SCREEN 0.
* WHEN 'TESTME'.
* PERFORM DISP1.
* ENDCASE.

You might also like