ZPPFM007 获取销售BOM数据

FUNCTION zppfm007.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(I_MATNR) TYPE  MATNR
*"     VALUE(I_VBELN) TYPE  KDST-VBELN
*"     VALUE(I_VBPOS) TYPE  KDST-VBPOS
*"  EXPORTING
*"     VALUE(O_MSG) TYPE  TEXT200
*"  TABLES
*"      O_STPOX STRUCTURE  STPOX
*"      O_CSCMAT STRUCTURE  CSCMAT
*"      O_MARA STRUCTURE  MARA
*"      O_MAKT STRUCTURE  MAKT
*"----------------------------------------------------------------------
*  TABLES: mara.
*  TABLES: makt.

  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE o_mara"主表
  FROM mara
  WHERE mara~matnr = i_matnr.

  IF sy-subrc IS NOT INITIAL.
    o_msg = '物料不存在'.
    EXIT.
  ELSE.
    o_msg = 'OK'.
  ENDIF.

  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE o_makt"主表
  FROM makt
  WHERE makt~matnr = i_matnr.






  CALL FUNCTION 'CS_BOM_EXPL_KND_V1'
    EXPORTING
      capid                 = 'PP01'
      datuv                 = sy-datum
      emeng                 = 0
      mktls                 = 'X'
      mehrs                 = 'X'
      mtnrv                 = i_matnr "BOM料号
      stpst                 = 0
      svwvo                 = 'X'
      werks                 = '1001'
      vbeln                 = i_vbeln "销售订单
      vbpos                 = i_vbpos "'000010'"行号
      vrsvo                 = 'X'
    TABLES
      stb                   = o_stpox
      matcat                = o_cscmat
    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.
ENDFUNCTION.

你可能感兴趣的:(SAP,APAP)