Posts

Showing posts with the label hashed table in abap example

SAP ABAP - Hashed Internal Table (Table's Key Access) With Example.

Image
Submitted By: Shilpa Gunjan (L&T Infotech) (Hashed Table performance when the key used is table’s key) Now the table SKB1 has a primary key which is a combination of BUKRS (Company Code) & SAKNR (G/L Account Number). When we make a hashed table with key same as the table key, the performance improves drastically as shown. REPORT z_internal_table_performance. *Sorted Internal table (Performance) PARAMETERS p_ktopl LIKE t001-ktopl. PARAMETERS p_bukrs LIKE skb1-bukrs. PARAMETERS p_saknr LIKE skb1-saknr. DATA: v_time1 TYPE i, v_time2 TYPE i, v_time_f TYPE i. DATA: st_skb1 TYPE STANDARD TABLE OF skb1, so_skb1 TYPE SORTED TABLE OF skb1 WITH UNIQUE KEY bukrs saknr, ha_skb1 TYPE HASHED TABLE OF skb1 WITH UNIQUE KEY bukrs saknr, wa_skb1 TYPE skb1. SELECT * FROM skb1 INTO TABLE st_skb1. WRITE: /'No.Of Entries Fetched:', sy-dbcnt. ULINE. so_skb1 = st_skb1. ha_skb1 = so_skb1. *********STANDARD TABLE************** CLEAR: wa_skb1, v_time1, v...

SAP ABAP - Hashed Internal Table (Partial Key Access) With Example.

Image
Submitted By: Shilpa Gunjan (L&T Infotech) Comparison between Standard, Sorted & Hashed internal tables & it's performance. (Hashed Table performance when the key used is table’s partial key) REPORT z_internal_table_performance. *Internal table (Performance) PARAMETERS p_ktopl LIKE t001-ktopl. PARAMETERS p_bukrs LIKE skb1-bukrs. PARAMETERS p_saknr LIKE skb1-saknr. DATA: v_time1 TYPE i, v_time2 TYPE i, v_time_f TYPE i. DATA: st_skb1  TYPE STANDARD TABLE  OF skb1, so_skb1  TYPE   SORTED TABLE OF skb1 WITH UNIQUE KEY  bukrs saknr, ha_skb1  TYPE HASHED TABLE OF skb1 WITH UNIQUE KEY  bukrs saknr, wa_skb1 TYPE skb1. SELECT * FROM skb1 INTO TABLE st_skb1. WRITE: /'No.Of Entries Fetched:', sy-dbcnt. ULINE. so_skb1 = st_skb1. ha_skb1 = so_skb1. *********STANDARD TABLE************** CLEAR: wa_skb1, v_time1, v_time2, v_time_f. GET RUN TIME FIELD v_time1. READ TABLE st_skb1 INTO wa_skb1 WITH KEY bukrs = p_bukrs. ...

SAP ABAP - Hashed Internal Table (Non-Index Table) With Example.

Submitted By: Shilpa Gunjan (L&T Infotech) - Hashed Internal Tables are the most appropriate type of table where the main operation or access is via key and not index. Hashed tables cannot be accessed via index. - Like database tables, hashed tables too have a unique key . Hashed tables cannot have a NON-Unique key. The key has to be Unique and hence one must specify UNIQUE keyword in the table definition . - The response time for key access remain constant, regardless of the number of table entries because the access is carried out via a hash algorithm. - If a hashed table is accessed with a key that is different to the unique table key, the table is handled like a standard table and searched linearly according to the entries. Same applies for partial key also. - Hashed table should only be used where the unique key is the only type of access, particularly if there is a need to process very large table. - Using hashed internal tables the 100,000th record...