相关的多层扩展bom的函数有很多,下面列出的是 三个最常用的物料bom扩展函数和两个文档结构扩展函数。
当然后有其它一些相关的函数,这些函数都是cs_bom开头。
在使用的时候注意这个属性 MEHRS ,如果 MEHRS = 'X' 则会多层扩展,否则,只打开当前bom。
DATA: stb TYPE STANDARD TABLE OF stpox WITH HEADER LINE.
DATA: matcat TYPE STANDARD TABLE OF cscmat WITH HEADER LINE.
p_mat TYPE rc29l-matnr OBLIGATORY, 物料号
p_wer TYPE rc29l-werks DEFAULT '2000' , "工厂
p_stl TYPE rc29l-stlal, " 可选择的bom
p_cap TYPE rc29l-capid OBLIGATORY, "bom应用 PP01 ZDES
p_dat TYPE rc29l-datuv DEFAULT sy-datum. "日期
"扩展物料BOM1
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = p_cap
datuv = p_dat
mehrs = 'X'
mtnrv = p_mat
stlal = p_stl
werks = p_wer
IMPORTING
topmat = topmat
TABLES
stb = stb " 详细列表
matcat = matcat "BOM列表
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.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"扩展物料BOM2
DATA: stbp TYPE STANDARD TABLE OF CSXGEN WITH HEADER LINE.
CALL FUNCTION 'CS_BOM_EXPLOSION'
EXPORTING
capid = p_cap
datuv = p_dat
mehrs = 'X'
mtnrv = p_mat
stlal = p_stl
werks = p_wer
IMPORTING
topmat = topmat
TABLES
stb = stb " 详细列表
matcat = matcat "BOM列表
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MISSING_AUTHORIZATION = 3
NO_BOM_FOUND = 4
NO_PLANT_DATA = 5
NO_SUITABLE_BOM_FOUND = 6
OBJECT_NOT_FOUND = 7
CONVERSION_ERROR = 8
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.
"扩展物料BOM3
DATA: stb TYPE STANDARD TABLE OF stpol WITH HEADER LINE.
CALL FUNCTION 'CS_BOM_EXPLOSION'
EXPORTING
capid = p_cap
datuv = p_dat
mehrs = 'X'
mtnrv = p_mat
stlal = p_stl
werks = p_wer
IMPORTING
topmat = topmat
TABLES
stb = stb " 详细列表
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
OTHERS = 8
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"扩展文档结构 1
CALL FUNCTION 'CS_BOM_EXPL_DOC_V1'
EXPORTING
DATUV = sy-datum
docnr = 文档号
docar = 类型
doctl = 部分
docvr = 版本
IMPORTING
TOPDOC = 返回文档结构头的文档信息
tables
stb = 返回详细清单
doccat = 返回文档结构的清单(有几个文档结构)
EXCEPTIONS
CALL_INVALID = 1
DOCUMENT_NOT_FOUND = 2
MISSING_AUTHORIZATION = 3
NO_BOM_FOUND = 4
NO_SUITABLE_BOM_FOUND = 5
BOM_NOT_ACTIVE = 6
BOM_FLAGGED_FOR_DELETION = 7
BOM_WITHOUT_POSITIONS = 8
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.
"扩展文档结构 2
CALL FUNCTION 'CS_BOM_EXPL_GNRL2_V1'
EXPORTING
DATUV = sy-datum
docnr = 文档号
docar = 类型
doctl = 部分
docvr = 版本
MEHRS = 'X'
IMPORTING
TOPDOC = =
tables
stbd =
stbp =
EXCEPTIONS
CALL_INVALID = 1
OBJECT_NOT_FOUND = 2
MISSING_AUTHORIZATION = 3
NO_BOM_FOUND = 4
NO_SUITABLE_BOM_FOUND = 5
BOM_NOT_ACTIVE = 6
BOM_FLAGGED_FOR_DELETION = 7
BOM_WITHOUT_POSITIONS = 8
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.