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

Problem inserting records in a table.

dev_parbutteea
Active Contributor
0 Likes
868

hello. my insert statement is as follows:

insert zfin_netting from TABLE gt_tab_netting ACCEPTING DUPLICATE KEYS.

however only 1 record is inserted while the table contains 12.

there is no primary key in the table.

9 REPLIES 9
Read only

Former Member
0 Likes
847

Hi,

How did u declared gt_tab_netting?

Try avoiding ACCEPTING DUPLICATE KEYS in your statement.

Write COMMIT WORK Statement after INSERT Statement.

Regards,

Satish

Read only

former_member188829
Active Contributor
0 Likes
847

Hi,

Did you put Insert in loop Statement.?

After insert Statement use Modify Statement.

Read only

Former Member
0 Likes
847

use the following statement

INSERT <DataBasetable> FROM TABLE <Internal table>.

Read only

dev_parbutteea
Active Contributor
0 Likes
847

im getting a dump when i use

insert zfin_netting from TABLE gt_tab_netting .

the declaration is:

BEGIN of tt_tab_netting,

mandt TYPE sy-mandt,

BELNR TYPE ZFIN_NETTING-BELNR,

BUKRS_DEST TYPE ZFIN_NETTING-BUKRS_DEST,

TYP_FACT TYPE ZFIN_NETTING-TYP_FACT,

NAT_FACT TYPE ZFIN_NETTING-NAT_FACT,

CODE_VENT TYPE ZFIN_NETTING-CODE_VENT,

MONT_HT TYPE ZFIN_NETTING-mont_ht,

TAUX_TVA TYPE ZFIN_NETTING-TAUX_TVA,

DATE_MOUV TYPE ZFIN_NETTING-DATE_MOUV,

NUM_FACT TYPE ZFIN_NETTING-NUM_FACT,

END of tt_tab_netting.

data: gt_tab_netting type standard table of tt_tab_netting.

Read only

0 Likes
847

Hi,

This program is working fine for me..

Check this Exmple..

TABLES:MARA.

DATA:ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

ITAB-MATNR = '123ABCDA'. .

ITAB-MBRSH = 'C'.

ITAB-MTART = 'FERT' .

ITAB-MEINS = 'KG' .

APPEND ITAB.

ITAB-MATNR = '123ABCDB'. .

ITAB-MBRSH = 'C'.

ITAB-MTART = 'FERT' .

ITAB-MEINS = 'KG' .

APPEND ITAB.

LOOP AT ITAB.

INSERT MARA FROM ITAB.

MODIFY MARA .

ENDLOOP.

Read only

0 Likes
847

Hi,

Try this

MODIFY dbtable FROM TABLE itab.

Regards,

Satish

Read only

Former Member
0 Likes
847

Hi,

If the addition ACCEPTING DUPLICATE KEYS is specified den only the internal table records that are duplicates(already exists in DBtable) ll be inserted....others ll be ignored....

so the record inserted (out of 12) is a duplicate entry.....

SAP Keyword help

Use of ACCEPTING DUPLICATE KEYS

If the addition ACCEPTING DUPLICATE KEYS is specified, all rows are inserted for which this is possible. The remaining rows are rejected and sy-subrc is set to 4. The system field sy-dbcnt is set to the number of lines that are inserted.

USE MODIFY KEYWORD

Cheers,

Will.

Edited by: Will smith on Feb 4, 2008 8:29 AM

Read only

dev_parbutteea
Active Contributor
0 Likes
847

Since the caller of the procedure could not have anticipated that

exception would occur, the current program is terminated.

The reason for the exception is:

If you use an ABAP/4 Open SQL array insert to insert a record in

the database and that record already exists with the same key,

this results in a termination.

Read only

dev_parbutteea
Active Contributor
0 Likes
847

i cannot use modify since the table might contain duplicates