FUNCTION zmm_fm_21_02.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(IN) TYPE ZSLIFNR_SRM
*" EXPORTING
*" VALUE(OUT) TYPE ZSLIFNR_SRM
*"----------------------------------------------------------------------
DATA: lt_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: ls_return LIKE bapiret2 .
* DATA: L_CUSTOMER TYPE KUNNR.
DATA lv_taxnum TYPE dfkkbptaxnum-taxnum.
CONSTANTS : gc_black TYPE char04 VALUE '@EB@',
gc_red TYPE char04 VALUE '@0A@',
gc_green TYPE char04 VALUE '@08@',
gc_yellow TYPE char04 VALUE '@09@'.
** 通过业务伙伴得到业务编号
* PERFORM FRM_GET_CUSCD_FROM_PATCD USING GW_LIST-KUNNR CHANGING L_CUSTOMER.
SELECT SINGLE taxnum FROM dfkkbptaxnum INTO lv_taxnum
WHERE taxnum = in-taxnum AND partner = in-partner.
IF sy-subrc = 0.
in-icon_a = gc_yellow.
in-remark = in-remark && '/' && '增值税号已经存在'.
ELSE.
* 增值税信息增加
CALL FUNCTION 'BAPI_BUPA_TAX_ADD'
EXPORTING
businesspartner = in-partner
taxtype = 'CN0'
taxnumber = in-taxnum
TABLES
return = lt_return.
LOOP AT lt_return WHERE type = 'A' OR type = 'E'.
in-icon_a = gc_yellow.
in-remark = in-remark && '/' && lt_return-message.
ENDLOOP.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ls_return.
IF ls_return-type = 'A' OR ls_return-type = 'E'.
in-icon_a = gc_red.
in-remark = in-remark && ls_return-message.
ENDIF.
IF in-icon_a NE gc_red.
in-icon_a = gc_yellow.
in-remark = in-remark && '/' && '已增加增值税号信息'.
ENDIF.
ENDIF.
ENDIF.
out = in.
ENDFUNCTION.