您的位置:首页 > 其它

创建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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: