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: 

Batch job cancellation

Former Member
0 Kudos

Dear Experts,

I have a program which is being used by many users at the same time .

The program is an interface that updates the SAP database table for the sales order pricing conditions.

I cannot have this program run in a sequential manner.

The program HAS to run parallely(business requirement) since it is used by about 25 countries.

The program also uses the function module "ENQUEUE_ESFUNCTION" , but this throws the error message that , "The program is being locked by another user".

My Question:

1.Is it possible to BYPASS the Function module?

2. I am in a fix here because i should and must use the FM since the updates to tables are happening.

And i should also let the parallel processing to happen. Seems like a deadlock!!!!

3.Can a wait of about 1000ms or so ( suggested by one of the experts) fis this issue?

Please suggest me a workaround for this. Help me fixing this issue please.

Regards,

SuryaD.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Surya,

The lock object ESFUNCTION is to lock an entry in table TFDIR. This is a repository table for all function modules.

If you open any function module in edit mode, a lock entry is created with lock object ESFUNCTION for that function module.

I couldn't understand why your program is trying to obtain lock on this. May be the funtion module being called is desinged to run in one instance at one time.

Do you know the name of the function module?

Regards,

Madhu.

18 REPLIES 18

Former Member
0 Kudos

This is a continuation of your post You may have only one active thread alive at the same time on the same subject. Please mark the other one as solved, or this one must be locked.

Rob

Former Member
0 Kudos

I have closed the other thread.Rob.

I had to open this new thread since i thought framing the question in a better way(alternative way) would help me get more inputs.

Dear SDNers,

Please help me fix this issue.

Regards,

SuryaD.

0 Kudos

That's fine - the reason for this is that when posters ask the same question multiple times, different people may try to help not knowing that the question has already been solved in another thread.

Rob

0 Kudos

Ok Rob. Thanks . I shall take care of the same and see to it that it does not happen again.

But i need someone's help/suggestion in a workaround for the issue.

Is it possible to BYPASS the Function module?

2. I am in a fix here because i should and must use the FM since the updates to tables are happening.

And i should also let the parallel processing to happen. Seems like a deadlock!!!!

3.Can a wait of about 1000ms or so ( suggested by one of the experts) fix this issue?

Regards,

SuryaD

0 Kudos

When calling the ENQUEUE function try setting the _WAIT parameter to 'X'.

Rob

0 Kudos

Thanks Rob.

Will try the same and will pass this info on the concerned team.

thanks for your time and suggestion and also for the inputs from others (for my rpev thread) .

Regards,

SuryaD.

Former Member
0 Kudos

Hi Surya,

The lock object ESFUNCTION is to lock an entry in table TFDIR. This is a repository table for all function modules.

If you open any function module in edit mode, a lock entry is created with lock object ESFUNCTION for that function module.

I couldn't understand why your program is trying to obtain lock on this. May be the funtion module being called is desinged to run in one instance at one time.

Do you know the name of the function module?

Regards,

Madhu.

Former Member
0 Kudos

Hi Madhu thanks for your input.

The users didn't have any issue with this in the oast.

But now that many countries have gone live and have begun to run this program ( interface) they have begun to get this error message "Program is been locked by another user" and as a result of this the batch job fails.

To answer your question on "Do you know the name of the function module?". i see that the program gets locked on this FM ENQUEUE_ESFUNCTION and throws the message.

This is the current flow of hte program.

Program1 calls the program2 that is embedded inside it.

PROGRAM1 : This program will read the file from application server and upload

the data into tables, used for interface.

PROGRAM2: This interface will select records from database table and based on record type it creates/changes the sales order .

Begin of Program1

.

Job Open

Call Function (ENQUEUE_ESFUNCTION) (in this the name of the program2 is mentioned)

Submit program2.

Unlock program2.

Job close.

End of Program1.

To answer your query on "I couldn't understand why your program is trying to obtain lock on this. May be the funtion module being called is desinged to run in one instance at one time. Do you know the name of the function module?"

The prgram gets locked on enqueue_esfunction.Should some othe rFM be used for hte same?

I have been suggested to add in "Wait" and i need to try that out on monday.

Meantime is there any other alternative for this?

Please suggest.

The issue being " Job gets cancelled due to lock" ..how can this be resolved?

do i need to call som other FM or something?

Regards,

SuryaD

Edited by: SuryaD on Oct 24, 2009 12:27 PM

Former Member
0 Kudos

am trying to get more inputs on the same issue.

Dear SDNErs has anyone come across this issue?

The issue being " Job gets cancelled due to lock" ..how can this be resolved?

Please help.\

Regards,

SuryaD.

Edited by: SuryaD on Oct 24, 2009 8:51 PM

0 Kudos

Are you sure this is the exact message? Could you tell us its number? Or does it correspond to a dump?

Former Member
0 Kudos

Yes Sandra, that is the exact message that we are getting.

Regards,

SuryaD.

0 Kudos

Could you tell us its number? Or does it correspond to a dump?

0 Kudos

Hi Sandra,

This is how it looks in the program.

Please find the same.

CALL FUNCTION 'ENQUEUE_ESFUNCTION'

EXPORTING

mode_tfdir = 'E'

funcname = 'Program2'

x_funcname = ' '

_scope = '2'

_wait = ' '

_collect = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e014 WITH

'Program is been locked by another user'(071).

ENDIF.

It does not correspond to a dump.

the job log entries show the error message 'Program is been locked by another user'""

And also says "Job cancelled after system exception erro_message".

Regards,

SuryaD.

Edited by: SuryaD on Oct 27, 2009 9:56 AM

0 Kudos

In fact, it's not a problem with this call function, the issue is how to handle locks in parallel processes.

Here are some major recommendations:

1) Be sure to lock only the minimum object needed

2) Be sure to unlock all locks each time you have finished with an update

3) If there is a lock, wait for a few seconds and repeat the operation, abort if there are a given number of failed tries

4) Be sure to not dead lock (if it's the same program, this should not happen)

In your case, the rule 1 seems to not be respected. Why are you locking everything? (each "thread" locks the same lock object and same value)

0 Kudos

Hi Sandra,

Thanks for your time on this.

The current program under discussion has been coded this way.

PROGRAM1 : This program will read the file from application server and upload

the data into tables, used for interface.

PROGRAM2: This interface will select records from database table and based on record type it creates/changes the sales order .

Begin of Program1.

Job Open

Lock the program 2 (ENQUEUE_ESFUNCTION)

Submit program2.

Unlock program2.

Job close.

End of Program1.

Sandra, when you say ""rule # 1 is not respected " please help me understand if you are referring to the scope of the lock.

If i have to make any change there, please let me know as to what has to be the scope of the lock.

Regards,

SuryaD.

Edited by: SuryaD on Oct 27, 2009 4:42 PM

0 Kudos

you don't need to keep the lock on the WHOLE program, in your case you just need to lock the sales order that you need to maintain, and unlock it when it's done (by the way, the lock may be done by SAP standard programs, but sometimes it is not sufficient, it depends what other objects are updated by your program).

For creation, you may have issues with number range used to number sales orders (there are some SAP notes about that).

Former Member
0 Kudos

Thank you all for your valuable inputs and for your time in helping me in this issue.

0 Kudos

could you give a real feedback ? Thx