Skip to Content

Getting dump ITAB DUPLICATE KEY when writing SELECT query on PA0001 into a hashed internal table ?

Jul 14, 2017 at 02:47 PM


avatar image
Former Member
TYPES: BEGIN OF typ_pernr,
	pernr LIKE pa0001-pernr,
	ename LIKE pa0001-ename,
	END OF typ_pernr.

DATA: BEGIN OF lt_partners OCCURS 0,
	pernr LIKE pa0001-pernr,
	END OF lt_partners.

DATA: it_partners TYPE HASHED TABLE OF typ_pernr 

*p_date is a parameter to check date
*Getting dump in this select query 
*In the table, there are multiple records that satisfy the date 
*condition for the same pernr. But, as I know, if duplicate entries 
*are attempted to insert in hashed table then it considers only first *and ignores the remaining entries

SELECT pernr, ename FROM pa0001
	INTO TABLE it_partners
	FOR ALL ENTRIES IN lt_partners
	WHERE pernr EQ lt_partners-pernr
	AND endda GE p_date.
10 |10000 characters needed characters left characters exceeded

Please reformat your post so that your text is outside the code !

* Please Login or Register to Answer, Follow or Comment.

2 Answers

Horst Keller
Jul 14, 2017 at 03:09 PM

Works as documented. It is not "as you know". A simple F1 on INTO would have helped.

"If there is a conflict with an existing unique table key, a non-handleable exception is raised like in the case of INSERT LINES OF."

10 |10000 characters needed characters left characters exceeded
Sandra Rossi Jul 14, 2017 at 06:38 PM

Maybe your assumption "as I know if duplicate entries ..." refer in fact to the behavior of FOR ALL ENTRIES.

If you read its documentation (, it states: "With respect to duplicate rows in the results set, the addition FOR ALL ENTRIES has the same effect as when the addition DISTINCT is specified in the definition of the selection set."

The term "duplicate rows" means the entire rows, so in your case it's PERNR + ENAME. As your hashed table has unique key PERNR, you'll get duplicate keys if you have the same personnel number with 2 different names. To be sure, change temporarily your internal table to the standard table type, and using the debugger, check whether there are two lines with the same personnel number.

10 |10000 characters needed characters left characters exceeded