05-22-2008 9:26 AM
Hi,
i build Transp. Table (se11) and i wont to insert to it data from program
the problem is that i don't have key field (just mandt) all the field can
come twice or more .
after the program stop to run i check the table and i have just 1 entries
instead 5000 How i can solve it?
Regards
05-22-2008 9:30 AM
hi check this..
in the program r u used the insert statement in a loop ..like this.
loop at itab .
ztable-field1 = itab-field1.
ztable-field2 = itab-field2.
ztable-field3 = itab-field3.
insert ztable .
endloop.
regards,
venkat.
05-22-2008 9:28 AM
u should be missing commit work and wait after insert statement..
commit work and wait. will update the table and wait untill its updated..
if you are using insert in a loop.. u need to write commit work in the loop... endloop.
05-22-2008 9:39 AM
HI Jackandjay ,
i don't Think that it dependent in Commit because i do insert to table and never use commit i think that the problem is because that now i don't have key to put in table.
Regards
05-22-2008 9:42 AM
05-22-2008 9:28 AM
HI,
Since you have mandt as key field, you will be able to insert only 1 row per client. Remove the mandt as key field and try to insert.
Else add a new key field along with mandt and insert
Pls reward points if useful
Shruthi
Edited by: Shruthi R on May 22, 2008 10:29 AM
05-22-2008 9:41 AM
Hi Shruthi R ,
i try it but When i remove mandt i have error i need to put any key
and for this table i don't have.
Regards
05-22-2008 9:43 AM
Hi,
Create a key field like NUMBER or something. When you insert into the table, generate a unique key and insert..
you have to have a unique identifier along with mandt.
Example :
client - unique no - data
000 1 data1
000 2 data2
Edited by: Shruthi R on May 22, 2008 10:44 AM
05-22-2008 9:30 AM
hi check this..
in the program r u used the insert statement in a loop ..like this.
loop at itab .
ztable-field1 = itab-field1.
ztable-field2 = itab-field2.
ztable-field3 = itab-field3.
insert ztable .
endloop.
regards,
venkat.
05-22-2008 9:43 AM
hi venkat appikonda ,
i use this Coomand .
in emp_tab i have all the data and i do insert 1 time for all the data.
DELETE FROM zs_per.
MODIFY zs_per FROM TABLE emp_tab.
Regards
05-22-2008 10:42 AM
Mate,
I can not think of any reason why a custom table be without any key. However, it is your / your tech-lead's design.
Here is a way to insert multiple records.
Adopt Native SQL. Assuming your underlying database is Oracle:
Loop through your internal table emp_tab into a work area say wa_emp.
For each loop pass call a sub-routine which implements below logic
EXEC SQL.
INSERT INTO zs_per
VALUES (:wa_emp-field1, :wa_emp-field2, ...)
ENDEXEC.
I worked on Oracle long long ago. Please excuse me if there is any syntax error in my Oracle INSERT statement.
Amit, There is always a way to do mate.
Regards
Suresh Radhakrishnan
05-22-2008 9:33 AM
hi,
as your primary key is mandt, it will take only one record. as primary key does not allow duplicates
goto your table and change the primary key (add one more field) and run your program,
your prob will be solved
regards
prasanth
05-22-2008 9:34 AM
You HAVE to define a key against the table else the database will only allow entries based on the client field (MANDT.) If you tried debugging through your code you will see that if you do individual inserts in a loop...endloop flow only the first insert will be successful. Think about what you are trying to do - you are trying to insert ~5000 records into the database but each and every entry has the same key ie. MANDT.
The only way to resolve this (that I can think of) is to create a proper primary key against your table. If you really have data that could be duplicated then try adding date/time stamps as part of the key, or better still create a number range object and use that as a unique key field for each row.
Gareth.
05-22-2008 9:45 AM
Hi ricardo,
1. The ONLY solution to this problem is that
you have to decide the PRIMARY KEYS.
(It can be more than 1 field, including MANDT)
2. If you are not sure, then make ALL fields as Primary keys.
3. In that case also, one should note that
if another record (EXACTLY SIMILAR to some old record)
comes, then it will not get inserted.
regards,
amit m.