07-14-2017 3:47 PM
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.
07-14-2017 4: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."
07-14-2017 4: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."
07-14-2017 7:16 PM
Please reformat your post so that your text is outside the code !
07-14-2017 7: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 (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.