Quantcast
Channel: SCN: Message List - SAP CRM: Webclient UI - Framework
Viewing all articles
Browse latest Browse all 7775

Re: uncaught exception CX_OS_DB_INSERT from custom persistent object -

$
0
0

Hi Jennifer!

 

Exception classes belong to three main superclasses (under the root class CX_ROOT), i.e. CX_STATIC_CHECK, CX_DYNAMIC_CHECK and CX_NO_CHECK.

 

The difference lies on when and how the exceptions are raised and propagated.  Static exceptions are checked and raised at design time by the compiler, dynamic exceptions at runtime and no_check exceptions are not part of any class signature, are never checked and can't be caught by us mortals in an ABAP program...they just generate a short dump.

 

CX_OS_DB_INSERT is a subclass of CX_NO_CHECK.  It is thrown because your program is trying to create a database record that already exists (based on the table key).  Since your program cannot catch that exception, the only way to prevent this is to actually check for yourself if the record exists in the table before creating it, as suggested by Abdullah's post.

 

I too had hoped that the persistent service would throw a cx_os_object_existing exception at the "create_persistent" phase but, apparently, the program is only concerned with transient state at that stage, i.e. what's in memory only.  Only after you do the commit that DB checks are performed by the persistence service.

 

Not very elegant but it does the job...

 

Regards,

 

Achille.


Viewing all articles
Browse latest Browse all 7775

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>