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

Error record

Hi,

Im using INSERT command to insert values into custom table from internal table.

My question is : I want to write the records thats are failed to insert in to the tables.

How to do this?

any examples plz.

Regards,

Vimal

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    Posted on Dec 26, 2007 at 08:48 AM

    after insert stmt use:

    if sy-subrc ne 0.

    write: itab-...

    endif.

    if sy-subrc is 0 it means record has been inserted else its not 0.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 08:49 AM

    Hi Vimal ,

    After insert statement check the SY-Subrc.

    If it is 0 means successfull and inserted correctly .

    If it not equal to 0 means unsuccessful and not inserted .

    THX

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 09:26 AM

    Hi,

    After Insert statement, check for sy-subrc value, if the value is not equal to zero. Write the records details in the output list.

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 08:50 AM

    Hi,

    declare one internal table with teh custom table structure..

    now please fill the internal table with error records and then finally update to custom table.

    UPDATE <CUSTOMTABLE> from table itab.

    Regards,

    nagaraj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 08:53 AM

    hi,

    You have to create some Ztable if you want to store those failed records permanently in the database.

    If you want to just disply to the user then you have to declare some internal table in the program in the strucrure you wanted like promary fields and some description for error.

    select ..stmt

    If sy-subrc = 0

    insert ztable from table itab.

    else.

    itab_error-field1 = ..

    itab_error-field2 = ..

    append itab_error.clear itab_error.

    endif.

    If you want to insert in database mean use itab_error.

    Regds

    Sivaparvathi

    Please reward points if helpful...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 09:04 AM

    hi vimal

    see this example

    • Structure of ZSAMP_ALTER

    TYPES: BEGIN OF t_alter,

    matgp LIKE zsamp_alter-zmatgp, "Customer code

    werks LIKE zsamp_alter-werks, "Plant

    matnr1 LIKE zsamp_alter-zmatnr1, "Material number

    matnr2 LIKE zsamp_alter-zmatnr2, "BOM material number

    END OF t_alter.

    • Structure of Error log file

    TYPES: BEGIN OF t_data_err,

    matgp LIKE zsamp_alter-zmatgp,

    werks LIKE zsamp_alter-werks,

    matnr1 LIKE zsamp_alter-zmatnr1,

    matnr2 LIKE zsamp_alter-zmatnr2,

    errorlog(50),

    activeflag(1),

    END OF t_data_err.

    u do like type declarations and internal tables

    and see below how to pass error records

    READ TABLE i_marc INTO wa_marc WITH KEY werks = wa_upload_file-werks

    matnr = wa_upload_file-matnr1

    BINARY SEARCH.

    IF sy-subrc NE 0.

    CONCATENATE 'Plant MaterialNumber' 'not in plant data meterialtable'

    INTO wa_data_err-errorlog SEPARATED BY space.

    wa_data_err-werks = wa_upload_file-werks.

    wa_data_err-matnr1 = wa_upload_file-matnr1.

    APPEND wa_data_err TO i_data_err .

    CLEAR wa_data_err.

    like this u will do

    it's will help u

    kk.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 09:41 AM

    Hi,

    if sy-subrc value is not equal to 0.

    But when INSERT command fails it goes to dump.

    Regards,

    Vimal

    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.