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

Insertin record in table

Hi,

I was inserting record in custom table, values of primary key in

work area where already present in table.

so i got short dump for entring duplicate values.

Is their any way to avoid short dump in this case so that program

should not be terminated.

Rgds,

Fattesingh

Add comment
10|10000 characters needed characters exceeded

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 04:53 AM

    Hi fattesingh,

    1. MODIFY

    2. Use MODIFY statement (instead of INSERT,UPDATE etc)

    3. MODIFY

    will AUTOMATICALLY

    take care of insert/update

    based upon the

    primary key combination

    FOUND / NOT FOUND

    in the database table,

    based upon the work area fields.

    regards,

    amit m.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 05:24 AM

    hi,

    I want to know how to do exception handling to avoid short dump.

    coz i had checked sy-subrc after the insert

    but still short dump was gifted to me.

    I know modify command.

    Rgds,

    Fattesingh

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      use 'ACCEPTING DUPLICATE KEYS' with insert statement.

      whenever any duplicate primary key record comes , system will modify existing records.

      Ex: INSERT ztable FROM TABLE i_tab ACCEPTING DUPLICATE KEYS.

      Regards

      Appana

  • Posted on Aug 03, 2006 at 04:54 AM

    Hi Fattesigh,

    Please use <b>MODIFY</b> statement instead of INSERT.

    It will modify the record with new values if the record already exits otherwise it will insert new record.

    Hope this will help.

    Regards,

    Ferry Lianto

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 04:59 AM

    Hi,

    Use MODIFY Statement which acts like 2 Open Sql queries (Insert and Update), if the records already exists it updates else it inserts the new record) and Regarding your case to avoid short dumps, use user-defined messages.

    For Ex:

    Insert zemployee.
    if sy-subrc <> 0.
    MESSAGE 'RECORD ALREADY EXISTS' TYPE 'S'.
    ELSE.
    MESSAGE 'RECORD SUCCESSFULLY CREATED' TYPE 'S'.
    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 05:17 AM

    Hi,

    Use MODIFY statment instead of INSERT.

    MODIFY stmt will insert the record in table only if it is not present in table else it will just update the record with new values in that workarea.

    Rgds,

    Prakash

    Add comment
    10|10000 characters needed characters exceeded