2007 Dec 26 8:46 AM
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
2007 Dec 26 8: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.
2007 Dec 26 8: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.
2007 Dec 26 8: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
2007 Dec 26 8: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
2007 Dec 26 8: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...
2007 Dec 26 9: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.
2007 Dec 26 9: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.
2007 Dec 26 9:41 AM
Hi,
if sy-subrc value is not equal to 0.
But when INSERT command fails it goes to dump.
Regards,
Vimal