批次特性设置必输,根据MRP控制者确定哪些特性无需必输。
FIELD-SYMBOLS:<FS_RESULT> TYPE DFBATCH.
FIELD-SYMBOLS:<FS_MSEG> TYPE MSEG.
DATA:LV_FIELDNAME TYPE STRING .
DATA:
LV_CLASSTYPE TYPE KLAH-KLART,
LV_CLASS TYPE KLAH-CLASS.
DATA:LV_MATNR TYPE MARC-MATNR,
LV_WERKS TYPE MARC-WERKS,
LV_CHARG TYPE MCHA-CHARG,
LV_BWART TYPE MSEG-BWART.
DATA:LS_NM TYPE NMTYPE .
DATA:LT_SEL TYPE TABLE OF COMW,
LS_SEL TYPE COMW.
FIELD-SYMBOLS:<FS_SEL> LIKE LT_SEL .
DATA:LV_TABLE TYPE STRING VALUE '(SAPLCLFM)SEL[]' ."MSC1N MSC2N
DATA:LV_MIGO TYPE STRING VALUE '(SAPLCTMS)SEL[]' ."migo 从migo获取批次信息。
DATA:LV_ATNAM1 TYPE ATNAM VALUE 'ZCG0006', "生产日期
LV_ATINN1 TYPE ATINN,
LV_ATNAM2 TYPE ATNAM VALUE 'ZCG0007', "生产批号
LV_ATINN2 TYPE ATINN,
LV_ATNAM3 TYPE ATNAM VALUE 'ZCG0012', "生产产线
LV_ATINN3 TYPE ATINN.
DATA:LV_FLAG TYPE CHAR01 .
DATA:LV_MEMORY TYPE STRING .
DATA:LV_NOCHECK TYPE CHAR01 .
*转换为内码。
CALL FUNCTION 'CONVERSION_EXIT_ATINN_INPUT'
EXPORTING
INPUT = LV_ATNAM1
IMPORTING
OUTPUT = LV_ATINN1.
CALL FUNCTION 'CONVERSION_EXIT_ATINN_INPUT'
EXPORTING
INPUT = LV_ATNAM2
IMPORTING
OUTPUT = LV_ATINN2.
CALL FUNCTION 'CONVERSION_EXIT_ATINN_INPUT'
EXPORTING
INPUT = LV_ATNAM3
IMPORTING
OUTPUT = LV_ATINN3.
CHECK SY-TCODE EQ 'MSC1N' OR SY-TCODE EQ 'MSC2N' OR SY-TCODE EQ 'MIGO' OR SY-TCODE EQ 'ZMM105' OR SY-TCODE EQ 'QA11'.
*
IF SY-TCODE EQ 'QA11' .
DELETE NM WHERE ATINN EQ LV_ATINN1 .
DELETE NM WHERE ATINN EQ LV_ATINN2 .
DELETE NM WHERE ATINN EQ LV_ATINN3 .
RETURN .
ENDIF .
IF SY-TCODE EQ 'ZMM105' .
*期初库存561导入需要排除批次必输校验。
IMPORT P1 = LV_MEMORY FROM MEMORY ID 'ZCHARG' .
IF SY-SUBRC = 0 AND LV_MEMORY = 'ZMM105' .
DELETE NM WHERE ATINN EQ LV_ATINN1 .
DELETE NM WHERE ATINN EQ LV_ATINN2 .
DELETE NM WHERE ATINN EQ LV_ATINN3 .
RETURN .
ENDIF .
ENDIF .
* IF SY-UNAME EQ 'YNS_MDM' .
IF SY-TCODE EQ 'MSC1N' OR SY-TCODE EQ 'MSC2N' .
LV_FIELDNAME = '(SAPLCHRG)DFBATCH' .
ASSIGN (LV_FIELDNAME) TO <FS_RESULT> .
IF SY-SUBRC = 0 .
LV_MATNR = <FS_RESULT>-MATNR.
LV_WERKS = <FS_RESULT>-WERKS .
LV_CHARG = <FS_RESULT>-CHARG .
ELSE .
RETURN .
ENDIF .
* ASSIGN (LV_TABLE) TO <FS_SEL> .
* IF SY-SUBRC <> 0 .
* RETURN .
* ENDIF .
ELSEIF SY-TCODE EQ 'MIGO' .
*MIGO 103创建批次不进行特性校验。
IMPORT P1 = LV_NOCHECK FROM MEMORY ID 'MIGO103' .
IF SY-SUBRC = 0 AND LV_NOCHECK = 'X' .
DELETE NM WHERE ATINN EQ LV_ATINN1 .
DELETE NM WHERE ATINN EQ LV_ATINN2 .
DELETE NM WHERE ATINN EQ LV_ATINN3 .
RETURN .
ELSE .
LV_FIELDNAME = '(SAPMM07M)MSEG' .
ASSIGN (LV_FIELDNAME) TO <FS_MSEG> .
IF SY-SUBRC = 0 .
LV_MATNR = <FS_MSEG>-MATNR .
LV_WERKS = <FS_MSEG>-WERKS .
ELSE .
RETURN .
ENDIF .
ENDIF .
* ASSIGN (LV_MIGO) TO <FS_SEL> .
* IF SY-SUBRC <> 0 .
* RETURN .
* ENDIF .
ENDIF .
*物料工厂不为空。
CHECK LV_WERKS IS NOT INITIAL AND LV_MATNR IS NOT INITIAL .
*获取物料类型和MRP控制着。
SELECT
SINGLE
MARA~MTART,
MARA~MATNR,
MARC~WERKS,
MARC~DISPO
INTO @DATA(LS_INFO)
FROM MARA INNER JOIN MARC ON MARC~MATNR EQ MARA~MATNR
WHERE MARA~MATNR EQ @LV_MATNR
AND MARC~WERKS EQ @LV_WERKS .
CHECK SY-SUBRC = 0 .
*校验物料类型和MRP控制者 。MRP控制者为成品或者半成品时候。
*4BCP 物料类型 2SCX AND (MARC-WERKS)= 输入参数工厂 AND (MARC-DISPO) = 106
*5CP 物料类型 2SCX AND (MARC-WERKS)= 输入参数工厂 AND (MARC-DISPO) = 104
*由于批次特性设置了必须输入,所以反正来。
CHECK LS_INFO-MTART EQ '2SCX'.
*获取物料的分类HYSCX001 。
CALL FUNCTION 'CLFC_BATCH_ALLOCATION_TO_CLASS'
EXPORTING
MATERIAL = LS_INFO-MATNR
* PLANT =
CLASSTYPE = '022'
* I_IGNORE_MATMASTER = ' '
* I_BATCHES_ONLY =
* I_IGNORE_BUFFER = ' '
IMPORTING
CLASSTYPE = LV_CLASSTYPE
CLASS = LV_CLASS
EXCEPTIONS
NO_CLASS_FOUND = 1
NO_CLASSTYPE_FOUND = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
RETURN .
ENDIF.
CHECK LV_CLASS EQ 'HYSCX001' .
*MIGO 104和106入库业务批次特性必输,出库则不受影响 。其它MRP控制者批次特性不用输入。
IF SY-TCODE EQ 'MIGO' .
CASE LS_INFO-DISPO .
WHEN '104' ."成品校验所有
WHEN '106' . "半成品不校验产线
DELETE NM WHERE ATINN EQ LV_ATINN3 .
WHEN OTHERS .
DELETE NM WHERE ATINN EQ LV_ATINN1 .
DELETE NM WHERE ATINN EQ LV_ATINN2 .
DELETE NM WHERE ATINN EQ LV_ATINN3 .
ENDCASE .
ELSE .
CASE LS_INFO-DISPO .
WHEN '104' ."成品校验所有
WHEN '106' . "半成品不校验产线
DELETE NM WHERE ATINN EQ LV_ATINN3 .
WHEN OTHERS .
DELETE NM WHERE ATINN EQ LV_ATINN1 .
DELETE NM WHERE ATINN EQ LV_ATINN2 .
DELETE NM WHERE ATINN EQ LV_ATINN3 .
ENDCASE .
ENDIF .
今天的文章SAP ABAP 批次特性必输项校验BADI CACL_MAIN01分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/8875.html