Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Duplicate records error when trying to update table from internal table

Former Member
0 Likes
608

Hi,

I have an internal table declared as follows:

DATA: itab2 TYPE STANDARD TABLE OF fmusfga with header line.

The key of FMUSFGA table is RCLNT (which does not appear populated in SE16N) and GL_SIRID.

The internal table is assigned values using the "split" command as follows:

Loop at itab.

split itab-rec at '|' into gv_blank2

itab2-gl_sirid

itab2-refdocnr

gv_date "itab2-budat

itab2-racct

itab2-usnam

gv_year "itab2-ryear

gv_per "itab2-poper

itab2-rfistl

itab2-rfund

itab2-belnr

gv_hsl

itab2-fmcmmtstr_9

itab2-sgtxt

gv_blank.

I have printed out "itab2-gl_sirid" in the program and the values are being assigned correctly to the internal table, e.g.:

000000002947872487

000000002947872488

000000002947884656

Also, I have individually checked each GL_SIRID value in FMUSFGA in SE16N, and there are NO records in the database that have those GL_SIRID.

The code to update the table is:

INSERT FMUSFGA FROM TABLE itab2.

COMMIT WORK AND WAIT.

And yet I get the following error:

SAPSQL_ARRAY_INSERT_DUPREC

Why?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
556

try this way..

if you are trying to insert fron table if one records fails to insert the commit work will not done so rest of the records will not inserted..


 Loop at itab.
 split itab-rec at '|' into gv_blank2
                            itab2-gl_sirid
                            itab2-refdocnr
                            gv_date    "itab2-budat
                            itab2-racct
                            itab2-usnam
                            gv_year      "itab2-ryear
                            gv_per       "itab2-poper
                            itab2-rfistl
                           itab2-rfund
                            itab2-belnr
                            gv_hsl
                           itab2-fmcmmtstr_9
                            itab2-sgtxt
                            gv_blank.
 "write this inside the loop
  INSERT FMUSFGA FROM itab2.   "remove table try to insert from work area or lin item
if sy-subrc = 0.
 COMMIT WORK AND WAIT.
else.
roll back.
endif.


ENDLoop.       

Hi,

I have an internal table declared as follows:

DATA: itab2 TYPE STANDARD TABLE OF fmusfga with header line.

The key of FMUSFGA table is RCLNT (which does not appear populated in SE16N) and GL_SIRID.

The internal table is assigned values using the "split" command as follows:

Loop at itab.

split itab-rec at '|' into gv_blank2

itab2-gl_sirid

itab2-refdocnr

gv_date "itab2-budat

itab2-racct

itab2-usnam

gv_year "itab2-ryear

gv_per "itab2-poper

itab2-rfistl

itab2-rfund

itab2-belnr

gv_hsl

itab2-fmcmmtstr_9

itab2-sgtxt

gv_blank.

I have printed out "itab2-gl_sirid" in the program and the values are being assigned correctly to the internal table, e.g.:

000000002947872487

000000002947872488

000000002947884656

Also, I have individually checked each GL_SIRID value in FMUSFGA in SE16N, and there are NO records in the database that have those GL_SIRID.

The code to update the table is:

INSERT FMUSFGA FROM TABLE itab2.

COMMIT WORK AND WAIT.

And yet I get the following error:

SAPSQL_ARRAY_INSERT_DUPREC

Why?

2 REPLIES 2
Read only

Former Member
0 Likes
557

try this way..

if you are trying to insert fron table if one records fails to insert the commit work will not done so rest of the records will not inserted..


 Loop at itab.
 split itab-rec at '|' into gv_blank2
                            itab2-gl_sirid
                            itab2-refdocnr
                            gv_date    "itab2-budat
                            itab2-racct
                            itab2-usnam
                            gv_year      "itab2-ryear
                            gv_per       "itab2-poper
                            itab2-rfistl
                           itab2-rfund
                            itab2-belnr
                            gv_hsl
                           itab2-fmcmmtstr_9
                            itab2-sgtxt
                            gv_blank.
 "write this inside the loop
  INSERT FMUSFGA FROM itab2.   "remove table try to insert from work area or lin item
if sy-subrc = 0.
 COMMIT WORK AND WAIT.
else.
roll back.
endif.


ENDLoop.       

Read only

Former Member
0 Likes
556

Have you checked to see if there are duplicate GL_SIRID in the file or internal table?

Rob