Skip to Content
avatar image
Former Member

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

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.
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • 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."

    Add comment
    10|10000 characters needed characters exceeded

  • 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.

    Add comment
    10|10000 characters needed characters exceeded