FUNCTION ZZSD_CUSTOMER_CREATE.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_RLTGR) TYPE BU_RLGROUP DEFAULT 'ZCUST'
*" VALUE(I_BU_GROUP) TYPE BU_GROUP DEFAULT 'Z001'
*" EXPORTING
*" VALUE(E_CODE) TYPE MSGTY
*" VALUE(E_MSG) TYPE MSGTXT
*" TABLES
*" T_INPUT STRUCTURE ZSSD0040
*" T_OUTPUT STRUCTURE ZSSD0041
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_RLTGR) TYPE BU_RLGROUP DEFAULT 'ZCUST'
*" VALUE(I_BU_GROUP) TYPE BU_GROUP DEFAULT 'Z001'
*" EXPORTING
*" VALUE(E_CODE) TYPE MSGTY
*" VALUE(E_MSG) TYPE MSGTXT
*" TABLES
*" T_INPUT STRUCTURE ZSSD0040
*" T_OUTPUT STRUCTURE ZSSD0041
" PROGRAMMED BY HANDYY 20181108 创建和修改日志记录同步到自建表ZTSD0041中
*"----------------------------------------------------------------------
MACRO_SAVE_LOG_BEFORE_PROC. "日志保存——保存函数名称
MACRO_SAVE_LOG_AFTER_PROC 'IN'. "日志保存——输入参数
DATA:S_INPUT TYPE ZSSD0040,
T_IN TYPE STANDARD TABLE OF ZSSD0040.
DATA: E_RTYPE TYPE MSGTY,
E_RTMSG TYPE MSGTXT.
LOOP AT T_INPUT INTO S_INPUT.
APPEND S_INPUT TO T_IN.
CASE S_INPUT-ZUDID.
WHEN 'A'.
"创建客户主数据(基本视图,公司视图,销售视图)
PERFORM FRM_CUSTOMER_CREATGE TABLES T_IN
T_OUTPUT
USING I_RLTGR
I_BU_GROUP
CHANGING E_CODE
E_MSG.
CLEAR T_IN[].
WHEN 'C'.
"创建客户主数据(公司视图,销售视图)
PERFORM FRM_CUSTOMER_CREATGE2 TABLES T_IN
T_OUTPUT
USING I_RLTGR
I_BU_GROUP
CHANGING E_CODE
E_MSG.
CLEAR T_IN[].
WHEN 'B'.
"修改客户主数据(修改账期【付款条件】字段)
PERFORM FRM_CUSTOMER_CHANGE TABLES T_IN
T_OUTPUT
USING I_RLTGR
I_BU_GROUP
CHANGING E_CODE
E_MSG.
CLEAR T_IN[].
WHEN OTHERS.
E_CODE = 'E'.
E_MSG = '您输入的标识错误,请重新输入'.
CLEAR T_IN[].
ENDCASE.
CLEAR S_INPUT.
ENDLOOP.
E_RTYPE = E_CODE.
E_RTMSG = E_MSG.
MACRO_SAVE_LOG_AFTER_PROC 'OUT'. "日志保存——输出参数
ENDFUNCTION.
*----------------------------------------------------------------------*
***INCLUDE LZSDI001F03. PROGRAMMED BY HANDYY 20181108
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_CUSTOMER_CREATGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_CUSTOMER_CREATGE TABLES PT_IN STRUCTURE ZSSD0040
PT_OUTPUT STRUCTURE ZSSD0041
USING PV_RLTGR
PV_BU_GROUP
CHANGING PV_CODE
PV_MSG.
TYPES:BEGIN OF TY_KNA1,
NAME1 TYPE KNA1-NAME1,
KUNNR TYPE KNA1-KUNNR,
END OF TY_KNA1.
DATA: LT_KNA1 TYPE STANDARD TABLE OF TY_KNA1,
LT_KUNNR TYPE STANDARD TABLE OF TY_KNA1,
LS_KUNNR TYPE TY_KNA1.
DATA: LS_OUTPUT TYPE ZSSD0041,
LT_RECORD TYPE STANDARD TABLE OF ZTSD0041, "同步日志到自建表
LS_RECORD TYPE ZTSD0041.
DATA : LT_PARTNERGUID_LIST TYPE BU_PARTNER_GUID_T,
LS_PARTNERGUID_LIST LIKE LINE OF LT_PARTNERGUID_LIST.
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.
FIELD-SYMBOLS:
DATA : LV_BPARTNERGUID TYPE BU_PARTNER_GUID_BAPI.
LOOP AT PT_IN ASSIGNING
TRY .
LV_BPARTNERGUID = CL_UUID_FACTORY=>CREATE_SYSTEM_UUID( )->CREATE_UUID_X16( ).
CATCH CX_UUID_ERROR.
"返回消息
ENDTRY.
IF
PV_CODE = 'E'.
PV_MSG = '请输入公司名称'.
ELSE.
SELECT
NAME1
INTO TABLE LT_KNA1
FROM KNA1
WHERE NAME1 =
IF SY-SUBRC <> 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "客户编号加前导零
EXPORTING
INPUT =
IMPORTING
OUTPUT =
LS_PARTNER-HEADER-OBJECT_TASK = 'I'. "I插入 U更新 M修改 D删除 C当前状态
LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNERGUID = LV_BPARTNERGUID. "唯一标识
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-CATEGORY = 2. "业务伙伴类别
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-GROUPING = PV_BU_GROUP. "业务伙伴分组
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME1 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME2 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME3 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME4 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CENTRALDATA-SEARCHTERM1 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CENTRALDATA-TITLE_KEY =
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-DATAX-BP_ORGANIZATION-NAME4 = ABAP_TRUE.
LS_PARTNER-CENTRAL_DATA-COMMON-DATAX-BP_CENTRALDATA-SEARCHTERM1 = ABAP_TRUE.
LS_PARTNER-CENTRAL_DATA-COMMON-DATAX-BP_CENTRALDATA-TITLE_KEY = ABAP_TRUE.
"必须扩充业务伙伴角色分组下的全部业务伙伴角色才能扩充出该业务伙伴角色分组
CLEAR:LS_ROLES,LT_ROLES.
LS_ROLES-TASK = 'I'.
LS_ROLES-DATA_KEY = 'FLCU00'. "业务伙伴角色
* LS_ROLES-DATA-ROLECATEGORY = 'FLCU00'. "业务伙伴角色类别
APPEND LS_ROLES TO LT_ROLES.
CLEAR:LS_ROLES.
LS_ROLES-TASK = 'I'.
LS_ROLES-DATA_KEY = 'FLCU01'. "业务伙伴角色
* LS_ROLES-DATA-ROLECATEGORY = 'FLCU01'. "业务伙伴角色类别
APPEND LS_ROLES TO LT_ROLES.
LS_PARTNER-CENTRAL_DATA-ROLE-ROLES = LT_ROLES.
CLEAR:LS_ADDRESSES,LT_ADDRESSES.
LS_ADDRESSES-TASK = 'I'. "I插入 U更新 M修改 D删除 C当前状态
LS_ADDRESSES-DATA-POSTAL-DATA-PO_CTRYISO =
LS_ADDRESSES-DATA-POSTAL-DATA-CITY =
LS_ADDRESSES-DATA-POSTAL-DATA-REGION =
LS_ADDRESSES-DATA-POSTAL-DATA-C_O_NAME =
LS_ADDRESSES-DATA-POSTAL-DATA-STREET =
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT =
IMPORTING
OUTPUT = LS_ADDRESSES-DATA-POSTAL-DATA-POSTL_COD1.
* LS_ADDRESSES-DATA-POSTAL-DATA-POSTL_COD1 =
LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL1 =
LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL2 =
LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL3 =
CALL FUNCTION 'CONVERSION_EXIT_ISOLA_INPUT'
EXPORTING
INPUT =
IMPORTING
OUTPUT = LS_ADDRESSES-DATA-POSTAL-DATA-LANGU
EXCEPTIONS
UNKNOWN_LANGUAGE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
* LS_ADDRESSES-DATA-POSTAL-DATA-LANGU =
LS_ADDRESSES-DATA-POSTAL-DATAX-PO_CTRYISO = ABAP_TRUE. " 国家代码
LS_ADDRESSES-DATA-POSTAL-DATAX-CITY = ABAP_TRUE. "城市
LS_ADDRESSES-DATA-POSTAL-DATAX-REGION = ABAP_TRUE. " 地区代码
LS_ADDRESSES-DATA-POSTAL-DATAX-C_O_NAME = ABAP_TRUE. " 代收人
LS_ADDRESSES-DATA-POSTAL-DATAX-POSTL_COD1 = ABAP_TRUE. " 邮政编码
LS_ADDRESSES-DATA-POSTAL-DATAX-STREET = ABAP_TRUE. " 街道
LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL1 = ABAP_TRUE. " 街道2
LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL2 = ABAP_TRUE. " 街道3
LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL3 = ABAP_TRUE. " 街道4
LS_ADDRESSES-DATA-POSTAL-DATAX-LANGU = ABAP_TRUE. "语言
CLEAR:LS_PHONE,LT_PHONE.
LS_PHONE-CONTACT-TASK = 'I'. "I插入 U更新 M修改 D删除 C当前状态
LS_PHONE-CONTACT-DATA-TELEPHONE =
LS_PHONE-CONTACT-DATAX-TELEPHONE = ABAP_TRUE.
APPEND LS_PHONE TO LT_PHONE.
CLEAR:LS_PHONE.
LS_PHONE-CONTACT-TASK = 'I'. "I插入 U更新 M修改 D删除 C当前状态
LS_PHONE-CONTACT-DATA-TELEPHONE =
LS_PHONE-CONTACT-DATA-R_3_USER = '3'. "3表示移动电话
LS_PHONE-CONTACT-DATAX-TELEPHONE = ABAP_TRUE.
LS_PHONE-CONTACT-DATAX-R_3_USER = ABAP_TRUE.
APPEND LS_PHONE TO LT_PHONE.
LS_ADDRESSES-DATA-COMMUNICATION-PHONE-PHONE = LT_PHONE.
CLEAR:LS_FAX,LT_FAX.
LS_FAX-CONTACT-TASK = 'I'. "I插入 U更新 M修改 D删除 C当前状态
LS_FAX-CONTACT-DATA-FAX =
LS_FAX-CONTACT-DATAX-FAX = ABAP_TRUE.
APPEND LS_FAX TO LT_FAX.
LS_ADDRESSES-DATA-COMMUNICATION-FAX-FAX = LT_FAX.
CLEAR:LS_SMTP,LT_SMTP.
LS_SMTP-CONTACT-TASK = 'I'. "I插入 U更新 M修改 D删除 C当前状态
LS_SMTP-CONTACT-DATA-E_MAIL =
LS_SMTP-CONTACT-DATAX-E_MAIL = ABAP_TRUE.
APPEND LS_SMTP TO LT_SMTP.
LS_ADDRESSES-DATA-COMMUNICATION-SMTP-SMTP = LT_SMTP.
APPEND LS_ADDRESSES TO LT_ADDRESSES.
LS_PARTNER-CENTRAL_DATA-ADDRESS-ADDRESSES = LT_ADDRESSES.
*******客户抬头数据***********************************************************
LS_HEADER-OBJECT_TASK = 'I'.
LS_CUSTOMER-HEADER = LS_HEADER.
****中心客户数据*************************************************
LS_CENTRAL-DATA-NIELS =
* LS_CENTRAL-DATA-BRSCH =
LS_CENTRAL-DATA-KUKLA =
LS_CENTRAL-DATA-BRAN1 =
* LS_CENTRAL-DATA-LIFNR =
LS_CENTRAL-DATA-KONZS =
* LS_CENTRAL-DATA-STCEG = |{
* LS_CENTRAL-DATA-KTOKD = |{
LS_CENTRAL-DATAX-NIELS = ABAP_TRUE.
* LS_CENTRAL-DATAX-BRSCH = ABAP_TRUE.
LS_CENTRAL-DATAX-KUKLA = ABAP_TRUE.
LS_CENTRAL-DATAX-BRAN1 = ABAP_TRUE.
* LS_CENTRAL-DATAX-LIFNR = ABAP_TRUE.
LS_CENTRAL-DATAX-KONZS = ABAP_TRUE.
LS_CUSTOMER-CENTRAL_DATA-CENTRAL = LS_CENTRAL.
****公司代码数据************************************************
IF
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " 统驭科目补前导零
EXPORTING
INPUT =
IMPORTING
OUTPUT =
LS_COMPANY-TASK = 'I'.
LS_COMPANY-DATA_KEY-BUKRS = '1210'. " 公司代码
LS_COMPANY-DATA-AKONT =
LS_COMPANY-DATA-ZTERM =
LS_COMPANY-DATA-EIKTO =
LS_COMPANY-DATA-KVERM =
LS_COMPANY-DATAX-AKONT = ABAP_TRUE.
LS_COMPANY-DATAX-ZTERM = ABAP_TRUE.
LS_COMPANY-DATAX-EIKTO = ABAP_TRUE.
LS_COMPANY-DATAX-KVERM = ABAP_TRUE.
APPEND LS_COMPANY TO LT_COMPANY.
LS_COMPANY-TASK = 'I'.
LS_COMPANY-DATA_KEY-BUKRS = '1200'. " 公司代码
LS_COMPANY-DATA-AKONT =
LS_COMPANY-DATA-ZTERM =
LS_COMPANY-DATA-EIKTO =
LS_COMPANY-DATA-KVERM =
LS_COMPANY-DATAX-AKONT = ABAP_TRUE.
LS_COMPANY-DATAX-ZTERM = ABAP_TRUE.
LS_COMPANY-DATAX-EIKTO = ABAP_TRUE.
LS_COMPANY-DATAX-KVERM = ABAP_TRUE.
APPEND LS_COMPANY TO LT_COMPANY.
LS_COMPANY_DATA-COMPANY = LT_COMPANY.
LS_CUSTOMER-COMPANY_DATA = LS_COMPANY_DATA.
ENDIF.
*********税收标识********************************************************
LS_TAX_IND-TASK = 'I'.
LS_TAX_IND-DATA_KEY-ALAND = 'CN'.
LS_TAX_IND-DATA_KEY-TATYP = 'MWST'.
IF
LS_TAX_IND-DATA-TAXKD = '0'. "客户税分类
ELSE.
LS_TAX_IND-DATA-TAXKD = '1'. "客户税分类
ENDIF.
LS_TAX_IND-DATA-TAXKD =
LS_TAX_IND-DATAX-TAXKD = ABAP_TRUE.
APPEND LS_TAX_IND TO LT_TAX_IND.
LS_CUSTOMER-CENTRAL_DATA-TAX_IND-TAX_IND = LT_TAX_IND.
*****销售数据****************************************************
* IF
IF
AND
AND
LS_SALES-TASK = 'I'.
LS_SALES-DATA_KEY-VKORG = '1200'. "销售组织
LS_SALES-DATA_KEY-VTWEG =
LS_SALES-DATA_KEY-SPART =
IF
LS_SALES-DATA-WAERS = 'USD'. "货币
LS_SALES-DATA-KALKS = '1'. "用于确定定价过程的客户分类
ELSE.
LS_SALES-DATA-WAERS = 'CNY'. "货币
LS_SALES-DATA-KALKS = '2'. "用于确定定价过程的客户分类
ENDIF.
* LS_SALES-DATA-KALKS =
LS_SALES-DATA-VSBED =
LS_SALES-DATA-KDGRP =
LS_SALES-DATA-KONDA =
LS_SALES-DATA-KTGRD =
LS_SALES-DATA-EIKTO =
LS_SALES-DATA-ZTERM =
* LS_SALES-DATAX-WAERS = ABAP_TRUE.
* LS_SALES-DATAX-KALKS = ABAP_TRUE.
LS_SALES-DATAX-VSBED = ABAP_TRUE.
* LS_SALES-DATAX-PODKZ = ABAP_TRUE.
* LS_SALES-DATAX-INCO1 = ABAP_TRUE.
* LS_SALES-DATAX-INCO2 = ABAP_TRUE.
LS_SALES-DATAX-KDGRP = ABAP_TRUE.
LS_SALES-DATAX-KONDA = ABAP_TRUE.
LS_SALES-DATAX-KTGRD = ABAP_TRUE.
LS_SALES-DATAX-EIKTO = ABAP_TRUE.
LS_SALES-DATAX-ZTERM = ABAP_TRUE.
* Function伙伴功能 (如果不添加,会导致销售视图无法维护成功,从而使公司代码视图也无法成功维护)
LS_FUNCTIONS-TASK = 'I'.
IF
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z1'.
* LS_FUNCTIONS-DATA-PARTNER =
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'BP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'PY' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SH' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
ELSE.
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z2'.
* LS_FUNCTIONS-DATA-PARTNER =
ENDIF.
* APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
LS_SALES-FUNCTIONS-FUNCTIONS = LT_FUNCTIONS.
APPEND LS_SALES TO LT_SALES.
*增加1210 s
LS_SALES-TASK = 'I'.
LS_SALES-DATA_KEY-VKORG = '1210'. "销售组织
LS_SALES-DATA_KEY-VTWEG =
LS_SALES-DATA_KEY-SPART =
IF
LS_SALES-DATA-WAERS = 'USD'. "货币
LS_SALES-DATA-KALKS = '1'. "用于确定定价过程的客户分类
ELSE.
LS_SALES-DATA-WAERS = 'CNY'. "货币
LS_SALES-DATA-KALKS = '2'. "用于确定定价过程的客户分类
ENDIF.
* LS_SALES-DATA-KALKS =
LS_SALES-DATA-VSBED =
LS_SALES-DATA-KDGRP =
LS_SALES-DATA-KONDA =
LS_SALES-DATA-KTGRD =
LS_SALES-DATA-EIKTO =
LS_SALES-DATA-ZTERM =
* LS_SALES-DATAX-WAERS = ABAP_TRUE.
* LS_SALES-DATAX-KALKS = ABAP_TRUE.
LS_SALES-DATAX-VSBED = ABAP_TRUE.
* LS_SALES-DATAX-PODKZ = ABAP_TRUE.
* LS_SALES-DATAX-INCO1 = ABAP_TRUE.
* LS_SALES-DATAX-INCO2 = ABAP_TRUE.
LS_SALES-DATAX-KDGRP = ABAP_TRUE.
LS_SALES-DATAX-KONDA = ABAP_TRUE.
LS_SALES-DATAX-KTGRD = ABAP_TRUE.
LS_SALES-DATAX-EIKTO = ABAP_TRUE.
LS_SALES-DATAX-ZTERM = ABAP_TRUE.
* Function伙伴功能
LS_FUNCTIONS-TASK = 'I'.
IF
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z1'.
* LS_FUNCTIONS-DATA-PARTNER =
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'BP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'PY' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SH' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
ELSE.
ENDIF.
LS_SALES-FUNCTIONS-FUNCTIONS = LT_FUNCTIONS.
APPEND LS_SALES TO LT_SALES.
*增加1210 e
LS_SALES_DATA-SALES = LT_SALES.
LS_CUSTOMER-SALES_DATA = LS_SALES_DATA.
ENDIF.
* ENDIF.
LS_DATA-PARTNER = LS_PARTNER.
LS_DATA-CUSTOMER = LS_CUSTOMER.
* LS_DATA-ENSURE_CREATE-CREATE_CUSTOMER = ABAP_TRUE.
APPEND LS_DATA TO LT_DATA.
"调用BP创建函数
CALL FUNCTION 'CVI_EI_INBOUND_MAIN'
EXPORTING
I_DATA = LT_DATA
IMPORTING
E_RETURN = LT_RETURN.
CLEAR: PV_CODE, PV_MSG.
LOOP AT LT_RETURN INTO LS_RETURN.
LOOP AT LS_RETURN-OBJECT_MSG INTO DATA(LS_OBJECT_MSG) WHERE TYPE CA 'EA'.
IF PV_MSG IS INITIAL.
PV_MSG = LS_OBJECT_MSG-MESSAGE.
ELSE.
CONCATENATE PV_MSG '/' LS_OBJECT_MSG-MESSAGE INTO PV_MSG.
ENDIF.
ENDLOOP.
IF SY-SUBRC = 0.
"回滚BAPI
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. "回滚BAPI
PV_CODE = 'E'.
EXIT.
ENDIF.
ENDLOOP.
IF PV_CODE <> 'E' .
"提交BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
* IMPORTING
* RETURN =
"去底表中取客户名称对应的客户编号
CLEAR LS_KUNNR.
SELECT SINGLE
NAME1
KUNNR
INTO LS_KUNNR
FROM KNA1
WHERE NAME1 =
PV_CODE = 'S'.
CONCATENATE '客户编号为' LS_KUNNR-KUNNR '的客户主数据创建成功' INTO PV_MSG.
ENDIF.
LS_OUTPUT-Z003 =
LS_OUTPUT-PARTNER = LS_KUNNR-KUNNR. "业务伙伴编码
LS_OUTPUT-RTYPE = PV_CODE. "消息类型
LS_OUTPUT-RTMSG = PV_MSG. "消息文本
APPEND LS_OUTPUT TO PT_OUTPUT.
LS_RECORD-ZZOANUM =
LS_RECORD-KUNNR = LS_KUNNR-KUNNR. "业务伙伴编码
LS_RECORD-ZZNAME1 =
LS_RECORD-BUKRS =
LS_RECORD-ZZDATE = SY-DATUM. "SAP接收日期
LS_RECORD-ZZTIME = SY-UZEIT. "SAP接收时间
LS_RECORD-ZZRES = PV_CODE. "导入状态
LS_RECORD-ZZEMES = PV_MSG. "报错信息
MODIFY ZTSD0041 FROM LS_RECORD. "更新日志表
ELSE.
PV_CODE = 'E'.
PV_MSG = '此公司客户主数据已存在'.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
***INCLUDE LZSDI001F06. PROGRAMMED BY HANDYY 20181108
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_CUSTOMER_CREATGE2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_IN text
* -->P_T_OUTPUT text
* -->P_I_RLTGR text
* -->P_I_BU_GROUP text
* <--P_E_CODE text
* <--P_E_MSG text
*----------------------------------------------------------------------*
FORM FRM_CUSTOMER_CREATGE2 TABLES PT_IN STRUCTURE ZSSD0040
PT_OUTPUT STRUCTURE ZSSD0041
USING PV_RLTGR
PV_BU_GROUP
CHANGING PV_CODE
PV_MSG.
DATA: LS_OUTPUT TYPE ZSSD0041,
LT_RECORD TYPE STANDARD TABLE OF ZTSD0041, "同步日志到自建表
LS_RECORD TYPE ZTSD0041.
DATA : LT_PARTNERGUID_LIST TYPE BU_PARTNER_GUID_T,
LS_PARTNERGUID_LIST LIKE LINE OF LT_PARTNERGUID_LIST.
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.
FIELD-SYMBOLS:
DATA : LV_BPARTNERGUID TYPE BU_PARTNER_GUID_BAPI.
LOOP AT PT_IN ASSIGNING
"获取业务伙伴对应的唯一标识
SELECT SINGLE
B~PARTNER,
A~PARTNER_GUID
INTO @DATA(LS_BUT000)
FROM CVI_CUST_LINK AS A INNER JOIN BUT000 AS B
ON A~PARTNER_GUID = B~PARTNER_GUID
WHERE CUSTOMER = @
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "客户编号加前导零
EXPORTING
INPUT =
IMPORTING
OUTPUT =
LS_BUT000-PARTNER = |{ LS_BUT000-PARTNER ALPHA = IN }|. "加前导零
LS_PARTNER-HEADER-OBJECT_TASK = 'M'. "I插入 U更新 M修改 D删除 C当前状态
LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNER = LS_BUT000-PARTNER. "业务伙伴编号
LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNERGUID = LS_BUT000-PARTNER_GUID. "唯一标识
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-CATEGORY = 2. "业务伙伴类别
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-GROUPING = PV_BU_GROUP. "业务伙伴分组
*******客户抬头数据***********************************************************
LS_HEADER-OBJECT_TASK = 'U'.
LS_HEADER-OBJECT_INSTANCE-KUNNR =
LS_CUSTOMER-HEADER = LS_HEADER.
****中心客户数据*************************************************
LS_CENTRAL-DATA-NIELS =
* LS_CENTRAL-DATA-BRSCH =
LS_CENTRAL-DATA-KUKLA =
LS_CENTRAL-DATA-BRAN1 =
* LS_CENTRAL-DATA-LIFNR =
LS_CENTRAL-DATA-KONZS =
* LS_CENTRAL-DATA-STCEG =
* LS_CENTRAL-DATA-KTOKD =
LS_CENTRAL-DATA-AUFSD = '01'. "客户主要订单块 (冻结相关)
LS_CENTRAL-DATAX-NIELS = ABAP_TRUE.
* LS_CENTRAL-DATAX-BRSCH = ABAP_TRUE.
LS_CENTRAL-DATAX-KUKLA = ABAP_TRUE.
LS_CENTRAL-DATAX-BRAN1 = ABAP_TRUE.
* LS_CENTRAL-DATAX-LIFNR = ABAP_TRUE.
LS_CENTRAL-DATAX-KONZS = ABAP_TRUE.
* LS_CENTRAL-DATAX-STCEG = ABAP_TRUE.
LS_CENTRAL-DATAX-AUFSD = ABAP_TRUE.
LS_CUSTOMER-CENTRAL_DATA-CENTRAL = LS_CENTRAL.
****公司代码数据************************************************
IF
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " 统驭科目补前导零
EXPORTING
INPUT =
IMPORTING
OUTPUT =
LS_COMPANY-TASK = 'M'.
LS_COMPANY-DATA_KEY-BUKRS =
LS_COMPANY-DATA-AKONT =
LS_COMPANY-DATA-ZTERM =
LS_COMPANY-DATA-EIKTO =
LS_COMPANY-DATA-KVERM =
LS_COMPANY-DATAX-AKONT = ABAP_TRUE.
LS_COMPANY-DATAX-ZTERM = ABAP_TRUE.
LS_COMPANY-DATAX-EIKTO = ABAP_TRUE.
LS_COMPANY-DATAX-KVERM = ABAP_TRUE.
APPEND LS_COMPANY TO LT_COMPANY.
LS_COMPANY_DATA-COMPANY = LT_COMPANY.
LS_CUSTOMER-COMPANY_DATA = LS_COMPANY_DATA.
ENDIF.
*********税收标识********************************************************
LS_TAX_IND-TASK = 'M'.
LS_TAX_IND-DATA_KEY-ALAND = 'CN'.
LS_TAX_IND-DATA_KEY-TATYP = 'MWST'.
IF
LS_TAX_IND-DATA-TAXKD = '0'. "客户税分类
ELSE.
LS_TAX_IND-DATA-TAXKD = '1'. "客户税分类
ENDIF.
* LS_TAX_IND-DATA-TAXKD =
APPEND LS_TAX_IND TO LT_TAX_IND.
LS_CUSTOMER-CENTRAL_DATA-TAX_IND-TAX_IND = LT_TAX_IND.
*****销售数据****************************************************
IF
AND
AND
LS_SALES-TASK = 'M'.
LS_SALES-DATA_KEY-VKORG =
LS_SALES-DATA_KEY-VTWEG =
LS_SALES-DATA_KEY-SPART =
* LS_SALES-DATA-WAERS =
* LS_SALES-DATA-KALKS =
LS_SALES-DATA-VSBED =
LS_SALES-DATA-KDGRP =
LS_SALES-DATA-KONDA =
LS_SALES-DATA-KTGRD =
LS_SALES-DATA-EIKTO =
LS_SALES-DATA-ZTERM =
* LS_SALES-DATA-AUFSD = '01'. "客户订单冻结(销售范围)
LS_SALES-DATAX-VSBED = ABAP_TRUE.
LS_SALES-DATAX-KDGRP = ABAP_TRUE.
LS_SALES-DATAX-KONDA = ABAP_TRUE.
LS_SALES-DATAX-KTGRD = ABAP_TRUE.
LS_SALES-DATAX-EIKTO = ABAP_TRUE.
LS_SALES-DATAX-ZTERM = ABAP_TRUE.
* LS_SALES-DATAX-AUFSD = ABAP_TRUE.
IF
LS_SALES-DATA-WAERS = 'USD'. "货币
LS_SALES-DATA-KALKS = '1'. "用于确定定价过程的客户分类
ELSE.
LS_SALES-DATA-WAERS = 'CNY'. "货币
LS_SALES-DATA-KALKS = '2'. "用于确定定价过程的客户分类
ENDIF.
LS_SALES-DATAX-WAERS = ABAP_TRUE.
LS_SALES-DATAX-KALKS = ABAP_TRUE.
* Function伙伴功能
LS_FUNCTIONS-TASK = 'M'.
IF
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z1'.
* LS_FUNCTIONS-DATA-PARTNER =
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'BP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'PY' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SH' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
ELSE.
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z2'.
* LS_FUNCTIONS-DATA-PARTNER =
ENDIF.
* 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.
ENDIF.
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.
CLEAR: PV_CODE, PV_MSG.
LOOP AT LT_RETURN INTO LS_RETURN.
LOOP AT LS_RETURN-OBJECT_MSG INTO DATA(LS_OBJECT_MSG) WHERE TYPE CA 'EA'.
IF PV_MSG IS INITIAL.
PV_MSG = LS_OBJECT_MSG-MESSAGE.
ELSE.
CONCATENATE PV_MSG '/' LS_OBJECT_MSG-MESSAGE INTO PV_MSG.
ENDIF.
ENDLOOP.
IF SY-SUBRC = 0.
"回滚BAPI
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. "回滚BAPI
PV_CODE = 'E'.
EXIT.
ENDIF.
ENDLOOP.
IF PV_CODE <> 'E' .
"提交BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
* IMPORTING
* RETURN =
PV_CODE = 'S'.
CONCATENATE '客户编号为'
ENDIF.
LS_OUTPUT-Z003 =
LS_OUTPUT-PARTNER =
LS_OUTPUT-RTYPE = PV_CODE. "消息类型
LS_OUTPUT-RTMSG = PV_MSG. "消息文本
APPEND LS_OUTPUT TO PT_OUTPUT.
LS_RECORD-ZZOANUM =
LS_RECORD-KUNNR =
LS_RECORD-ZZNAME1 =
LS_RECORD-BUKRS =
LS_RECORD-ZZDATE = SY-DATUM. "SAP接收日期
LS_RECORD-ZZTIME = SY-UZEIT. "SAP接收时间
LS_RECORD-ZZRES = PV_CODE. "导入状态
LS_RECORD-ZZEMES = PV_MSG. "报错信息
MODIFY ZTSD0041 FROM LS_RECORD.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------*
***INCLUDE LZSDI001F05. PROGRAMMED BY HANDYY 20181108
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_CUSTOMER_CHANGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_IN text
* -->P_T_OUTPUT text
* -->P_I_RLTGR text
* -->P_I_BU_GROUP text
* <--P_E_CODE text
* <--P_E_MSG text
*----------------------------------------------------------------------*
FORM FRM_CUSTOMER_CHANGE TABLES PT_IN STRUCTURE ZSSD0040
PT_OUTPUT STRUCTURE ZSSD0041
USING PV_RLTGR
PV_BU_GROUP
CHANGING PV_CODE
PV_MSG.
TYPES:BEGIN OF TY_KNA1,
NAME1 TYPE KNA1-NAME1,
KUNNR TYPE KNA1-KUNNR,
END OF TY_KNA1.
DATA: LT_KNA1 TYPE STANDARD TABLE OF TY_KNA1,
LT_KUNNR TYPE STANDARD TABLE OF TY_KNA1,
LS_KUNNR TYPE TY_KNA1.
DATA: LS_OUTPUT TYPE ZSSD0041,
LT_RECORD TYPE STANDARD TABLE OF ZTSD0041, "同步日志到自建表
LS_RECORD TYPE ZTSD0041.
DATA : LT_PARTNERGUID_LIST TYPE BU_PARTNER_GUID_T,
LS_PARTNERGUID_LIST LIKE LINE OF LT_PARTNERGUID_LIST.
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.
FIELD-SYMBOLS:
DATA : LV_BPARTNERGUID TYPE BU_PARTNER_GUID_BAPI.
LOOP AT PT_IN ASSIGNING
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT =
IMPORTING
OUTPUT =
SELECT
KUNNR
INTO TABLE LT_KNA1
FROM KNA1
WHERE KUNNR =
IF SY-SUBRC = 0.
SELECT SINGLE
B~PARTNER,
A~PARTNER_GUID
INTO @DATA(LS_BUT000)
FROM CVI_CUST_LINK AS A INNER JOIN BUT000 AS B
ON A~PARTNER_GUID = B~PARTNER_GUID
WHERE CUSTOMER = @
LS_PARTNER-HEADER-OBJECT_TASK = 'M'. "I插入 U更新 M修改 D删除 C当前状态
LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNER = LS_BUT000-PARTNER. "业务伙伴编号
LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNERGUID = LS_BUT000-PARTNER_GUID. "唯一标识
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-CATEGORY = 2. "业务伙伴类别
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-GROUPING = PV_BU_GROUP. "业务伙伴分组
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME1 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME2 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME3 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME4 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CENTRALDATA-SEARCHTERM1 =
LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CENTRALDATA-TITLE_KEY =
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-DATAX-BP_ORGANIZATION-NAME4 = ABAP_TRUE.
LS_PARTNER-CENTRAL_DATA-COMMON-DATAX-BP_CENTRALDATA-SEARCHTERM1 = ABAP_TRUE.
LS_PARTNER-CENTRAL_DATA-COMMON-DATAX-BP_CENTRALDATA-TITLE_KEY = ABAP_TRUE.
CLEAR:LS_ADDRESSES,LT_ADDRESSES.
LS_ADDRESSES-TASK = 'M'. "I插入 U更新 M修改 D删除 C当前状态
SELECT SINGLE
ADDRESS_GUID
INTO @DATA(LV_PARTNER_GUID)
FROM BUT020
WHERE PARTNER = @
IF SY-SUBRC = 0.
LS_ADDRESSES-DATA_KEY-GUID = LV_PARTNER_GUID.
ENDIF.
LS_ADDRESSES-DATA-POSTAL-DATA-PO_CTRYISO =
LS_ADDRESSES-DATA-POSTAL-DATA-CITY =
LS_ADDRESSES-DATA-POSTAL-DATA-REGION = |{
LS_ADDRESSES-DATA-POSTAL-DATA-C_O_NAME =
* LS_ADDRESSES-DATA-POSTAL-DATA-POSTL_COD1 =
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT =
IMPORTING
OUTPUT = LS_ADDRESSES-DATA-POSTAL-DATA-POSTL_COD1.
LS_ADDRESSES-DATA-POSTAL-DATA-STREET =
LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL1 =
LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL2 =
LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL3 =
LS_ADDRESSES-DATA-POSTAL-DATA-LANGU =
LS_ADDRESSES-DATA-POSTAL-DATAX-PO_CTRYISO = ABAP_TRUE. " 国家代码
LS_ADDRESSES-DATA-POSTAL-DATAX-CITY = ABAP_TRUE. "城市
LS_ADDRESSES-DATA-POSTAL-DATAX-REGION = ABAP_TRUE. " 地区代码
LS_ADDRESSES-DATA-POSTAL-DATAX-C_O_NAME = ABAP_TRUE. " 代收人
LS_ADDRESSES-DATA-POSTAL-DATAX-POSTL_COD1 = ABAP_TRUE. "邮政编码
LS_ADDRESSES-DATA-POSTAL-DATAX-STREET = ABAP_TRUE. " 街道
LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL1 = ABAP_TRUE. " 街道2
LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL2 = ABAP_TRUE. " 街道3
LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL3 = ABAP_TRUE. " 街道4
LS_ADDRESSES-DATA-POSTAL-DATAX-LANGU = ABAP_TRUE. "语言
CLEAR:LS_PHONE,LT_PHONE.
LS_PHONE-CONTACT-TASK = 'U'. "I插入 U更新 M修改 D删除 C当前状态
LS_PHONE-CONTACT-DATA-TELEPHONE =
LS_PHONE-CONTACT-DATAX-TELEPHONE = ABAP_TRUE.
APPEND LS_PHONE TO LT_PHONE.
CLEAR:LS_PHONE.
LS_PHONE-CONTACT-TASK = 'U'. "I插入 U更新 M修改 D删除 C当前状态
LS_PHONE-CONTACT-DATA-TELEPHONE =
LS_PHONE-CONTACT-DATA-R_3_USER = '3'. "3表示移动电话
LS_PHONE-CONTACT-DATAX-TELEPHONE = ABAP_TRUE.
LS_PHONE-CONTACT-DATAX-R_3_USER = ABAP_TRUE.
APPEND LS_PHONE TO LT_PHONE.
LS_ADDRESSES-DATA-COMMUNICATION-PHONE-PHONE = LT_PHONE.
CLEAR:LS_FAX,LT_FAX.
LS_FAX-CONTACT-TASK = 'U'. "I插入 U更新 M修改 D删除 C当前状态
LS_FAX-CONTACT-DATA-FAX =
LS_FAX-CONTACT-DATAX-FAX = ABAP_TRUE.
APPEND LS_FAX TO LT_FAX.
LS_ADDRESSES-DATA-COMMUNICATION-FAX-FAX = LT_FAX.
CLEAR:LS_SMTP,LT_SMTP.
LS_SMTP-CONTACT-TASK = 'U'. "I插入 U更新 M修改 D删除 C当前状态
LS_SMTP-CONTACT-DATA-E_MAIL =
LS_SMTP-CONTACT-DATAX-E_MAIL = ABAP_TRUE.
APPEND LS_SMTP TO LT_SMTP.
LS_ADDRESSES-DATA-COMMUNICATION-SMTP-SMTP = LT_SMTP.
APPEND LS_ADDRESSES TO LT_ADDRESSES.
LS_PARTNER-CENTRAL_DATA-ADDRESS-ADDRESSES = LT_ADDRESSES.
*******客户抬头数据***********************************************************
LS_HEADER-OBJECT_TASK = 'U'.
LS_HEADER-OBJECT_INSTANCE-KUNNR =
LS_CUSTOMER-HEADER = LS_HEADER.
****中心客户数据*************************************************
LS_CENTRAL-DATA-NIELS =
* LS_CENTRAL-DATA-BRSCH =
LS_CENTRAL-DATA-KUKLA =
LS_CENTRAL-DATA-BRAN1 =
* LS_CENTRAL-DATA-LIFNR =
LS_CENTRAL-DATA-KONZS =
* LS_CENTRAL-DATA-STCEG =
* LS_CENTRAL-DATA-KTOKD =
LS_CENTRAL-DATAX-NIELS = ABAP_TRUE.
* LS_CENTRAL-DATAX-BRSCH = ABAP_TRUE.
LS_CENTRAL-DATAX-KUKLA = ABAP_TRUE.
LS_CENTRAL-DATAX-BRAN1 = ABAP_TRUE.
* LS_CENTRAL-DATAX-LIFNR = ABAP_TRUE.
LS_CENTRAL-DATAX-KONZS = ABAP_TRUE.
* LS_CENTRAL-DATAX-STCEG = ABAP_TRUE.
LS_CUSTOMER-CENTRAL_DATA-CENTRAL = LS_CENTRAL.
****公司代码数据************************************************
IF
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' " 统驭科目补前导零
EXPORTING
INPUT =
IMPORTING
OUTPUT =
LS_COMPANY-TASK = 'U'.
LS_COMPANY-DATA_KEY-BUKRS =
LS_COMPANY-DATA-AKONT =
LS_COMPANY-DATA-ZTERM =
LS_COMPANY-DATA-EIKTO =
LS_COMPANY-DATA-KVERM =
LS_COMPANY-DATAX-AKONT = ABAP_TRUE.
LS_COMPANY-DATAX-ZTERM = ABAP_TRUE.
LS_COMPANY-DATAX-EIKTO = ABAP_TRUE.
LS_COMPANY-DATAX-KVERM = ABAP_TRUE.
APPEND LS_COMPANY TO LT_COMPANY.
LS_COMPANY_DATA-COMPANY = LT_COMPANY.
LS_CUSTOMER-COMPANY_DATA = LS_COMPANY_DATA.
ENDIF.
*********税收标识********************************************************
LS_TAX_IND-TASK = 'U'.
LS_TAX_IND-DATA_KEY-ALAND = 'CN'.
LS_TAX_IND-DATA_KEY-TATYP = 'MWST'.
IF
LS_TAX_IND-DATA-TAXKD = '0'. "客户税分类
ELSE.
LS_TAX_IND-DATA-TAXKD = '1'. "客户税分类
ENDIF.
* LS_TAX_IND-DATA-TAXKD =
LS_TAX_IND-DATAX-TAXKD = ABAP_TRUE.
APPEND LS_TAX_IND TO LT_TAX_IND.
LS_CUSTOMER-CENTRAL_DATA-TAX_IND-TAX_IND = LT_TAX_IND.
*****销售数据****************************************************
* IF
IF
AND
AND
LS_SALES-TASK = 'U'.
LS_SALES-DATA_KEY-VKORG =
LS_SALES-DATA_KEY-VTWEG =
LS_SALES-DATA_KEY-SPART =
IF
LS_SALES-DATA-WAERS = 'USD'. "货币
LS_SALES-DATA-KALKS = '1'. "用于确定定价过程的客户分类
ELSE.
LS_SALES-DATA-WAERS = 'CNY'. "货币
LS_SALES-DATA-KALKS = '2'. "用于确定定价过程的客户分类
ENDIF.
* LS_SALES-DATA-WAERS =
* LS_SALES-DATA-KALKS =
LS_SALES-DATA-VSBED =
LS_SALES-DATA-KDGRP =
LS_SALES-DATA-KONDA =
LS_SALES-DATA-KTGRD =
LS_SALES-DATA-EIKTO =
LS_SALES-DATA-ZTERM =
* LS_SALES-DATAX-WAERS = ABAP_TRUE.
* LS_SALES-DATAX-KALKS = ABAP_TRUE.
LS_SALES-DATAX-VSBED = ABAP_TRUE.
* LS_SALES-DATAX-PODKZ = ABAP_TRUE.
* LS_SALES-DATAX-INCO1 = ABAP_TRUE.
* LS_SALES-DATAX-INCO2 = ABAP_TRUE.
* LS_SALES-DATAX-ZTERM = ABAP_TRUE.
LS_SALES-DATAX-KDGRP = ABAP_TRUE.
LS_SALES-DATAX-KONDA = ABAP_TRUE.
LS_SALES-DATAX-KTGRD = ABAP_TRUE.
LS_SALES-DATAX-EIKTO = ABAP_TRUE.
LS_SALES-DATAX-ZTERM = ABAP_TRUE.
"Function伙伴功能
LS_FUNCTIONS-TASK = 'U'.
IF
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z1'.
* LS_FUNCTIONS-DATA-PARTNER =
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'BP' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'PY' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
INPUT = 'SH' "收票方
IMPORTING
OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW.
APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
ELSE.
* LS_FUNCTIONS-DATA_KEY-PARVW = 'Z2'.
* LS_FUNCTIONS-DATA-PARTNER =
ENDIF.
* APPEND LS_FUNCTIONS TO LT_FUNCTIONS.
LS_SALES-FUNCTIONS-FUNCTIONS = LT_FUNCTIONS.
APPEND LS_SALES TO LT_SALES.
*增加1210 s
LS_SALES-TASK = 'U'.
LS_SALES-DATA_KEY-VKORG = '1210'. "销售组织
LS_SALES-DATA_KEY-VTWEG =
LS_SALES-DATA_KEY-SPART =
IF
LS_SALES-DATA-WAERS = 'USD'. "货币
LS_SALES-DATA-KALKS = '1'. "用于确定定价过程的客户分类
ELSE.
LS_SALES-DATA-WAERS = 'CNY'. "货币
LS_SALES-DATA-KALKS = '2'. "用于确定定价过程的客户分类
ENDIF.
* LS_SALES-DATA-KALKS =
LS_SALES-DATA-VSBED =
LS_SALES-DATA-KDGRP =
LS_SALES-DATA-KONDA =
LS_SALES-DATA-KTGRD =
LS_SALES-DATA-EIKTO =
LS_SALES-DATA-ZTERM =
* LS_SALES-DATAX-WAERS = ABAP_TRUE.
* LS_SALES-DATAX-KALKS = ABAP_TRUE.
LS_SALES-DATAX-VSBED = ABAP_TRUE.
* LS_SALES-DATAX-PODKZ = ABAP_TRUE.
* LS_SALES-DATAX-INCO1 = ABAP_TRUE.
* LS_SALES-DATAX-INCO2 = ABAP_TRUE.
LS_SALES-DATAX-KDGRP = ABAP_TRUE.
LS_SALES-DATAX-KONDA = ABAP_TRUE.
LS_SALES-DATAX-KTGRD = ABAP_TRUE.
LS_SALES-DATAX-EIKTO = ABAP_TRUE.
LS_SALES-DATAX-ZTERM = ABAP_TRUE.
APPEND LS_SALES TO LT_SALES.
*增加1210 e
LS_SALES_DATA-SALES = LT_SALES.
LS_CUSTOMER-SALES_DATA = LS_SALES_DATA.
ENDIF.
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.
CLEAR: PV_CODE, PV_MSG.
LOOP AT LT_RETURN INTO LS_RETURN.
LOOP AT LS_RETURN-OBJECT_MSG INTO DATA(LS_OBJECT_MSG) WHERE TYPE CA 'EA'.
IF PV_MSG IS INITIAL.
PV_MSG = LS_OBJECT_MSG-MESSAGE.
ELSE.
CONCATENATE PV_MSG '/' LS_OBJECT_MSG-MESSAGE INTO PV_MSG.
ENDIF.
ENDLOOP.
IF SY-SUBRC = 0.
"回滚BAPI
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. "回滚BAPI
PV_CODE = 'E'.
EXIT.
ENDIF.
ENDLOOP.
IF PV_CODE <> 'E' .
"提交BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
* IMPORTING
* RETURN =
PV_CODE = 'S'.
CONCATENATE '客户编号为'
ENDIF.
LS_OUTPUT-Z003 =
LS_OUTPUT-PARTNER = LS_KUNNR-KUNNR. "业务伙伴编码
LS_OUTPUT-RTYPE = PV_CODE. "消息类型
LS_OUTPUT-RTMSG = PV_MSG. "消息文本
APPEND LS_OUTPUT TO PT_OUTPUT.
LS_RECORD-ZZOANUM =
LS_RECORD-KUNNR = LS_KUNNR-KUNNR. "业务伙伴编码
LS_RECORD-ZZNAME1 =
LS_RECORD-BUKRS =
LS_RECORD-ZZDATE = SY-DATUM. "SAP接收日期
LS_RECORD-ZZTIME = SY-UZEIT. "SAP接收时间
LS_RECORD-ZZRES = PV_CODE. "导入状态
LS_RECORD-ZZEMES = PV_MSG. "报错信息
MODIFY ZTSD0041 FROM LS_RECORD.
ELSE.
PV_CODE = 'E'.
PV_MSG = '此公司客户主数据不存在,无法修改'.
ENDIF.
ENDLOOP.
ENDFORM.