9/26/25, 12:16 AM Sorted Internal Table - LearnSapAbap
HOME ABOUT US CONTACT US
[Link]
DOWNLOAD
Download Free Trial Now
HOME BASICS STATEMENT CONTROL BREAK DATABASE QUERY ADVANCE ABAP DOWNLOAD APPLICATION
SUBSCRIBE
Sorted Internal Table LearnSapAbap
12:18 PM YouTube 5K
Sorted table is another kind of index table which has unique / non unique key. It also can be accessed via
index or key. For sorted table the key must be specified. The declaration is as follows:
DATA: it_mat TYPE SORTED TABLE OF ty_mat WITH UNIQUE KEY matnr,
it_mat TYPE SORTED TABLE OF ty_mat WITH NON-UNIQUE KEY matnr. GOOGLE TRANSLATE
Select Language ▼
Unique key means the MATNR (material no) will must be unique. If same material number is inserted then a run
time error will happen. However we can declare the sorted table with non unique key also. In this case same
material number can be entered but it will be sorted after entering the number. Here the sorted table behaves
similar to sorted standard table. We use INSERT statement to enter any records to the sorted table.
SEARCH THIS BLOG
Search
SLIDEBAR
Discover more SAP ERP SAP
ABAP Development for SAP HANA
Database ABAP for Hana
INSERT wa_mat INTO TABLE it_mat.
Here is an example of sorted table by using unique key concept.
REPORT FOLLOW US
zabap_gui.
* Declaring the local structure of internal table
TYPES: 3 0 2
5 4
BEGIN .
OF ty_tab, 4
item TYPE char10,
quantity TYPE i,
price TYPE
i,
END OF ty_tab.
SUBSCRIBE
* Declaring the Sorted internal table with non unique key
DATA: Subscribe via Email
itab TYPE Enter email address he Submit
SORTED TABLE OF ty_tab WITH
UNIQUE
KEY item,
wtab TYPE ty_tab.
* Entering records to each field POPULAR POSTS
wtab-item = 'Rice'. wtab-quantity = 2. wtab-price = 80.
Parallel Cursor in SAP
ABAP | Parallel cursor in
* Now one single row has been fulfilled with data
abap | Parallel cursor in
* Next inserting one single row data into the table
sap
INSERT wtab INTO
TABLE itab.
Extra Programs
[Link] 1/4
9/26/25, 12:16 AM Sorted Internal Table - LearnSapAbap
wtab-item = 'Suger'. wtab-quantity = 1. wtab-price = 90.
INSERT wtab INTO
TABLE itab.
wtab-item = 'Tea'. wtab-quantity = 1. wtab-price = 100.
Object Oriented ABAP -
INSERT wtab INTO TABLE itab.
Events
wtab-item = 'Rice'. wtab-quantity = 3. wtab-price = 150.
INSERT wtab INTO TABLE itab.
How to Display ALV table
as pop up screen | ALV
wtab-item = 'Horlicks'. wtab-quantity = 1. wtab-price = 200.
INSERT wtab INTO TABLE itab.
table | Display ALV output
table.
wtab-item = 'Suger'. wtab-quantity = 2. wtab-price = 70.
INSERT wtab INTO TABLE itab.
WRITE: /3 'Item',
13 'Quantity (KG)',
28 'Price (Rs)'.
WRITE / '=========================================='.
SKIP. " Skipping one single line PAGEVIEWS PAST WEEK
LOOP AT itab INTO wtab. 4 0 2 3
WRITE: /3 wtab-item,
12 wtab-quantity,
25 wtab-price.
ENDLOOP.
SKIP.
WRITE '=========================================='.
Since the key is unique the similar entries are ignored by the system.
Here is an example of sorted table by using non unique key concept.
REPORT zabap_gui.
* Declaring the local structure of internal table
TYPES:
BEGIN OF ty_tab,
item TYPE char10,
quantity TYPE i,
[Link] 2/4
9/26/25, 12:16 AM Sorted Internal Table - LearnSapAbap
price TYPE i,
END OF ty_tab.
* Declaring the Standard internal table with non unique key
DATA:
itab TYPE SORTED TABLE OF ty_tab WITH NON-UNIQUE KEY item,
wtab TYPE ty_tab.
* Entering records to each field
wtab-item = 'Rice'. wtab-quantity = 2. wtab-price = 80.
* Now one single row has been fulfilled with data
* Next inserting one single row data into the table
INSERT wtab INTO TABLE itab.
wtab-item = 'Suger'. wtab-quantity = 1. wtab-price = 90.
INSERT wtab INTO TABLE itab.
wtab-item = 'Tea'. wtab-quantity = 1. wtab-price = 100.
INSERT wtab INTO TABLE itab.
wtab-item = 'Rice'. wtab-quantity = 3. wtab-price = 150.
INSERT wtab INTO TABLE itab.
wtab-item = 'Horlicks'. wtab-quantity = 1. wtab-price = 200.
INSERT wtab INTO TABLE itab.
wtab-item = 'Suger'. wtab-quantity = 2. wtab-price = 70.
INSERT wtab INTO TABLE itab.
WRITE: /3 'Item',
13 'Quantity(KG)',
28 'Price(Rs)'.
WRITE / '=========================================='.
SKIP. " Skipping one single line
LOOP AT itab INTO wtab.
WRITE: /3 wtab-item,
12 wtab-quantity,
25 wtab-price.
ENDLOOP.
SKIP.
WRITE '=========================================='.
RELATED POSTS
PREVIOUS NEXT
Standard Internal Table Hashed Internal Table
[Link] 3/4
9/26/25, 12:16 AM Sorted Internal Table - LearnSapAbap
POST A COMMENT
No comments
To leave a comment, click the button below to sign in with Google.
SIGN IN WITH GOOGLE
Discover more SAP ERP SAP ABAP for Hana Database
ABAP Development for SAP HANA
RECENT POSTS POPULAR POSTS
ABAP CDS View With Input Parallel Cursor in SAP ABAP |
parameters | Parameters in CDS Parallel cursor in abap | Parallel
Views | CDS View with Parameters cursor in sap
May 01, 2020
Extra Programs
ABAP For Iteration with Where
condition | For Statement with
Where clause | For syntax with
Where condition
April 25, 2020
Object Oriented ABAP - Events
ABAP 7.40 For Iteration Expression |
For Iteration in SAP ABAP | For
Statement in SAP ABAP 7.40 | For
syntax in ABAP
April 19, 2020
CREATED BY SORATEMPLATES | DISTRIBUTED BY GOOYAABI TEMPLATES
[Link] 4/4