通过调用系统提供的FM 来实现BOM 展开的函数。以下是实现代码的函数。
FUNCTION Z_BOM_EXPAND.
*”———————————————————
*”*”Local Interface:
*” IMPORTING
*” VALUE(MATNR) LIKE MARA-MATNR
*” VALUE(WERKS) LIKE MARC-WERKS OPTIONAL
*” VALUE(CAPID) LIKE TC04-CAPID DEFAULT ‘PP01’
*” TABLES
*” STB STRUCTURE STPOX
*” RETURN STRUCTURE BAPIRET2
*”———————————————————
IF WERKS IS INITIAL.”Added in case external call does not know
WERKS = ‘3001’.
ENDIF.
IF CAPID IS INITIAL.
CAPID = ‘PP01’.
ENDIF.
CALL FUNCTION ‘CS_BOM_EXPL_MAT_V2’
EXPORTING
CAPID = CAPID
DATUV = SY-DATUM
MEHRS = ‘X’
MTNRV = MATNR
WERKS = WERKS
TABLES
STB = STB
EXCEPTIONS
NO_BOM_FOUND = 1.
IF sy-subrc <> 0.
msg_typ = ‘E’.
msg_id = ‘Z_EF’.
msg_no = ‘002’.
msg_v1 = MATNR.
if not msg_typ is initial.
* append error to table RETURN
call function ‘BALW_BAPIRETURN_GET2’
exporting
type = msg_typ
cl = msg_id
number = msg_no
par1 = msg_v1
par2 = msg_v2
par3 = msg_v3
par4 = msg_v4
parameter = space
row = space
field = space
importing
return = wa_return_tmp.
append wa_return_tmp to return.
endif.
ENDIF.
ENDFUNCTION.
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/20017.html