CS_BOM_EXPL_MAT_V2

*&---------------------------------------------------------------------*
*&      Form  BOM_EXPLOSION
*&---------------------------------------------------------------------*
FORM bom_explosion.
  DATA: g_ccxfeld TYPE ccxfeld.

  IF r_nobom = 'X'.
    g_ccxfeld = ''.
  ELSE.
    g_ccxfeld = 'X'.  " 展BOM
  ENDIF.

  CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
    EXPORTING
*"     VALUE(FTREL) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(ALEKZ) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(ALTVO) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(AUFSW) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(AUMGB) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(AUMNG) LIKE  STKO-BMENG DEFAULT 0
*"     VALUE(AUSKZ) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(AMIND) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(BAGRP) LIKE  MARA-MATNR DEFAULT SPACE
*"     VALUE(BEIKZ) LIKE  STPO-BEIKZ DEFAULT SPACE
*"     VALUE(BESSL) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(BGIXO) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(BREMS) LIKE  CSDATA-XFELD DEFAULT SPACE
      capid  = 'PP01'
*"     VALUE(CHLST) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(COSPR) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(CUOBJ) LIKE  MARC-CUOBJ DEFAULT 000000000000000
*"     VALUE(CUOVS) TYPE  IBVERSION DEFAULT 0
*"     VALUE(CUOLS) LIKE  CSDATA-XFELD DEFAULT SPACE
      datuv  = sy-datum
*"     VALUE(DELNL) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(DRLDT) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(EHNDL) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(EMENG) LIKE  STKO-BMENG DEFAULT 0
*"     VALUE(ERSKZ) LIKE  STPO-ERSKZ DEFAULT SPACE
*"     VALUE(ERSSL) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(FBSTP) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(KNFBA) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(KSBVO) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(MBWLS) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(MKTLS) LIKE  CSDATA-XFELD DEFAULT 'X'
*"     VALUE(MDMPS) LIKE  CSDATA-XFELD DEFAULT SPACE
      mehrs  = g_ccxfeld  " X:多階, 空白:單階
*"     VALUE(MKMAT) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(MMAPS) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(SALWW) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(SPLWW) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(MMORY) LIKE  CSDATA-XFELD DEFAULT SPACE
      mtnrv  = gt_input-matnr "gt_data-matnr
*"     VALUE(NLINK) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(POSTP) LIKE  STPO-POSTP DEFAULT SPACE
*"     VALUE(RNDKZ) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(RVREL) LIKE  STPO-RVREL DEFAULT SPACE
*"     VALUE(SANFR) LIKE  STPO-SANFE DEFAULT SPACE
*"     VALUE(SANIN) LIKE  STPO-SANIN DEFAULT SPACE
*"     VALUE(SANKA) LIKE  STPO-SANKA DEFAULT SPACE
*"     VALUE(SANKO) LIKE  STPO-SANKO DEFAULT SPACE
*"     VALUE(SANVS) LIKE  STPO-SANVS DEFAULT SPACE
*"     VALUE(SCHGT) LIKE  STPO-SCHGT DEFAULT SPACE
*"     VALUE(STKKZ) LIKE  STPO-STKKZ DEFAULT SPACE
*"     VALUE(STLAL) LIKE  STKO-STLAL DEFAULT SPACE
*"     VALUE(STLAN) LIKE  STZU-STLAN DEFAULT SPACE
      stpst  = 0
*"     VALUE(SVWVO) LIKE  CSDATA-XFELD DEFAULT 'X'
      werks  = gt_input-werks "'BP01'
*"     VALUE(NORVL) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(MDNOT) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(PANOT) LIKE  CSDATA-XFELD DEFAULT SPACE
*"     VALUE(QVERW) LIKE  TMQ2-USEQU DEFAULT SPACE
      verid  = 'X'
*"     VALUE(VRSVO) LIKE  CSDATA-XFELD DEFAULT 'X'
    IMPORTING
      topmat = topmatx
    TABLES
      stb    = stbp
    EXCEPTIONS
      alt_not_found
      call_invalid
      material_not_found
      missing_authorization
      no_bom_found
      no_plant_data
      no_suitable_bom_found
      conversion_error.

  IF NOT sy-subrc = 0.
    EXIT.
  ENDIF.
ENDFORM. " BOM_EXPLOSION