业务场景和目的
批量创建S4 BP客户
考虑使用CVI_EI_INBOUND_MAIN。
本文重点讨论的业务场景:使用用户上传的EXCLE文件批量创建客户,节省时间操作时间。
开发申请要求:给出前台(TCODE:BP)创建客户相关数据,批量创建客户。
前台操作,根据界面底部的消息提示一步一步输入BP客户的相关数据。
2.1 CVI_EI_INBOUND_MAIN(创建客户主要数据)
2.1.1功能描述
根据客户主数据创建客户数据相关信息。
2.1.2相关参数说明
接收数据的结构,改方法只有一个导入参数,所有的信息都在这个导入参数里面。
主要的数据填充在CUSTOMER这个组件内
对于CUSTOMER这个组件,分别填充客户的相关数据到对应组件
这里主要有三个组件CENTRAL_DATA(中心数据)、COMPANY_DATA(公司代码数据)、SALES_DATA(销售数据),分别在根据所需数据的类别分别填入对应的组件里。
BAPI_BUPA_TAX_ADD(类别、税号数据)
对于前台标识页签下的税号相关数据,需要采用BAPI_BUPA_TAX_ADD进行维护
代码示例
CALL FUNCTION 'BAPI_BUPA_TAX_ADD'
EXPORTING
BUSINESSPARTNER = <FS_DATA>-PARTNER
TAXTYPE = <FS_DATA>-TAXTYPE "类别
TAXNUMBER = <FS_DATA>-TAXNUMXL "税号
TABLES
RETURN = LT_RETURN_TAX.
BAPI_BUTX_FRG0010_ADD (税分类国家/地区 税收类型 税收组数据)
对于前台控制页签下的税分类相关数据,如下图,需要用BAPI_BUTX_FRG0010_ADD才能添加进去。
调用代码示例:
CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD'
EXPORTING
BUSINESSPARTNER = <FS_DATA>-PARTNER
TAXCOUNTRY = <FS_DATA>-TAX_CTY "国家/地区
TAXREGION = '' "地区
TAXTYPE = <FS_DATA>-TAX_TYPE "税收类型
DATA = <FS_DATA>-TAX_GROUP "税收组
TABLES
RETURN = LT_RETURN_FRG.
2.4 IO_BUPA_FACTORY->GET_CREDIT_ACCOUNT(信用参数文件数据)
对于信用参数文件页签下的计分相关数据,如下图,需要采用类IO_BUPA_FACTORY下的方法GET_CREDIT_ACCOUNT进行维护。
调用代码示例
FORM FRM_ADD_UKMBP CHANGING C_RETURN TYPE UKM_T_MONITOR_RETURN.
DATA: IO_FACADE TYPE REF TO CL_UKM_FACADE,
IO_BUPA_FACTORY TYPE REF TO CL_UKM_BUPA_FACTORY,
IO_PARTNER TYPE REF TO CL_UKM_BUSINESS_PARTNER,
IO_ACCOUNT TYPE REF TO CL_UKM_ACCOUNT,
LW_BP_CREDIT_SGM TYPE UKM_S_BP_CMS_SGM.
DATA: LWA_UKM_S_BP_CMS TYPE UKM_S_BP_CMS.
DATA: LV_PARTNER TYPE BU_PARTNER,
LV_CREDIT_SGMNT TYPE UKM_CREDIT_SGMNT.
* 创建'MAINTAIN'对象
IO_FACADE = CL_UKM_FACADE=>CREATE( I_ACTIVITY = CL_UKM_CNST_EVENTING=>BP_MAINTENANCE ).
IO_BUPA_FACTORY = IO_FACADE->GET_BUPA_FACTORY( ).
LV_PARTNER = <FS_DATA>-PARTNER. "客户代码
LV_CREDIT_SGMNT = <FS_DATA>-CREDIT_SGMNT."信用段
IO_PARTNER = IO_BUPA_FACTORY->GET_BUSINESS_PARTNER( LV_PARTNER ).
IO_PARTNER->GET_BP_CMS( IMPORTING ES_BP_CMS = LWA_UKM_S_BP_CMS ).
LWA_UKM_S_BP_CMS-RISK_CLASS = <FS_DATA>-RISK_CLASS. "风险类
LWA_UKM_S_BP_CMS-CHECK_RULE = <FS_DATA>-CHECK_RULE. "检查规则
LWA_UKM_S_BP_CMS-LIMIT_RULE = <FS_DATA>-LIMIT_RULE. "规则
LWA_UKM_S_BP_CMS-CREDIT_GROUP = <FS_DATA>-CREDIT_GROUP. "客户组
IO_PARTNER->SET_BP_CMS( LWA_UKM_S_BP_CMS ).
CALL METHOD IO_BUPA_FACTORY->GET_CREDIT_ACCOUNT
EXPORTING
I_PARTNER = LV_PARTNER
I_CREDIT_SGMNT = LV_CREDIT_SGMNT
RECEIVING
RO_CREDIT_ACCOUNT = IO_ACCOUNT.
IO_ACCOUNT->GET_BP_CMS_SGM( IMPORTING ES_BP_CMS_SGM = LW_BP_CREDIT_SGM ).
LW_BP_CREDIT_SGM-CREDIT_LIMIT = <FS_DATA>-CREDIT_LIMIT."信用额度
IO_ACCOUNT->SET_BP_CMS_SGM( EXPORTING IS_BP_CMS_SGM = LW_BP_CREDIT_SGM ).
IO_BUPA_FACTORY->SAVE_ALL( EXPORTING I_UPD_TASK = ABAP_FALSE
RECEIVING ET_RETURN = C_RETURN ).
ENDFORM.
代码示例
REPORT ZSD010.
TABLES:SSCRFIELDS.
TYPE-POOLS: OLE2 ,ICON ,SLIS.
*----------------alv报表结构定义----------------------------------------------------*
TYPES : BEGIN OF TY_UPLOAD_DATA,
PARTNER TYPE BUT000-PARTNER, "业务伙伴编号
TYPE TYPE BUT000-TYPE, "合作伙伴类别
CUS001X TYPE CHAR7, "角色 WD
KTOKD TYPE BUT000-BU_GROUP, "客户账户组
ANRED TYPE KNA1-ANRED, "称谓
NAME1 TYPE KNA1-NAME1, "名称1
NAME2 TYPE KNA1-NAME2, "名称2
NAME3 TYPE KNA1-NAME3, "名称3 WD
NAME4 TYPE KNA1-NAME4, "名称4 WD
SORTL TYPE KNA1-SORTL, "搜索项
NAME_CO TYPE AD_NAME_CO, "代收人
STREET TYPE AD_STREET, "街道
STR_SUPPL1 TYPE AD_STRSPP1, "街道2 WD
STR_SUPPL2 TYPE AD_STRSPP2, "街道3 WD
STR_SUPPL3 TYPE AD_STRSPP3, "街道4
LOCATION TYPE AD_LCTN, "街道5
CITY1 TYPE ADRC-CITY1, "城市 WD
PSTLZ TYPE KNA1-PSTLZ, "邮政编码
LAND1 TYPE KNA1-LAND1, "国家/地区
REGIO TYPE REGIO, "地区
LANGU TYPE LAISO, "语言
TELF1 TYPE KNA1-TELF1, "电话
PHONE TYPE ADRC-TEL_NUMBER, "移动电话
EMAIL TYPE AD_SMTPADR, "电子邮件
*--WD-------------------------------------------------------*
FAX_NUMBER TYPE ADRC-FAX_NUMBER, "传真
REMARK TYPE ADRCT-REMARK, "联系人
TAXTYPE TYPE DFKKBPTAXNUM-TAXTYPE, "类别
TAXNUMXL TYPE CHAR20, "DFKKBPTAXNUM-TAXNUMXL, "税号
TAX_CTY TYPE BUT_FRG0011-TAX_CTY, "税分类国家/地区
TAX_TYPE TYPE BUT_FRG0011-TAX_TYPE, "税收类型
TAX_GROUP TYPE BUT_FRG0011-TAX_GROUP, "税收组
LIMIT_RULE TYPE UKMBP_CMS-LIMIT_RULE, "规则
RISK_CLASS TYPE UKMBP_CMS-RISK_CLASS, "风险类
CHECK_RULE TYPE UKMBP_CMS-CHECK_RULE, "检查规则
CREDIT_GROUP TYPE UKMBP_CMS-CREDIT_GROUP, "客户组
*--WD-------------------------------------------------------*
KUKLA TYPE KNA1-KUKLA, "客户分类
BRAN1 TYPE KNA1-BRAN1, " 行业代码1 WD
BUKRS TYPE BUKRS, "公司代码
AKONT TYPE KNB1-AKONT, "统驭科目
ZUAWA TYPE KNB1-ZUAWA, "排序码
ZTERM TYPE KNB1-ZTERM, "付款条款
ZWELS TYPE KNB1-ZWELS, "付款方式
VKORG TYPE KNVV-VKORG, "销售组织
VTWEG TYPE KNVV-VTWEG, "分销渠道
SPART TYPE KNVV-SPART, "分部 (产品组)
BZIRK TYPE KNVV-BZIRK, "销售区域 WD
KDGRP TYPE KNVV-KDGRP, "客户组 WD
VKBUR TYPE KNVV-VKBUR, "销售部门
VKGRP TYPE KNVV-VKGRP, "销售组
KTONR TYPE GPANR, "货运代理编号
WAERS TYPE KNVV-WAERS, "币种
KALKS TYPE KNVV-KALKS, "定价过程
VWERK TYPE KNVV-VWERK, "交货工厂
VSBED TYPE KNVV-VSBED, "装运条件
PODKZ TYPE KNVV-PODKZ, "pod相关
INCO1 TYPE KNVV-INCO1, "国际贸易术语解释通则
INCO2 TYPE KNVV-INCO2, "国际贸易条款位置
ZTERM1 TYPE KNVV-ZTERM, "付款条款
KTGRD TYPE KNVV-KTGRD, "客户科目分配组
TAXKD TYPE KNVI-TAXKD, "税分类
KVGR1 TYPE KVGR1 , "客户组1 WD
KVGR2 TYPE KVGR2 , "客户组2 WD
KVGR3 TYPE KVGR3 , "客户组3 WD
KVGR4 TYPE KVGR4 , "客户组4 WD
KVGR5 TYPE KVGR5 , "客户组5 WD
CREDIT_SGMNT TYPE UKMBP_CMS_SGM-CREDIT_SGMNT , "信用段 WD
CREDIT_LIMIT TYPE UKMBP_CMS_SGM-CREDIT_LIMIT , "额度 WD
CHECK,
MEMO(200), "消息文本
END OF TY_UPLOAD_DATA.
DATA: GS_ALV_DATA TYPE TY_UPLOAD_DATA,
GT_ALV_DATA TYPE TABLE OF TY_UPLOAD_DATA.
FIELD-SYMBOLS: <FS_DATA> TYPE TY_UPLOAD_DATA.
DATA: GV_FULLPATH TYPE STRING,
GV_PATH TYPE STRING,
GV_NAME TYPE STRING.
" 标识模拟导入还是正式导入
CONSTANTS : C_PARVW1 TYPE PARVW VALUE 'SP', "售达方
C_PARVW2 TYPE PARVW VALUE 'BP', "收票方
C_PARVW3 TYPE PARVW VALUE 'PY', "付款方
C_PARVW4 TYPE PARVW VALUE 'CR', "货运代理
C_PARVW5 TYPE PARVW VALUE 'SH'. "送达方
DATA: "报表定义
GS_LAYOUT TYPE LVC_S_LAYO,
GT_FIELDCAT TYPE LVC_T_FCAT,
GS_FIELDCAT LIKE LINE OF GT_FIELDCAT,
GT_EVENTS TYPE SLIS_T_EVENT,
GS_EVENTS LIKE LINE OF GT_EVENTS,
GT_EXCLUDING TYPE SLIS_T_EXTAB,
GS_EXCLUDING TYPE SLIS_EXTAB,
GT_SORT TYPE LVC_T_SORT,
GS_SORT TYPE LVC_S_SORT,
GT_EXCLUDE TYPE SLIS_T_EXTAB,
GS_EXCLUDE TYPE SLIS_EXTAB.
* 根据伙伴GUID取出客户编号
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,
*--地址注释 WD
LT_REMARKS_A TYPE BUS_EI_BUPA_ADDRESSREMARK_T,
LS_REMARKS_A TYPE BUS_EI_BUPA_ADDRESSREMARK.
*--进度条
"进度条标志
DATA:V_FLAG TYPE C.
"进度条变量
DATA:V_TABIX TYPE I.
"上传模板条目数
DATA:LV_LINES TYPE I.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_PATH TYPE STRING MODIF ID M1. " 导入文件
*PARAMETERS: P_UP RADIOBUTTON GROUP GRP1 DEFAULT 'X' USER-COMMAND COMM. " 上传文件
*PARAMETERS: P_DOWN RADIOBUTTON GROUP GRP1 . "下载模板
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN FUNCTION KEY 1. "在初始屏幕上出现下载按钮
*----------------------------------------------------------------------*
* INITIALIZATION事件
*----------------------------------------------------------------------*
INITIALIZATION.
SSCRFIELDS-FUNCTXT_01 = '@49@下载导入模板'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.
PERFORM FRM_BROWSER_FILE. "选择屏幕获取本地excel
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = 'FC01'.
PERFORM DOWNLOAD_TEMPLATE. "下载SWM0上传过的模版
ENDIF.
*-----------------------------------------------------------------------
* 控制选择画面 文件选择框的显隐
*-----------------------------------------------------------------------
*AT SELECTION-SCREEN OUTPUT.
* LOOP AT SCREEN.
* IF SCREEN-GROUP1 = 'M1' OR SCREEN-GROUP1 = 'M2'.