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: 

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

Former Member
0 Kudos
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 
	WITH UNIQUE KEY 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.
1 ACCEPTED SOLUTION

horst_keller
Product and Topic Expert
Product and Topic Expert

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

https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abapinto_clause.ht...

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

3 REPLIES 3

horst_keller
Product and Topic Expert
Product and Topic Expert

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

https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abapinto_clause.ht...

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

Sandra_Rossi
Active Contributor
0 Kudos

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

Sandra_Rossi
Active Contributor
0 Kudos

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

If you read its documentation (https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abenwhere_logexp_i...), 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.