Application Development and Automation 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: 
Read only

how to catch write errors

Former Member
0 Likes
918

Hello.

I have to write data to database tables.

I write the data like this:

insert (tabname) from TABLE <it>.

<it> is a field symbol with the table contents to write..

How can I catch errors like 'duplicate records' or ...

There will probably be a lot of errors to catch. :d

Thx.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
899
6 REPLIES 6
Read only

Former Member
0 Likes
899

best way is Enque (get the lock) . if you get lock successfully then you can update insert without err. & Deque after successfullt completing that operation.

This is required because otherwise you may get short dump also,

http://help.sap.com/saphelp_47x200/helpdata/en/ce/532b3a6b4f4644e10000000a11402f/frameset.htm

Read only

Former Member
0 Likes
900
Read only

0 Likes
899

hmm.. So there isn't just a simple function like Try.. Catch in VB.net?

Read only

0 Likes
899

Hi,

we have the functionality same as try...catch in abap also.

please refer to this link

http://help.sap.com/saphelp_nw04/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/content.htm

rgds,

bharat.

Read only

0 Likes
899

THX!

Read only

0 Likes
899

it is easy task if you are updating std SAP table, because most of the cases lock will already exist.

So you can

call function enqueu_xxxx

then insert xxx

dequeue_all

**if lock does not exist, then you need to create in Se11.

e.g. for MARA table update/insert you can use existing function module

ENQUEUE_E_PDTC_MARA