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

Insert into DBTable

Hello,

I need to insert records into a custom table 'ZDATA' from a program.

The table fields are: KUNNR VBELN POSNR MATNR PRSDT ZDATE ZTIME.

Among these the key fields are: <b>KUNNR VBELN POSNR MATNR</b>.

For eg: the table already has the records like:

<b>

<u>KUNNR|VBELN|MATNR|POSNR|PRSDT|ZDATE|ZTIME|</u></b>

10001|12356|00001|14056|08/12/2006|12/04/2007|11:15:23

10001|12356|00002|14057|08/12/2006|12/04/2007|11:15:23

10001|12356|00003|14058|08/12/2006|12/04/2007|11:15:23

10001|12356|00004|14059|08/12/2006|12/04/2007|11:15:23

10001|12356|00005|14052|08/12/2006|12/04/2007|11:15:23

10001|12356|00006140563|08/12/2006|12/04/2007|11:15:23

Now, I want to insert more records into this table for the same KUNNR VBELN MATNR POSNR PRSDT ZDATE but with different and ZTIME.

Eg:

<b>

<u>KUNNR|VBELN|MATNR|POSNR|PRSDT|ZDATE|ZTIME|</u></b>

10001|12356|00001|14056|08/12/2006|12/04/2007|12:00:00

10001|12356|00002|14057|08/12/2006|12/04/2007|12:00:00

10001|12356|00003|14058|08/12/2006|12/04/2007|12:00:00

10001|12356|00004|14059|08/12/2006|12/04/2007|12:00:00

10001|12356|00005|14052|08/12/2006|12/04/2007|12:00:00

10001|12356|00006140563|08/12/2006|12/04/2007|12:00:00

Can anybody please let me know how can I insert these <b>"duplicates"</b>(although these are not duplicates, technically)?

Do I have to add more key fields?

FYI....The ZDATE and ZTIME are the SY-DATUM and SY-UZEIT.

Thanks much.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 11:24 PM

    Hi,

    Since the Key field combination is with only 4 fields, it accepts different values if any of the value of 4 fields is different that is not existing.

    So add ZDATE and ZTIME also as the key fields and adjust the database first using the menu UTILITIES--> DATABASE OBJECT --> DATABASE UTILITY --> ACTIVATE AND ADJUST DATABASE.

    Reward if it is useful.

    Thanks,

    Srinivas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 10:32 PM

    Hi,

    Do this

    INSERT ZDATA FROM TABLE ITAB ACCEPTING DUPLICATE KEYS.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2007 at 12:20 AM

    I dont think it will accept the duplicate records. use more key fields or delete from internal table if you dont want to insert. use delete adjusent duplicates to delete from itab. or like the other guy said, add key fields and then adjust the table.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2007 at 12:35 AM

    Include your ZDATE and ZTIME into the key like:

    <b> KUNNR VBELN POSNR MATNR PRSDT ZDATE ZTIME.</b>

    Regards,

    Naimesh Patel

    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.