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: 

BAPI_MATERIAL_SAVEDATA - Locking issue

Former Member
0 Kudos
672

Hi All-

I am using BAPI(BAPI_MATERIAL_SAVEDATA) to modify the existing Materials...I am facing locking problem, if I am trying to change for multiple plants to the same material...It is updating for the first palnt, but for the second plant onwards it is getting locked...

I tired with wait upto 4 seconds, it is working....But, user does not want to wait for each record for 4 seconds...

I tried with DEQUEUE, but still gets locked...

I tried passing wait = '4' seconds in BAPI_TRANSACTION_COMMIT..I ran in the background, but job still not completed...

Even though, if I use ENQUEUE_EMMARCE and DEQUEUE_EMMARCE will not resolve my issue...

Please guide me, if anyone come across this issue in real time...We are upgrading system from 4.6c to ECC6.0...We don't have locking issue in 4.6c, same program working fine without any locking issue in 4.6c...

Thanks,

Sony

2 REPLIES 2

former_member188685
Active Contributor
0 Kudos
209

recently i have similar kind of problem, if there is any error then also lock will not be released, are you checking the return messages also. based on success you commit.

MatthieuG
Discoverer
0 Kudos
84

Hello I got the same issue and debug.

Issue is due to FORM sperren_mara in include LMG21FSQ whe perform ENQUEUE_EMMARAE 

So I enhance it and remove autolock :

IF my_transaction

    CALL FUNCTION 'ENQUEUE_EMMARAE'
      EXPORTING
          matnr          mara_keytab-matnr
      EXCEPTIONS
          foreign_lock   01
          system_failure 02.
    IF sy-subrc IS NOT INITIAL
      AND sy-msgv1 EQ sy-uname.
      CALL FUNCTION 'DEQUEUE_EMMARAE'
        EXPORTING
          matnr mara_keytab-matnr.
      WAIT UP TO SECONDS.
    ENDIF.

    CALL FUNCTION 'ENQUEUE_EMMARAS'
      EXPORTING
          matnr          mara_keytab-matnr
      EXCEPTIONS
          foreign_lock   01
          system_failure 02.
    IF sy-subrc IS NOT INITIAL
      AND sy-msgv1 EQ sy-uname.
      CALL FUNCTION 'DEQUEUE_EMMARAS'
        EXPORTING
          matnr mara_keytab-matnr.
      WAIT UP TO SECONDS.
    ENDIF.

Regards