Application Development 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: 

inserting table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

Hi,

You should do a loop, no ?

You don't loop, so this is why only the first line is inserted.

Erwan

Former Member
0 Kudos

Hello,

Always use modify statement.

Check this.

<b>

MODIFY ZVBELN FROM I_ITAB1.

</b>

Vasanth

Former Member
0 Kudos

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^

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.