关于展开销售订单BOM和物料BOM

 

**销售订单BOM展开**

DATA:  BEGIN OF it_stb OCCURS 0 .
        INCLUDE STRUCTURE stpox.
DATA:  END OF it_stb.

DATA: it_matcat LIKE TABLE OF cscmat WITH HEADER LINE.

DATA: BEGIN OF it_vbap1 OCCURS 0,
        vbeln LIKE vbap-vbeln,
        posnr LIKE vbap-posnr,
        cuobj LIKE vbap-cuobj ,
        matnr LIKE vbap-matnr ,
        werks LIKE vbap-werks,
        sernr LIKE vbap-sernr,   "bom展开号
        datuv LIKE sy-datum,
      END OF it_vbap1.

*取展销售订单BOM所需信息
  SELECT vbeln posnr cuobj matnr werks sernr
          "INTO (vbap-cuobj , vbap-matnr , vbap-werks)
          INTO CORRESPONDING FIELDS OF TABLE it_vbap1

          FROM vbap
          FOR ALL ENTRIES IN it_vbap
          WHERE vbeln = it_vbap-kdauf
            AND posnr = it_vbap-kdpos .
  IF it_vbap1[] IS INITIAL.
    EXIT.
  ENDIF.

  SELECT sernr brutr INTO TABLE it_snum
    FROM snum
    FOR ALL ENTRIES IN it_vbap1
    WHERE sernr = it_vbap1-sernr.

*取销售订单bom
          REFRESH: it_stb , it_matcat .
          CALL FUNCTION 'CS_BOM_EXPL_KND_V1'
            EXPORTING
              capid                 = 'PP01'                "BOM类别 pp01-Ebom(设计) pp02-Mbom(生产)
              datuv                 = it_snum-brutr         "BOM生效日期
              cuobj                 = it_vbap1-cuobj        "内部对象号
              brems                 = 'X'  有限展开
              stpst                 = '0'  "展开层级 0为展到底 默认为0        
              mdmps                 = 'X'  "仅展开到实件X  
              mehrs                 = 'X'  "多层展开 为空则只展开一层
              mtnrv                 = it_vbap1-matnr        "物料
              werks                 = it_vbap1-werks        "工厂
              vbeln                 = it_vbap-kdauf         "销售订单号
              vbpos                 = it_vbap-kdpos         "项目
            TABLES
              stb                   = it_stb
              matcat                = it_matcat
            EXCEPTIONS
              alt_not_found         = 1
              call_invalid          = 2
              material_not_found    = 3
              missing_authorization = 4
              no_bom_found          = 5
              no_plant_data         = 6
              no_suitable_bom_found = 7
              conversion_error      = 8
              OTHERS                = 9.

 DELETE it_stb WHERE stufe > 2 AND dumps = 'X' .  "stufe-BOM层级   dumps-虚件标识


**物料BOM展开**

DATA:  BEGIN OF it_stb1 OCCURS 100 .
        INCLUDE STRUCTURE stpox.
DATA:  END OF it_stb1.

DATA: it_matcat1 LIKE TABLE OF cscmat WITH HEADER LINE.

                  REFRESH: it_stb1 , it_matcat1.
                  CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
                    EXPORTING
                      capid                  = 'PP01'          "BOM类别
                      datuv                  = sy-datum        "BOM有效日期
                      mdmps                  = ' '             "仅展开道实零件
                      mehrs                  = 'X'             "多层展开
                      mtnrv                  = it_stb-idnrk    "物料号        
                      werks                  = '2000'          "工厂
*         IMPORTING
*           TOPMAT                      =
*           DSTST                       =
                    TABLES
                      stb                    = it_stb1
                      matcat                 = it_matcat1
                    EXCEPTIONS
                      alt_not_found               = 1
                      call_invalid                = 2
                      material_not_found          = 3
                      missing_authorization       = 4
                      no_bom_found                = 5
                      no_plant_data               = 6
                      no_suitable_bom_found       = 7
                      conversion_error            = 8
                      OTHERS                      = 9 .

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值