T-Code:SMOD-PPCO0007
*&---------------------------------------------------------------------* *& 包含 ZXCO1U06 *&---------------------------------------------------------------------* *[MOD-01] 18.09.2021 17:51:22 ysx 检查工单所有工序的工序控制码,有且只能是最后一道工序的控制码为ZP04 *[MOD-02] 31.08.2022 14:19:42 YSX 已下达工单保存判断工序是否状态为删除_ysx_pkm_20220831 DATA:lv_order TYPE cobrb-objnr. DATA:lt_afvg TYPE TABLE OF afvgdget WITH HEADER LINE. DATA:lt_afvg_old TYPE TABLE OF afvgd WITH HEADER LINE. DATA: lv_line TYPE i. DATA: lt_resbd TYPE TABLE OF resbdget WITH HEADER LINE. SELECT SINGLE * FROM zbasis_zq INTO @DATA(lv_zbasis_zq) WHERE zkhd = @sy-mandt. CASE lv_zbasis_zq-zkzma. WHEN 'Z001'. "凯卓威 "校验结算规则是否维护订单 IF header_imp-auart = 'ZK07' . CONCATENATE 'OR' header_imp-aufnr INTO lv_order. ASSIGN ('(SAPLKOBS)COBL-VORGN') TO FIELD-SYMBOL(<fs_str2>) . IF sy-subrc = 0.. IF <fs_str2> IS INITIAL.. SELECT SINGLE * FROM cobrb INTO @DATA(ls_cobrb) WHERE objnr = @lv_order. IF sy-subrc = 0 . IF ls_cobrb-aufnr IS INITIAL . * MESSAGE '订单未维护' TYPE 'E'. MESSAGE e000(zpp) . ENDIF. ELSE. MESSAGE e000(zpp) . ENDIF. ELSE. ASSIGN ('(SAPLKOBS)COBL-AUFNR') TO FIELD-SYMBOL(<fs_str>) . IF sy-subrc = 0. IF <fs_str> IS INITIAL. MESSAGE e000(zpp). ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. * ASSIGN ('(SAPLKOBS)COBL-AUFNR') TO FIELD-SYMBOL(<fs_str>) . * ** IMPORT i_aufk FROM MEMORY ID 'KO'. * IF sy-subrc = 0. * IF <fs_str> IS INITIAL. * SELECT SINGLE * FROM cobrb INTO @DATA(ls_cobrb) WHERE objnr = @lv_order. * IF sy-subrc = 0 . * IF ls_cobrb-aufnr IS INITIAL . ** MESSAGE '订单未维护' TYPE 'E'. * MESSAGE e000(zpp) . * ENDIF. * ELSE. * MESSAGE e000(zpp) . * ENDIF. * * ENDIF. * ENDIF. *ADD BY JT-WUW 20210517-保存校验反冲料组件库存地点不为空 CALL FUNCTION 'CO_BC_RESBD_OF_ORDER_GET' EXPORTING aufnr_act = header_imp-aufnr TABLES resbd_get = lt_resbd. LOOP AT lt_resbd WHERE rgekz = abap_true AND xloek = space. IF lt_resbd-lgort IS INITIAL. * 反冲组件&1库存地点为空! MESSAGE e001(zpp) WITH lt_resbd-matnr. ENDIF. ENDLOOP. *END ADD "[MOD-01] YSX 有且只能是最后一道工序的控制码为ZP04 CASE header_imp-auart. WHEN 'ZD04' OR 'ZD07' OR 'ZD08' OR 'ZY04' OR 'ZY07' OR 'ZY08' OR 'ZC04' OR 'ZC07' OR 'ZC08' . WHEN OTHERS. CALL FUNCTION 'CO_BO_OPR_OF_ORDER_GET' EXPORTING aufnr_imp = header_imp-aufnr TABLES afvgd_get = lt_afvg. * AFVGT_OLD =. "考虑:重读后历史工序删除后进行判断 * SORT lt_afvg BY vornr rueck ASCENDING. * DELETE ADJACENT DUPLICATES FROM lt_afvg COMPARING vornr. DELETE lt_afvg WHERE vbkz = 'D'. SORT lt_afvg BY vornr DESCENDING. READ TABLE lt_afvg INTO DATA(ls_afvg) INDEX 1. IF sy-subrc = 0. IF ls_afvg-steus <> 'ZP04'. MESSAGE e002(zpp) WITH header_imp-matnr. ELSE. LOOP AT lt_afvg INTO DATA(ls_afvg_l). IF ls_afvg_l-steus = 'ZP04' AND sy-tabix <> '1' . MESSAGE e002(zpp) WITH header_imp-matnr. ENDIF. ENDLOOP. ENDIF. ENDIF. ENDCASE. WHEN 'K001'. "凯迪 "用于订单状态修改时,实时变更模具平台自建表的状态. "add by jt-tansh 20210127 IF header_imp-sttxt CS 'REL'. "update zppt001 set zmjzt = '05' WHERE aufnr = HEADER_IMP-aufnr. ELSEIF header_imp-sttxt CS 'DLV'. SELECT SINGLE * INTO @DATA(ls_zppt001) FROM zppt001 WHERE aufnr = @header_imp-aufnr. IF sy-subrc = 0. ls_zppt001-zmjzt = '07'."完模入库 MODIFY zppt001 FROM ls_zppt001 . ENDIF. ENDIF. "校验结算规则是否维护订单 IF header_imp-auart = 'ZD09' . CONCATENATE 'OR' header_imp-aufnr INTO lv_order. ASSIGN ('(SAPLKOBS)COBL-VORGN') TO <fs_str2> . IF sy-subrc = 0.. IF <fs_str2> IS INITIAL.. SELECT SINGLE * FROM cobrb INTO ls_cobrb WHERE objnr = lv_order. IF sy-subrc = 0 . IF ls_cobrb-aufnr IS INITIAL . * MESSAGE '订单未维护' TYPE 'E'. MESSAGE e000(zpp) . ENDIF. ELSE. MESSAGE e000(zpp) . ENDIF. ELSE. ASSIGN ('(SAPLKOBS)COBL-AUFNR') TO <fs_str> . IF sy-subrc = 0. IF <fs_str> IS INITIAL. MESSAGE e000(zpp). ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. * ASSIGN ('(SAPLKOBS)COBL-AUFNR') TO FIELD-SYMBOL(<fs_str>) . * ** IMPORT i_aufk FROM MEMORY ID 'KO'. * IF sy-subrc = 0. * IF <fs_str> IS INITIAL. * SELECT SINGLE * FROM cobrb INTO @DATA(ls_cobrb) WHERE objnr = @lv_order. * IF sy-subrc = 0 . * IF ls_cobrb-aufnr IS INITIAL . ** MESSAGE '订单未维护' TYPE 'E'. * MESSAGE e000(zpp) . * ENDIF. * ELSE. * MESSAGE e000(zpp) . * ENDIF. * * ENDIF. * ENDIF. *ADD BY JT-WUW 20210517-保存校验反冲料组件库存地点不为空 CALL FUNCTION 'CO_BC_RESBD_OF_ORDER_GET' EXPORTING aufnr_act = header_imp-aufnr TABLES resbd_get = lt_resbd. LOOP AT lt_resbd WHERE rgekz = abap_true AND xloek = space. IF lt_resbd-lgort IS INITIAL. * 反冲组件&1库存地点为空! MESSAGE e001(zpp) WITH lt_resbd-matnr. ENDIF. ENDLOOP. *END ADD "[MOD-01] YSX 有且只能是最后一道工序的控制码为ZP04 CASE header_imp-auart. WHEN 'ZD04' OR 'ZD07' OR 'ZD08' OR 'ZY04' OR 'ZY07' OR 'ZY08' OR 'ZC04' OR 'ZC07' OR 'ZC08' . WHEN OTHERS. CALL FUNCTION 'CO_BO_OPR_OF_ORDER_GET' EXPORTING aufnr_imp = header_imp-aufnr TABLES afvgd_get = lt_afvg afvgt_old = lt_afvg_old. "考虑:重读后历史工序删除后进行判断 * SORT lt_afvg BY vornr rueck ASCENDING. * DELETE ADJACENT DUPLICATES FROM lt_afvg COMPARING vornr. DELETE lt_afvg WHERE vbkz = 'D'. SORT lt_afvg BY vornr DESCENDING. "[MOD-02] 31.08.2022 14:20:01 YSX LOOP AT lt_afvg INTO ls_afvg. "判断该工序状态是否已经删除 SELECT COUNT(*) FROM jest WHERE objnr = @ls_afvg-objnr AND stat = 'I0013' AND inact IS INITIAL . IF sy-subrc = 0. DELETE lt_afvg WHERE vornr = ls_afvg-vornr. CONTINUE. ENDIF. "判断是否逻辑删除 CALL FUNCTION 'STATUS_CHECK' EXPORTING objnr = ls_afvg-objnr status = 'I0013' EXCEPTIONS object_not_found = 01 status_not_active = 02. IF sy-subrc = 0. DELETE lt_afvg WHERE vornr = ls_afvg-vornr. ENDIF. ENDLOOP. READ TABLE lt_afvg INTO ls_afvg INDEX 1. IF sy-subrc = 0. IF ls_afvg-steus <> 'ZP04'. MESSAGE e002(zpp) WITH header_imp-matnr. ELSE. LOOP AT lt_afvg INTO ls_afvg_l. IF ls_afvg_l-steus = 'ZP04' AND sy-tabix <> '1' . MESSAGE e002(zpp) WITH header_imp-matnr. ENDIF. ENDLOOP. ENDIF. ENDIF. ENDCASE. WHEN OTHERS. ENDCASE.
标签:imp,afvg,lt,CO02,CO03,ABAP,ls,ENDIF,MESSAGE From: https://www.cnblogs.com/ap-ad-java-abap/p/17756867.html