Currently, We're developing mass GI posting by parallelism, to reduce work time dramatically, because we have to post GI item about 300k+ at one day.
Problem
I know there is a restraint about BAPI_GOODSMVT_CREATE - You can't post same material simutaneously because of table lock, so I grouped materials like this :
It seems reasonable, so I make parallel job for each material number, which total 7 in example.
When I try process this process, SAP refused to process with error :
M3 897 : The plant data of the material XXX is locked by the user XXX
Question
The error is about plant data, not stock data - so it's really confusing about why this error happening. Is there a more restraint about BAPI_GOODSMVT_CREATE?
Note 369518 won't help about this situation.
Any help would be appreciated!
Program Code
LOOP AT gt_matnr_collect INTO wa_matnr_collect.
WAIT UNTIL g_progs <= pa_wpnum.
g_progs = g_progs + 1.
CALL FUNCTION 'Z_PP_STAMP_PARA_DISTRIBUTE'
STARTING NEW TASK g_task DESTINATION IN GROUP DEFAULT
PERFORMING return_stamp_para ON END OF TASK
EXPORTING
p_matnr = wa_matnr_collect-gi_code
p_spmon = p_spmon
TABLES
p_list = gt_main_para_list
p_item = gt_main.
g_task = g_task + 1.
g_sprog = g_sprog + 1.
ENDLOOP.
gt_matnr_collect looks like this :
gt_main_para_list looks like this :
gt_main looks like this :
FM 'Z_PP_STAMP_PARA_DISTRIBUTE'
FUNCTION z_pp_stamp_para_distribute.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(P_MATNR) TYPE MATNR_D
*" VALUE(P_SPMON) TYPE SPMON
*" EXPORTING
*" VALUE(E_MATNR) TYPE MATNR_D
*" TABLES
*" P_LIST STRUCTURE ZSPP6030_PA_LIST
*" P_ITEM STRUCTURE ZSPP6030_PA_ITEM
*" R_RESULT STRUCTURE BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
DATA : gs_head LIKE bapi2017_gm_head_01,
gs_gmcd LIKE bapi2017_gm_code,
gs_doc LIKE bapi2017_gm_head_ret,
gt_item LIKE TABLE OF bapi2017_gm_item_create
WITH HEADER LINE,
gt_return LIKE TABLE OF bapiret2 WITH HEADER LINE,
gs_return LIKE bapiret2,
group_id(22) TYPE c,
l_begda LIKE p0001-begda,
g_last_date TYPE d,
lv_matnr TYPE ztpp5360-gi_code,
lv_batch TYPE ztpp5360-gi_batch,
lv_aufnr TYPE ztpp5360-arbpl,
lv_cnt(3) TYPE c.
CONCATENATE p_spmon '01' INTO l_begda.
e_matnr = p_matnr.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = l_begda
IMPORTING
last_day_of_month = g_last_date
EXCEPTIONS
day_in_no_date = 1
OTHERS = 2.
CONCATENATE p_matnr '*' INTO group_id.
LOOP AT p_list WHERE group_id CP group_id.
CLEAR : lv_matnr, lv_batch, lv_aufnr, lv_cnt.
SPLIT p_list-group_id AT '-' INTO lv_matnr lv_batch lv_aufnr lv_cnt.
CASE lv_batch.
WHEN 'EMPTY'.
lv_batch = ''.
ENDCASE.
p_list-status = 'WIP'.
MODIFY p_list.
LOOP AT p_item WHERE group_id = p_list-group_id.
MOVE : p_item-gi_m_q TO gt_item-entry_qnt,
* 'KG' TO gt_item-entry_uom,
'X' TO gt_item-withdrawn,
'3100' TO gt_item-stge_loc.
MOVE : '261' TO gt_item-move_type,
p_item-gi_code TO gt_item-material,
p_item-werks TO gt_item-plant,
p_item-aufnr TO gt_item-orderid,
lv_batch TO gt_item-batch.
APPEND : gt_item. CLEAR : gt_item.
ENDLOOP.
MOVE : g_last_date TO gs_head-doc_date,
g_last_date TO gs_head-pstng_date,
'03' TO gs_gmcd-gm_code.
REFRESH : gt_return.
CLEAR : gt_return, gs_doc.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gs_head
goodsmvt_code = gs_gmcd
IMPORTING
goodsmvt_headret = gs_doc
TABLES
goodsmvt_item = gt_item
return = gt_return.
READ TABLE gt_return WITH KEY type = 'E'.
IF sy-subrc = 0 OR gs_doc IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT p_item WHERE group_id = p_list-group_id.
p_item-ecode = 'E'.
p_item-msgtx = gt_return-message.
p_item-aedat = sy-datum.
p_item-aezet = sy-uzeit.
p_item-aenam = sy-uname.
MODIFY p_item.
ENDLOOP.
p_list-status = 'ERR'.
p_list-msgty = 'E'.
CONCATENATE gt_return-message '/' gt_return-id '/' gt_return-number INTO p_list-msgtx.
MODIFY p_list.
ELSE.
CLEAR : gs_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = gs_return.
IF gs_return-type = 'E'.
p_list-status = 'ERR'.
p_list-msgty = 'E'.
p_list-msgtx = gs_return-message.
ELSE.
LOOP AT p_item WHERE group_id = p_list-group_id.
p_item-gi_m_mblnr = gs_doc-mat_doc.
p_item-gi_m_mjahr = gs_doc-doc_year.
p_item-ecode = 'S'.
p_item-msgtx = ''.
p_item-aedat = sy-datum.
p_item-aezet = sy-uzeit.
p_item-aenam = sy-uname.
MODIFY p_item.
ENDLOOP.
p_list-status = 'FIN'.
p_list-msgty = 'S'.
p_list-msgtx = ''.
MODIFY p_list.
ENDIF.
ENDIF.
REFRESH : gt_item.
CLEAR : gs_head, gs_gmcd.
WAIT UP TO 2 SECONDS.
ENDLOOP.
ENDFUNCTION.
i dont know if this already solved or not. but if still not then.... i dont know about your case. but can you try to discuss with functional team. this is standard error that can be "pass" by configuration there is MM configuration about this one Locking activity (exclusive/late/shared). usually this will be EXCLUSIVE. you need to change it to LATE. try to discuss and explore this locking material config with your team