SD 客户主数据创建、修改:CVI_EI_INBOUND_MAIN/CL_MD_BP_MAINTAIN=>MAINTAIN

*&---------------------------------------------------------------------*
*& Form FRM_CREAT_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&      --> <FS_TAB>
*&---------------------------------------------------------------------*
FORM frm_creat_data
  USING    ps_tab    TYPE gy_tab
  CHANGING ps_return TYPE zssd18_rsp.

  CONSTANTS:c_parvw1 TYPE parvw VALUE 'SP', " 售达方
            c_parvw2 TYPE parvw VALUE 'BP', " 收票方
            c_parvw3 TYPE parvw VALUE 'PY', " 付款方
            c_parvw5 TYPE parvw VALUE 'SH'. " 送达方

* 根据伙伴GUID取出客户编号
  DATA:lt_partnerguid_list TYPE bu_partner_guid_t,
       ls_partnerguid_list TYPE bu_partner_guid.
  DATA:lt_customer_list TYPE cvis_cust_link_t,
       ls_customer_list TYPE cvi_cust_link.

  DATA:ls_data   TYPE  cvis_ei_extern,
       lt_data   TYPE  cvis_ei_extern_t,
       lt_return TYPE  bapiretm,
       ls_return TYPE  bapireti,
       ls_msg    TYPE  bapiretc.

  DATA:ls_partner  TYPE bus_ei_extern,
       ls_customer TYPE cmds_ei_extern.
  DATA:ls_header       TYPE cmds_ei_header,
       ls_central_data TYPE cmds_ei_central_data,
       ls_company_data TYPE cmds_ei_cmd_company,
       ls_sales_data   TYPE cmds_ei_cmd_sales.
  DATA:lt_roles         TYPE bus_ei_bupa_roles_t,
       ls_roles         TYPE bus_ei_bupa_roles,
       lt_ident_numbers TYPE bus_ei_bupa_identification_t,
       ls_ident_numbers TYPE bus_ei_bupa_identification,
       lt_addresses     TYPE bus_ei_bupa_address_t,
       ls_addresses     TYPE bus_ei_bupa_address,
       lt_phone         TYPE bus_ei_bupa_telephone_t,
       ls_phone         TYPE bus_ei_bupa_telephone,
       lt_fax           TYPE bus_ei_bupa_fax_t,
       ls_fax           TYPE bus_ei_bupa_fax,
       lt_smtp          TYPE bus_ei_bupa_smtp_t,
       ls_smtp          TYPE bus_ei_bupa_smtp,
       ls_remarks       TYPE bus_ei_bupa_comrem,
       lt_remarks       TYPE bus_ei_bupa_comrem_t,
       lt_company       TYPE cmds_ei_company_t,
       ls_company       TYPE cmds_ei_company,
       lt_sales         TYPE cmds_ei_sales_t,
       ls_sales         TYPE cmds_ei_sales,
       lt_functions     TYPE cmds_ei_functions_t,
       ls_functions     TYPE cmds_ei_functions,
       ls_central       TYPE cmds_ei_cmd_central,
       lt_tax_ind       TYPE cmds_ei_tax_ind_t,
       ls_tax_ind       TYPE cmds_ei_tax_ind,
       lt_remarks_a     TYPE bus_ei_bupa_addressremark_t,
       ls_remarks_a     TYPE bus_ei_bupa_addressremark,
       lt_banks         TYPE bus_ei_bupa_bankdetail_t,
       ls_banks         TYPE bus_ei_bupa_bankdetail.

  DATA:lv_msg TYPE string.
  DATA:lv_msg1 TYPE string.
  DATA:lv_bpartnerguid TYPE bu_partner_guid_bapi.

  DATA:lt_return_tax TYPE TABLE OF bapiret2 WITH HEADER LINE,
       lt_return_frg TYPE TABLE OF bapiret2 WITH HEADER LINE.

  DATA:lt_return_ukmbp TYPE ukm_t_monitor_return .

  CLEAR:ls_central_data,ls_company_data,ls_sales_data,ls_partner,ls_customer.
  CLEAR:ls_partnerguid_list,lt_partnerguid_list,lt_customer_list,ls_customer_list,lt_data,ls_data,lv_bpartnerguid,
        lt_return,lv_msg,lt_tax_ind,ls_tax_ind,ls_central,ls_company,lt_company,ls_sales,lt_sales,ls_functions,lt_functions.

  ls_partner-header-object_task = ps_tab-zczlx.            " I-新增   U-修改   C-当前状态    D-删除
  CASE ps_tab-zczlx.
    WHEN 'I'.
*     创建伙伴GUID
      TRY .
          lv_bpartnerguid = cl_uuid_factory=>create_system_uuid( )->create_uuid_x16( ).
        CATCH cx_uuid_error.
*   返回消息
      ENDTRY.
      ls_partner-header-object_instance-bpartnerguid = lv_bpartnerguid.
      ls_partner-central_data-common-data-bp_control-category = 2.                       " 业务伙伴类别
    WHEN 'U'.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = ps_tab-partner
        IMPORTING
          output = ps_tab-partner.
      ls_header-object_task = 'U'.
      ls_partner-header-object_instance-bpartner = ps_tab-partner .         " 客户号
      SELECT SINGLE partner_guid
               FROM but000
             WHERE partner = @ps_tab-partner
              INTO @DATA(lv_bpartnerguid_u).
      ls_partner-header-object_instance-bpartnerguid = lv_bpartnerguid_u.
    WHEN OTHERS.
  ENDCASE.
* 账户组
  ls_partner-central_data-common-data-bp_control-grouping         = ps_tab-bu_group.
* 名称1
  ls_partner-central_data-common-data-bp_organization-name1       = ps_tab-name_org1.
  ls_partner-central_data-common-datax-bp_organization-name1      = COND #( WHEN ls_partner-central_data-common-data-bp_organization-name1 IS NOT INITIAL THEN abap_true ).
* 搜索项
  ls_partner-central_data-common-data-bp_centraldata-searchterm1  = ps_tab-bu_sort1.
  ls_partner-central_data-common-datax-bp_centraldata-searchterm1 = COND #( WHEN ls_partner-central_data-common-data-bp_centraldata-searchterm1 IS NOT INITIAL THEN abap_true ).
* 称谓
  ls_partner-central_data-common-data-bp_centraldata-title_key    = ps_tab-title.
  ls_partner-central_data-common-datax-bp_centraldata-title_key   = COND #( WHEN ls_partner-central_data-common-data-bp_centraldata-title_key   IS NOT INITIAL THEN abap_true ).

  CLEAR:lt_roles.
  ls_roles-task = ps_tab-zczlx.
  ls_roles-data_key = 'FLCU01'.     "角色
  APPEND ls_roles TO lt_roles.

  ls_roles-task = ps_tab-zczlx.
  ls_roles-data_key = 'FLCU00'.     "角色
  APPEND ls_roles TO lt_roles.
  ls_partner-central_data-role-roles = lt_roles.

  CLEAR:ls_addresses,lt_addresses.
  ls_addresses-data-postal-data-street       = ps_tab-stras.  " 街道
  ls_addresses-data-postal-data-city         = ps_tab-ort01.  " 城市
  ls_addresses-data-postal-data-district     = ps_tab-city2.  " 区域
  ls_addresses-data-postal-data-postl_cod1   = ps_tab-pstlz.  " 邮政编码
  ls_addresses-data-postal-data-country      = ps_tab-land1.  " 国家代码
  ls_addresses-data-postal-data-region       = ps_tab-regio.  " 地区代码
  ls_addresses-data-postal-data-c_o_name     = ps_tab-name_co." 代收人
  IF ps_tab-zczlx = 'U'.
    ls_addresses-task = '5'.
    ls_addresses-data-postal-data-validfromdate   = sy-datum.
    ls_addresses-data-postal-datax-validfromdate  = 'X'.
    ls_addresses-data-postal-data-validtodate     = '99991231'.
    ls_addresses-data-postal-datax-validtodate    = 'X'.
  ELSEIF ps_tab-zczlx = 'I'.
    ls_addresses-task = ps_tab-zczlx.
  ENDIF.
  CALL FUNCTION 'CONVERSION_EXIT_ISOLA_INPUT'
    EXPORTING
      input            = ps_tab-spras
    IMPORTING
      output           = ls_addresses-data-postal-data-languiso " 语言
    EXCEPTIONS
      unknown_language = 1.
  ls_addresses-data-postal-data-langu        = ls_addresses-data-postal-data-languiso." 语言
  ls_addresses-data-postal-datax-street      = COND #( WHEN ls_addresses-data-postal-data-street      IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-city        = COND #( WHEN ls_addresses-data-postal-data-city        IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-district    = COND #( WHEN ls_addresses-data-postal-data-district    IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-postl_cod1  = COND #( WHEN ls_addresses-data-postal-data-postl_cod1  IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-country     = COND #( WHEN ls_addresses-data-postal-data-country     IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-region      = COND #( WHEN ls_addresses-data-postal-data-region      IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-c_o_name    = COND #( WHEN ls_addresses-data-postal-data-c_o_name    IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-langu_iso   = COND #( WHEN ls_addresses-data-postal-data-languiso    IS NOT INITIAL THEN abap_true ).
  ls_addresses-data-postal-datax-langu       = COND #( WHEN ls_addresses-data-postal-data-langu       IS NOT INITIAL THEN abap_true ).

  CLEAR:ls_phone,lt_phone.
  IF ps_tab-zczlx = 'I'.
    ls_phone-contact-task = ps_tab-zczlx.
  ELSE.
    ls_phone-contact-task = '2'.
  ENDIF.
  ls_phone-contact-task             = ps_tab-zczlx.
  ls_phone-contact-data-telephone   = ps_tab-tel_number2.  " 开票电话
  ls_phone-contact-data-country     = ps_tab-land1.
  ls_phone-contact-data-r_3_user    = '1'.
  ls_phone-contact-data-consnumber  = '001'.
  ls_phone-contact-data-std_no      = 'X'.
  ls_phone-contact-datax-telephone  = COND #( WHEN ls_phone-contact-data-telephone IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-country    = COND #( WHEN ls_phone-contact-data-country   IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-r_3_user   = COND #( WHEN ls_phone-contact-data-r_3_user  IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-consnumber = COND #( WHEN ls_phone-contact-data-consnumber IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-std_no     = COND #( WHEN ls_phone-contact-data-consnumber IS NOT INITIAL THEN abap_true ).
  APPEND ls_phone TO lt_phone.

  CLEAR:ls_phone.
  IF ps_tab-zczlx = 'I'.
    ls_phone-contact-task = ps_tab-zczlx.
  ELSE.
    ls_phone-contact-task = '2'.
  ENDIF.
  ls_phone-contact-data-telephone  = ps_tab-tel_number.  " 移动电话
  ls_phone-contact-data-country    = ps_tab-land1.
  ls_phone-contact-data-r_3_user   = '3'.
  ls_phone-contact-data-consnumber = '002'.
  ls_phone-contact-datax-telephone = COND #( WHEN ls_phone-contact-data-telephone IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-country   = COND #( WHEN ls_phone-contact-data-country   IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-r_3_user  = COND #( WHEN ls_phone-contact-data-r_3_user  IS NOT INITIAL THEN abap_true ).
  ls_phone-contact-datax-consnumber = COND #( WHEN ls_phone-contact-data-consnumber IS NOT INITIAL THEN abap_true ).
  APPEND ls_phone TO lt_phone.

  ls_addresses-data-communication-phone-phone = lt_phone.

  CLEAR:ls_smtp,lt_smtp.
  IF ps_tab-zczlx = 'I'.
    ls_smtp-contact-task = ps_tab-zczlx.
  ELSE.
    ls_smtp-contact-task = '2'.
  ENDIF.
  ls_smtp-contact-data-e_mail      = ps_tab-email. " 邮件
  ls_smtp-contact-data-consnumber  = '001'.        " 序号
  ls_smtp-contact-data-std_no      = 'X'.
  ls_smtp-contact-data-home_flag   = 'X'.
  ls_smtp-contact-datax-e_mail     = COND #( WHEN ls_smtp-contact-data-e_mail     IS NOT INITIAL THEN abap_true ).
  ls_smtp-contact-datax-consnumber = COND #( WHEN ls_smtp-contact-data-consnumber IS NOT INITIAL THEN abap_true ).
  ls_smtp-contact-datax-std_no     = COND #( WHEN ls_smtp-contact-data-std_no     IS NOT INITIAL THEN abap_true ).
  ls_smtp-contact-datax-home_flag  = COND #( WHEN ls_smtp-contact-data-home_flag  IS NOT INITIAL THEN abap_true ).
  APPEND ls_smtp TO lt_smtp.
  ls_addresses-data-communication-smtp-smtp = lt_smtp.

*--传真
  CLEAR:ls_fax.
  REFRESH lt_fax.
  IF ps_tab-zczlx = 'I'.
    ls_fax-contact-task      = ps_tab-zczlx.
  ELSE.
    ls_fax-contact-task = '2'.
  ENDIF.
  ls_fax-contact-data-fax  = ps_tab-fax_number .
  ls_fax-contact-datax-fax = COND #( WHEN ls_fax-contact-data-fax IS NOT INITIAL THEN abap_true ).
  APPEND ls_fax TO lt_fax .
  ls_addresses-data-communication-fax-fax = lt_fax.

  APPEND ls_addresses TO lt_addresses.
  ls_partner-central_data-address-addresses = lt_addresses.


*客户数据表头**********************************************
  ls_header-object_task = ps_tab-zczlx.
  ls_customer-header    = ls_header.
*中心数据**************************************************
  ls_central-data-kukla   = ps_tab-kukla."客户分类
  ls_central-datax-kukla  = COND #( WHEN ls_central-data-kukla IS NOT INITIAL THEN abap_true ).
  ls_central_data-central = ls_central.

* 客户销售的出发票
  ls_tax_ind-task           = ps_tab-zczlx.
  ls_tax_ind-data_key-aland = 'CN'.
  ls_tax_ind-data_key-tatyp = 'MWST'.
  ls_tax_ind-data-taxkd     = ps_tab-taxkd.
  ls_tax_ind-datax-taxkd = COND #( WHEN ls_tax_ind-data-taxkd IS NOT INITIAL THEN abap_true ).
  APPEND ls_tax_ind TO lt_tax_ind.
  ls_central_data-tax_ind-tax_ind = lt_tax_ind.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = ps_tab-vbund
    IMPORTING
      output = ps_tab-vbund.
  ls_customer-central_data = ls_central_data.
  ls_customer-central_data-central-data-vbund  = ps_tab-vbund.
  ls_customer-central_data-central-datax-vbund = COND #( WHEN ls_customer-central_data-central-data-vbund IS NOT INITIAL THEN abap_true ).

*公司代码数据************************************************
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'   " 统驭科目补零
    EXPORTING
      input  = ps_tab-hkont
    IMPORTING
      output = ps_tab-hkont.
  ls_company-task           = ps_tab-zczlx.
  ls_company-data_key-bukrs = ps_tab-bukrs. " 公司代码
  ls_company-data-akont     = ps_tab-hkont. " 统驭科目
  ls_company-data-zterm     = ps_tab-zterm. " 付款条款
  ls_company-datax-akont    = COND #( WHEN ls_company-data-akont IS NOT INITIAL THEN abap_true ).
  ls_company-datax-zterm    = COND #( WHEN ls_company-data-zterm IS NOT INITIAL THEN abap_true ).
  APPEND ls_company TO lt_company.
  ls_company_data-company   = lt_company.
  ls_company_data-current_state = 'X'.
  ls_customer-company_data = ls_company_data.

******销售数据****************************************************
  ls_sales-task           = ps_tab-zczlx.
  ls_sales-data_key-vkorg = ps_tab-vkorg.
  ls_sales-data_key-vtweg = ps_tab-vtweg.
  ls_sales-data_key-spart = ps_tab-spart.

  ls_sales-data-vkbur = ps_tab-vkbur.
  ls_sales-data-vkgrp = ps_tab-vkgrp.
  ls_sales-data-waers = ps_tab-waers.
  ls_sales-data-kalks = ps_tab-kalks.
  ls_sales-data-vwerk = ps_tab-werks.
  ls_sales-data-vsbed = ps_tab-vsbed.
  ls_sales-data-inco1 = ps_tab-inco1.
  ls_sales-data-inco2 = ps_tab-inco2.
* ls_sales-data-zterm = ps_tab-zterm.
  ls_sales-data-ktgrd = ps_tab-ktgrd.
  ls_sales-data-kdgrp = ps_tab-kdgrp.
  ls_sales-data-zterm = ps_tab-zterm.

  ls_sales-datax-vkbur = COND #( WHEN ls_sales-data-vkbur IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-vkgrp = COND #( WHEN ls_sales-data-vkgrp IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-waers = COND #( WHEN ls_sales-data-waers IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-kalks = COND #( WHEN ls_sales-data-kalks IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-vwerk = COND #( WHEN ls_sales-data-vwerk IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-vsbed = COND #( WHEN ls_sales-data-vsbed IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-inco1 = COND #( WHEN ls_sales-data-inco1 IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-inco2 = COND #( WHEN ls_sales-data-inco2 IS NOT INITIAL THEN abap_true ).
* ls_sales-datax-zterm = COND #( WHEN ls_sales-data-zterm IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-ktgrd = COND #( WHEN ls_sales-data-ktgrd IS NOT INITIAL THEN abap_true ).
  ls_sales-datax-zterm = COND #( WHEN ls_sales-data-zterm IS NOT INITIAL THEN abap_true ).

*  function伙伴功能
  ls_functions-task = ps_tab-zczlx..
  CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
    EXPORTING
      input  = c_parvw1  "售达方
    IMPORTING
      output = ls_functions-data_key-parvw.
  APPEND ls_functions TO lt_functions.

  CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
    EXPORTING
      input  = c_parvw2 "收票方
    IMPORTING
      output = ls_functions-data_key-parvw.
  APPEND ls_functions TO lt_functions.

  CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
    EXPORTING
      input  = c_parvw5 "送达方
    IMPORTING
      output = ls_functions-data_key-parvw.
  APPEND ls_functions TO lt_functions.

  CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
    EXPORTING
      input  = c_parvw3 "付款方
    IMPORTING
      output = ls_functions-data_key-parvw.
  APPEND ls_functions TO lt_functions.

  ls_sales-functions-functions = lt_functions.
  APPEND ls_sales TO lt_sales.
  ls_sales_data-sales = lt_sales.
  ls_customer-sales_data = ls_sales_data.

****银行数据****************************************************
  IF ps_tab-zczlx = 'U'.
    ls_banks-task      =  '2'.
    ls_banks-data_key      =  '0001'.
  ELSE.
    ls_banks-task      = ps_tab-zczlx.
  ENDIF.
  ls_banks-data-bank_key         =  ps_tab-bankl.    "银行代码
  ls_banks-datax-bank_key        = COND #( WHEN ls_banks-data-bank_key IS NOT INITIAL THEN abap_true ).
  ls_banks-data-bankaccountname  =  ps_tab-banka.    "开户行
  ls_banks-datax-bankaccountname = COND #( WHEN ls_banks-data-bankaccountname IS NOT INITIAL THEN abap_true ).
  ls_banks-data-bank_acct        =  ps_tab-bankn.    "账号
  ls_banks-datax-bank_acct       = COND #( WHEN ls_banks-data-bank_acct IS NOT INITIAL THEN abap_true ).
  ls_banks-data-bank_ctry        =  ps_tab-banks.     "银行国家代码
  ls_banks-datax-bank_ctry       = COND #( WHEN ls_banks-data-bank_ctry IS NOT INITIAL THEN abap_true ).
  ls_banks-data-accountholder    =  ps_tab-koinh.     "银行户主
  ls_banks-datax-accountholder   = COND #( WHEN ls_banks-data-accountholder IS NOT INITIAL THEN abap_true ).
  APPEND ls_banks TO lt_banks.
  ls_partner-central_data-bankdetail-bankdetails = lt_banks.

  ls_data-partner  = ls_partner.
  ls_data-customer = ls_customer.
  APPEND ls_data TO lt_data.

*  CALL FUNCTION 'CVI_EI_INBOUND_MAIN'
*    EXPORTING
*      i_data   = lt_data
*    IMPORTING
*      e_return = lt_return.
  cl_md_bp_maintain=>maintain(
        EXPORTING
          i_data   = lt_data
        IMPORTING
          e_return = lt_return ).
  CLEAR lv_msg.
  LOOP AT lt_return INTO ls_return.
    LOOP AT ls_return-object_msg INTO ls_msg WHERE type = 'E' OR type = 'A'.
      CONCATENATE lv_msg ls_msg-message INTO lv_msg.
    ENDLOOP.
  ENDLOOP.

  IF lv_msg IS INITIAL.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = abap_true.
*  根据伙伴GUID取出客户编号
    ls_partnerguid_list = ls_partner-header-object_instance-bpartnerguid.
    APPEND ls_partnerguid_list TO lt_partnerguid_list.
    lt_customer_list = cvi_mapper=>get_instance( )->get_assigned_customers_for_bps(
                                              i_partner_guids = lt_partnerguid_list ).
    IF lt_customer_list IS NOT INITIAL.
      READ TABLE lt_customer_list INTO ls_customer_list INDEX 1 .
      IF sy-subrc EQ 0.
        ps_return-is_result  = 'S'.
        ps_return-is_message = |客户{ ls_customer_list-customer }创建成功!|.
      ENDIF.
    ELSE.
      "可能创建成功了BP,但未创建成功customer
      DATA : ls_cvis_error TYPE cvis_error.

      ls_cvis_error = cvi_mapper=>get_instance( )->undo_assignments(
                                              i_for_partners = lt_partnerguid_list ).
      ps_return-is_result    = 'E'.
      ps_return-is_message   = |客户创建出错,客户部分数据出错,请检查是否是BP伙伴功能问题!|.
    ENDIF.

  ELSE.
    ps_return-is_result  = 'E'.
    ps_return-is_message = lv_msg.
  ENDIF.
  IF ps_tab-zczlx = 'I'.
    ps_return-kunnr      = ls_customer_list-customer.
    ps_tab-partner       = ls_customer_list-customer.
  ELSEIF ps_tab-zczlx = 'U'.
    ps_return-kunnr      = ps_tab-partner.
  ENDIF.
  ps_return-name_org1  = ps_tab-name_org1.
*-------------------------------------------------------------------------------*
  "客户创建成功后开始维护税号等数据
  DATA :lt_taxr TYPE TABLE OF bapiret2 WITH HEADER LINE.
  DATA :lv_taxmsg TYPE char100.
  DATA: iv_taxtype   TYPE  bapibus1006tax-taxtype,
        iv_taxnumber TYPE  bapibus1006tax-taxnumber.
  iv_taxtype = 'CN0'.
  iv_taxnumber =  ps_tab-stceg.
  IF ps_tab-zczlx = 'I'.
    CALL FUNCTION 'BAPI_BUPA_TAX_ADD'
      EXPORTING
        businesspartner = ps_tab-partner
        taxtype         = iv_taxtype
        taxnumber       = iv_taxnumber
      TABLES
        return          = lt_taxr.
  ELSE.
    CALL FUNCTION 'BAPI_BUPA_TAX_CHANGE'
      EXPORTING
        businesspartner = ps_tab-partner
        taxtype         = iv_taxtype
        taxnumber       = iv_taxnumber
      TABLES
        return          = lt_taxr.
  ENDIF.


  LOOP AT lt_taxr WHERE type = 'E' OR type = 'A'.
    CONCATENATE lv_taxmsg lt_taxr-message INTO lv_taxmsg.
  ENDLOOP.

  IF lv_taxmsg IS INITIAL .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = abap_true.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .
    ps_return-is_result    = 'E'.
    ps_return-is_message = |{ ps_return-is_message }但是税号相关数据创建失败!|.
  ENDIF.

ENDFORM.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值