banner ads

Hashed Internal Table

Hashed table is not an index table. It follows the hash algorithm. Here the declaration of key is must and also the key must be unique. Hence no duplicate entry will be in the hashed table. We can access records only by the key. Similar to sorted tables data can be inserted here by INSERT statement. Hashed tables are used when the internal table contains huge volume of data.


REPORT  zabap_gui.

* Declaring the local structure of internal table
TYPES:
      BEGIN OF ty_tab,
        item     TYPE char10,
        quantity TYPE i,
        price    TYPE i,
      END OF ty_tab.

* Declaring the Hashed internal table with non unique key
DATA:
      itab TYPE HASHED TABLE OF ty_tab WITH 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 '=========================================='.

Due to uniqueness of the key similar entries are ignored.















Hashed table can be sorted. If we sort this table it will be as follows.


3 comments:

  1. Hence no duplicate entry will be in the hashed table. We can access records only by the key. Similar to sorted tables data can be inserted here by INSERT statement. Hashed tables are used when the internal table contains huge volume of data. 250-437 dumps

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. A humility board screens the front edge and some of the time the sides of the desk to forestall seeing under.
    http://ergodesks.co/

    ReplyDelete