简体   繁体   English

具有多个物料编号和相同 PP 订单的 BAPI_GOODSMVT_CREATE?

[英]BAPI_GOODSMVT_CREATE with multiple material numbers and same PP order?

As I know of, When you're using BAPI_GOODSMVT_CREATE at the same time(by loop or just coincidence), Using same material number puts you an error about locked object (Material XXXX is locked by USER YYYY).据我所知,当您同时使用 BAPI_GOODSMVT_CREATE(通过循环或巧合)时,使用相同的材料编号会给您带来有关锁定 object 的错误(材料 XXXX 已被用户 YYYY 锁定)。

But, as i know of, using BAPI_GOODSMVT_CREATE at the same time, but different material number WITH same production order makes no error.但是,据我所知,同时使用 BAPI_GOODSMVT_CREATE,但具有相同生产订单的不同材料编号不会出错。

Issue问题

Recently I found an error about M3/897 (Plant Data of Material XXXX is locked by user XXXX) when I'm doing BAPI_GOODSMVT_CREATE when I'm trying GI for Production order, by parallel processing, which are putting different Material number to same production order.最近我发现一个关于 M3/897 的错误(物料 XXXX 的工厂数据被用户 XXXX 锁定)当我尝试 GI 用于生产订单时执行 BAPI_GOODSMVT_CREATE,通过并行处理,将不同的物料编号放入同一生产命令。

Question问题

So, I'm asking about constraint of BAPI_GOODSMVT_CREATE.所以,我问的是 BAPI_GOODSMVT_CREATE 的约束。

So far I know is -到目前为止我知道的是 -

A. You can't issue GI for Production Order(Mvt 261) at the same time, when you're putting same material number for different production order . A. 当您为不同的生产订单放置相同的物料编号时,您不能同时为生产订单 (Mvt 261) 发出 GI。

B. (I'm not sure about this) You can't issue GI for Production Order(Mvt 261) at the same time, when you're putting different material number for same production order . B.(我对此不确定)当您为同一生产订单放置不同的物料编号时,您不能同时为生产订单 (Mvt 261) 发出 GI。

Is both is right, or just A is right?两者都对,还是只有 A 对? Any help from experienced ABAPer or MM consultant would be appreciated!经验丰富的 ABAPer 或 MM 顾问的任何帮助将不胜感激!

To post GI in a loop you need to make commit after each run, and unlock the object explicitly, otherwise you will get the PP lock.要在循环中发布 GI,您需要在每次运行后进行提交,并显式解锁 object,否则您将获得 PP 锁。

Try like this:试试这样:

LOOP AT lt_orders ASSIGNING <fs>.
...
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
 EXPORTING
  goodsmvt_header  = ls_header
  goodsmvt_code    = ls_code
 IMPORTING
  goodsmvt_headret = ls_headret
  materialdocument = ls_retmtd
 TABLES
  goodsmvt_item    = lt_item
  return           = lt_return.

 IF line_exists( lt_return[ type = 'E' ] ).

  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

 ELSE.

  COMMIT WORK AND WAIT.
  CALL FUNCTION 'DEQUEUE_ALL'.

 ENDIF.

ENDLOOP.

Always use BAPI_TRANSACTION_COMMIT with WAIT parameter or COMMIT WORK with the same after each BAPI call.在每次 BAPI 调用后始终使用带有 WAIT 参数的 BAPI_TRANSACTION_COMMIT 或带有相同参数的 COMMIT WORK。

Also there can be tricky issues with the GR and implicit GI movements, see the note 369518 about this. GR 和隐式 GI 运动也可能存在棘手的问题,请参阅关于此的注释369518

You can check the presence of existing lock at runtime using this FM - "ENQUE_READ2".您可以使用此 FM - “ENQUE_READ2”在运行时检查现有锁的存在。

data: RAW_ENQ like LOCKSEDX_ENQ_TAB, SUBRC type SY-SUBRC, NUMBER type I. data: RAW_ENQ like LOCKSEDX_ENQ_TAB, SUBRC type SY-SUBRC, NUMBER type I.

clear : RAW_ENQ[], SUBRC, NUMBER.

add 1 to COUNTER.
call function 'ENQUE_READ2'
  importing
    SUBRC  = SUBRC
    NUMBER = NUMBER
  tables
    ENQ    = RAW_ENQ.

But if you have to prevent a failure of GOODS mvt.但是如果你必须防止 GOODS mvt 失败。 in general you have instead to implement some reprocessing logic to store errors.通常,您必须实施一些重新处理逻辑来存储错误。

The steps would be: Catch errors --> store bapi information or header doc number --> retry later步骤是:捕获错误 --> 存储 bapi 信息或 header 文档编号 --> 稍后重试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM