概述
SAP 生产订单工序外协对应的工序报工后,对应的采购订单自动入库
对于工序外协的采购订单,一般不会涉及到库存管理,收货也只是一笔费用,然而对于工序外协的采购订单收货后,一般都需要质检。质检会对合格数量进行确认。我们比较理想的情况就是确认合格数量的时候其对应的采购订单自动入库。基本配置及流程如下:
1.定义控制码:用于质检和外协
2.该物料维护03的检验类型,下达生产订单自动产生检验批。
3.调度员打印工序外协派工单,供应商按照工序外协派工单进行送货
4,质检对供应商送的货物进行判定,使用QE51N,记录检验结果,确认合格数量
5.业务员按照供应商开具的发票进行发票校验
在增强CONFPP05-PP定单确认:储存时的客户特殊增强中添加如下代码:
DATA: L_WERKS LIKE CAUFVD_TAB-WERKS, "工厂
L_AUFNR LIKE CAUFVD_TAB-AUFNR, "生产订单
L_AUFPL LIKE CAUFVD_TAB-AUFPL, "工艺路线号
L_LMNGA LIKE AFRUD_TAB-LMNGA, "报工数量
L_VORNR LIKE AFRUD_TAB-VORNR. "工序号
DATA: L_FRGKZ LIKE EBAN-FRGKZ, "采购申请批准标识
L_STEUS LIKE AFVC-STEUS,
L_BANFN LIKE AFVC-BANFN, "采购申请号
L_BNFPO LIKE AFVC-BNFPO. "采购申请行项目
DATA: BEGIN OF T_EKPO OCCURS 0,
MATNR LIKE EKPO-MATNR,
WERKS LIKE EKPO-WERKS,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
BANFN LIKE EKPO-BANFN,
BNFPO LIKE EKPO-BNFPO, "采购申请行项目
MENGE LIKE EKPO-MENGE,
WEMNG LIKE EKET-WEMNG,
END OF T_EKPO.
DATA: BEGIN OF T_EKET OCCURS 0,
EBELN LIKE EKET-EBELN,
EBELP LIKE EKET-EBELP,
WEMNG LIKE EKET-WEMNG,
END OF T_EKET.
IF sy-tcode = 'QE51N'.
LOOP AT CAUFVD_TAB.
L_WERKS = CAUFVD_TAB-WERKS.
L_AUFNR = CAUFVD_TAB-AUFNR.
L_AUFPL = CAUFVD_TAB-AUFPL.
ENDLOOP.
LOOP AT AFRUD_TAB.
L_LMNGA = AFRUD_TAB-LMNGA.
L_VORNR = AFRUD_TAB-VORNR.
ENDLOOP.
SELECT SINGLE STEUS BANFN BNFPO
INTO (L_STEUS,L_BANFN,L_BNFPO)
FROM AFVC
WHERE AUFPL = L_AUFPL
AND VORNR = L_VORNR.
IF L_WERKS = '5000'.
IF L_STEUS = 'ZP02' OR L_STEUS = 'ZP05' .
SELECT SINGLE FRGKZ
INTO L_FRGKZ
FROM EBAN
WHERE BANFN = L_BANFN
AND BNFPO = L_BNFPO.
IF L_FRGKZ = '2'.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE T_EKPO
FROM EKPO
WHERE BANFN = L_BANFN
AND BNFPO = L_BNFPO.
IF T_EKPO[] IS NOT INITIAL."+++采购订单+++
SELECT *
INTO CORRESPONDING FIELDS OF TABLE T_EKET
FROM EKET
FOR ALL ENTRIES IN T_EKPO
WHERE EBELN = T_EKPO-EBELN
AND EBELP = T_EKPO-EBELP.
LOOP AT T_EKPO.
READ TABLE T_EKET WITH KEY EBELN = T_EKPO-EBELN EBELP = T_EKPO-EBELP.
IF SY-SUBRC = 0.
T_EKPO-WEMNG = T_EKET-WEMNG.
MODIFY T_EKPO.
ENDIF.
ENDLOOP.
"调用BAPI自动报工
IF L_LMNGA > 0. "+++判断报工数量+++
DATA: BEGIN OF T_HEADER.
INCLUDE STRUCTURE BAPI2017_GM_HEAD_01.
DATA: END OF T_HEADER.
DATA: BEGIN OF T_CODE.
INCLUDE STRUCTURE BAPI2017_GM_CODE.
DATA: END OF T_CODE.
DATA: MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC,
T_ITEM TYPE TABLE OF BAPI2017_GM_ITEM_CREATE WITH HEADER LINE,
T_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
DATA: L_MENGE LIKE EKPO-MENGE.
T_HEADER-PSTNG_DATE = sy-datum.
T_HEADER-DOC_DATE = sy-datum.
T_HEADER-PR_UNAME = sy-uname.
T_HEADER-HEADER_TXT = '外协工序质检报工后自动收货'.
T_CODE-GM_CODE = '01'.
LOOP AT T_EKPO.
L_MENGE = T_EKPO-MENGE - T_EKPO-WEMNG.
IF L_LMNGA >= L_MENGE.
T_ITEM-ENTRY_QNT = L_MENGE.
L_LMNGA = L_LMNGA - L_MENGE.
ELSE.
T_ITEM-ENTRY_QNT = L_LMNGA.
ENDIF.
* T_ITEM-MATERIAL = T_EKPO-MATNR.
T_ITEM-PLANT = T_EKPO-WERKS.
* T_ITEM-STGE_LOC = T_EKPO-LGORT.
T_ITEM-MOVE_TYPE = 'X01'.
T_ITEM-MVT_IND = 'B'.
* T_ITEM-MOVE_PLANT = '1000'.
* T_ITEM-MOVE_STLOC = zblko-lgort_s.
T_ITEM-PO_NUMBER = T_EKPO-EBELN.
T_ITEM-PO_ITEM = T_EKPO-EBELP.
APPEND T_ITEM.
ENDLOOP.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = T_HEADER
GOODSMVT_CODE = T_CODE
* TESTRUN = ' '
* GOODSMVT_REF_EWM =
IMPORTING
* GOODSMVT_HEADRET =
MATERIALDOCUMENT = MATERIALDOCUMENT
* MATDOCUMENTYEAR =
TABLES
GOODSMVT_ITEM = T_ITEM
* GOODSMVT_SERIALNUMBER =
RETURN = T_RETURN
* GOODSMVT_SERV_PART_DATA =
* EXTENSIONIN =
.
IF MATERIALDOCUMENT IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
ELSE.
* MESSAGE '自动入库不成功,请通知库房收货!' TYPE 'I'.
* 处理BAPI错误 "消息类型: S 成功,E 错误,W 警告,I 信息,A 中断
LOOP AT T_RETURN.
IF T_RETURN-TYPE = 'E'.
MESSAGE T_RETURN-MESSAGE TYPE 'E'.
ENDIF.
ENDLOOP.
ENDIF.
ELSE.
MESSAGE '您输入的报工数量为0!' TYPE 'W'.
ENDIF. "+++判断报工数量+++
ELSE.
MESSAGE '此工序对应的采购申请未转采购订单,该工序无法质检报工!' TYPE 'E'.
ENDIF. "+++判断采购订单+++
ELSE.
MESSAGE '此工序对应的采购申请未审批,该工序无法质检报工!' TYPE 'E'.
ENDIF. "+++判断采购申请是否审批通过+++
ENDIF. "+++判断控制码+++
ENDIF."+++判断工厂+++
ENDIF. "+++判断事物代码+++
最后
以上就是火星上跳跳糖为你收集整理的SAP 生产订单工序的全部内容,希望文章能够帮你解决SAP 生产订单工序所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复