创建IM盘点凭证,录入数量,修改数量

  *& 创建IM盘点凭证,录入数量,修改数量

REPORT  ztest_inventory.
DATA:it_item LIKE TABLE OF bapi_physinv_count_items WITH HEADER LINE,
     ret_msg LIKE TABLE OF bapiret2                 WITH HEADER LINE,
     g_invdoc LIKE ikpf-iblnr.
*& 产生盘点凭证
PERFORM create_inventory_document.
*&录入盘点数量
PERFORM record_quantity.
*& 更改数量
PERFORM change_quantity.
*&---------------------------------------------------------------------*
*&      Form  CREATE_INVENTORY_DOCUMENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_inventory_document .

  DATA:l_head TYPE bapi_physinv_create_head,
       item   LIKE TABLE OF bapi_physinv_create_items WITH HEADER LINE .

  l_head-plant = '1000'.
  l_head-stge_loc = 'X601'.
  l_head-doc_date = sy-datum.
  l_head-plan_date = sy-datum.

  item-material = '1000-00066'.
  APPEND item.

  CALL FUNCTION 'BAPI_MATPHYSINV_CREATE_MULT'
    EXPORTING
      head   = l_head
    TABLES
      items  = item
      return = ret_msg.

  PERFORM commit_operation.

ENDFORM.                    " CREATE_INVENTORY_DOCUMENT
*&---------------------------------------------------------------------*
*&      Form  COMMIT_OPERATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM commit_operation .

  READ TABLE ret_msg WITH KEY type = 'E'.
  IF sy-subrc <> 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
    READ TABLE ret_msg INDEX 1.
    IF sy-subrc = 0.
      WRITE:/ 'document:',ret_msg-message_v1.
    ENDIF.
  ELSE.
    LOOP AT ret_msg.
      WRITE:/ 'erro message:',ret_msg-message.
    ENDLOOP.
  ENDIF.

ENDFORM.                    " COMMIT_OPERATION
*&---------------------------------------------------------------------*
*&      Form  RECORD_QUANTITY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM record_quantity .

  REFRESH:ret_msg.
  g_invdoc = '0100045002'."(The length is 10)
  it_item-item = '001'.
  it_item-material = '1000-00066'.
  it_item-entry_qnt = 1.
  it_item-entry_uom = 'TAI'."(the measure is inner format)
  APPEND it_item.

  CALL FUNCTION 'BAPI_MATPHYSINV_COUNT'
    EXPORTING
      physinventory = g_invdoc
      fiscalyear    = 2010
      count_date    = sy-datum
    TABLES
      items         = it_item
      return        = ret_msg.

  PERFORM commit_operation.

ENDFORM.                    " RECORD_QUANTITY
*&---------------------------------------------------------------------*
*&      Form  CHANGE_QUANTITY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM change_quantity .
  CALL FUNCTION 'BAPI_MATPHYSINV_CHANGECOUNT'
    EXPORTING
      physinventory             = g_invdoc
      fiscalyear                = '2010'
*   PERCENTAGE_VARIANCE       =
    TABLES
      items                     = it_item
      return                    = ret_msg
*   SERIALNUMBERS             =
            .

  PERFORM commit_operation.

ENDFORM.                    " CHANGE_QUANTITY

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值