‎2009 Apr 07 3:39 PM
Hello,
I am using "BAPI_GOODSMVT_CREATE" to post 344 Movement Type. When I am running the program(foreground), sometimes it is running successfully and sometimes it is giving errors saying Material XXXXX is currently blocked. When I run this program in debug mode to see what is happening, it is running successfully. Following is my code. Anybody please let me know if there is an issue.
Thanks Much.
loop at 344_data.
refresh: i_item, i_return.
clear: i_header, i_headret, i_item, i_return.
*--- Start Transaction
CALL FUNCTION 'TRANSACTION_BEGIN'
IMPORTING
TRANSACTION_ID = l_tid.
*--- Set up document header data.
i_header-pstng_date = sy-datum.
i_header-doc_date = sy-datum.
i_header-pr_uname = sy-uname.
*--- Set up document item data.
i_item-move_type = '344'. "Movement Type
i_item-plant = 344_data-werks. "Plant
i_item-material = 344_data-matnr. "Material
i_item-entry_qnt = 344_data-clabs. "Quantity
i_item-batch = 344_data-charg. "Batch
i_item-stge_loc = 344_data-lgort. "Storage Location
append i_item.
*--- Transfer posting.
call function 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = i_header
goodsmvt_code = '04' "MB1B Transaction
testrun = l_test
IMPORTING
goodsmvt_headret = i_headret
TABLES
goodsmvt_item = i_item
return = i_return.
*--- End transaction.
if i_return[] is initial.
call function 'TRANSACTION_END'
EXPORTING
transaction_id = l_tid.
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
else.
call function 'TRANSACTION_ABORT'
EXPORTING
transaction_id = l_tid.
add 1 to err_344.
l_subrc = sy-subrc.
read table i_return index 1.
l_text = i_return-message.
continue.
endif.
if sy-subrc = 0.
add 1 to ok_344.
else.
add 1 to err_344.
l_subrc = sy-subrc.
read table i_return index 1.
l_text = i_return-message.
endif.
endloop.
‎2009 Apr 07 3:44 PM
well if someone is changing an material MM02 or MM42 he is blocking this material.
NOONE else can maintain it at the same time, even not the BAPI. Nothing wrong with your code so far.
‎2009 Apr 07 3:44 PM
well if someone is changing an material MM02 or MM42 he is blocking this material.
NOONE else can maintain it at the same time, even not the BAPI. Nothing wrong with your code so far.
‎2009 Apr 07 4:11 PM
If possible use WAIT statement in your code and try if it works for you.
‎2009 Apr 07 4:31 PM
Thanks for the responses. I have added "Commit Work and wait" statement. But I'm still seeing that error. Any idea?
‎2009 Apr 08 12:13 AM
I have modified the program to post goods movement at end of material and it worked.