事务代码:BP
BP相关的方法/BAPI
方法:
cvis_ei_extern_t,
cl_md_bp_maintain=>maintain(
EXPORTING
i_data = lt_data
IMPORTING
e_return = lt_return ).
对税号单独操作(BP会强制将CN0改为CN5)
BAPI:BAPI_BUPA_TAX_ADD,BAPI_BUPA_TAX_CHANGE
明细:银行/税号/公司代码/采购组织
BP创建/修改
FORM frm_process_data TABLES pt_bukrs STRUCTURE zmms_vms02
pt_banks STRUCTURE zmms_vms04
USING ps_basic TYPE zmms_vms01
pv_system TYPE zel_sys_id
CHANGING ps_output TYPE zbcs001
pt_data TYPE cvis_ei_extern_t
pv_partner_guid TYPE bu_partner_guid.
CONSTANTS: l_object_task_i TYPE bus_ei_object_task VALUE 'I'.
*CONSTANTS: l_object_task_i TYPE bus_ei_object_task VALUE 'U'.
*修改校验供应商是否存在
DATA: lv_tabix TYPE sy-tabix,
ls_data TYPE cvis_ei_extern,
ls_msg TYPE bapiretc,
ls_partner TYPE bus_ei_extern,
ls_vendor TYPE vmds_ei_extern,
lt_roles TYPE bus_ei_bupa_roles_t,
ls_roles TYPE bus_ei_bupa_roles,
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_remarks TYPE bus_ei_bupa_comrem_t,
ls_remarks TYPE bus_ei_bupa_comrem,
lt_bankdetails TYPE bus_ei_bupa_bankdetail_t,
ls_bankdetails TYPE bus_ei_bupa_bankdetail,
lt_company TYPE vmds_ei_company_t,
ls_company TYPE vmds_ei_company,
lt_purchasing TYPE vmds_ei_purchasing_t,
ls_purchasing TYPE vmds_ei_purchasing,
lt_functions TYPE vmds_ei_functions_t,
ls_functions TYPE vmds_ei_functions,
lt_bapiret2 TYPE bapiret2_t,
ls_bapiret2 TYPE bapiret2.
DATA: lt_version TYPE TABLE OF bus_ei_bupa_version,
ls_version TYPE bus_ei_bupa_version.
DATA: l_str TYPE string,
lv_lifnr TYPE lfa1-lifnr,
lv_bpkind TYPE but000-bpkind,
lv_akont TYPE lfb1-akont.
** BP check
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ps_basic-partner
IMPORTING
output = lv_lifnr.
SELECT SINGLE partner INTO @lv_lifnr FROM but000 WHERE partner = @lv_lifnr.
IF sy-subrc = 0.
** BP已存在,不能重复创建
ps_output-type = 'G'.
ps_output-message = TEXT-e01 && ps_basic-partner && TEXT-e02.
EXIT.
ENDIF.
TRY .
pv_partner_guid = cl_uuid_factory=>create_system_uuid( )->create_uuid_x16( ).
CATCH cx_uuid_error.
"返回消息
ps_output-type = 'E'.
ps_output-message = TEXT-e01 && ps_basic-partner && TEXT-e03.
EXIT.
ENDTRY.
** 基本信息
ls_partner-header-object_task = l_object_task_i.
ls_partner-header-object_instance-bpartner = lv_lifnr.
ls_partner-header-object_instance-bpartnerguid = pv_partner_guid.
****业务合作伙伴数据的中心数据***********************************
ls_partner-central_data-common-data-bp_control-category = '2'. "VMS系统传输的是外部供应商,通过“organization”形式创建,接口默认字段值为“2”
ls_partner-central_data-common-data-bp_control-grouping = ps_basic-bu_group. "业务伙伴分组
ls_partner-central_data-common-data-bp_centraldata-partnertype = ps_basic-bpkind. "业务伙伴类型
ls_partner-central_data-common-datax-bp_centraldata-partnertype = abap_true. "业务伙伴类型
ls_partner-central_data-common-data-bp_organization-name1 = ps_basic-name_org1. "供应商名称
ls_partner-central_data-common-data-bp_organization-name2 = ps_basic-name_org2. "供应商名称
ls_partner-central_data-common-data-bp_organization-name3 = ps_basic-name_org3. "供应商名称
ls_partner-central_data-common-datax-bp_organization-name1 = abap_true.
ls_partner-central_data-common-datax-bp_organization-name2 = abap_true.
ls_partner-central_data-common-datax-bp_organization-name3 = abap_true.
** 增强字段:供应商附加信息
ls_partner-central_data-common-data-zservice = ps_basic-zservice. " 服务范围
ls_partner-central_data-common-data-zsocialcc = ps_basic-zsocialcc. " 统一社会信用代码
ls_partner-central_data-common-data-zindustry = ps_basic-zindustry. " 供应商行业分类
ls_partner-central_data-common-data-ztype = ps_basic-ztype. " 供应商类型
ls_partner-central_data-common-datax-zservice = abap_true. " 服务范围
ls_partner-central_data-common-datax-zsocialcc = abap_true. " 统一社会信用代码
ls_partner-central_data-common-datax-zindustry = abap_true. " 供应商行业分类
ls_partner-central_data-common-datax-ztype = abap_true. " 供应商类型
** 角色
** VMS系统传输的供应商数据,接口自动扩充基础数据、财务数据、采购数据。
** 000000-general data;FLVN00-财务数据;FLVN01-采购数据"
REFRESH: lt_roles[].
* ls_roles-task = 'I'.
* ls_roles-data_key = '000000'. "general data
* APPEND ls_roles TO lt_roles.
ls_roles-task = 'I'.
ls_roles-data_key = 'FLVN00'. "财务公司角色
APPEND ls_roles TO lt_roles.
ls_roles-task = 'I'.
ls_roles-data_key = 'FLVN01'. "采购角色
APPEND ls_roles TO lt_roles.
ls_partner-central_data-role-roles = lt_roles.
** 地址信息
REFRESH: lt_addresses[].
ls_addresses-task = l_object_task_i.
ls_addresses-data-postal-data-street = ps_basic-street. "街道
ls_addresses-data-postal-data-country = ps_basic-country. "国家
PERFORM frm_get_langu TABLES pt_banks
USING ps_basic
CHANGING ls_addresses-data-postal-data-langu. "语言
ls_addresses-data-postal-data-postl_cod1 = ps_basic-post_code1. "邮编
ls_addresses-data-postal-data-str_suppl1 = ps_basic-str_suppl1. "街道2
ls_addresses-data-postal-datax-street = abap_true.
ls_addresses-data-postal-datax-country = abap_true.
ls_addresses-data-postal-datax-langu = abap_true.
ls_addresses-data-postal-datax-postl_cod1 = abap_true.
ls_addresses-data-postal-datax-str_suppl1 = abap_true. "街道2
*begin add by Ellis 20210705
ls_addresses-data-remark-remarks = VALUE bus_ei_bupa_addressremark_t( ( task = l_object_task_i
data-langu = '1'
data-adr_notes = ps_basic-remark
datax-langu = abap_true
datax-adr_notes = abap_true )
( task = l_object_task_i
data-langu = 'E'
data-adr_notes = ps_basic-remark
datax-langu = abap_true
datax-adr_notes = abap_true ) ).
*End add by Ellis 20210705
** 供应商英文名称
IF ps_basic-name_org1_f IS NOT INITIAL OR ps_basic-name_org2_f IS NOT INITIAL
OR ps_basic-name_org3_f IS NOT INITIAL.
CLEAR: ls_version.
REFRESH: lt_version.
ls_version-data-organization-addr_vers = 'I'.
ls_version-data-organization-name = ps_basic-name_org1_f.
ls_version-data-organization-name_2 = ps_basic-name_org2_f.
ls_version-data-organization-name_3 = ps_basic-name_org3_f.
ls_version-datax-organization-name = abap_true.
ls_version-datax-organization-name_2 = abap_true.
ls_version-datax-organization-name_3 = abap_true.
APPEND ls_version TO lt_version.
ls_addresses-data-version-versions = lt_version.
ENDIF.
APPEND ls_addresses TO lt_addresses.
ls_partner-central_data-address-addresses = lt_addresses.
** 检查分行代码有没有,没有则创建
REFRESH: lt_bankdetails[].
LOOP AT pt_banks INTO DATA(ls_banks).
PERFORM f_check_bankl USING ls_banks.
** 银行信息
IF ls_banks-banks IS NOT INITIAL AND ls_banks-bankl IS NOT INITIAL.
ls_bankdetails-task = l_object_task_i.
ls_bankdetails-data_key = ls_banks-bkvid.
ls_bankdetails-data-bank_ctry = ls_banks-banks.
ls_bankdetails-data-bank_key = ls_banks-bankl.
ls_bankdetails-data-bank_acct = ls_banks-bankn.
ls_bankdetails-data-accountholder = ls_banks-koinh.
ls_bankdetails-data-bank_ref = ls_banks-bkref.
ls_bankdetails-datax-bank_ctry = abap_true.
ls_bankdetails-datax-bank_key = abap_true.
ls_bankdetails-datax-bank_acct = abap_true.
ls_bankdetails-datax-accountholder = abap_true.
ls_bankdetails-datax-bank_ref = abap_true.
APPEND ls_bankdetails TO lt_bankdetails.
CLEAR:ls_bankdetails.
ENDIF.
ENDLOOP.
ls_partner-central_data-bankdetail-bankdetails = lt_bankdetails.
****公司代码数据************************************************
ls_vendor-header-object_instance-lifnr = lv_lifnr.
ls_vendor-header-object_task = l_object_task_i.
REFRESH: lt_company[].
SORT pt_bukrs BY bukrs.
DELETE ADJACENT DUPLICATES FROM pt_bukrs COMPARING bukrs.
LOOP AT pt_bukrs INTO DATA(ls_bukrs).
CLEAR:ls_company.
CLEAR: lv_akont.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " 统驭科目补零
EXPORTING
input = ls_bukrs-akont
IMPORTING
output = lv_akont.
ls_company-task = l_object_task_i.
ls_company-data_key-bukrs = ls_bukrs-bukrs. "公司代码
ls_company-data-akont = lv_akont. "统驭科目
ls_company-data-zterm = ls_bukrs-zterm. "付款条件
IF ls_bukrs-zwels IS NOT INITIAL.
ls_company-data-zwels = ls_bukrs-zwels. "付款方式
ELSE.
ls_company-data-zwels = 'T'. " 默认T
ENDIF.
ls_company-data-reprf = abap_true. "检查重复发票 默认 X
IF pv_system = 'VMS'.
ls_company-data-zgrup = '01'.
ls_company-datax-zgrup = abap_true.
ENDIF.
ls_company-datax-akont = abap_true.
ls_company-datax-zwels = abap_true.
ls_company-datax-zterm = abap_true.
ls_company-datax-reprf = abap_true.
** 增强字段:供应商联系信息
ls_company-data-zsalesperson = ls_bukrs-zsalesperson. " 联系人
ls_company-data-zposition = ls_bukrs-zposition. " 职位
ls_company-data-ztel_number = ls_bukrs-ztel_number. " 联系电话
ls_company-data-zemail = ls_bukrs-zemail. " 邮箱
ls_company-datax-zsalesperson = abap_true. " 联系人
ls_company-datax-zposition = abap_true. " 职位
ls_company-datax-ztel_number = abap_true. " 联系电话
ls_company-datax-zemail = abap_true. " 邮箱
APPEND ls_company TO lt_company.
ENDLOOP.
ls_vendor-company_data-company = lt_company.
****采购数据****************************************************
REFRESH: lt_purchasing[].
ls_purchasing-task = l_object_task_i.
IF ps_basic-ekorg IS NOT INITIAL.
ls_purchasing-data_key-ekorg = ps_basic-ekorg. "采购组织
ELSE.
ls_purchasing-data_key-ekorg = 'HBMP'. "采购组织 默认 HBMP
ENDIF.
ls_purchasing-data-waers = ps_basic-waers. "货币
ls_purchasing-data-webre = abap_true. "基于收货的发票校验 默认X
ls_purchasing-data-zterm = ps_basic-zterm. "付款条件
ls_purchasing-data-ekgrp = ps_basic-ekgrp.
ls_purchasing-datax-waers = abap_true.
ls_purchasing-datax-webre = abap_true.
ls_purchasing-datax-zterm = abap_true.
ls_purchasing-datax-ekgrp = abap_true.
APPEND ls_purchasing TO lt_purchasing.
ls_vendor-purchasing_data-purchasing = lt_purchasing.
***** 汇总
ls_data-partner = ls_partner.
ls_data-vendor = ls_vendor.
ls_data-ensure_create-create_vendor = abap_true.
APPEND ls_data TO pt_data.
ENDFORM.
BP冻结(全部冻结/按明细冻结公司代码采购组织)
FORM frm_process_frzdata USING ps_basic TYPE zmms_vms03
CHANGING ps_output TYPE zbcs001
pt_data TYPE cvis_ei_extern_t
pv_partner_guid TYPE bu_partner_guid.
CONSTANTS: l_object_task_m TYPE bus_ei_object_task VALUE 'U'.
DATA: lv_tabix TYPE sy-tabix,
ls_data TYPE cvis_ei_extern,
ls_msg TYPE bapiretc,
ls_partner TYPE bus_ei_extern,
ls_vendor TYPE vmds_ei_extern,
lt_roles TYPE bus_ei_bupa_roles_t,
ls_roles TYPE bus_ei_bupa_roles,
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_remarks TYPE bus_ei_bupa_comrem_t,
ls_remarks TYPE bus_ei_bupa_comrem,
lt_bankdetails TYPE bus_ei_bupa_bankdetail_t,
ls_bankdetails TYPE bus_ei_bupa_bankdetail,
lt_company TYPE vmds_ei_company_t,
ls_company TYPE vmds_ei_company,
lt_purchasing TYPE vmds_ei_purchasing_t,
ls_purchasing TYPE vmds_ei_purchasing,
lt_functions TYPE vmds_ei_functions_t,
ls_functions TYPE vmds_ei_functions,
lt_bapiret2 TYPE bapiret2_t,
ls_bapiret2 TYPE bapiret2.
DATA: l_str TYPE string,
lv_lifnr TYPE lfa1-lifnr,
lv_bpkind TYPE but000-bpkind,
lv_akont TYPE lfb1-akont.
** BP check
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ps_basic-partner
IMPORTING
output = lv_lifnr.
SELECT SINGLE partner, partner_guid INTO ( @lv_lifnr, @pv_partner_guid ) FROM but000 WHERE partner = @lv_lifnr.
IF sy-subrc NE 0.
** BP不存在,不能冻结
ps_output-type = 'E'.
ps_output-message = TEXT-e01 && ps_basic-partner && TEXT-e05.
EXIT.
ENDIF.
** 基本信息
ls_partner-header-object_task = l_object_task_m.
ls_partner-header-object_instance-bpartner = lv_lifnr.
ls_partner-header-object_instance-bpartnerguid = pv_partner_guid.
ls_partner-central_data-common-data-bp_centraldata-centralblock = abap_true. "业务伙伴的集中冻结
ls_partner-central_data-common-datax-bp_centraldata-centralblock = abap_true. "业务伙伴的集中冻结
** 取BP所有公司信息
SELECT lifnr, bukrs FROM lfb1 INTO TABLE @DATA(lt_lfb1) WHERE lifnr = @lv_lifnr.
IF sy-subrc = 0.
ls_vendor-header-object_instance-lifnr = lv_lifnr.
ls_vendor-header-object_task = l_object_task_m.
ls_vendor-central_data-central-data-sperr = ps_basic-sperr. " 公司集中冻结
ls_vendor-central_data-central-datax-sperr = abap_true. " 公司集中冻结
REFRESH: lt_company[].
LOOP AT lt_lfb1 INTO DATA(ls_lfb1).
ls_company-task = l_object_task_m.
ls_company-data_key-bukrs = ls_lfb1-bukrs. "公司代码
ls_company-data-sperr = ps_basic-sperr. "公司代码冻结
ls_company-datax-sperr = abap_true. "公司代码冻结
APPEND ls_company TO lt_company.
ENDLOOP.
ls_vendor-company_data-company = lt_company.
ENDIF.
** 取BP所有采购组织信息
SELECT lifnr, ekorg FROM lfm1 INTO TABLE @DATA(lt_lfm1) WHERE lifnr = @lv_lifnr.
IF sy-subrc = 0.
REFRESH: lt_purchasing[].
LOOP AT lt_lfm1 INTO DATA(ls_lfm1).
ls_purchasing-task = l_object_task_m.
ls_purchasing-data_key-ekorg = ls_lfm1-ekorg. "采购组织
ls_purchasing-data-sperm = ps_basic-sperm. "采购组织冻结
ls_purchasing-datax-sperm = abap_true. "采购组织冻结
APPEND ls_purchasing TO lt_purchasing.
ENDLOOP.
ls_vendor-purchasing_data-purchasing = lt_purchasing.
ENDIF.
***** 汇总
ls_data-partner = ls_partner.
ls_data-vendor = ls_vendor.
APPEND ls_data TO pt_data.
ENDFORM.
后记:写这些东西只是为了让给自己做个记录。如果你看到了这篇博文希望能对你有那么一点帮助,关于里面的注解只是我自己的理解,不正确的地方,请指出。