process_item
METHOD if_ex_me_process_po_cust~process_item.
DATA(ls_item) = im_item->get_data( ).
IF ls_item-bwtar IS INITIAL.
* 获取header
DATA(lo_header) = im_item->get_header( ).
DATA(ls_hddata) = lo_header->get_data( ).
* 获取评估类型
SELECT SINGLE
bwtar
FROM zmmt1009
INTO ls_item-bwtar
WHERE lifnr = ls_hddata-lifnr.
im_item->set_data( ls_item ).
ENDIF.
INCLUDE mm_messages_mac. "useful macros for message handling
DATA(lo_header2) = im_item->get_header( ).
CHECK lo_header2 IS NOT INITIAL.
DATA(ls_header) = lo_header2->get_data( ).
*订单类型 + 科目分配类别 + 采购凭证中的项目类别
* LOOP AT lt_o_items INTO DATA(ls_o_item).
*
* DATA(ls_item) = ls_o_item-item->get_data( ).
*ls_item
SELECT SINGLE @abap_true
FROM zmmt1023
WHERE bsart = @ls_header-bsart AND knttp = @ls_item-knttp AND epstp = @ls_item-pstyp
INTO @DATA(lv_exists).
IF lv_exists = abap_false.
* 采购订单类型+科目分配类别+项目类别不满足要求 在
mmpur_business_obj_id ls_item-id. "确定错误消息显示到哪个行项目上
MESSAGE e009(zmm100) INTO DATA(lv_dummy).
mmpur_message_forced sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* ch_failed = abap_true.
ENDIF.
* ENDLOOP.
ENDMETHOD.
check
METHOD if_ex_me_process_po_cust~check.
*检查采购订单类型
CALL METHOD check_purchase_order_type
EXPORTING
im_header = im_header
im_hold = im_hold
im_park = im_park
CHANGING
ch_failed = ch_failed.
ENDMETHOD.
METHOD check_purchase_order_type.
INCLUDE mm_messages_mac. "useful macros for message handling
DATA:lt_o_items TYPE purchase_order_items..
DATA(ls_header) = im_header->get_data( ).
lt_o_items = im_header->get_items( ).
* 获取订单类型对应的供应商
SELECT *
FROM zmmt1010
INTO TABLE @DATA(lt_zmmt1010).
*采购订单类型 存在配置供应商
READ TABLE lt_zmmt1010 INTO DATA(ls_zmmt1010) WITH KEY bsart = ls_header-bsart.
IF sy-subrc = 0.
*去除非订单类型的供应商
DATA(lt_zmmt1010_doc_type) = lt_zmmt1010.
DELETE lt_zmmt1010_doc_type WHERE bsart <> ls_header-bsart.
READ TABLE lt_zmmt1010_doc_type INTO DATA(ls_lifnr) WITH KEY lifnr = ls_header-lifnr.
IF sy-subrc <> 0.
* 订单类型&1下的供应商&2在表[ZMMT1010]中不存在!
MESSAGE e001(zmm100) WITH ls_header-bsart ls_header-lifnr INTO DATA(lv_dummy).
mmpur_message_forced sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ch_failed = abap_true.
ENDIF.
*采购订单类型 不存在配置供应商
ELSE.
*检查供应商编号是否维护在配置表 订单类型不在配置表,但供应商存在配置报错
READ TABLE lt_zmmt1010 INTO ls_zmmt1010 WITH KEY lifnr = ls_header-lifnr.
IF sy-subrc = 0.
* 订单类型 供应商不可选择
MESSAGE e008(zmm100) WITH ls_header-bsart ls_header-lifnr INTO lv_dummy.
mmpur_message_forced sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ch_failed = abap_true.
ENDIF.
ENDIF.
*订单类型 + 科目分配类别 + 采购凭证中的项目类别
LOOP AT lt_o_items INTO DATA(ls_o_item).
DATA(ls_item) = ls_o_item-item->get_data( ).
SELECT SINGLE @abap_true
FROM zmmt1023
WHERE bsart = @ls_header-bsart AND knttp = @ls_item-knttp AND epstp = @ls_item-pstyp
INTO @DATA(lv_exists).
IF lv_exists = abap_false.
* 采购订单类型+科目分配类别+项目类别不满足要求 在
mmpur_business_obj_id ls_item-id. "确定错误消息显示到哪个行项目上
MESSAGE e009(zmm100) INTO lv_dummy.
mmpur_message_forced sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ch_failed = abap_true.
ENDIF.
ENDLOOP.
ENDMETHOD.