2011 Mar 18 1:48 AM
Hi,
I have entries in internal table gt_zfgl_dm31_EST03. But i Couldn't able to insert these entries in custom table: zfgl_dm31_EST03 . Following insert statement is giving SY-SUBRC 4. Please advise how can i insert table entries from Internal table to Custom table.
INSERT zfgl_dm01_EST03 FROM TABLE gt_zfgl_dm31_EST03 ACCEPTING DUPLICATE KEYS.
Cheers
Srikanth
2011 Mar 18 3:52 AM
Hi,
If you get sy-subrc = 4, some of the records of the internal table are already contained in the database table.
If you need multiple records with a same key, you must add another key to the primary key. For this use timestamp.
2011 Mar 18 3:50 AM
Hi Sreekanth,
Please check if the structure of the internal table and database table are the same . This may sometime be the problem .
Hope this is helpful.
Cheers,
Vivek.
2011 Mar 18 3:52 AM
Hi,
If you get sy-subrc = 4, some of the records of the internal table are already contained in the database table.
If you need multiple records with a same key, you must add another key to the primary key. For this use timestamp.
2011 Mar 18 3:59 AM
Hi Kanth,
Need more clarity. As i understood you want to insert records in your custom table. Create work area and insert from that.
ex Insert ztab from wa. Are you inserting on record at at a time or bulk of records.Please post if this is not solved.
Regards,
Madhu.
2011 Mar 18 4:17 AM
Hi Srikanth,
Ideally, we cannot insert entries with duplicate keys inside a database table. So it is better that you sort the internal table and delete all the duplicate entries from the internal table before inserting the entries inside the database table.
You can try something like this .
sort gt_zfgl_dm31_EST03.
delete adjacent duplicates from gt_zfgl_dm31_EST03 comparing "key field"
modify zfgl_dm01_EST03 from gt_zfgl_dm31_EST03
The reason to use modify is that, it will do the work of insert and update.
Hope this is helpful.
Cheers,
Vivek.
2011 Mar 18 4:35 AM
Hi,
It is as simple as INSERT cannot add duplicate entries into the table. The use of the addition with duplicate keys helps in not taking the INSERT to dump when there are duplicate values and it returns sy-subrc = 4.
Thanks,
Sri.
Edited by: Sri on Mar 18, 2011 10:05 AM
2011 Mar 18 4:44 AM
2011 Mar 18 4:52 AM
Hi,
Please check whether duplicate entries are there in internal table comparing standard table entries. If you are trying to insert records which is already present in the table, it will give sy-subrc = 4. Check the primary keys for checking the duplicates. I mean the records with same primary key if trying to insert again will result this.