‎2009 Jul 02 11:46 AM
Hi,
I am uploading afile into one database table.Whenever a wrong file(which is not the type of the data base table) is uploaded,the program goes for dump at the at the INSERT statement.
Please guide me how to avoid this dump.
Thanks in Advance.
Edited by: Ginger on Jul 2, 2009 6:47 AM
‎2009 Jul 02 11:49 AM
Pleae make sure that the duplicate records are not inserted in database,otheriwse it will lead to dump.
use accepting duplicate key,if requirment there for duplicate records.
‎2009 Jul 02 11:50 AM
hi ,
U can catch the Error by using sy-subrc = 0 then Insert.
if sy-subrc = 0.
Insert statment.
elseif .
message type e.
endif.
hope this will help U.
if duplicates are there , then use Delete adjcent duplicate from itab comparing <Field name>.
Regards,
Prakash
Edited by: Abaplover on Jul 2, 2009 12:50 PM
‎2009 Jul 02 11:58 AM
Hi,
It always better to validate the records of the uploaded file data before inserting it to the database table. Loop at the uploaded records and validate each fields with respect to database table, maintain a error log table and populate it for invalid records. After validation, if the error log table is initial then go for insert else display error log report.
If you don't any validation in the program then you have to compulsorily maintain proper & validate data in the upload file to match database table field data type and other criteria to avoid short dump.
Thanks,
Muthu
‎2009 Jul 02 12:08 PM
Hi,
You may use CATCH......... ENDCATCH for catching the system exceptions,
Regards
Raju chitale
‎2009 Jul 02 12:24 PM
Hi Ginger ,
From your problem I feel -
When you upload file to internal table , the internal table must be having same structure of that database table.
If your internal table is not updated properly (check sy-subrc <> 0 ) then you can avoide updating database.
‎2009 Jul 02 12:29 PM
Hi,
Never insert or update the database table blindly. You need to validate the data before any updation. Once you upload the data from file, check whether the data uploaded is in correct format. If the data validation is successful, you can insert only those data to database.
‎2009 Jul 02 1:02 PM
Hi Ginger,
this is good for the addition
FROM TABLE itab [ACCEPTING DUPLICATE KEYS] ...
The SY-SUBRC will tell you if it is OK.
Regards,
Clemens
‎2009 Jul 02 1:11 PM
Hi Ginger,
Can you tell me what is the shortdump says?
May be put this insert statement in a try endtry block. But I t=dont think this will help you.
Try.
insert *******.
catch CX_SY_OPEN_SQL_DB
endtry.
With regards,
Vamsi
‎2009 Jul 02 2:06 PM
Check the dump analysis (ST22). If the issue is because of the duplicate records then either remove duplicate entries from your internal table before inserting or use the addition ACCEPTING DUPLICATE KEYS in the insert statement. This will ignore all the duplicate records.
Hope this helps you,
Susanta