Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using HASH TABLES

Former Member
0 Kudos

Im trying to use hash table in a program but Im gettin an error I cant understand...

DATA gt_kna1 TYPE HASHED TABLE OF kna1 WITH UNIQUE KEY kunnr.

SELECT kunnr INTO TABLE gt_kna1

FROM kna1.

Im gettin this error:

An entry was to be entered into the table "\PROGRAM=ZTABLA_HASH\DATA=GT_KNA1" (which should havehad a unique table key (UNIQUE KEY)).

However, there already existed a line with an identical key.

But this is impossible, the field kunnr is key in table kna1.

Does Anybody know why Im gettin this dump?

Regards

2 REPLIES 2

Former Member
0 Kudos

Hi,

Use this code now it will not go dump.



DATA gt_kna1 TYPE HASHED TABLE OF kna1 WITH UNIQUE KEY kunnr.
SELECT kunnr INTO corresponding fields of TABLE gt_kna1
FROM kna1.

Regards and Best wishes.

former_member194669
Active Contributor
0 Kudos

Try this way


TYPES: BEGIN OF TY_KUNNR,
         KUNNR  LIKE KNA1-KUNNR.
TYPES: END   OF TY_KUNNR.
DATA:  IT_KUNNR  TYPE  HASHED TABLE OF TY_KUNNR  WITH UNIQUE KEY KUNNR.
SELECT KUNNR INTO TABLE IT_KUNNR
FROM KNA1