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: 

Abending a job when data is locked

srinivas_krishnamoorthy
Active Contributor
0 Kudos

We are working in APO DP. there are some jobs that show a Finished status (successfully) even when the log says that data was locked. hence the process that typically takes 10 minutes finishes successfully in 1 sec. Is there a way through some user parameter or lock object setting to abend or stop the job if it finds that the object that it is supposed to work on is found locked by another user?

5 REPLIES 5

Former Member
0 Kudos

Issue an error message.

Rob

0 Kudos

Sorry, if this sounds dumb. I am a functional person and do not understand most of the ABAP mumbo jumbo. Can you expand on what exactly needs to be done ?

0 Kudos

Srinivas,

Your program is trying to access the table and sometimes you are getting a message in LOG , "data is locked" which means it already in process by some other process.

so what you need to do is before you access the table you need to include the above code jsut to make sure the table not locked by any other user, if you use that code internally it will try to access the table, if it is locked by another user it will wait for some time(this time gap will be set by basis), and try to re-acess the table, and it will do 3 times(i believe).

If it fails in 3 attempts, it will continue. so in that case sy-subrc will be <> 0,

then ask you abap programmer to check this condition and ask him raise error message, which will abend your background job.

Hope this helps

Pavan

0 Kudos

I'll be quicker if you sit down with one of your own ABAPers to sort this out.

Rob

Former Member
0 Kudos

Hi

My best guess is,

when sap is trying to read data and it found locked at that stage you write a program to check for locking concept for the table, then you will need to raise an error

sample code

DATA: l_varkey TYPE rstable-varkey.

l_varkey = sy-mandt.

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

mode_rstable = 'E'

tabname = '/VWNA/WHRS_MULTI'

varkey = l_varkey

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE E038.

ELSE.

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

mode_rstable = 'E'

tabname = '/VWNA/WHRS_MULTI'

varkey = l_varkey.

ENDIF.

Thanks

Pavan