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

Inserting data into ZTABLE created in data dictionary

stefan_kolev4
Participant
0 Likes
1,582

Hi,

I've created ztable in data dictionary via se11 called zzcalc.

I am able to insert only one record using code, which you could see below.

When I try to insert second record sy-subrc = 4.

Why ? How can I insert more than one record ?

My code:

zzcalc-zzmeins = rv45a-zzmeins.

zzcalc-zzfield1 = rv45a-zzfield1.

zzcalc-zzfield2 = rv45a-zzfield2.

zzcalc-zzfield3 = rv45a-zzfield3.

zzcalc-ZZQTYAUM = rv45a-ZZQTYAUM.

insert zzcalc.

Thanks,

Stefan

Edited by: Stefan Kolev on Mar 17, 2009 11:31 AM

13 REPLIES 13
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,388

I think u may b inserting a duplicate record where the key already exists... check it

Read only

Former Member
0 Likes
1,388

hi.

Ist paste ur code

and use * append zztable* not insert

Edited by: tahir naqqash on Mar 17, 2009 3:33 PM

Read only

matt
Active Contributor
0 Likes
1,388

>

> and use * append zztable* not insert

This is a database table, NOT an internal table. And even if it was, your answer would still be incorrect.

Read only

former_member585060
Active Contributor
0 Likes
1,388

HI,

Use MODIFY statement, as it performs both operations as INSERT and UPDATE

Regards

Bala Krishna

Read only

Former Member
0 Likes
1,388

it will not allow to enter values for a particular set of primary keys if a value already exists.

it will simply overwrite with new value.

plz check that u are not inserting values for the same set of primary keys which already has a value.

Read only

Former Member
0 Likes
1,388

Hi,

There is nothing wrong in your code

1.If you want to insert the data using INSERT statement then make sure you are

not enetring the duplicate records

2.Better to use the MODIFY statement that checks if the record is already presetn in the tbale it

simply update the record, if record not prersent then it will insert the new into table.

Hope this might help you.

Pooja

Read only

0 Likes
1,388

I have field MANDT which I set to be 'Key' and 'Initial values'. This is my primary key.

Is this correct or I have to change ?

Stefan

Read only

0 Likes
1,388

Hi,

If Mandt is same for all records,how can u distinguish records.

So,better declare one field as primary key,then mandt and the field(primary key) together will be unique to identify record.

In this case ,u can insert any number of records,by changing primary key.

Read only

0 Likes
1,388

Hi Stefan,

YOu need not to fill in MANDT fields value...its value will be filled automatically but rest all the field values you need to supply.

And I am sure MANDT is not only the key field in the table (if its value is constant in the table),if it is so then please make some other field along with the MANDT filed as key fields or every time you need to insert new value for this field.

Pooja

Edited by: Pooja Gupta on Mar 17, 2009 12:24 PM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,388

go for this

INSERT dbtab FROM TABLE itab

Inserts all lines of the internal table itab in a single operation.

When the command has been executed, the system field SYDBCNT contains the number of inserted lines.

If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0 after the call.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,388

link:[http://members.tripod.com/sap_abap/insert_d.htm]

Read only

Former Member
0 Likes
1,388

Hi ,

May be entering same key alues .

so try modify or check roeply thee is no othe reason.

Regards

Read only

stefan_kolev4
Participant
0 Likes
1,388

We solved the problem.

Thanks.