2010 May 03 11:05 AM
Hi All,
In our developement system,I am facing an error SAPSQL_ARRAY_INSERT_DUPREC in one of the Z program , which when ran in backgrond in goes to dump (job gets canceled) & the dump states the above error.
In my program I am just uploading the data to a custom table, the dump points towards the INSERT statement in the below code.
Later, assuming that there might be duplicate entries getting populated, I used DELETE ADJACENT DUPLICATES FROM it_toolkit COMPARING ALL FIELDS statement to avoid duplicate entries & then used INSERT statement as below. It worked. But later again after two days the same error occured.
The surprising thing is that, the job gets canelled but at the same time custom table gets updated also. The code as follows :-
IF p_sys_id = c_ck04 OR
p_sys_id = c_ck02.
IF c_cntl_complt = c_2 AND ztsifcntl-btchstatus = c_a.
SORT it_toolkit BY sl_no.
DELETE ADJACENT DUPLICATES
FROM it_toolkit
COMPARING ALL FIELDS.
INSERT zmm_toolkit FROM TABLE it_toolkit.
COMMIT WORK.
ENDIF.
ENDIF.
Could anybody shed light on this ?
Regards
Abhii
Edited by: Abhii on May 3, 2010 12:06 PM
2010 May 03 11:11 AM
Problem is related to the insertion of duplicate records. Use MODIFY statement instead of INSERT statement in your code
INSERT zmm_toolkit FROM TABLE it_toolkit. "Change to MODIFY
Regards
Vinod
2010 May 03 11:11 AM
Problem is related to the insertion of duplicate records. Use MODIFY statement instead of INSERT statement in your code
INSERT zmm_toolkit FROM TABLE it_toolkit. "Change to MODIFY
Regards
Vinod
2010 May 03 11:12 AM
Use
sort it_toolkit by the key fields.
DELETE ADJACENT DUPLICATES
FROM it_toolkit
COMPARING ALL FIELDS. "Instead of all fields specify the key fields of the table
modify zmm_toolkit FROM TABLE it_toolkit.
Edited by: Keshav.T on May 3, 2010 3:42 PM
2010 May 03 11:12 AM
Hi Abhii,
Check the primary keys of The Ztable once.SORT as per these keys.
In the SORT statement you have sorted only by sl_no.
Not sure whether this field is the only primary key or not.Please check once.
While using DELETE ADJACENT DUPLICATES use primary key fields for deletion(Not all fields.)
I feel its better to use MODIFY statement which updates the table if the record doesnot exist.
Regards,
Lakshman.
2010 May 03 11:13 AM
Your internal table may be contains a set of primary key values , which are already present in the table. Now, in database there can't be two rows with same primary key values.
Delete adjacent duplicates will not help as it will only delete duplicate entries from your internal table. But it won't check whether any internal table entry is already there in database with same primary key values.
You can check the table, whether any entries exist with the same value of primary keys before the insert, otherwise you can use MODIFY/UPDATE statements.