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: 

Error record

Former Member
0 Kudos
147

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

1 ACCEPTED SOLUTION

former_member188827
Active Contributor
0 Kudos
119

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.

7 REPLIES 7

former_member188827
Active Contributor
0 Kudos
120

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.

Former Member
0 Kudos
119

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

former_member404244
Active Contributor
0 Kudos
119

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

Former Member
0 Kudos
119

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...

Former Member
0 Kudos
119

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.

Former Member
0 Kudos
119

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.

Former Member
0 Kudos
119

Hi,

if sy-subrc value is not equal to 0.

But when INSERT command fails it goes to dump.

Regards,

Vimal