2015 Nov 27 9:49 AM
Hi Experts,
I wanted to catch one SQL exception "SAPSQL_ARRAY_INSERT_DUPREC". I am in 4.6C system and there is no 'try' statement there. I read from documentation that in 4.6c we can catch exceptions using statement. . CATCH SYSTEM-EXCEPTIONS . But I am not finding the error id for SQL errors in 4.6.
B.R.
2015 Nov 27 10:00 AM
Hi,
isn't there an option in the INSERT statement to specify ACCEPTING DUPLICATE KEYS
regards
Fred
Hi Experts,
I wanted to catch one SQL exception "SAPSQL_ARRAY_INSERT_DUPREC". I am in 4.6C system and there is no 'try' statement there. I read from documentation that in 4.6c we can catch exceptions using statement. . CATCH SYSTEM-EXCEPTIONS . But I am not finding the error id for SQL errors in 4.6.
B.R.
2015 Nov 27 10:00 AM
Hi,
isn't there an option in the INSERT statement to specify ACCEPTING DUPLICATE KEYS
regards
Fred
2015 Nov 27 10:04 AM
I do not want duplicate keys. I need to raise an exception and message in case of duplicate record.
B.R.
2015 Nov 27 12:44 PM
ACCEPTING DUPLICATE KEYS does not insert duplicate records and does tell you if there were duplicates. Please read the ABAP help.
2015 Nov 27 2:03 PM
SELECT before inserting. If sy-subrc <> 0, INSERT; otherwise exception.
Rob
2015 Nov 27 2:30 PM
Yes that's the same solution I thought . I think there is no other standard exception help in 4.6.
2015 Nov 27 12:11 PM
What does DUMP says? I am afraid that this is not catchable exception.
I guess it says this is not it? 🙂
Error analysis
If you use an ABAP/4 Open SQL array insert to insert a record in
the database and that record already exists with the same key,
this results in a termination.
(With an ABAP/4 Open SQL single record insert in the same error
situation, processing does not terminate, but SY-SUBRC is set to 4.)
How to correct the error
Use an ABAP/4 Open SQL array insert only if you are sure that none of
the records passed already exists in the database.
(in later ABAP/SAP versions it can be catched via CX_SY_OPEN_SQL_DB exception class)