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: 

Enqueue lock failure and subsequent program failure

Former Member
0 Kudos

Hi,

I tried reading all the posts and SAP resources on the SAP Lock concept but I still have some questions left unanswered, hence I posting a new question here.

Every day the production system receives sales orders through EDI. After the sales order is generated, an user exit is triggered to update the custom fields in the VBAK table. The custom fields are sometimes not updated and I am guessing that this happens only in case of large orders since the sales order may not yet be completely saved even though the sales order number is generated.

This is the code currently used in the user exit of the EDI


DO 20 TIMES.
      CALL FUNCTION 'ENQUEUE_EVVBAKE'
        EXPORTING
          vbeln          = sales_document
          _wait          = 'X'
        EXCEPTIONS
          foreign_lock   = 1
          system_failure = 2
          OTHERS         = 3.
      IF sy-subrc EQ 0.
        MOVE 'X' TO l_lock_set.
        EXIT.
      ENDIF.
ENDDO.

    UPDATE vbak SET ............

    IF l_lock_set IS NOT INITIAL.
      CALL FUNCTION 'DEQUEUE_EVVBAKE'
        EXPORTING
          vbeln = sales_document.
    ENDIF.

My questions are

1. Is there a way I can find whether the VBAK sales order is still being updated before I use the FM 'ENQUEUE_EVVBAKE' ?

2. If I use a COMMIT WORK AND WAIT before 'ENQUEUE_EVVBAKE', does it wait for the VBAK update LUW to complete before it triggers FM 'ENQUEUE_EVVBAKE' ?

3. The program tries 20 times to lock the VBAK header data. Could you tell me how much time it waits before it goes through the 'do.. endo' loop, I read that the value of parameter '_wait' is set by BASIS team, is there any way I can find this value.

4. Will the UPDATE VBAK statement fail if the lock failed ?

5. Does the DEQEUE FM automatically perform 'COMMIT WORK' or should I do write this statement explicitly ?

Edited by: Grame Smith on Jun 2, 2011 5:56 PM

4 REPLIES 4

krishnendu_laha
Active Contributor
0 Kudos

Please find my reply below.

1. Is there a way I can find whether the VBAK sales order is still being updated before I use the FM 'ENQUEUE_EVVBAKE' ?

If you can manage 'In process' document number then check in database table

2. If I use a COMMIT WORK AND WAIT before 'ENQUEUE_EVVBAKE', does it wait for the VBAK update LUW to complete before it triggers FM 'ENQUEUE_EVVBAKE' ?

I think wait statement could do the trick, because locking of the sales order fails due to the fact it is in process in another update work process

3. The program tries 20 times to lock the VBAK header data. Could you tell me how much time it waits before it goes through the 'do.. endo' loop, I read that the value of parameter '_wait' is set by BASIS team, is there any way I can find this value.

'_wait' determine if lock attempt fail, it will retry but it does not wait for lock to be successful.

4. Will the UPDATE VBAK statement fail if the lock failed ?

Yes, because database will reject because sales order does not exist at that time.

5. Does the DEQEUE FM automatically perform 'COMMIT WORK' or should I do write this statement explicitly ?

No, DE..FM only release the lock.

My suggestion:

Use 'user exit' available in SAP to pass values in custom fields.

Thanks.

0 Kudos

Thanks for the answers.

I think COMMIT WORK AND WAIT may not work in this scenario since the VBAK table update could be carried out in a different LUW.

Former Member
0 Kudos

Hi,

Correct me if my understanding of your scenario is incorrect,

Orders are created in the system VIA EDI, IDOCs. Also, you have some Z fields(being sent in custom segment???) that need updated in VBAK table. I guess you are using "IDOC_INPUT_ORDERS" and one of the below exits "EXIT_SAPLVEDA_003/4/5" where you have the update statement on VBAK.

If my understanding is correct, then i am afraid the design is not only incorrect, but also overlooks the rule of thumb "Do not update standard table using SQL statements" even though it is only to update Z fields.

Below are my thoughts on how you could overcome this,

1) Use the Enhancement VEDA0001 - EXIT_SAPLVEDA_001 - In this function exit read the custom fields from the custom segments/standard segments(in case you have mapped the Z field values to unused fields in a standard segment) and map them to the changing parameter "DXVBAK" of the above FM, i guess this should do it.

2) If not, then export the Z field values from the above customer exit into the ABAP memory and import the same in any of the user exits of SAPMV45A - USEREXIT_MOVE_TO_VBAK/SAVE_DOCUMENT_PREPARE and update the VBAK structure.

3) Create a program which will read all the IDOCs processed successfully, read the Z field values for each IDOC and update them using BAPISALESORDERCHANGE*.

I would suggest you try with 1 and 2(this will definitely work), before you choose 3.

Regards,

Chen

0 Kudos

You are right. The UPDATE VBAK statement could be completely avoided by shifting the code into a user exit, which is called before the VA01 update. I am doing a check whether there would be any implications if I shift the code.