iSU ABAP Level 1 Internal Tables[1]
-
Upload
andreealiviana -
Category
Documents
-
view
244 -
download
0
Transcript of iSU ABAP Level 1 Internal Tables[1]
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
1/40
1 iSU
INTERNAL TABLES
Powered ByiGATE SAP University
Making SAP Simple
~ Madhusudan
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
2/40
2 iSU
INTERNAL TABLES
These internal tables can be created as a
replica of data base table, using some or all
fields of one table or more tables.
These internal tables are created only during
run time. No memory is reserved.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
3/40
3 iSU
Why we need inttables?
Long Life data is stored in database tables. When we are
directly modifying data, there is every possibility that wemay loose data by accident, which we can not afford to doso. As such we need some intermediate tables to do some
operations. Up on satisfactory results, we can modifydatabase table
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
4/40
4 iSU
Types of internal tables
Basically there are 2 types of Internal tables.
Internal tables with header line.
Internal tables without header line.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
5/40
5 iSU
Internal tables with header line
When you create internal table with header
line, a default work area is created.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
6/40
6 iSU
Internal table with out header line
In this case, we need to create explicit work
area to work with it. When we need to nest the tables with in
tables, we need to use this type of internal table.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
7/40
7 iSU
Steps in creating internal tables
There are 3 steps involved in creating Internal
tables.
Declaration of Internal table.
Populating Internal table.
Processing Internal table.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
8/40
8 iSU
Declaration of internal table
Declaring table type
1. Data dictionary
2. Using TYPES key word
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
9/40
9 iSU
Using TYPES key word
TYPES: Begin of ,.
End of . First
DATA: TYPE OF
WITH {UNIQUE|NON-UNIQUE} KEY ]
[INITIAL SIZE ]
[WITH HEADER LINE].
Second
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
10/40
10 iSU
TABKIND ( TABLE KIND)
1. STANDARD TABLE
2. SORTED TABLE
3. HASHED TABLE
4. INDEX TABLE
5. ANY TABLE
Which TABKIND to choose depends on how you are accessing the
Entries in the internal table.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
11/40
11 iSU
STANDARD TABLE
This table type is most appropriate when you intendto address the table entries using the index.
Key access to the standard table uses linear search.
This means that the time required for a search is inlinear relation to the number of table entries.
You should use index operations to access standardtables.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
12/40
12 iSU
SORTED TABLE
Defines the table as one that is always savedcorrectly sorted.
Key access to a sorted table uses a binary key.
You can also access sorted tables by indexoperations.
The time required for a search is in logarithmicalrelation to the number of table entries.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
13/40
13 iSU
HASHED TABLE
Defines the table as one that is managed with aninternal hash procedure.
You can imagine a hashed table as a set, whoseelements you can address using their unique key.
Unlike standard and sorted tables, you cannot access
hash tables using an index.
Access time using the key is constant, regardless ofthe number of table entries.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
14/40
14 iSU
INDEX TABLES
Standard and sorted tables belong to the generic classindex tables.
An index table is one that you can access using an index.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
15/40
15 iSU
ANY TABLE
The set of permitted operations for a table with type ANYTABLE consists of the intersection of all permittedoperations for STANDARD, SORTED and HASHED
TABLES, and so is identical to the set of operationspermitted for hashed tables.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
16/40
16 iSU
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
17/40
17 iSU
LINETYP ( LINE TYPE)
The line type of an internal table can be any ABAP datatype (including another internal table).
Line type gives the columns required for the internal table.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
18/40
18 iSU
Key
The key is used to identify lines in the table.
There are two possible keys for an internal table
1. The default key
2 User-defined key.
You can specify that the key should by
UNIQUE or NON-UNIQUE.
If the key is unique, the internal table may not containduplicate entries. The uniqueness of the key dependspartly on the table type.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
19/40
19 iSU
Populating internal tables
Selecting the fields from the standard table(s) and transferring them tothe internal table created.
For this we use SELECT STATEMENTS.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
20/40
20 iSU
PROCESSING INTERNAL TABLES
Processing of internal table includes:
Write
Read
Insert Modify
Delete
Collect
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
21/40
21 iSU
PROCESSING INTERNAL TABLES CONTD
Other operations like..
Clear
Refresh
Free
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
22/40
22 iSU
Write
loop at itab < where carried = LH >.
Write:/ itab-carrid,itab-connid,itab-fldate.
endloop.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
23/40
23 iSU
Loop At...
Carrid Connid FldateAA
AA
DL
0017
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998AL
11/29/1998
Internal Table
SCREEN
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
24/40
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
25/40
25 iSU
Read Table
Carrid Connid FldateAA
AA
DL
0017
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998AL
11/29/1998
AA 0017 10/29/1998
Internal Table
Header line
Body
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
26/40
26 iSU
Insert
itab-carrid = MN.
itab-connid = 1111.
insert itab index 3.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
27/40
27 iSU
Insert table
Carrid Connid Fldate
AA
AA
DL
0017
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998AL
11/29/1998
Header line
Body
Internal Table
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
28/40
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
29/40
29 iSU
Modify
Header line Header line
Internal Table Internal Table
Modify
Carrid Connid Fldate
TABLE: SFLIGHT
AA
AA
ALDL
0017
0026
05551699
10/29/1998
11/26/1998
11/21/1998
11/29/1998
Carrid Connid Fldate
AA 0017 AA
AA
AL
DL
0050
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998
11/29/1998
AA 0017 10/29/1998 AA 0050 10/29/1998(change)
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
30/40
30 iSU
Delete
delete itab index 3.
OR
delete from itab where carrid = LH.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
31/40
31 iSU
Delete
Header line Header line
Internal Table Internal Table
Modify
Carrid Connid Fldate
TABLE: SFLIGHT
AA 0017
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998
11/29/1998
Carrid Connid Fldate
AA
AA
AL
DL
0017
AA
AL
DL
0026
0555
1699
11/26/1998
11/21/1998
11/29/1998
AA 0017 10/29/1998 (delete) 10/29/19980017AA
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
32/40
32 iSU
Initializing internal table
clear itab. : clears header of int table.
clear itab [ ]. : clears body.
refresh itab. : remove contents.
free itab : deallocates memory associated with int table.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
33/40
33 iSU
Carrid Connid Fldate
AA
AA
DL
0017
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998AL
11/29/1998
CLEAR
REFRESH
Clear - Refresh
Internal Table
Header line
Body
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
34/40
34 iSU
Sorting of internal table
sort itab.
This command will sort internal table on all
non-numeric fileds in ascending
order.
sort itab by carrid.
sort itab by carrid descending.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
35/40
35 iSU
Sort
Header line Header line
Database TableInternal Table
Body Body
Move
Appen
d
Carrid Connid Fldate Carrid Connid Fldate
TABLE: SFLIGHT
DL
AA
AL
AA
1699
0026
0555
0017 10/29/1998
11/26/1998
11/21/1998
11/29/1998 AA
AA
AL
DL
0017
0026
0555
1699
10/29/1998
11/26/1998
11/21/1998
11/29/1998
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
36/40
36 iSU
Collect itab
If non numeric fields are same, then numeric fields will be added byusing this command.
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
37/40
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
38/40
38 iSU
Questions???
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
39/40
39 iSU
Please complete the feed back form which will be sent across and sendit back to [email protected].
iGATE SAP UniversityMaking SAP Simple
THANKS!
-
8/3/2019 iSU ABAP Level 1 Internal Tables[1]
40/40
40 iSU
KEY CONTACTS:
Presenter : Madhusudan Rao Budati
iSU Team Details :
Pradeep Kumar Reddy Dinesh [email protected] [email protected]
Aswani Kumar Nune Madhusudan Rao Budati