zoukankan      html  css  js  c++  java
  • SAP BOM 读取

    1.查找 物料号、工厂、物料描述。

                表:MARA MARC MAKT

                逻辑:  

                           输入物料(选择选项)中的物料编号(MARA-MATNR)和
                           输入工厂(选择选项)中的工厂(MARC-WERKS)和
                           输入物料类型(选择选项)中的物料类型(MARA-MTART)。
                           注意:继续执行步骤2或3或4取决于“生产”或“工程”或“所有物料清单”选项的输入单选按钮。

               代码:

    SELECT   A~MATNR,
                  B~WERKS,
                  A~MTART,
                  C~MAKTX  
                INTO TABLE @DATA(LT_MAT)
                FROM MARA AS A 
                JOIN  MARC AS B ON A~MATNR = B~MATNR
                JOIN  MAKT AS C ON B~MATNR = C~MATNR
                WHERE A~MATNR IN @S_MATNR
                AND B~WERKS IN @S_WERKS
                AND  A~MTART IN  @S_MTART.

    2.查找BOM  工程项目。

           表:MAST.

           代码:

    SELECT MATNR,
                WERKS,
                STLAN,     "BOM Usage
                STLNR,     "Bill of material
                STLAL       "Alternative BOM
           INTO TABLE @DATA(LT_MAST)
           FROM MAST 
           FOR ALL ENTRIES IN @LT_MAT
           WHERE MATNR = @LT_MAT-MATNR
            AND     WERKS IN @S_WERKS
           AND     STLAN =  '2'."engineering usage.
    
         IF LT_MAST IS NOT INITIAL.
          "BOM HEADER DATA
          SELECT STLTY,    "BOM category
                      STLNR,
                      STLAL ,
                      STKOZ,   "Internal counter
                      LOEKZ ,    "Deletion flag for BOMs
                      ANDAT,     "Date record created on
                      BMEIN,     "Base unit of measure for BOM
                      BMENG,    "Base quantity
             INTO TABLE @DATA(LT_STKO)
             FROM STKO 
             FOR ALL ENTRIES IN @LT_MAST
             WHERE STLNR = @LT_MAST-STLNR
             AND     STLAL = @LT_MAST-STLAL.
    
            "BOM ITEM DATA
             SELECT STLNR,
                         STLKN,
                         STPOZ,
                         POSTP
              INTO TABLE @DATA(LT_STPO)
              FROM STPO
              FOR ALL ENTRIES IN @LT_MAST
              WHERE STLNR = @LT_MAST-STLNR.
    
             "PERMANENT BOM DATA
               SELECT STLNR,
                           STLAN,
                           EXSTL,
                           ZTEXT
                INTO TABLE @DATA(LT_STZU)
                FROM STZU 
                FOR ALL ENTRIES IN @LT_MAST
                WHERE STLNR = @LT_MAST-STLNR.
    
              
         ENDIF.    

    3、查找BOM  产品。

               

           SELECT MATNR,
                       WERKS,
                       STLAN,     "BOM Usage
                       STLNR,     "Bill of material
                       STLAL       "Alternative BOM
           INTO TABLE @DATA(LT_MAST)
           FROM MAST 
           FOR ALL ENTRIES IN @LT_MAT
           WHERE MATNR = @LT_MAT-MATNR
            AND     WERKS IN @S_WERKS
           AND     STLAN =  '1'."Production usage
    
        
    
          "BOM HEADER          STKO
          "BOM ITEM               STPO
          "BOM TEXT               STZU
    
    "使用以下条件从表MKAL中按照数据映射读取生产版本和资源:
    
                 SELECT MATNR,
                             WERKS,
                             STLAL,
                             STLAN
                 INTO TABLE @DATA(LT_MKAL)
                  RROM MKAL 
                  FOR ALL ENTRIES IN @LT_MAST
                  WHERE MATNR = @LT_MAST-MATNR
                  AND     WERKS = @LT_MAST-WERKS.
    "注意:
        如果有多个工厂,则报告按工厂显示

    4、物料BOM比较。

             

           SELECT MATNR,
                       WERKS,
                       STLAN,     "BOM Usage
                       STLNR,     "Bill of material
                       STLAL       "Alternative BOM
           INTO TABLE @DATA(LT_MAST)
           FROM MAST 
           FOR ALL ENTRIES IN @LT_MAT
           WHERE MATNR = @LT_MAT-MATNR
            AND     WERKS IN @S_WERKS。
           
    
    "相关表列表:MAST Material BOM
    "STKO BOM Header
    "STPO BOM Positions (detail)
    "MAPL Assignment fo Task Lists to Materials
    "PLKO Routing Group Header
    "PLSO Routing Group Sequence
    "PLPO Routing Group Operations
    "AFKO Production Order Header
    "AFPO Production Order Position (details)
    "MKAL Production Version

    5.函数

               1》APIs for BOMs: Display Material BOM

                     CSAP_MAT_BOM_READ

    6、BOM 展开。

                 

    CALL FUNCTION 'CSAP_MAT_BOM_READ' "
    
      EXPORTING
    
        material =                  " csap_mbom-matnr  Material 物料编码
    
    *   plant =                      " csap_mbom-werks  Plant    工厂
    
        bom_usage =                 " csap_mbom-stlan  BOM usage BOM用途
    
    *   alternative =               " csap_mbom-stlal  Alternative BOM 可选的BOM
    
    *   valid_from =                " csap_mbom-datuv  Valid-from date 开始日期
    
    *   valid_to =                  " csap_mbom-datub  Valid-to date  截止日期
    
    *   change_no =                 " csap_mbom-aennr  Change number  变更号
    
    *   revision_level =            " csap_mbom-revlv  Revision level  版本级别
    
      IMPORTING
    
        fl_warning =                " capiflag-flwarning  Log contains warning messages
    
    * TABLES
    
    *   t_stpo =                    " stpo_api02    BOM items BOM明细
    
    *   t_stko =                    " stko_api02    BOM headers BOM表头
    
    *   t_dep_data =                " csdep_dat     Object dependencies: basic data
    
    *   t_dep_descr =               " csdep_desc    Object dependencies: description
    
    *   t_dep_order =               " csdep_ord     Object dependencies: sort sequence
    
    *   t_dep_source =              " csdep_sorc    Object dependencies: source code
    
    *   t_dep_doc =                 " csdep_doc     Object dependencies: documentation
    
      EXCEPTIONS
    
        ERROR = 1                   "               Terminate processing
    
     
    
    
    You can use this function module to display simple material BOMs. You cannot display BOM groups (for example, all variants of a variant BOM). as in transaction CS03.
    Current restrictions:

       

    CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
    
            EXPORTING
    
    *       ALEKZ                       = ' '              " 是否计算耗损
    
              capid                       = 'PP01'           " BOM应用
    
              datuv                       = sy-datum         " 有效起始日
    
              ehndl                       = '1'
    
              emeng                       = '1'              " 需求数量
    
              mehrs                       = 'X'              " 多层展开
    
              mmory                       = '1'              " 是否使用缓存
    
              mtnrv                       = itab_mast-matnr "'000000000090000199'     " 展开物料号
    
              stlan                       = '1'              " BOM用途
    
              werks                       = itab_mast-werks  "'1002'      " 物料所在工厂
    
    *     IMPORTING
    
    *       TOPMAT                      =
    
    *       DSTST                       =
    
            TABLES
    
              stb                         = stb
    
    *       MATCAT                      =
    
            EXCEPTIONS
    
              alt_not_found               = 1
    
              material_not_found          = 3
    
              missing_authorization       = 4
    
              no_bom_found                = 5
    
              OTHERS                      = 9
    
                    .
    
      IF sy-subrc <> 0.
    
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    
      ENDIF.
  • 相关阅读:
    go语言中文网
    理解Golang包导入
    如何保证对象的唯一性
    模拟java.util.Collection一些简单的用法
    静态代码块,构造代码块,局部代码块演示
    java中paint方法和paintComponent方法的不同
    java中异常注意问题(发生在多态是的异常问题)
    java中异常注意的细节2
    java中异常注意的细节1
    java中匿名类的注意细节
  • 原文地址:https://www.cnblogs.com/JackeyLove/p/13035597.html
Copyright © 2011-2022 走看看