修改盘点数量、过账
1、MI04: 库存盘点
2、MI07过账
3、MI09 = MI01 + MI04
【MI04: 库存盘点】
回车输入盘点数量
点保存即可
【
MI07
过账】
MI07:
系统根据账面库存数量和用户输入的盘点数量,计算出差额。检查无误后,点击保存按钮,屏幕左下角会显示凭证保存成功的信息
![修改盘点数量MI04过账Mi07:BAPI_MATPHYSINV_COUNT/BAPI_MATPHYSINV_POSTDIFF 修改盘点数量MI04过账Mi07:BAPI_MATPHYSINV_COUNT/BAPI_MATPHYSINV_POSTDIFF](https://i-blog.csdnimg.cn/blog_migrate/a4c26d1e5885305701be709a3d33442f.gif)
【BAPI】
REPORT YLM_TEST012.
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS:P_WERKS LIKE MARD-WERKS DEFAULT 'RYL5',
P_LGORT LIKE MARD-LGORT DEFAULT '3100',
P_MATNR LIKE MARD-MATNR DEFAULT '0609990060199012',
P_CHARG TYPE ISEG-CHARG DEFAULT '2013102799',
P_ERFMG TYPE ISEG-ERFMG DEFAULT '999',
P_MEINS TYPE MEINS DEFAULT 'CTL',
P_IBLNR TYPE IKPF-IBLNR DEFAULT '100000173',
P_DATE TYPE IKPF-BLDAT DEFAULT '20140618',
P_GJAHR TYPE IKPF-GJAHR DEFAULT '2014'.
SELECTION-SCREEN END OF BLOCK BLK1.
DATA:
GT_RETURN_CODE LIKE TABLE OF BAPIRET2 WITH HEADER LINE, "创建凭证返回信息
GT_RETURN_CODE2 LIKE TABLE OF BAPIRET2 WITH HEADER LINE, "创建凭证返回信息
GT_ITEM LIKE ISEG OCCURS 0 WITH HEADER LINE,
GT_BAPI_ITEM LIKE BAPI_PHYSINV_COUNT_ITEMS OCCURS 0 WITH HEADER LINE,
GT_BAPI_ITEM2 LIKE BAPI_PHYSINV_POST_ITEMS
OCCURS 0 WITH HEADER LINE.
DATA: GV_DATUM LIKE IKPF-BLDAT, "盘点日期
GV_IBLNR LIKE IKPF-IBLNR, "盘点凭证号
GV_GJAHR LIKE IKPF-GJAHR. "会计年度
GT_BAPI_ITEM-ITEM = 1. "行号
GT_BAPI_ITEM-MATERIAL = P_MATNR."物料编码
GT_BAPI_ITEM-BATCH = P_CHARG."批次
GT_BAPI_ITEM-ENTRY_QNT = P_ERFMG."录入系统实盘数
GT_BAPI_ITEM-ENTRY_UOM = P_MEINS."计量单位
CASE P_ERFMG.
WHEN 0.
GT_BAPI_ITEM-ZERO_COUNT = 'X'.
WHEN OTHERS.
ENDCASE.
APPEND GT_BAPI_ITEM.
GT_BAPI_ITEM2-ITEM = 1. "行号
GT_BAPI_ITEM2-MATERIAL = P_MATNR."物料编码
GT_BAPI_ITEM2-BATCH = P_CHARG. "批次
APPEND GT_BAPI_ITEM2.
**************调用bapi,相当于MI04录入实盘数
GV_IBLNR = P_IBLNR."盘点凭证
GV_DATUM = P_DATE."盘点日期
GV_GJAHR = P_GJAHR."会计年度
CALL FUNCTION 'BAPI_MATPHYSINV_COUNT'
EXPORTING
PHYSINVENTORY = GV_IBLNR
FISCALYEAR = GV_GJAHR
COUNT_DATE = GV_DATUM
TABLES
ITEMS = GT_BAPI_ITEM
RETURN = GT_RETURN_CODE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*
**************调用bapi,相当于MI07差异过帐
CALL FUNCTION 'BAPI_MATPHYSINV_POSTDIFF'
EXPORTING
PHYSINVENTORY = GV_IBLNR
FISCALYEAR = GV_GJAHR
PSTNG_DATE = GV_DATUM
TABLES
ITEMS = GT_BAPI_ITEM2
RETURN = GT_RETURN_CODE2.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
* EXPORTING
* WAIT = 'X'.