Skip to Content
author's profile photo Former Member
Former Member

inserting table

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 12: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 12: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 12:16 PM

    Hi,

    You should do a loop, no ?

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

    Erwan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 12:20 PM

    Hello,

    Always use modify statement.

    Check this.

    <b>

    MODIFY ZVBELN FROM I_ITAB1.

    </b>

    Vasanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 12: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^

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2007 at 12: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.