‎2009 Mar 17 10:30 AM
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
‎2009 Mar 17 10:32 AM
I think u may b inserting a duplicate record where the key already exists... check it
‎2009 Mar 17 10:33 AM
hi.
Ist paste ur code
and use * append zztable* not insert
Edited by: tahir naqqash on Mar 17, 2009 3:33 PM
‎2009 Mar 17 10:37 AM
>
> 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.
‎2009 Mar 17 10:35 AM
HI,
Use MODIFY statement, as it performs both operations as INSERT and UPDATE
Regards
Bala Krishna
‎2009 Mar 17 10:35 AM
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.
‎2009 Mar 17 10:59 AM
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
‎2009 Mar 17 11:14 AM
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
‎2009 Mar 17 11:23 AM
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.
‎2009 Mar 17 11:24 AM
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
‎2009 Mar 17 11:17 AM
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.
‎2009 Mar 17 11:19 AM
‎2009 Mar 17 11:36 AM
Hi ,
May be entering same key alues .
so try modify or check roeply thee is no othe reason.
Regards
‎2009 Mar 18 7:19 AM