创建IM盘点凭证,录入数量,修改数量
2010-05-04 17:12
295 查看
*& 创建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
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
相关文章推荐
- 修改域用户创建计算机帐户的数量
- sap批量创建盘点凭证以及盘点凭证过账
- 生产盘点凭证并录入实盘数据
- SAP盘点:创建盘点凭证BAPI_MATPHY…
- 修改盘点数量MI04过账Mi07:BAPI_M…
- MySQL创建修改表结构
- SQL Server 2005教程:如何创建修改分区表和如何查看分区表
- 创建或修改配置文件
- 创建数据表和修改数据表
- 『ORACLE』创建和修改索引(11g)
- 创建trigger,审计和禁止用户的密码修改
- C# 轻松读取、改变文件的创建、修改、访问时间 z
- linux创建用户、设置密码、修改用户、删除用户
- vb.net 创建、修改、读取XML的方法
- 修改CCS首页显示的论坛帖子和Blog日志的数量
- Javascript实例教程:DOM方法创建和修改表格
- 想让eclipse的工程能够导入myeclipse中,在创建是需要修改配置
- suse创建的虚拟机,修改ip地址
- Unity中创建自己的mesh以及动态修改mesh
- 资产盘点帐实相符的条码录入Excel方法