Insert Data Into Hashed Table

REPORT zhashed_table .

types: begin of t_foo,
field1 type char2,
field2 type char2,
field3 type char2,
field4 type i,
end of t_foo.

data: lt_foo type HASHED TABLE OF t_foo
WITH UNIQUE KEY field1 field2 field3.

data: ls_foo like line of lt_foo.

FIELD-SYMBOLS: like LINE OF lt_foo.

* Must assign it to use it.
assign ls_foo to .

clear .
-field1 = 'AB'.
-field2 = 'CD'.
-field3 = 'EF'.
-field4 = '2'.
insert into table lt_foo.

clear .
-field1 = 'AB'.
-field2 = 'CD'.
-field3 = 'EF'.
-field4 = '2'.
insert into table lt_foo.
If sy-subrc ne 0.
write:/ ' this is the duplidate key'.
endif.


Serkan AKKAVAK
Computer Engineer
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com