下层boom
DATA: lt_matcat TYPE TABLE OF cscmat,
lt_stpox TYPE TABLE OF stpox.
"BOOM组件
CLEAR lt_stpox.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = 'PP01' " BOM应用
datuv = sy-datum " 有效起始日
emeng = ls_afko-gamng " 需求数量
mktls = 'X'
mehrs = 'X' " 多层展开 "'X'-多阶;''-单阶
mdmps = '' "是否显示虚拟件 "'X'-不显示
mtnrv = ls_afko-plnbez " 展开物料号
stlan = '1' " BOM用途 默认为'1'
werks = '2103' " 物料所在工厂
TABLES
stb = lt_stpox
* matcat = lt_matcat
EXCEPTIONS
alt_not_found = 1
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
OTHERS = 9.
LOOP AT lt_stpox INTO DATA(ls_stpox) WHERE idnrk = '000000310103020301' OR idnrk = '000000310103020302' OR idnrk = '000000310103020303'.
LOOP AT lt_stpox INTO DATA(ls_stpox1) WHERE ttidx = ls_stpox-ttidx .
SELECT SINGLE * INTO @DATA(ls_pp002) FROM zzd_tpp002 WHERE matnr = @ls_stpox1-idnrk AND zfl IN ( '111','112' ,'113' ).
IF sy-subrc = 0.
gs_jmk-zfl = ls_pp002-zfl.
gs_jmk-matnr = ls_stpox-idnrk.
gs_jmk-plnbez = ls_stpox1-idnrk.
gs_jmk-maktx = ls_pp002-maktx.
* gs_jmk-menge = ls_stpox-mngko / gs_jmk-gamng.
gs_jmk-menge_zz = ls_stpox-mngko .
APPEND gs_jmk TO gt_jmk.
ENDIF.
CLEAR ls_stpox1.
ENDLOOP.
CLEAR ls_stpox.
ENDLOOP.
上层boom
TCODE:CS15(单个物料)/CS15M(多个物料)
可以通过submit该tcode对应的报表程序RCS15001获取返回的结果
* submit 相关变量
DATA :ls_data TYPE REF TO data.
FIELD-SYMBOLS : <lt_data> TYPE table,
<l_data> TYPE data.
cl_salv_bs_runtime_info=>set( display = ''
metadata = ''
data = 'X' ) .
CLEAR:ls_data.
SUBMIT rcs15001 WITH pm_werks = '2103'
WITH pm_stlan = '1'
WITH pm_mehrs = 'X' " 多级
WITH pm_idnrk = gs_data_032-matnr
WITH pm_rmeng = '1' " 结果数量
AND RETURN .
TRY .
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = ls_data ) .
ASSIGN ls_data->* TO <lt_data> .
CATCH cx_salv_bs_sc_runtime_info .
CONTINUE.
ENDTRY .
cl_salv_bs_runtime_info=>clear_all( ) .
CHECK ls_data IS NOT INITIAL.
DATA: l_dcpfm LIKE usr01-dcpfm.
SELECT SINGLE dcpfm INTO l_dcpfm
FROM usr01
WHERE bname = sy-uname.
LOOP AT <lt_data> ASSIGNING <l_data> .
MOVE-CORRESPONDING <l_data> TO gs_cs15.
CALL FUNCTION 'UNITS_STRING_CONVERT'
EXPORTING
units_string = gs_cs15-dimng
dcpfm = l_dcpfm "此时为X
* MLLN = 'M'
* TSND = 'T'
IMPORTING
units = gs_cs15-zmljxqzjs
EXCEPTIONS
invalid_type = 1
OTHERS = 2.
gs_cs15-matnr_kt = gs_data_032-matnr."卡特子件物料
APPEND gs_cs15 TO gt_cs15 .
CLEAR:gs_cs15.
ENDLOOP .