当前位置: 首页 > article >正文

SAP PP CSAP_MAT_BOM_MAINTAIN BOM ECN 删除组件

SAP PP CSAP_MAT_BOM_MAINTAIN BOM ECN 删除组件

DATA: TEMP_MAT     TYPE MATNR,
        TEMP_WERKS   TYPE WERKS_D,
        TEMP_STLNR   LIKE MAST-STLNR, "物料单号(bom号)
        RETURN(220)  TYPE C,
        ISFIND(1)    TYPE C,
        FROMDATE(10) TYPE C.
  DATA:TEMP_MATNR TYPE MATNR.
  DATA: BEGIN OF ZLOG,
          MATNR             TYPE MATNR,
          WERKS             TYPE WERKS_D,
          INTERFACENAME(60) TYPE C,
          LOGDATE           TYPE DATUM,
          LOGTIME           TYPE UZEIT,
          MAKTX             TYPE MAKTX,
          MEINS             TYPE MEINS,
          MBRSH             TYPE MBRSH,
          LVORM             TYPE LVORM,
          MTART             TYPE MTART,
          SPART             TYPE SPART,
          MATKL             TYPE MATKL,
          BISMT             TYPE BISMT,
          LGFSB             TYPE LGFSB,
          EORIGINNO(40)     TYPE C,
          CREATER(20)       TYPE C,
          MESSAGETYPE(1)    TYPE C,
          MESSAGE(220)      TYPE C,
        END OF ZLOG.

  DATA: BEGIN OF SUBMATNR_COUNT,"用于记录在同一层级下相同子物料,相同数量,出现的次数。
          SUBMATNR TYPE MATNR,
          MENGE    TYPE KMPMG,
          COUNT    TYPE I,
        END OF SUBMATNR_COUNT.

  DATA:SAP_SUBMATNR_COUNT LIKE SUBMATNR_COUNT,
       PLM_SUBMATNR_COUNT LIKE SUBMATNR_COUNT.

  DATA: NO1 TYPE I,
        NO2 TYPE I.

  DATA:I_STKO LIKE STKO_API01.

  DATA:BEGIN OF GS_INPUTPBOM,
         MATNR   TYPE MATNR,
         WERKS   TYPE WERKS_D,
         IDNRK   TYPE IDNRK,
         KMPMG   TYPE KMPMG,
         XUHAO   TYPE I,
         MEINS   TYPE MEINS,
         SORTP   TYPE SORTP,
         LOGDATE TYPE DATUM,
         LOGTIME TYPE UZEIT,
       END OF GS_INPUTPBOM.

  DATA:GT_STPO_INPUT LIKE TABLE OF STPO_API03 WITH HEADER LINE.
  DATA:GT_STPO_INPUTTO LIKE TABLE OF STPO_API03 WITH HEADER LINE.

  DATA: SAP_STPO LIKE TABLE OF STPO_API03 WITH HEADER LINE.
  DATA: SAP_STPU LIKE TABLE OF STPU_API01 WITH HEADER LINE.
  DATA: PDATAV LIKE  CSAP_MBOM-DATUV.
  DATA:INPUT_PBOM LIKE TABLE OF ZPBOM WITH HEADER LINE.
  DATA:I_MATNR LIKE MARA-MATNR.
  DATA:I_WERKS LIKE MARC-WERKS.
  I_MATNR = '000000000001900578'.
  I_WERKS = '1001'.
  PDATAV = SY-DATUM+0(4) && '-' &&  SY-DATUM+4(2) && '-' &&  SY-DATUM+6(2) .
*1. 根据父物料字段,对输入BOM表排序:
  CALL FUNCTION 'CSAP_MAT_BOM_READ'
    EXPORTING
      MATERIAL   = I_MATNR
      PLANT      = I_WERKS
      BOM_USAGE  = '1'
*     ALTERNATIVE = I_STLAL
      VALID_FROM = PDATAV
    TABLES
      T_STPO     = SAP_STPO
      T_STPU     = SAP_STPU
    EXCEPTIONS
      ERROR      = 1
      OTHERS     = 2.

*2.将plm的bom格式转化为SAP能处理的单层bom,并处理(行项目新建或修改和删除的处理)

  CLEAR TEMP_MAT.
  CLEAR TEMP_WERKS.
  I_STKO-BASE_QUAN = 1.
  I_STKO-BOM_STATUS = '01'.

  SELECT SINGLE DATUV INTO @DATA(LDATE1) FROM AENR WHERE AENNR = 'BG1010234'.
  PDATAV = LDATE1+(4) && '-' &&  LDATE1+4(2) && '-' &&  LDATE1+6(2).
  READ TABLE SAP_STPO INTO DATA(LSTMPSTPO) WITH KEY ITM_IDENT = 'A0000001'.
  IF LSTMPSTPO IS NOT INITIAL.
    MOVE-CORRESPONDING LSTMPSTPO TO GT_STPO_INPUT.
    GT_STPO_INPUT-ITM_IDENT = 'A0000001'.
    GT_STPO_INPUT-CHG_NO_TO = 'BG1010234'.
    GT_STPO_INPUT-VALID_TO = PDATAV.
    GT_STPO_INPUT-FLDELETE = 'X'.

    APPEND GT_STPO_INPUT.
  ENDIF.

  I_STKO-BASE_QUAN = 1.
  I_STKO-BASE_UNIT = 'EA'.

  CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'
    EXPORTING
      MATERIAL           = '000000000001900578'
      PLANT              = '1001'
      BOM_USAGE          = '1'   "物料清单用途 默认1
      CHANGE_NO          = 'BG1010234'
      VALID_FROM         = PDATAV
      I_STKO             = I_STKO
      FL_COMMIT_AND_WAIT = 'X'
      FL_BOM_CREATE      = 'X'
      FL_NEW_ITEM        = 'X'
      FL_COMPLETE        = 'X'
    TABLES
      T_STPO             = GT_STPO_INPUT
    EXCEPTIONS
      ERROR              = 1
      OTHERS             = 2.

  CALL FUNCTION 'MESSAGE_TEXT_BUILD'
    EXPORTING
      MSGID               = SY-MSGID
      MSGNR               = SY-MSGNO
      MSGV1               = SY-MSGV1
      MSGV2               = SY-MSGV2
      MSGV3               = SY-MSGV3
      MSGV4               = SY-MSGV4
    IMPORTING
      MESSAGE_TEXT_OUTPUT = RETURN.


  WRITE:/ RETURN.

写于 浙江台州  20241227


http://www.kler.cn/a/460744.html

相关文章:

  • 《深度学习梯度消失问题:原因与解决之道》
  • 整合版canal ha搭建--基于1.1.4版本
  • Servlet解析
  • Linux驱动开发学习准备(Linux内核源码添加到工程-Workspace)
  • springboot集成qq邮箱服务
  • 大带宽服务器和普通服务器相比较的优势
  • docker-compos mysql5.7主从配置
  • Python入门:9.递归函数和高阶函数
  • 2020最新整理版SpringBoot 面试题
  • 【C++】2029:【例4.15】水仙花数
  • Python列表推导常见问题解析:高效编程的陷阱与避坑指南
  • DeepSeek V3“报错家门”:我是ChatGPT
  • 【brew安装失败】DNS 查询 raw.githubusercontent.com 返回的是 0.0.0.0
  • 电子电气架构 --- 汽车电子电器设计概述
  • 用Pyside6 和sqlite3 重写了《电脑装配单》 加入切换主题 样式
  • 构建一个rust生产应用读书笔记7-确认邮件3
  • 【信息系统项目管理师】高分论文:论信息系统项目的沟通管理(不动产登记系统)
  • Python世界:人生苦短,我用Python
  • 一文讲清楚CSS3新特性
  • Hessian 矩阵与函数的凸性
  • 网络渗透测试实验二:网络嗅探与身份认证
  • 从零到一:构建高效、安全的电商数据API接口
  • Leetcode 从中序与后序遍历序列构造二叉树
  • Rocky Linux 下安装Liboffice
  • 计算机网络 (17)点对点协议PPP
  • Android音频效果处理:基于`android.media.audiofx`包的原理、架构与实现