Application Development and Automation 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: 
Read only

Material is getting lock with BAPI_GOODSMVT_CREATE,

former_member182379
Contributor
0 Likes
2,266

Hi,

I have made a RFC by using BAPI_GOODSMVT_CREATE, but some some times in case the document is not posted due to some error the material is getting lock entry in SM12, and system is not allowing to perform any other work for that material the code part is below

**************

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = goodsmvt_header

goodsmvt_code = goodsmvt_code

  • TESTRUN = TESTRUN

  • GOODSMVT_REF_EWM =

IMPORTING

goodsmvt_headret = goodsmvt_headret

materialdocument = materialdocument

matdocumentyear = matdocumentyear

TABLES

goodsmvt_item = goodsmvt_item

goodsmvt_serialnumber = goodsmvt_serialnumber

return = return

  • GOODSMVT_SERV_PART_DATA =

  • EXTENSIONIN =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

****************

what can be done for this also try by adding the

IF NOT materialdocument IS INITIAL., " befoe commit FM

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

endif.

regards,

zafar

Hi,

I have made a RFC by using BAPI_GOODSMVT_CREATE, but some some times in case the document is not posted due to some error the material is getting lock entry in SM12, and system is not allowing to perform any other work for that material the code part is below

**************

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = goodsmvt_header

goodsmvt_code = goodsmvt_code

  • TESTRUN = TESTRUN

  • GOODSMVT_REF_EWM =

IMPORTING

goodsmvt_headret = goodsmvt_headret

materialdocument = materialdocument

matdocumentyear = matdocumentyear

TABLES

goodsmvt_item = goodsmvt_item

goodsmvt_serialnumber = goodsmvt_serialnumber

return = return

  • GOODSMVT_SERV_PART_DATA =

  • EXTENSIONIN =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

****************

what can be done for this also try by adding the

IF NOT materialdocument IS INITIAL., " befoe commit FM

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

endif.

regards,

zafar

6 REPLIES 6
Read only

former_member404244
Active Contributor
0 Likes
1,645

Hi,

Use the FM (enqueue_read) to check whether there is lock for the material

if you find it is locked then use the function module(DEQUEUE_ERSPLS_LOCK_SYNC) to release the lock.

Make sure you use these function modules correctly in appropriate place.

Regards,

Nagaraj

Read only

0 Likes
1,645

Hi,

What parameters required to be pass for this DEQUEUE_ERSPLS_LOCK_SYNC,

regards,

zafar

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,645

Hi,

You are using the standard bapi BAPI_GOODSMVT_CREATE. Its returning the exact message when the entry is locked.

What is the problem in it ? If its locked then somebody else is using the material.

kesav

Read only

0 Likes
1,645

Hi,

The probelm is when we execute the RFC at that time no other user using it , as we are doing iin development, also the material get lock only when the document is not posted means if there if some error msg. and it is lock by same user by which we execute the RFC from non SAP system.

regards,

zafar

Read only

0 Likes
1,645

Zafar,

IT is standard SAP behaviour to give error is material is locked by some other user/session/process. So, you should just put an automatic retry kind of thing for this particular error to get your BAPI run successfully as soon as material lock is released.

Check that who/why is material being locked. If it some parallel process and the locks are getting released after that particular process is complete then it is Fine and NORMAL.

BR,

Diwakar

Read only

0 Likes
1,645

solve by adding below code

************

if not materialdocument is initial.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

else.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

IMPORTING

RETURN = RETURN1.

endif.

************

regards,

zafar