‎2010 Sep 01 11:32 AM
Hi SAP Guru's
Can u please help me out with the solution
Short text
The ABAP/4 Open SQL array insert results in duplicate database records.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
in
procedure "HRPY_GROUPING_CHANGE_PAYROLL" "(FUNCTION)", nor was it propagated by
a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
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.)
Missing RAISING Clause in Interface
Program SAPLHRPAY99_RGDIR_WPBP
Include LHRPAY99_RGDIR_WPBPU07
Row 1
Module type (FUNCTION)
Module Name HRPY_GROUPING_CHANGE_PAYROLL
Trigger Location of Exception
Program SAPLHRPAY99_RGDIR_WPBP
33 * the solution is:
34 * for an existing SEQNR delete everything in HRPY_GROUPING and then
35 * insert the new lines.
36
37 LOOP AT grouping where pernr = employeenumber.
38 read table before_image_rgdir with key seqnr = grouping-seqnr.
39 IF sy-subrc NE 0. "no entry for this seqnr --> new result
40 move-corresponding grouping to insert_grouping.
41 append insert_grouping.
42 else. "seqnr already exists
43 if grouping-seqnr ne delete_rgdir-seqnr. "each seqnr only once
44 delete_rgdir-pernr = employeenumber.
45 delete_rgdir-seqnr = grouping-seqnr.
46 append delete_rgdir.
47 endif.
48 move-corresponding grouping to insert_grouping.
49 append insert_grouping.
50 endif.
51 ENDLOOP.
52 ENDIF.
53
54 * real delete and insert************************************************
55 if test = space.
56
57 loop at delete_rgdir.
58 delete from hrpy_grouping where pernr = delete_rgdir-pernr and
59 seqnr = delete_rgdir-seqnr.
60 endloop.
61
62 if not insert_grouping[] is initial.
>>> insert hrpy_grouping from table insert_grouping.
64 endif.
65 endif.
66 ENDFUNCTION.
Include LHRPAY99_RGDIR_WPBPU07
Row 63
Module type (FUNCTION)
Module Name HRPY_GROUPING_CHANGE_PAYROLL
‎2010 Sep 01 11:42 AM
Hi,
you might check SAP Note [957989|https://service.sap.com/sap/support/notes/957989] "OCWB+CE: Dump SAPSQL_ARRAY_INSERT_DUPREC".
Best regards,
Andreas