批量创建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\'. **下载/日志隐藏 * IF P_DOWN = \'X\'. * SCREEN-ACTIVE = 0. * ENDIF. **上传文件显示 * IF P_UP = \'X\' AND SCREEN-GROUP1 = \'M2\'. * SCREEN-ACTIVE = 0. * ENDIF. * * MODIFY SCREEN. * ENDIF. * ENDLOOP. START-OF-SELECTION. * IF P_DOWN = \'X\'. * PERFORM FRM_GET_FULLPATH CHANGING GV_FULLPATH GV_PATH GV_NAME. * ** 路径为空则退出 * IF GV_FULLPATH IS INITIAL. * MESSAGE \'用户取消操作\' TYPE \'S\'. * RETURN. * ENDIF. * * "下载模板 * PERFORM FRM_DOWN USING GV_FULLPATH. * ENDIF . * * IF P_PATH IS INITIAL AND P_UP = \'X\'. * MESSAGE \'请选择导入文件\' TYPE \'S\' DISPLAY LIKE \'W\'. * STOP. * ENDIF. * IF P_UP = \'X\' AND P_PATH IS NOT INITIAL. PERFORM FRM_UPLOAD_DATA. " 将本地excel文件上传到程序 PERFORM FRM_DISPLAY. "报表展示导入结果 * ENDIF. *&---------------------------------------------------------------------* *& Form FRM_BROWSER_FILE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM FRM_BROWSER_FILE . DATA: LV_RC TYPE I, LV_USER TYPE I, LT_FILE TYPE FILETABLE, LS_FILE TYPE FILE_TABLE. CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG EXPORTING WINDOW_TITLE = \'选择文件\' FILE_FILTER = \'Excel文件(*.XLSX)|*.XLSX|全部文件 (*.*)|*.*|\' CHANGING FILE_TABLE = LT_FILE RC = LV_RC USER_ACTION = LV_USER EXCEPTIONS FILE_OPEN_DIALOG_FAILED = 1 CNTL_ERROR = 2 ERROR_NO_GUI = 3 NOT_SUPPORTED_BY_GUI = 4 OTHERS = 5. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE. CHECK LV_RC = 1 AND LV_USER <> 9. READ TABLE LT_FILE INTO LS_FILE INDEX 1. P_PATH = LS_FILE-FILENAME. ENDIF. ENDFORM. " FRM_BROWSER_FILE *&---------------------------------------------------------------------* *& Form FRM_UPLOAD_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM FRM_UPLOAD_DATA . DATA: LS_DATA TYPE TRUXS_T_TEXT_DATA, LS_PATH TYPE RLGRAP-FILENAME. LS_PATH = P_PATH. CALL FUNCTION \'TEXT_CONVERT_XLS_TO_SAP\' EXPORTING I_LINE_HEADER = \'X\' I_TAB_RAW_DATA = LS_DATA I_FILENAME = LS_PATH TABLES I_TAB_CONVERTED_DATA = GT_ALV_DATA EXCEPTIONS CONVERSION_FAILED = 1 OTHERS = 2. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. * LOOP AT gt_alv_data ASSIGNING <fs_data>. * IF <fs_data>-ktokd <> \'ZS02\' AND <fs_data>-ktokd <> \'ZS05\'. * IF <fs_data>-bukrs IS INITIAL. * <fs_data>-memo = \'公司抬头数据不完整\'. * ENDIF. * ENDIF. * * IF <fs_data>-ktokd <> \'ZS03\' AND <fs_data>-ktokd <> \'ZS07\' AND <fs_data>-ktokd <> \'ZS08\'. * IF <fs_data>-vkorg IS INITIAL OR <fs_data>-vtweg IS INITIAL OR <fs_data>-spart IS INITIAL. * <fs_data>-memo = \'销售抬头数据不完整\'. * ENDIF. * ENDIF. * ENDLOOP. ENDFORM. " FRM_UPLOAD_DATA *&---------------------------------------------------------------------* *& Form FRM_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_DISPLAY . PERFORM FRM_LAYOUT. PERFORM FRM_FIELDCAT. PERFORM FRM_OUTPUT. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_LAYOUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_LAYOUT . GS_LAYOUT-ZEBRA = \'X\'. GS_LAYOUT-CWIDTH_OPT = \'X\'. GS_LAYOUT-BOX_FNAME = \'CHECK\'. GS_LAYOUT-SEL_MODE = \'A\'. ENDFORM. DEFINE INIT_FIELDCAT. "宏定义 用于alv报表输出的样式设计 CLEAR gs_fieldcat. gs_fieldcat-fieldname = &1. gs_fieldcat-coltext = &2. gs_fieldcat-ref_table = &3. gs_fieldcat-ref_field = &4. APPEND gs_fieldcat TO gt_fieldcat. END-OF-DEFINITION. *&---------------------------------------------------------------------* *& Form FRM_FIELDCAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_FIELDCAT . INIT_FIELDCAT \'MEMO\' TEXT-F01 \'\' \'\'. INIT_FIELDCAT \'PARTNER\' TEXT-F02 \'\' \'\'. " 业务伙伴 INIT_FIELDCAT \'TYPE\' \'\' \'BUT000\' \'TYPE\'. " 业务伙伴类别 INIT_FIELDCAT \'CUS001X\' \'角色\' \'\' \'\'. " 业务伙伴角色 INIT_FIELDCAT \'KTOKD\' \'\' \'BUT000\' \'BU_GROUP\'. " 客户账户组 INIT_FIELDCAT \'ANRED\' \'\' \'KNA1\' \'ANRED\'. " 称谓 INIT_FIELDCAT \'NAME1\' \'\' \'KNA1\' \'NAME1\'. " 名称1 INIT_FIELDCAT \'NAME2\' \'\' \'KNA1\' \'NAME2\'. " 名称2 INIT_FIELDCAT \'NAME3\' \'\' \'KNA1\' \'NAME3\'. " 名称3 WD INIT_FIELDCAT \'NAME4\' \'\' \'KNA1\' \'NAME4\'. " 名称4 WD INIT_FIELDCAT \'SORTL\' \'\' \'KNA1\' \'SORTL\'. " 搜索项 INIT_FIELDCAT \'NAME_CO\' TEXT-F03 \'\' \'\'. " 代收人 INIT_FIELDCAT \'STREET\' TEXT-F04 \'\' \'\'. " 街道 INIT_FIELDCAT \'STR_SUPPL1\' \'街道2\' \'\' \'\'. " 街道2 WD INIT_FIELDCAT \'STR_SUPPL2\' \'街道3\' \'\' \'\'. " 街道3 WD INIT_FIELDCAT \'STR_SUPPL3\' TEXT-F05 \'\' \'\'. " 街道4 INIT_FIELDCAT \'LOCATION\' TEXT-F06 \'\' \'\'. " 街道5 INIT_FIELDCAT \'CITY1\' \'城市\' \'\' \'\'. "WD INIT_FIELDCAT \'PSTLZ\' \'\' \'KNA1\' \'PSTLZ\'. " 邮政编码 INIT_FIELDCAT \'LAND1\' \'\' \'KNA1\' \'LAND1\'. " 国家/地区 INIT_FIELDCAT \'REGIO\' TEXT-F07 \'\' \'\'. " 地区 INIT_FIELDCAT \'LANGU\' TEXT-F11 \'\' \'\'. " 语言 INIT_FIELDCAT \'TELF1\' \'\' \'KNA1\' \'TELF1\'. " 电话 INIT_FIELDCAT \'PHONE\' \'\' \'ADRC\' \'TEL_NUMBER\'. "移动电话 INIT_FIELDCAT \'EMAIL\' TEXT-F08 \'\' \'\'. " 电子邮件 *--WD-------------------------------------------------------* INIT_FIELDCAT \'FAX_NUMBER \' \'传真\' \'\' \'\'. " INIT_FIELDCAT \'REMARK \' \'联系人\' \'\' \'\'. " INIT_FIELDCAT \'TAXTYPE \' \'类别\' \'\' \'\'. " INIT_FIELDCAT \'TAXNUMXL \' \'税号\' \'\' \'\'. " INIT_FIELDCAT \'TAX_CTY \' \'税分类国家/地区\' \'\' \'\'. " INIT_FIELDCAT \'TAX_TYPE \' \'税收类型\' \'\' \'\'. " INIT_FIELDCAT \'TAX_GROUP \' \'税收组\' \'\' \'\'. " INIT_FIELDCAT \'LIMIT_RULE \' \'规则\' \'\' \'\'. " INIT_FIELDCAT \'RISK_CLASS \' \'风险类\' \'\' \'\'. " INIT_FIELDCAT \'CHECK_RULE \' \'检查规则\' \'\' \'\'. " INIT_FIELDCAT \'CREDIT_GROUP\' \'客户组\' \'\' \'\'. " * INIT_FIELDCAT \'\' \'\' \'\' \'\'. " *--WD-------------------------------------------------------* INIT_FIELDCAT \'KUKLA\' \'\' \'KNA1\' \'KUKLA\'. "客户分类 INIT_FIELDCAT \'BRAN1\' \'行业代码1\' \'\' \'\'. "行业代码1 WD INIT_FIELDCAT \'BUKRS\' TEXT-F09 \'\' \'\'. "公司代码 INIT_FIELDCAT \'AKONT\' \'\' \'KNB1\' \'AKONT\'. "统驭科目 INIT_FIELDCAT \'ZUAWA\' \'\' \'KNB1\' \'ZUAWA\'. "排序码 INIT_FIELDCAT \'ZTERM\' \'\' \'KNB1\' \'ZTERM\'. "付款条款 INIT_FIELDCAT \'ZWELS\' \'\' \'KNB1\' \'ZWELS\'. "付款方式 INIT_FIELDCAT \'VKORG\' \'\' \'KNVV\' \'VKORG\' ."销售组织 INIT_FIELDCAT \'VTWEG\' \'\' \'KNVV\' \'VTWEG\' ."分销渠道 INIT_FIELDCAT \'SPART\' \'\' \'KNVV\' \'SPART\'. "产品组 INIT_FIELDCAT \'VKBUR\' \'销售部门\' \'\' \'\'. " 销售部门 WD INIT_FIELDCAT \'VKGRP\' \'销售组\' \'\' \'\'. " 销售组 WD INIT_FIELDCAT \'VKBUR\' \'\' \'KNVV\' \'VKBUR\' ."销售部门 INIT_FIELDCAT \'VKGRP\' \'\' \'KNVV\' \'VKGRP\' ."销售组 INIT_FIELDCAT \'KTONR\' TEXT-F10 \'\' \'\' . "货运代理编号 INIT_FIELDCAT \'WAERS\' \'\' \'KNVV\' \'WAERS\' ."币种 INIT_FIELDCAT \'KALKS\' \'\' \'KNVV\' \'KALKS\' ."定价过程 INIT_FIELDCAT \'VWERK\' \'\' \'KNVV\' \'VWERK\' ."交货工厂 INIT_FIELDCAT \'VSBED\' \'\' \'KNVV\' \'VSBED\' ."装运条件 INIT_FIELDCAT \'PODKZ\' \'\' \'KNVV\' \'PODKZ\' ."pod相关 INIT_FIELDCAT \'INCO1\' \'\' \'KNVV\' \'INCO1\' ."国际贸易术语解释通则 INIT_FIELDCAT \'INCO2\' \'\' \'KNVV\' \'INCO2\' ."国际贸易条款位置 INIT_FIELDCAT \'ZTERM1\' \'\' \'KNVV\' \'ZTERM\'. "付款条款 INIT_FIELDCAT \'KTGRD\' \'\' \'KNVV\' \'KTGRD\' ."客户科目分配组 INIT_FIELDCAT \'TAXKD\' \'\' \'KNVI\' \'TAXKD\' ."税分类 INIT_FIELDCAT \'CREDIT_SGMNT\' \'信用段\' \'\' \'\' ."信用段 WD INIT_FIELDCAT \'CREDIT_LIMIT\' \'额度\' \'\' \'\' . "额度 WD ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_OUTPUT. CALL FUNCTION \'REUSE_ALV_GRID_DISPLAY_LVC\' EXPORTING I_CALLBACK_PROGRAM = SY-REPID I_CALLBACK_PF_STATUS_SET = \'ALV_STATUS\' I_CALLBACK_USER_COMMAND = \'ALV_COMMAND\' IS_LAYOUT_LVC = GS_LAYOUT IT_FIELDCAT_LVC = GT_FIELDCAT TABLES T_OUTTAB = GT_ALV_DATA EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. " FRM_OUTPUT *& Form ALV_PF_STATUS *&---------------------------------------------------------------------* * GUI状态设置 *----------------------------------------------------------------------* * -->RT_EXTAB GUI状态设置 *----------------------------------------------------------------------* FORM ALV_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB. SET PF-STATUS \'STANDARD_FULLSCREEN\'. ENDFORM. "ALV_PF_STATUS *&---------------------------------------------------------------------* *& Form ALV_USER_COMMAND *&---------------------------------------------------------------------* * ALV执行查询后的事件响应 *----------------------------------------------------------------------* * -->R_UCOMN 响应码 * -->RS_SELFIELD 当前行信息 *----------------------------------------------------------------------* FORM ALV_COMMAND USING PV_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. DATA:LV_INDEX TYPE SY-TABIX. CASE PV_UCOMM. WHEN \'IMPORT\'. PERFORM FRM_BAPI. "CHANGING l_subrc l_icon l_memo. * PERFORM refurbish_alv. WHEN OTHERS. ENDCASE. RS_SELFIELD-REFRESH = \'X\'. ENDFORM. "ALV_USER_COMMAND *&---------------------------------------------------------------------* *& Form FRM_BAPI *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM FRM_BAPI . DATA : LV_MSG TYPE STRING. DATA : LV_MSG1 TYPE STRING. DATA : LV_BPARTNERGUID TYPE BU_PARTNER_GUID_BAPI. * LOOP AT gt_alv_data ASSIGNING <fs_data>. * IF <fs_data>-memo IS NOT INITIAL. * MESSAGE: \'请先处理错误数据再进行导入!\' TYPE \'S\' DISPLAY LIKE \'E\'. * RETURN. * ENDIF. * ENDLOOP. 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:V_FLAG. *&---循环导入 V_TABIX = 0. DESCRIBE TABLE GT_ALV_DATA LINES LV_LINES . LOOP AT GT_ALV_DATA ASSIGNING <FS_DATA>. *&---当前条目 V_TABIX = V_TABIX + 1. *&---进度条 * WAIT UP TO 3 SECONDS. PERFORM FRM_INDICATOR USING V_TABIX. 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. TRY . LV_BPARTNERGUID = CL_UUID_FACTORY=>CREATE_SYSTEM_UUID( )->CREATE_UUID_X16( ). CATCH CX_UUID_ERROR. "返回消息 ENDTRY. CHECK LV_BPARTNERGUID IS NOT INITIAL. LS_PARTNER-HEADER-OBJECT_TASK = \'I\'. LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNERGUID = LV_BPARTNERGUID. LS_PARTNER-HEADER-OBJECT_INSTANCE-BPARTNER = <FS_DATA>-PARTNER ."客户号 LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-CATEGORY = 2. "业务伙伴类别 LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CONTROL-GROUPING = <FS_DATA>-KTOKD. " 分组 LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME1 = <FS_DATA>-NAME1. " 名称1 LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME2 = <FS_DATA>-NAME2. " 名称2 LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME3 = <FS_DATA>-NAME3. " 名称3 WD LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_ORGANIZATION-NAME4 = <FS_DATA>-NAME4. " 名称4 WD LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CENTRALDATA-SEARCHTERM1 = <FS_DATA>-SORTL. "搜索项 LS_PARTNER-CENTRAL_DATA-COMMON-DATA-BP_CENTRALDATA-TITLE_KEY = <FS_DATA>-ANRED. "称谓 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_CENTRALDATA-TITLE_KEY = ABAP_TRUE. LS_PARTNER-CENTRAL_DATA-COMMON-DATAX-BP_CENTRALDATA-SEARCHTERM1 = ABAP_TRUE. CLEAR:LT_ROLES. *----------------------------此处根据业务不同需要添加的BP角色也不同,先注释掉,需要用的请自行解掉注释并且根据业务添加所需角色,此处为必须要的字段 * IF <FS_DATA>-KTOKD <> \'ZS02\' AND <FS_DATA>-KTOKD <> \'ZS05\'. * LS_ROLES-TASK = \'I\'. * LS_ROLES-DATA_KEY = \'ZYCU00\'. "公司角色 * APPEND LS_ROLES TO LT_ROLES. * ENDIF. * * IF <FS_DATA>-KTOKD <> \'ZS03\' AND <FS_DATA>-KTOKD <> \'ZS07\' AND <FS_DATA>-KTOKD <> \'ZS08\'. * LS_ROLES-TASK = \'I\'. * LS_ROLES-DATA_KEY = \'ZYCU01\'. "销售角色 * APPEND LS_ROLES TO LT_ROLES. * ENDIF. LS_ROLES-TASK = \'I\'. LS_ROLES-DATA_KEY = <FS_DATA>-CUS001X. "角色 APPEND LS_ROLES TO LT_ROLES. IF <FS_DATA>-CUS001X = \'FLCU01\' . LS_ROLES-TASK = \'I\'. LS_ROLES-DATA_KEY = \'FLCU00\'. "角色 APPEND LS_ROLES TO LT_ROLES. LS_ROLES-TASK = \'I\'. LS_ROLES-DATA_KEY = \'UKM000\'. "角色 APPEND LS_ROLES TO LT_ROLES. ELSE. ENDIF. LS_PARTNER-CENTRAL_DATA-ROLE-ROLES = LT_ROLES. CLEAR:LS_ADDRESSES,LT_ADDRESSES. LS_ADDRESSES-TASK = \'I\'. LS_ADDRESSES-DATA-POSTAL-DATA-POSTL_COD1 = <FS_DATA>-PSTLZ. " 邮政编码 LS_ADDRESSES-DATA-POSTAL-DATA-COUNTRY = <FS_DATA>-LAND1. " 国家代码 LS_ADDRESSES-DATA-POSTAL-DATA-REGION = <FS_DATA>-REGIO. " 地区代码 LS_ADDRESSES-DATA-POSTAL-DATA-C_O_NAME = <FS_DATA>-NAME_CO. " 代收人 LS_ADDRESSES-DATA-POSTAL-DATA-STREET = <FS_DATA>-STREET. " 街道 LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL1 = <FS_DATA>-STR_SUPPL1. " 街道2 WD LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL2 = <FS_DATA>-STR_SUPPL2. " 街道3 WD LS_ADDRESSES-DATA-POSTAL-DATA-STR_SUPPL3 = <FS_DATA>-STR_SUPPL3. " 街道4 LS_ADDRESSES-DATA-POSTAL-DATA-LOCATION = <FS_DATA>-LOCATION. " 街道5 LS_ADDRESSES-DATA-POSTAL-DATA-LANGUISO = <FS_DATA>-LANGU."语言 LS_ADDRESSES-DATA-POSTAL-DATAX-POSTL_COD1 = ABAP_TRUE. " 邮政编码 LS_ADDRESSES-DATA-POSTAL-DATAX-COUNTRY = 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-STREET = ABAP_TRUE. " 街道 LS_ADDRESSES-DATA-POSTAL-DATAX-STR_SUPPL3 = ABAP_TRUE. " 街道4 LS_ADDRESSES-DATA-POSTAL-DATAX-LOCATION = ABAP_TRUE. " 街道5 LS_ADDRESSES-DATA-POSTAL-DATAX-LANGU_ISO = ABAP_TRUE."语言 CLEAR:LS_PHONE,LT_PHONE. LS_PHONE-CONTACT-TASK = \'I\'. LS_PHONE-CONTACT-DATA-TELEPHONE = <FS_DATA>-TELF1. "电话 LS_PHONE-CONTACT-DATAX-TELEPHONE = ABAP_TRUE. APPEND LS_PHONE TO LT_PHONE. CLEAR:LS_PHONE. LS_PHONE-CONTACT-TASK = \'I\'. LS_PHONE-CONTACT-DATA-TELEPHONE = <FS_DATA>-PHONE. "手机 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_SMTP,LT_SMTP. LS_SMTP-CONTACT-TASK = \'I\'. LS_SMTP-CONTACT-DATA-E_MAIL = <FS_DATA>-EMAIL. "邮件 LS_SMTP-CONTACT-DATAX-E_MAIL = ABAP_TRUE. APPEND LS_SMTP TO LT_SMTP. LS_ADDRESSES-DATA-COMMUNICATION-SMTP-SMTP = LT_SMTP. *--传真 WD CLEAR:LS_FAX. REFRESH LT_FAX. LS_FAX-CONTACT-TASK = \'I\'. LS_FAX-CONTACT-DATA-FAX = <FS_DATA>-FAX_NUMBER . LS_FAX-CONTACT-DATAX-FAX = ABAP_TRUE. APPEND LS_FAX TO LT_FAX . LS_ADDRESSES-DATA-COMMUNICATION-FAX-FAX = LT_FAX. *--地址注释 WD(联系人) REFRESH LT_REMARKS_A. CLEAR:LS_REMARKS_A. LS_REMARKS_A-TASK = \'I\'. LS_REMARKS_A-DATA-LANGU = SY-LANGU.. LS_REMARKS_A-DATAX-LANGU = ABAP_TRUE. LS_REMARKS_A-DATA-ADR_NOTES = <FS_DATA>-REMARK. LS_REMARKS_A-DATAX-ADR_NOTES = ABAP_TRUE. APPEND LS_REMARKS_A TO LT_REMARKS_A . LS_ADDRESSES-DATA-REMARK-REMARKS = LT_REMARKS_A. APPEND LS_ADDRESSES TO LT_ADDRESSES. LS_PARTNER-CENTRAL_DATA-ADDRESS-ADDRESSES = LT_ADDRESSES. ****客户数据表头********************************************** LS_HEADER-OBJECT_TASK = \'I\'. LS_CUSTOMER-HEADER = LS_HEADER. ****中心数据**************************************************** "数据已经在BP里面录入了,此处不需重复的填写了 * IF <FS_DATA>-BUKRS IS NOT INITIAL. LS_CENTRAL-DATA-KUKLA = <FS_DATA>-KUKLA."客户分类 LS_CENTRAL-DATAX-KUKLA = \'X\'. LS_CENTRAL-DATA-BRAN1 = <FS_DATA>-BRAN1."行业代码1 LS_CENTRAL-DATAX-BRAN1 = \'X\'. LS_CENTRAL_DATA-CENTRAL = LS_CENTRAL. * "客户销售的出发票 LS_TAX_IND-TASK = \'I\'. LS_TAX_IND-DATA_KEY-ALAND = \'CN\'. LS_TAX_IND-DATA_KEY-TATYP = \'MWST\'. LS_TAX_IND-DATA-TAXKD = <FS_DATA>-TAXKD. LS_TAX_IND-DATAX-TAXKD = \'X\'. APPEND LS_TAX_IND TO LT_TAX_IND. LS_CENTRAL_DATA-TAX_IND-TAX_IND = LT_TAX_IND. LS_CUSTOMER-CENTRAL_DATA = LS_CENTRAL_DATA. * ENDIF. ****公司代码数据************************************************ IF <FS_DATA>-BUKRS IS NOT INITIAL. CALL FUNCTION \'CONVERSION_EXIT_ALPHA_INPUT\' EXPORTING INPUT = <FS_DATA>-KTONR IMPORTING OUTPUT = <FS_DATA>-KTONR. CALL FUNCTION \'CONVERSION_EXIT_ALPHA_INPUT\' " 统驭科目补零 EXPORTING INPUT = <FS_DATA>-AKONT IMPORTING OUTPUT = <FS_DATA>-AKONT. LS_COMPANY-TASK = \'I\'. LS_COMPANY-DATA_KEY-BUKRS = <FS_DATA>-BUKRS. " 公司代码 LS_COMPANY-DATA-AKONT = <FS_DATA>-AKONT. " 统驭科目 LS_COMPANY-DATA-ZUAWA = <FS_DATA>-ZUAWA. " 排序码 LS_COMPANY-DATA-ZTERM = <FS_DATA>-ZTERM. " 付款条款 LS_COMPANY-DATA-ZWELS = <FS_DATA>-ZWELS. " 付款方式 LS_COMPANY-DATAX-AKONT = ABAP_TRUE. LS_COMPANY-DATAX-ZUAWA = ABAP_TRUE. LS_COMPANY-DATAX-ZTERM = ABAP_TRUE. LS_COMPANY-DATAX-ZWELS = ABAP_TRUE. APPEND LS_COMPANY TO LT_COMPANY. LS_COMPANY_DATA-COMPANY = LT_COMPANY. LS_CUSTOMER-COMPANY_DATA = LS_COMPANY_DATA. ENDIF. *****销售数据**************************************************** * IF <FS_DATA>-KTOKD <> \'ZS03\' AND <FS_DATA>-KTOKD <> \'ZS07\' AND <FS_DATA>-KTOKD <> \'ZS08\' . IF <FS_DATA>-VKORG IS NOT INITIAL AND <FS_DATA>-VTWEG IS NOT INITIAL AND <FS_DATA>-SPART IS NOT INITIAL. LS_SALES-TASK = \'I\'. LS_SALES-DATA_KEY-VKORG = <FS_DATA>-VKORG. LS_SALES-DATA_KEY-VTWEG = <FS_DATA>-VTWEG. LS_SALES-DATA_KEY-SPART = <FS_DATA>-SPART. LS_SALES-DATA-VKBUR = <FS_DATA>-VKBUR. LS_SALES-DATA-VKGRP = <FS_DATA>-VKGRP. LS_SALES-DATA-WAERS = <FS_DATA>-WAERS. LS_SALES-DATA-KALKS = <FS_DATA>-KALKS. LS_SALES-DATA-VWERK = <FS_DATA>-VWERK. LS_SALES-DATA-VSBED = <FS_DATA>-VSBED. LS_SALES-DATA-PODKZ = <FS_DATA>-PODKZ. LS_SALES-DATA-INCO1 = <FS_DATA>-INCO1. LS_SALES-DATA-INCO2 = <FS_DATA>-INCO2. LS_SALES-DATA-ZTERM = <FS_DATA>-ZTERM1. LS_SALES-DATA-KTGRD = <FS_DATA>-KTGRD. LS_SALES-DATA-BZIRK = <FS_DATA>-BZIRK. "销售区域 WD LS_SALES-DATA-KDGRP = <FS_DATA>-KDGRP. "客户组 WD LS_SALES-DATA-KVGR1 = <FS_DATA>-KVGR1 ."客户组1 WD LS_SALES-DATA-KVGR2 = <FS_DATA>-KVGR2 ."客户组2 WD LS_SALES-DATA-KVGR3 = <FS_DATA>-KVGR3 ."客户组3 WD LS_SALES-DATA-KVGR4 = <FS_DATA>-KVGR4 ."客户组4 WD LS_SALES-DATA-KVGR5 = <FS_DATA>-KVGR5 ."客户组5 WD LS_SALES-DATAX-VKBUR = ABAP_TRUE. LS_SALES-DATAX-VKGRP = ABAP_TRUE. LS_SALES-DATAX-WAERS = ABAP_TRUE. LS_SALES-DATAX-KALKS = ABAP_TRUE. LS_SALES-DATAX-VWERK = 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-KTGRD = ABAP_TRUE. LS_SALES-DATAX-BZIRK = ABAP_TRUE. "销售区域 WD LS_SALES-DATAX-KDGRP = ABAP_TRUE. "客户组 WD LS_SALES-DATAX-KVGR1 = <FS_DATA>-KVGR1 ."客户组1 WD LS_SALES-DATAX-KVGR2 = <FS_DATA>-KVGR2 ."客户组2 WD LS_SALES-DATAX-KVGR3 = <FS_DATA>-KVGR3 ."客户组3 WD LS_SALES-DATAX-KVGR4 = <FS_DATA>-KVGR4 ."客户组4 WD LS_SALES-DATAX-KVGR5 = <FS_DATA>-KVGR5 ."客户组5 WD "Function伙伴功能 LS_FUNCTIONS-TASK = \'I\'. *begin of 业务伙伴 此处为业务所需的限制,根据客户的账户组进行限制,需要用到的可以根据业务进行修改 IF <FS_DATA>-KTOKD <> \'ZS04\' AND <FS_DATA>-KTOKD <> \'ZS02\'. "限制一下ZS04的伙伴只有一个,给多了伙伴不会报错但是销售数据不会传进去 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. ENDIF. IF <FS_DATA>-KTOKD = \'ZS02\'. CALL FUNCTION \'CONVERSION_EXIT_PARVW_INPUT\' EXPORTING INPUT = C_PARVW5 "送达方 IMPORTING OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW. APPEND LS_FUNCTIONS TO LT_FUNCTIONS. ENDIF. IF <FS_DATA>-KTOKD = \'ZS04\'. CALL FUNCTION \'CONVERSION_EXIT_PARVW_INPUT\' EXPORTING INPUT = C_PARVW3 "付款方 IMPORTING OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW. APPEND LS_FUNCTIONS TO LT_FUNCTIONS. ENDIF. *此处为业务需求,对货运代理这个业务伙伴的货运代理编号进行更换,如无此业务可以自行删除 * IF <FS_DATA>-KTOKD <> \'ZS04\' AND <FS_DATA>-KTOKD <> \'ZS02\'. * CALL FUNCTION \'CONVERSION_EXIT_PARVW_INPUT\' * EXPORTING * INPUT = C_PARVW4 "货运代理 * IMPORTING * OUTPUT = LS_FUNCTIONS-DATA_KEY-PARVW. * IF <FS_DATA>-KTOKD = \'ZS01\'. "只有ZS01售达方需要货运代理换值 * LS_FUNCTIONS-DATA-PARTNER = <FS_DATA>-KTONR. * LS_FUNCTIONS-DATAX-PARTNER = ABAP_TRUE. * ENDIF. * APPEND LS_FUNCTIONS TO LT_FUNCTIONS. * ENDIF. *END of 业务伙伴 此处为业务所需的限制,需要用到的可以根据业务进行修改 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. * 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 * I_EXT_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. CONCATENATE \'客户\' LS_CUSTOMER_LIST-CUSTOMER \'创建成功!\' INTO <FS_DATA>-MEMO. <FS_DATA>-PARTNER = LS_CUSTOMER_LIST-CUSTOMER. ENDIF. ELSE. "可能创建成功了BP,但未创建成功customer DATA : LS_CVIS_ERROR TYPE CVIS_ERROR. * LT_RETURN TYPE BAPIRET2_T, * LS_RETURN TYPE BAPIRET2. LS_CVIS_ERROR = CVI_MAPPER=>GET_INSTANCE( )->UNDO_ASSIGNMENTS( I_FOR_PARTNERS = LT_PARTNERGUID_LIST ). <FS_DATA>-MEMO = \'客户创建出错,客户部分数据出错,请检查是否是BP伙伴功能问题\'. ENDIF. *--BAPI_BUPA_TAX_ADD 类别 税号 CLEAR LV_MSG1 . CLEAR:LT_RETURN_TAX. REFRESH LT_RETURN_TAX[]. CALL FUNCTION \'BAPI_BUPA_TAX_ADD\' EXPORTING BUSINESSPARTNER = <FS_DATA>-PARTNER TAXTYPE = <FS_DATA>-TAXTYPE "类别 TAXNUMBER = <FS_DATA>-TAXNUMXL "税号 TABLES RETURN = LT_RETURN_TAX. LOOP AT LT_RETURN_TAX WHERE TYPE = \'E\' OR TYPE = \'A\'. CONCATENATE LV_MSG1 LT_RETURN_TAX-MESSAGE INTO LV_MSG1. ENDLOOP. IF LV_MSG1 IS INITIAL . CALL FUNCTION \'BAPI_TRANSACTION_COMMIT\' EXPORTING WAIT = ABAP_TRUE. ELSE. CALL FUNCTION \'BAPI_TRANSACTION_ROLLBACK\' * IMPORTING * RETURN = . <FS_DATA>-MEMO = \'客户创建成功,但是类别、税号创建失败\'. ENDIF. *--BAPI_BUTX_FRG0010_ADD 税分类国家/地区 税收类型 税收组 CLEAR LV_MSG1 . CLEAR:LT_RETURN_FRG. REFRESH LT_RETURN_FRG[]. 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. LOOP AT LT_RETURN_FRG WHERE TYPE = \'E\' OR TYPE = \'A\'. CONCATENATE LV_MSG1 LT_RETURN_FRG-MESSAGE INTO LV_MSG1. ENDLOOP. IF LV_MSG1 IS INITIAL . CALL FUNCTION \'BAPI_TRANSACTION_COMMIT\' EXPORTING WAIT = ABAP_TRUE. ELSE. CALL FUNCTION \'BAPI_TRANSACTION_ROLLBACK\' * IMPORTING * RETURN = . <FS_DATA>-MEMO = \'客户创建成功,但是税收组相关数据创建失败\'. ENDIF. *--维护信用段数据 CLEAR:LV_MSG1. REFRESH LT_RETURN_UKMBP[]. PERFORM FRM_ADD_UKMBP CHANGING LT_RETURN_UKMBP . LOOP AT LT_RETURN_FRG WHERE TYPE = \'E\' OR TYPE = \'A\'. CONCATENATE LV_MSG1 LT_RETURN_FRG-MESSAGE INTO LV_MSG1. ENDLOOP. IF LV_MSG1 IS INITIAL . CALL FUNCTION \'BAPI_TRANSACTION_COMMIT\' EXPORTING WAIT = ABAP_TRUE. ELSE. CALL FUNCTION \'BAPI_TRANSACTION_ROLLBACK\' * IMPORTING * RETURN = . <FS_DATA>-MEMO = \'客户创建成功,但是信用相关数据创建失败\'. ENDIF. ELSE. CALL FUNCTION \'BAPI_TRANSACTION_ROLLBACK\' * IMPORTING * RETURN = . <FS_DATA>-MEMO = LV_MSG. ENDIF. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_FULLPATH *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_L_FULLPATH text * <--P_L_PATH text *----------------------------------------------------------------------* FORM FRM_GET_FULLPATH CHANGING PV_FULLPATH TYPE STRING PV_PATH TYPE STRING PV_NAME TYPE STRING. DATA: LV_INIT_PATH TYPE STRING, LV_INIT_FNAME TYPE STRING, LV_PATH TYPE STRING, LV_FILENAME TYPE STRING, LV_FULLPATH TYPE STRING. * 初始名称(输出的文件名称) * concatenate \'Material_Doc_\' SY-DATUM \'.xslx\' into L_INIT_FNAME. LV_INIT_FNAME = TEXT-003. * 获取桌面路径 CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY CHANGING DESKTOP_DIRECTORY = LV_INIT_PATH EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 OTHERS = 4. IF SY-SUBRC <> 0. EXIT. ENDIF. * 用户选择名称、路径 CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG EXPORTING * window_title = \'指定保存文件名\' * default_extension = \'DOC\' DEFAULT_FILE_NAME = LV_INIT_FNAME * FILE_FILTER = CL_GUI_FRONTEND_SERVICES=>FILETYPE_EXCEL * FILE_FILTER = CL_GUI_FRONTEND_SERVICES=>FILETYPE_WORD INITIAL_DIRECTORY = LV_INIT_PATH PROMPT_ON_OVERWRITE = \'X\' CHANGING FILENAME = LV_FILENAME PATH = LV_PATH FULLPATH = LV_FULLPATH * USER_ACTION = * FILE_ENCODING = EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 OTHERS = 4. IF SY-SUBRC = 0. PV_FULLPATH = LV_FULLPATH. PV_PATH = LV_PATH. ENDIF. ENDFORM. " FRM_GET_FULLPATH *&---------------------------------------------------------------------* *& Form FRM_DOWN *&---------------------------------------------------------------------* * 下载xls模板 *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_DOWN USING PR_FILENAME. DATA: LV_OBJDATA LIKE WWWDATATAB, LV_MIME LIKE W3MIME, LV_DESTINATION LIKE RLGRAP-FILENAME, LV_OBJNAM TYPE STRING, LV_RC LIKE SY-SUBRC, LV_ERRTXT TYPE STRING. DATA: LV_FILENAME TYPE STRING, LV_RESULT, LV_SUBRC TYPE SY-SUBRC. DATA: LV_OBJID TYPE WWWDATATAB-OBJID . LV_OBJID = \'ZSDB_802\'. "上传的模版名称 "查找文件是否存在。 SELECT SINGLE RELID OBJID FROM WWWDATA INTO CORRESPONDING FIELDS OF LV_OBJDATA WHERE SRTF2 = 0 AND RELID = \'MI\' AND OBJID = LV_OBJID. "判断模版不存在则报错 IF SY-SUBRC NE 0 OR LV_OBJDATA-OBJID EQ SPACE. CONCATENATE \'模板文件:\' LV_OBJID \'不存在,请用TCODE:SMW0进行加载\' INTO LV_ERRTXT. MESSAGE E000(SU) WITH LV_ERRTXT. ENDIF. LV_FILENAME = PR_FILENAME. "判断本地地址是否已经存在此文件。 CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST EXPORTING FILE = LV_FILENAME RECEIVING RESULT = LV_RESULT EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 WRONG_PARAMETER = 3 NOT_SUPPORTED_BY_GUI = 4 OTHERS = 5. IF SY-SUBRC <> 0. ENDIF. IF LV_RESULT EQ \'X\'. "如果存在则删除原始文件,重新覆盖 CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE EXPORTING FILENAME = LV_FILENAME CHANGING RC = LV_SUBRC EXCEPTIONS FILE_DELETE_FAILED = 1 CNTL_ERROR = 2 ERROR_NO_GUI = 3 FILE_NOT_FOUND = 4 ACCESS_DENIED = 5 UNKNOWN_ERROR = 6 NOT_SUPPORTED_BY_GUI = 7 WRONG_PARAMETER = 8 OTHERS = 9. IF LV_SUBRC <> 0. "如果删除失败,则报错。 CONCATENATE \'同名EXCEL文件已打开\' \'请关闭该EXCEL后重试。\' INTO LV_ERRTXT. MESSAGE E000(SU) WITH LV_ERRTXT. ENDIF. ENDIF. LV_DESTINATION = PR_FILENAME. "下载模版。 CALL FUNCTION \'DOWNLOAD_WEB_OBJECT\' EXPORTING KEY = LV_OBJDATA DESTINATION = LV_DESTINATION IMPORTING RC = LV_RC. IF LV_RC NE 0. CONCATENATE \'模板文件\' \'下载失败\' INTO LV_ERRTXT. MESSAGE E000(SU) WITH LV_ERRTXT. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_ADD_UKMBP *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* 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. *&---------------------------------------------------------------------* *& Form FRM_ADD_TAX *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* * <--P_LT_RETURN_TAX text *&---------------------------------------------------------------------* FORM FRM_ADD_TAX CHANGING P_LT_RETURN_TAX. ENDFORM. *&---------------------------------------------------------------------* *& Form DOWNLOAD_TEMPLATE *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM DOWNLOAD_TEMPLATE . DATA: LS_WWWDATATAB LIKE WWWDATATAB, LT_MIME LIKE W3MIME OCCURS 10, LV_FILENAME TYPE STRING, LV_PATH TYPE STRING, LV_FULLPATH TYPE STRING, WINDOW_TITLE TYPE STRING, DEFAULT_FILE_NAME TYPE STRING. CLEAR: LS_WWWDATATAB,LT_MIME[],LV_FILENAME,LV_PATH,LV_FULLPATH,WINDOW_TITLE,DEFAULT_FILE_NAME. LS_WWWDATATAB-RELID = \'MI\'. "IMPORT/EXPORT 数据表中的区域 CASE SSCRFIELDS-UCOMM. WHEN \'FC01\'. LS_WWWDATATAB-OBJID = \'ZSD010\'. LS_WWWDATATAB-TEXT = \'客户导入程序模版.xlsx\'."WWWDATA 对象的短文本 DEFAULT_FILE_NAME = \'客户导入程序模版.xlsx\'. ENDCASE. WINDOW_TITLE = \'下载导入模板\'. CALL FUNCTION \'WWWDATA_IMPORT\' "#EC * EXPORTING KEY = LS_WWWDATATAB TABLES MIME = LT_MIME EXCEPTIONS WRONG_OBJECT_TYPE = 1 IMPORT_ERROR = 2 OTHERS = 3. CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG EXPORTING WINDOW_TITLE = WINDOW_TITLE DEFAULT_EXTENSION = \'xlsx\' DEFAULT_FILE_NAME = DEFAULT_FILE_NAME FILE_FILTER = \'EXCEL\' CHANGING FILENAME = LV_FILENAME PATH = LV_PATH FULLPATH = LV_FULLPATH EXCEPTIONS CNTL_ERROR = 1 ERROR_NO_GUI = 2 NOT_SUPPORTED_BY_GUI = 3 OTHERS = 4. IF SY-SUBRC <> 0. STOP. ENDIF. IF LV_FULLPATH IS NOT INITIAL. CALL FUNCTION \'GUI_DOWNLOAD\' EXPORTING FILENAME = LV_FULLPATH FILETYPE = \'BIN\' TABLES DATA_TAB = LT_MIME. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_INDICATOR *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p_1 text * <-- p_2 text *----------------------------------------------------------------------* FORM FRM_INDICATOR USING P_INDEX. "data declaration/进度条变量 CONSTANTS LC_STEP_WIDTH TYPE I VALUE 1." 5. "Width of each step DATA: LV_STEP TYPE I VALUE LC_STEP_WIDTH, "current step * lv_lines TYPE i, "total records to be processed LV_LINESC TYPE C LENGTH 20, "total records to be processed of string LV_INDEX TYPE I, "current records being processed LV_PERCENTAGE TYPE F, "percentage of processed records LV_REMAINING TYPE I, "remaining records to be processed LV_TEXT TYPE C LENGTH 80, "info displayed at progress indicator LV_START TYPE TIMESTAMP. "time stamp of process started "process logic LV_INDEX = P_INDEX. "Initialization IF V_FLAG IS INITIAL."sy-batch IS INITIAL. V_FLAG = \'X\'. GET TIME STAMP FIELD LV_START. ENDIF. "show progress indicator/显示进度条 IF LV_LINES GE LC_STEP_WIDTH AND LV_INDEX >= LV_STEP. ADD LC_STEP_WIDTH TO LV_STEP. "当前占比% LV_PERCENTAGE = LV_INDEX / LV_LINES * 100. "剩余条目数 LV_REMAINING = LV_LINES - LV_INDEX. "数字文本强制转换 WRITE LV_LINES TO LV_LINESC LEFT-JUSTIFIED. WRITE LV_REMAINING TO LV_TEXT LEFT-JUSTIFIED. "进度条(记录) CONCATENATE TEXT-904 "\'Processing remaining\'(005) LV_TEXT \'/\' LV_LINESC TEXT-905"\'items\'(007) INTO LV_TEXT SEPARATED BY SPACE. "时间记录 PERFORM ESTIMATE_REMAINING_TIME USING LV_START LV_INDEX LV_LINES CHANGING LV_TEXT. "SAP GUI 进度条 CALL FUNCTION \'SAPGUI_PROGRESS_INDICATOR\' EXPORTING PERCENTAGE = LV_PERCENTAGE TEXT = LV_TEXT. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form ESTIMATE_REMAINING_TIME *&---------------------------------------------------------------------* * text 时间设定 *----------------------------------------------------------------------* * -->P_LV_START text * -->P_LV_INDEX text * -->P_LV_LINES text * <--P_LV_TEXT text *----------------------------------------------------------------------* FORM ESTIMATE_REMAINING_TIME USING PV_START TYPE P "timestamp of start processing PV_INDEX TYPE I "current record being processed PV_TOTAL TYPE I "total number of records to be processed CHANGING PV_TEXT TYPE C."text to display remaining time "Data declaration/进度条时间变量 DATA:LV_CURRENT TYPE TIMESTAMP, "当前时间戳 LV_DURATION TYPE TZNTSTMPL, "持续时间 LV_REMAINING TYPE C LENGTH 15, "剩余时间 LV_HOURS TYPE C LENGTH 4, "换算小时数 LV_MINUTES TYPE N LENGTH 2, "换算分钟数 LV_SECONDS TYPE N LENGTH 2. "换算秒数 "Get current time stamp/获取当前时间戳 GET TIME STAMP FIELD LV_CURRENT. "calculate execution time (so far)/计算持续时间 TRY. CALL METHOD CL_ABAP_TSTMP=>SUBTRACT EXPORTING TSTMP1 = LV_CURRENT TSTMP2 = PV_START RECEIVING R_SECS = LV_DURATION. CATCH CX_PARAMETER_INVALID_RANGE . "#EC NO_HANDLER CATCH CX_PARAMETER_INVALID_TYPE . "#EC NO_HANDLER ENDTRY. "estimate remaining execution time/剩余执行时间 LV_REMAINING = LV_DURATION / PV_INDEX * ( PV_TOTAL - PV_INDEX ). "整小时数 LV_HOURS = LV_REMAINING DIV 3600. "剩余分钟数 LV_REMAINING = LV_REMAINING MOD 3600. "整分钟数 LV_MINUTES = LV_REMAINING DIV 60. "剩余秒数 LV_SECONDS = LV_REMAINING MOD 60. "append to the text/文本 CONCATENATE PV_TEXT \' (\' TEXT-906" \'estimated remaining time:\'(006) LV_HOURS \':\' LV_MINUTES \':\' LV_SECONDS \')\' INTO PV_TEXT. ENDFORM. " ESTIMATE_REMAINING_TIME