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

Insert statement is returning sy-subrc 4

Former Member
11,806

I have genereated a table maintenance for a custom table and maintaining values using the table maintenance.

The below code is quto generated.

INSERT ZCSC_EAP_BTI .

When I check in debug it returns sy-subrc = 4. But the values are not in the table.

What can be issue.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
5,073

<b>Insert (into database) is valid in this format, but obsolete</b>

Read the ABAP help for the keyword INSERT, and you'll see that sy-subrc = 4 means:

<i>At least one row could not be inserted, because the database table already contains a row with the same primary key or a unique secondary index.</i>

You should be able to use UPDATE rather than INSERT. Or just use MODIFY.

matt

<b>Insert (into database) is valid in this format, but obsolete</b>

Read the ABAP help for the keyword INSERT, and you'll see that sy-subrc = 4 means:

<i>At least one row could not be inserted, because the database table already contains a row with the same primary key or a unique secondary index.</i>

You should be able to use UPDATE rather than INSERT. Or just use MODIFY.

matt

8 REPLIES 8
Read only

Former Member
0 Likes
5,073

Hi

SY-SUBRC = 4 means that stament not executed successfully

if it equals to zero then only that table fileds will be update d

Read only

Former Member
0 Likes
5,073

Use syntax.

Insert ZCSC_EAP_BTI from <work area>.
commit work.

Regards,

Satish

Read only

former_member386202
Active Contributor
0 Likes
5,073

Hi,

Try like this

INSERT INTO dbtab VALUES dbtab. OR

INSERT INTO scustom VALUES wa

Regards,

Prashant

Read only

Former Member
0 Likes
5,073

hi

the syntax for insert is :

INSERT INTO dbtab VALUES WA.

n if it sy-subrc returns any value other than '0' then the statement has not executed correctly.

regards,

sohi

Read only

matt
Active Contributor
0 Likes
5,074

<b>Insert (into database) is valid in this format, but obsolete</b>

Read the ABAP help for the keyword INSERT, and you'll see that sy-subrc = 4 means:

<i>At least one row could not be inserted, because the database table already contains a row with the same primary key or a unique secondary index.</i>

You should be able to use UPDATE rather than INSERT. Or just use MODIFY.

matt

Read only

Former Member
0 Likes
5,073

Since the insert statement is autogenerated by SAP by generating table maintenance. I donot want to change that code. I want to know what is the issue

Read only

Former Member
0 Likes
5,073

check in your work area if there is any value present not

normally it occurs because you are trying to enter a value which is already present in the unique field of table

please cross check again may be it is u r missing some data

Read only

matt
Active Contributor
0 Likes
5,073

The issue is that you are trying to create a record with the same key as a record already in the table.

>Read the ABAP help for the keyword INSERT, and you'll

>see that sy-subrc = 4 means:

<b>>At least one row could not be inserted, because the

>database table already contains a row with the same

>primary key or a unique secondary index.</b>

matt