我很好
分类: WINDOWS
2008-04-26 10:21:51
用户出口:PPCO0007 保存生产订单时退出
需求:如果成品的主数据mara-normt 字段等于ROHS,则展开BOM到最底层,检查每一个原材料是否有ROHS的标识,只要有一个原材料没有,就不让保存.
*&---------------------------------------------------------------------*
*& 包括 ZXCO1U06
*&---------------------------------------------------------------------*
DATA : wa_mara TYPE mara .
DATA : BEGIN OF it_mara OCCURS 0 .
INCLUDE STRUCTURE mara .
DATA : END OF it_mara .
DATA : BEGIN OF it_resb OCCURS 0.
INCLUDE STRUCTURE stpox.
DATA: END OF it_resb.
DATA: "存储索引
BEGIN OF i_mat OCCURS 0.
INCLUDE STRUCTURE cscmat.
DATA: END OF i_mat.
SELECT SINGLE normt FROM mara
INTO CORRESPONDING FIELDS OF wa_mara
WHERE matnr = header_imp-plnbez.
IF wa_mara-normt = 'ROHS'.
REFRESH :it_resb,it_mara.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = 'PP01'
datuv = sy-datum
mtnrv = header_imp-plnbez "产品物料信息
mehrs = 'X' "完全展开
stlan = '1'
stlal = '' "可选BOM信息,如果可选BOM为空,那么系统指定
为最小值
werks = header_imp-WERKS "工厂信息
TABLES
stb = it_resb "最终输出的物料信息
matcat = i_mat "物料索引信息
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 NOT it_resb[] IS INITIAL.
SELECT normt matnr FROM mara
INTO CORRESPONDING FIELDS OF TABLE it_mara
FOR ALL ENTRIES IN it_resb
WHERE matnr = it_resb-idnrk .
ENDIF .
LOOP AT it_mara.
IF it_mara-normt <> 'ROHS'.
MESSAGE e001(zpp) WITH it_mara-matnr.
* EXIT.
ENDIF.
ENDLOOP.
ELSE.
ENDIF.