本文主要是介绍MIGO批次增强总结技巧,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、批次增强的出口包含程序是ZXVBZU02,在ZXVBZU02中添加如下代码可实现同物料&工厂生成同一个批次
*&---------------------------------------------------------------------*
*& 包含 ZXVBZU02
*&---------------------------------------------------------------------*
*data z_bncom like bncom.
*data num(10) type c.
*z_bncom = x_bncom.
*concatenate sy-datum+2(6) new_charg+6(4) into num.
*new_charg = num.
TABLES : MCHB.
DATA: LAST_CHARG LIKE MCHB-CHARG,
DATE_STR(6) TYPE C,
SERIAL(4) TYPE C.
SELECT MAX( CHARG ) INTO LAST_CHARG
FROM MCHB
WHERE MATNR = X_BNCOM-MATNR
AND WERKS = X_BNCOM-WERKS
AND ERSDA = SY-DATUM+2(6).
DATE_STR = SY-DATUM+2(6).
IF LAST_CHARG IS INITIAL.
CONCATENATE DATE_STR '0001' INTO NEW_CHARG.
ELSE.
NEW_CHARG = LAST_CHARG + 1.
* if serial < 10 .
* CONCATENATE '0' serial into serial.
* endif.
* CONCATENATE date_str serial into new_charg.
ENDIF.
2、如果同物料&工厂有多行,并且想要分配不同批次则需要使用自建表,并在每次调用增强是进行存储操作,具体代码如下。
*&---------------------------------------------------------------------*
*& 包含 ZXVBZU02
*&---------------------------------------------------------------------*
*data z_bncom like bncom.
*data num(10) type c.
*z_bncom = x_bncom.
*concatenate sy-datum+2(6) new_charg+6(4) into num.
*new_charg = num.
TABLES : MCHB.
DATA: LAST_CHARG LIKE MCHB-CHARG,
LV_ZBATCH TYPE ZBATCH,
DATE_STR(6) TYPE C,
SERIAL(4) TYPE C.
SELECT MAX( CHARG ) INTO LAST_CHARG
FROM ZBATCH
WHERE MATNR = X_BNCOM-MATNR
AND WERKS = X_BNCOM-WERKS
AND CHARG_C = SY-DATUM+2(6).
DATE_STR = SY-DATUM+2(6).
IF LAST_CHARG IS INITIAL.
CONCATENATE DATE_STR '0001' INTO NEW_CHARG.
ELSE.
NEW_CHARG = LAST_CHARG + 1.
* if serial < 10 .
* CONCATENATE '0' serial into serial.
* endif.
* CONCATENATE date_str serial into new_charg.
ENDIF.
CLEAR LV_ZBATCH .
LV_ZBATCH-MATNR = X_BNCOM-MATNR .
LV_ZBATCH-WERKS = X_BNCOM-WERKS .
LV_ZBATCH-ERSDA = SY-DATUM .
LV_ZBATCH-CHARG = NEW_CHARG .
LV_ZBATCH-CHARG_C = LV_ZBATCH-CHARG(6) .
MODIFY ZBATCH FROM LV_ZBATCH .
自建表格式:
MANDT | X | MANDT | CLNT | 3 | 0 | 集团 |
MATNR | X | MATNR | CHAR | 40 | 0 | 物料编号 |
WERKS | X | WERKS_D | CHAR | 4 | 0 | 工厂 |
CHARG | X | CHARG_D | CHAR | 10 | 0 | 批号 |
CHARG_C | CHAR | 6 | 0 | 批号截取 | ||
ERSDA | ERSDA | DATS | 8 | 0 | 创建日期 |
这样做的弊端是:
1*如果MIGO操作只进行了检查没有保存或保存不成功就会产生跳号的现象
2*系统期初导入的批次数据无法自动流入自建表
3、如何使导入的期初数据自动流入自建表且能避免跳号问题?我的思路是由于批次是不可跨天累计的,所以可以在进入MIGO界面并伴有PAI动作时将自建批次表当天的数据清空,并将MCHB当天的数据更新进入自建表,这样便可以解决上面两个问题。具体做法如下:
此处加入如下代码
*{ INSERT D01K900321 1
DATA GT_MCHB TYPE TABLE OF MCHB WITH HEADER LINE .
DATA GT_ZBATCH TYPE TABLE OF ZBATCH WITH HEADER LINE .
IF SY-TCODE = 'MIGO'.
DELETE FROM ZBATCH WHERE ERSDA = SY-DATUM .
CLEAR GT_MCHB[] .
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_MCHB[] FROM MCHB
WHERE ERSDA = SY-DATUM
.
LOOP AT GT_MCHB.
GT_ZBATCH-MATNR = GT_MCHB-MATNR.
GT_ZBATCH-WERKS = GT_MCHB-WERKS.
GT_ZBATCH-CHARG = GT_MCHB-CHARG.
GT_ZBATCH-ERSDA = GT_MCHB-ERSDA.
GT_ZBATCH-CHARG_C = GT_MCHB-CHARG(6).
APPEND GT_ZBATCH .
CLEAR GT_MCHB .
CLEAR GT_ZBATCH .
ENDLOOP.
MODIFY ZBATCH FROM TABLE GT_ZBATCH[] .
ENDIF.
*} INSERT
这篇关于MIGO批次增强总结技巧的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!