Skip to Content
-5

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

Jul 14, 2017 at 02:47 PM

262

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

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

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

2 Answers

Horst Keller
Jul 14, 2017 at 03:09 PM
4

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

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

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

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_itab.htm), 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.

Share
10 |10000 characters needed characters left characters exceeded