首页 > 其他分享 >ABAP:生产订单CO01/CO02/CO03保存前增强

ABAP:生产订单CO01/CO02/CO03保存前增强

时间:2023-10-11 13:58:54浏览次数:41  
标签:imp afvg lt CO02 CO03 ABAP ls ENDIF MESSAGE

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

相关文章

  • ABAP:CO11N报工选择屏幕增强
    T-Code:SMOD-CONFPP07AFRUD接口增强字段: 返回组件赋值*&---------------------------------------------------------------------**&包含ZXCOFU24*&---------------------------------------------------------------------*TABLES:afrud.DAT......
  • SAP ABAP 域(domain)固定值读取方法
    1SELECTSINGLEVALPOS2FROMDD07V3INTO@DATA(GT_DD07V)4WHEREDOMNAME='ZSTUTYPE'ANDVALPOS=@P_ZSTUTYP."域名和值5IFSY-SUBRC<>0.6MESSAGETEXT-134TYPE'S'DISPLAYLIKE'E......
  • SAP ABAP 常用事务代码
    SAPS4/HANA版本事务代码描述备注SE38ABAP编辑器 SE39ABAP分屏编辑器可用于编辑/检查两个程序(可在不同系统间)SE37ABAP函数编辑器 SE24ABAP类编辑器 SE80ABAP工作台 SA38ABAP程序执行仅适用于执行没有SE38权限且没有创建事务码的程序......
  • ABAP:财务的增强
    1.替代T-CODE:OBBH 配置公司代码下的调用点及替代步骤 这里需要进入T-CODE:GCX2中进行配置,然后再出口程序中进行代码编写,下面详解T-CODE:GCX2维护应用区域的退出程序 复制RGGBS000到ZRGGBS000,更改GBLS的退出程序名进入出口程序编写代码:首先把出口FORM添加到EX......
  • ABAP:年份+月份搜索帮助
    *&---------------------------------------------------------------------**&包含ZPPR011_S01*&---------------------------------------------------------------------*SELECTION-SCREENBEGINOFBLOCKblk1WITHFRAMETITLETEXT-001.......
  • SAP ABAP 关于SMARTFORMS编辑文本出现WORD样式
    SAPABAP关于SMARTFORMS编辑文本出现WORD样式问题描述:SAPABAP关于SMARTFORMS编辑时文本默认使用WORD在使用smartforms打开编辑文本的时候会出现word样式,这样就会出现无法拖拽字段和系统默认信息情况,导致部分功能无法使用解决方案:通过SE38打开程序RSCPSETEDITOR将SAPscript......
  • 【wabapp】jsp输出内容
    静态HTML内容:JSP页面中的所有静态HTML内容,例如标签、文本、图像等,会直接显示在生成的HTML页面中。这些内容不受JSP代码的影响,会原样输出。jspCopy<!DOCTYPEhtml><html><head><metacharset="UTF-8"><title>StaticHTMLContent</title></head><......
  • 什么是 ABAP Dynpro 程序
    在SAP系统中,Dynpro(DynamicProgram)是一个非常重要的概念。Dynpro是用于建立SAP的图形界面的一种工具,可以帮助我们创建和管理用户界面。ABAPDynpro程序通常用于创建交互式应用程序,可以帮助用户以图形界面的方式与系统进行交互。一个ABAPDynpro程序由一系列的屏幕组成,每......
  • 什么是 SAP ABAP 系统的 Transport Request
    在SAP系统中,TransportRequest(TR)是一个非常重要的组成部分,它是SAP系统中实施改变和确保这些改变能够从一个系统(例如开发系统)传输到另一个系统(例如测试或生产系统)的关键工具。简单来说,TransportRequest主要用于在SAP系统间迁移配置和开发对象。在SAP系统中,所有的配......
  • ABAP 异常处理(Exception Handling) - 什么是 Non-Class-Based 异常试读版
    本教程前一篇文章,笔者介绍了ABAP系统里查看程序运行时错误的一个有用工具:事务码ST22:112.SAPABAPDumpAnalysis(ST22)工具的使用和背景介绍在笔者实际工作过程中,发现部分开发人员,对于运行时错误(RuntimeError)和异常(Exception)这些概念的区别,理解得不是很清楚,因此使......