18 Replies Latest reply: Oct 27, 2009 1:27 PM by Sandra Rossi RSS

Batch job cancellation

Surya Dorairaj
Currently Being Moderated

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.

  • Re: Batch job cancellation
    Rob Burbank
    Currently Being Moderated

    This is a continuation of your post Batch job fails with error "Program is been locked by another user"" 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

  • Re: Batch job cancellation
    Surya Dorairaj
    Currently Being Moderated

    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.

  • Re: Batch job cancellation
    Bakka Madhusudhanarao
    Currently Being Moderated

    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.

  • Re: Batch job cancellation
    Surya Dorairaj
    Currently Being Moderated

    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

  • Re: Batch job cancellation
    Surya Dorairaj
    Currently Being Moderated

    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

  • Re: Batch job cancellation
    Surya Dorairaj
    Currently Being Moderated

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

     

    Regards,

    SuryaD.

    • Re: Batch job cancellation
      Sandra Rossi
      Currently Being Moderated

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

      • Re: Batch job cancellation
        Surya Dorairaj
        Currently Being Moderated

        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

        • Re: Batch job cancellation
          Sandra Rossi
          Currently Being Moderated

          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)

          • Re: Batch job cancellation
            Surya Dorairaj
            Currently Being Moderated

            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

            • Re: Batch job cancellation
              Sandra Rossi
              Currently Being Moderated

              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).

  • Re: Batch job cancellation
    Surya Dorairaj
    Currently Being Moderated

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

Actions