07-02-2007 1:15 PM
Hi experts,
I am writing below code to insert data into the table.
IF NOT i_tab1[] IS INITIAL.
INSERT zvbeln FROM TABLE i_itab1 ACCEPTING DUPLICATE KEYS .
IF sy-subrc = 0.
MESSAGE s000(zn).
ELSE.
MESSAGE s002(zn).
ENDIF.
ENDIF.
the value of itab1 contains 10010 as VBELN and POSNR as 10 and
10010 as VBELN and POSNR as 20.
but my prg only updating only the first entry, I need to insert both.
Pls suggest hoe to do this.
Thanks in advance
karthik
07-02-2007 1:36 PM
i think ur database table ZVBELN does not has POSNR as key field(whereas ur VBELN is a key field right?) if u make POSNR as key field, ur problem will be solved.
07-02-2007 1:16 PM
Hi,
You should do a loop, no ?
You don't loop, so this is why only the first line is inserted.
Erwan
07-02-2007 1:20 PM
Hello,
Always use modify statement.
Check this.
<b>
MODIFY ZVBELN FROM I_ITAB1.
</b>
Vasanth
07-02-2007 1:30 PM
hi
good
go through this link which ll give you detail idea about the inserting the data into a table,.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm
thanks
mrutyun^
07-02-2007 1:36 PM
i think ur database table ZVBELN does not has POSNR as key field(whereas ur VBELN is a key field right?) if u make POSNR as key field, ur problem will be solved.
07-02-2007 1:51 PM
hi
iF NOT i_tab1[] IS INITIAL..
loop at i_tab1.
INSERT zvbeln FROM TABLE i_itab1 ACCEPTING DUPLICATE KEYS .
IF sy-subrc = 0.
MESSAGE s000(zn).
ELSE.
MESSAGE s002(zn).
ENDIF.
endloop.
ENDIF.
this will work provided that posnr as primary key.(vbeln should not be P.K)
reward if useful.
07-02-2007 1:56 PM
Hi,
Tour table ZVEBLN may not have posnr in key. It is reqd for your code to work as desired. I think you are assuming that the addition ACCEPTING DUPLI... will allow duplicates entry. It si not so. A table key cannot be violated. The addition ACCEPTING DUPLI... will allow correct rows to get inserted while neglecting the error rows. If this additoin is not mentioned then presence of even a single errorneous row will result in failure of all thye rows.