需求:供应商和客户加"名称+税号"强校验,防止同一客商重复录入
供应商名称重复校验:SE18->BADI->BUPA_ADDR_CHECK(地址及一般信息检查)
METHOD if_ex_bupa_addr_check~check.
DATA:ev_ok_code TYPE bu_fcode.
CALL FUNCTION 'BUS_LOCATOR_OKCODE'
IMPORTING
ev_ok_code = ev_ok_code.
IF ( ev_ok_code = 'BUS_MAIN_SAVE' OR ( ev_ok_code = 'BUS_MAIN_BACK' AND sy-ucomm = 'YES' ) ) AND
sy-tcode = 'BP' AND
( sy-mandt EQ '140' OR sy-mandt EQ '400' OR sy-mandt EQ '900' ) AND
iv_activity EQ '01' AND
is_but000-bu_group = 'S001'.
FIELD-SYMBOLS:<fs_role> TYPE any.
ASSIGN ('(SAPLBUPA_DIALOG_JOEL)BUS_JOEL_MAIN-PARTNER_ROLE') TO <fs_role>.
IF <fs_role> EQ 'ZKD001X'.
"查询
SELECT COUNT(*)
FROM lfa1
WHERE name1 EQ is_but000-name_org1.
IF sy-subrc EQ 0.
MESSAGE '存在相同名称的供应商,请确认' TYPE 'A'.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
税号校验:SE38->LBUPA_BUTX_DIALOGF01->FORM gt_bptaxnum_modify(隐式增强).
ENHANCEMENT 1 ZBP_CHECK_TAXNUM. "active version
IF sy-tcode EQ 'BP' AND
( sy-mandt EQ '140' OR sy-mandt EQ '400' OR sy-mandt EQ '900' ).
FIELD-SYMBOLS <fs_group> TYPE any.
FIELD-SYMBOLS <fs_role> TYPE any.
DATA:ev_ok_code TYPE bu_fcode.
CALL FUNCTION 'BUS_LOCATOR_OKCODE'
IMPORTING
ev_ok_code = ev_ok_code.
IF ( ev_ok_code = 'BUS_MAIN_SAVE' OR ( ev_ok_code = 'BUS_MAIN_BACK' AND sy-ucomm = 'YES' ) ).
ASSIGN ('(SAPLBUPA_DIALOG_JOEL)BUS_JOEL_MAIN-CREATION_GROUP') TO <fs_group>.
ASSIGN ('(SAPLBUPA_DIALOG_JOEL)BUS_JOEL_MAIN-PARTNER_ROLE') TO <fs_role>.
IF <fs_group> IS ASSIGNED AND <fs_role> IS ASSIGNED.
IF <fs_group> EQ 'S001' AND <fs_role> EQ 'ZKD001X'.
SELECT COUNT(*)
FROM lfa1
WHERE lifnr EQ dfkkbptaxnum-partner.
"新建
IF sy-subrc NE 0 AND dfkkbptaxnum-taxnumxl IS NOT INITIAL.
"查询是否有相同税号的供应商
SELECT COUNT(*)
FROM lfa1
WHERE stcd5 EQ dfkkbptaxnum-taxnumxl.
IF sy-subrc EQ 0.
MESSAGE '已存在相同税号的供应商,请确认' TYPE 'A'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDENHANCEMENT.