‎2009 Jul 30 8:17 PM
Hi Experts,
I want to insert records into a custom DB table that has already having values.
It is like, if the table has 100 records, the insert/modify statement should insert the records from 101 onwards without eliminating the previous records.
Thanks,
Micheal
‎2009 Jul 30 8:29 PM
As long as you know there won't be any key violations on this table, you could do it as follows:
INSERT
ztable
FROM
wa_workarea.
‎2009 Jul 30 8:29 PM
As long as you know there won't be any key violations on this table, you could do it as follows:
INSERT
ztable
FROM
wa_workarea.
‎2009 Jul 30 8:31 PM
Hi micheal,
before inserting in to table ..
select * from ztable.
if sy-subrc = 0.
sy-tabix will contains the number of records..
endif.
next increment the record..
or check the
select max(record) from ztable.
if sy-subrc = 0.
endif.
insert the new record with number record = record + 1.
prabhudas
‎2009 Jul 31 4:13 AM
Hi,
Take a look at the following code. it will insert the record and display the error message for duplicate records.
DATA: lv_err_flag TYPE c,
lv_recnum(10) TYPE c.
LOOP AT gi_itab INTO wa_itab.
INSERT into ztab values wa_itab.
IF sy-subrc NE 0.
READ TABLE gi_itab INTO wa_itab INDEX sy-tabix.
lv_recnum = sy-tabix.
WRITE: /'Record# '(001) NO-GAP, lv_recnum NO-GAP, 'was not created- '(002), wa_itab.
lv_err_flag = 'X'.
ENDIF.
ENDLOOP.
ULINE.
IF lv_err_flag = 'X'.
WRITE /'Process completed with some error records.'(003).
ELSE.
WRITE /'Process completed successfully.'(004).
ENDIF.
Hope it helps.
Regards,
Rajesh Kumar
Edited by: Rajesh Kumar on Jul 31, 2009 5:41 AM
‎2009 Jul 31 6:49 AM
hi michal,
According to the Data base concepts duplicate records wond be inserted into the data base table. but ensure that all the values in the record should be differnt then only the record will be inserted. otherwise it wont be inserted into data base table.
eventhough when your inserting the values inserted record will be sorted and placed based onthe order.
‎2009 Jul 31 7:44 AM
Hi,
What are all the records you have to inset into the customized table is updated into an internal table
then use this statement to update this internal table values into customized table
INSERT <Z table name> FROM TABLE <internal table name>
Before use this query you have to check the primary key fields.
Thanks,
John Victor
‎2009 Sep 03 6:34 AM
Hi,
Could you please let me know whether we need to check the duplicate entries for primary key fields.
Since when I am trying to insert a new record with same entries, I am getting an error. Its working fine.
But when I try to insert a new record with same primary key(onle plant is the key in my table, so i cant change the value everytime when I insert records), its not getting inserted into the table using INSERT dbtab from wa.
Please help me out.
‎2009 Sep 04 6:51 AM
If u want to insert more rows with the same plant then u must have more than one fields as the key for ur table. The plant can have the same value then but the combination of plant plus other field must be unique.
Hope this clarifies.
‎2011 Apr 11 9:12 AM
If you have declarew primary key in you table then dublictarrecord can not br inserted at any cost becose the functionality
of primary key is removing dublicacy
‎2009 Jul 31 10:39 AM
Fill your record in a work area(WA) and then use
insert into Ztable values WA.
thats it.
let me know if you have any doubt
Regards
Manu