ABAP 客户主数据批量导入

使用到的BAPI: RFC_CVI_EI_INBOUND_MAIN

这个BAPI 可以用来创建/修改 供应商和客户。
本篇文章只用来导入客户主数据,想要导供应商的请转到:ABAP 供应商主数据批量导入
使用方法,与我上一篇供应商导入基本一致,数据填写与校验逻辑有所不同而已。
另外,本文有长文本创建,以及一些Z开头的参数值,要根据你的需求来调整。注意下。
源代码


TABLES:sscrfields.

TYPE-POOLS:truxs,icon,slis.

*INCLUDE BDCRECX1_S.
************************************************************************
* GLOBAL STRUCTURES
************************************************************************

TYPES: BEGIN OF ty_out,
         sel        TYPE  c LENGTH 3,  "选中标记
         zt         TYPE  c LENGTH 2, "状态
         scdw       TYPE  c LENGTH 4, "生产单位
         yxtbm      TYPE  c LENGTH 10, "原系统编码
         kunnr      TYPE  kunnr,       "客户编号
         ktokd      TYPE  ktokd,       "客户帐户组
         zhzmc      TYPE  txt30,       "集团账户组名称
         name_org1  TYPE  c LENGTH 80,       "客户名称
         bu_sort1   TYPE  bu_sort1,    "客户简称  检索词
         land1      TYPE  land1,       "国家
         landx      TYPE  landx,       "国家名称
         regio      TYPE  regio,       "地区代码
         bezei      TYPE  bezei,       "地区名称
         mcod3      TYPE  ort01_gp,    "城市名称
         stras      TYPE  c LENGTH 220, "注册地址
         pstl2      TYPE  pstl2,       "邮政编码
         dianh      TYPE  ad_tlnmbr1,  "电话
         fenji      TYPE  ad_tlxtns1,  "电话分机号
         yddhh      TYPE  ad_tlnmbr1,  "移动电话
         ad_fxnmbr1 TYPE  ad_fxnmbr1,  "传真
         ad_fxxtns1 TYPE  ad_fxxtns1,  "传真分机号
         ad_smtpadr TYPE  ad_smtpadr,  "电子邮件地址
         katr1      TYPE  kna1-katr1,  "是否完成三证合一
         swdjz      TYPE  ltext,  "税务登记证号
         sydjh      TYPE  ltext, "商业登记号
         zzjgh      TYPE  ltext, "组织机构代码
         xydmh      TYPE  ltext, "社会统一信用代码
         jyfw       TYPE  ltext, "经营范围
         zczb       TYPE  ltext, "注册资本(单位:万元)
         zcsj       TYPE  ltext, "注册时间
         fddbr      TYPE  ltext, "法定代表人
         frsfz      TYPE  ltext, "法人身份证
         myhb       TYPE  ltext, "贸易伙伴
         ssjtb      TYPE  gpanr, "集团编码
         ssjtm      TYPE  ltext, "集团名称
         kunnr2     TYPE  gpanr, "终端编码
         zname      TYPE  name1, "终端名称
         bukrs      TYPE  bukrs, "公司代码
         vtweg      TYPE  vtweg, "分销渠道
         bzirk      TYPE  bzirk , "销售地区
         vkbur      TYPE  vkbur, "销售办公室
         kdgrp      TYPE  kdgrp, "客户组(ABC等级)
         vmibz      TYPE  kna1-katr7, "VMI业务标志
         kalks      TYPE  knvv-kalks, "价格类别
         vsbed      TYPE  vsbed, "装运条件
         zterm      TYPE  dzterm, "付款条件(账期)
         inco1      TYPE  inco1,   "国贸条款
         inco2_l    TYPE  inco2_l, "国际贸易条款位置 1
         inco3_l    TYPE  inco3_l, "国际贸易条款位置 2
         xszjm      TYPE  c LENGTH 10, "销售总监姓名
         xszjg      TYPE  gpanr, "销售总监工号
         xsjlm      TYPE  c LENGTH 10, "销售经理姓名
         xsjlg      TYPE  gpanr, "销售经理工号
         xsyzm      TYPE  c LENGTH 10, "业务助理姓名
         xsyzg      TYPE  gpanr, "业务助理工号
         zjs1m      TYPE  c LENGTH 10, "中间商1名称
         zjs1g      TYPE  gpanr, "中间商1编号
         zjs2m      TYPE  c LENGTH 10, "中间商2名称
         zjs2g      TYPE  gpanr, "中间商2编号
         zjs3m      TYPE  c LENGTH 10, "中间商3名称
         zjs3g      TYPE  gpanr, "中间商3编号
         waers      TYPE  waers, "币种
         name3      TYPE  c LENGTH 80, "客户名称(英文)
         zyddm      TYPE  c LENGTH 40, "装运地点名称
         scgc       TYPE  lfa1-lifnr, "审厂工厂
         kurst      TYPE  c LENGTH 10, "税率种类
         bpkind     TYPE  but000-bpkind, "经销/终销(业务伙伴合作类型)
         group_1    TYPE  bp001-group_feature, "终端/非终端  分组特征
         dzrq       TYPE  ltext, "对帐日期
         akont      TYPE  akont, "总帐中的统驭科目
         ktgrd      TYPE  ktgrd, "此客户的账户分配组
         zxy1       TYPE ukmbp_cms-limit_rule, "信用参数文件记分规则
         zxy2       TYPE ukmbp_cms_sgm-credit_sgmnt,  "信用段
         zxy3       TYPE ukmbp_cms_sgm-credit_limit,   "信用额度
         zxy4       TYPE ukmbp_cms_sgm-limit_valid_date,  "有效终止日期
         zkhfxjg    TYPE c LENGTH 100, "客户风险警告
         drjg       TYPE  c LENGTH 500 , "导入结果
       END OF ty_out.

TYPES: BEGIN OF ty_out1,
         kunnr TYPE  kunnr,  "客户编号
         vkorg TYPE  vkorg, "销售组织
         vtweg TYPE  vtweg, "分销渠道
         spart TYPE spart, "产品组
       END OF ty_out1.

************************************************************************
* INTERNAL TABLES
************************************************************************

*----------数据存储表----------
DATA: gt_out TYPE TABLE OF ty_out,
      gs_out TYPE ty_out.

*"------------ALV-----------------
DATA: gt_fieldcat TYPE lvc_t_fcat, "字段目录
      gs_fieldcat LIKE LINE OF gt_fieldcat,
      gs_layout   TYPE lvc_s_layo.

*---------------信用段数据-----------------------------------*
DATA: return TYPE ukm_t_monitor_return.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE TEXT-001.
PARAMETERS: cb_up RADIOBUTTON GROUP grp3 DEFAULT 'X' USER-COMMAND com1 .
PARAMETERS: cb_down RADIOBUTTON GROUP grp3 .
SELECTION-SCREEN END OF BLOCK b3.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-002.
PARAMETERS: p_file TYPE rlgrap-filename MODIF ID mg1 MEMORY ID me2 . " 导入文件下载模板
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN: FUNCTION KEY 1 .
*&---------------------------------------------------------------------*
*& INITIALIZATION/选择屏幕前初始化                                     *
*&---------------------------------------------------------------------*
INITIALIZATION.

AT SELECTION-SCREEN OUTPUT.
*&---控制选择条件显示设置M1
  LOOP AT SCREEN.
    IF screen-group1 = 'MG1' .
*&---下载模板隐藏
      IF cb_down = abap_true.
        screen-active = 0.
      ENDIF.
*&---上传文件显示
      IF cb_up = abap_true .
        screen-active = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.
*&---文件路径搜索帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM frm_get_filename.

*&---------------------------------------------------------------------*
*& FORM FRM_GET_FILENAME
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& -->  CB_CENTR        TEXT
*& <--  CB_BANK        TEXT
*&---------------------------------------------------------------------*
FORM frm_get_filename .

  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename     = p_file
      mask             = '*.*,*.*,*.XLS,*.XLS,*.XLSX,*.XLSX.' "DEF_PATH = 'C:\'
*     MASK             = '*.TXT,*.TXT.' "DEF_PATH = 'C:\'
      mode             = 'O'
    IMPORTING
      filename         = p_file
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form EXCEL_CREATE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM excel_create .
*&---------------------------------------------------------------------*
*& FORM FRM_DOWN_LOAD
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
*& -->  CB_CENTR        TEXT
*& <--  CB_BANK        TEXT
*&---------------------------------------------------------------------*
*FORM frm_down_load .

*&---变量定义
  DATA: lv_text       TYPE string,                    "MESSAGE
        lv_filename   TYPE string,                    "DOWNLOAD FILE NAME
        lv_path       TYPE string,                    "DOWNLOAD FILE PATH
        ls_functxt    TYPE smp_dyntxt,                "MENU NAME
        lv_filepath   TYPE rlgrap-filename VALUE 'C', "FILE PATCH
        lv_mod(20)    TYPE c VALUE 'ZSDB001',         "MODEL
        lv_fullpath   TYPE string,                    "FULL PATH
        ls_object     TYPE wwwdatatab,                "OBJECT NAME
        lv_rc         TYPE sy-subrc,                  "RETURN CODE
        lv_title      TYPE string VALUE '保存',    "TITLE
        lv_title_name TYPE string VALUE '客户主数据导入模板'.       "TITLE NAME


*&---调用OS 操作系统对话框
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title              = lv_title
      default_extension         = 'XLSX'
      default_file_name         = lv_title_name
    " WITH_ENCODING             =
      file_filter               = 'EXCEL文件(*.XLS)|*.XLS|全部文件 (*.*)|*.*|'
      initial_directory         = 'D:\'
      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
      invalid_default_file_name = 4
      OTHERS                    = 5.
  IF sy-subrc <> 0.
*   IMPLEMENT SUITABLE ERROR HANDLING HERE
  ENDIF.
*&---操作系统文件路径
  CONCATENATE lv_path
  lv_filename
  '.XLSX'
  INTO lv_filepath.
*&---OS长度控制/*&---下载模板
  IF strlen( lv_filepath ) <> 5.
*&---查询模板.
    SELECT SINGLE
      relid objid
    FROM wwwdata
    INTO CORRESPONDING FIELDS OF ls_object
    WHERE srtf2 = '0'
      AND objid = lv_mod.                         "SMW0里对象名称
    IF sy-subrc <> 0 OR ls_object-objid = space .
      CONCATENATE '模板文件'"'模板文件:'
      lv_mod
      '不存在,请用smw0进行加载'"'不存在,请用SMW0进行加载.'
      INTO lv_text.
      MESSAGE lv_text TYPE 'E'.
      STOP.
    ENDIF.
*&---下载模板
    CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
      EXPORTING
        key         = ls_object
        destination = lv_filepath
      IMPORTING
        rc          = lv_rc.
    IF lv_rc <> 0.
      CONCATENATE TEXT-911"''模板文件:'
      lv_mod
      '下载失败,请与开发人员联系'"''下载失败,请与开发人员联系.'
      INTO lv_text.
      MESSAGE lv_text TYPE 'E'.
      STOP.
    ENDIF.
*&---'已下载'
    MESSAGE '已下载' TYPE 'S'.
  ELSE.
*&---'已取消下载'
    MESSAGE '已取消下载' TYPE 'S'.
  ENDIF.

ENDFORM.

*************************************************************************
**EVENT  START-OF-SELECTION.
*************************************************************************
START-OF-SELECTION.

  IF cb_down EQ 'X'.
    PERFORM excel_create.      "下载模板
    LEAVE LIST-PROCESSING.
  ENDIF.

  PERFORM check_file .        "检查上传文件的格式
  PERFORM upload_document .   "进行文档上传

*************************************************************************
**EVENT  END-OF-SELECTION
*************************************************************************
END-OF-SELECTION.
  PERFORM frm_output. "导入消息输出
*************************************************************************
**EVENT  END-OF PAGE
*************************************************************************
END-OF-PAGE.

*&---------------------------------------------------------------------*
*&      Form  FRM_OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_output ."输出
  PERFORM form_fieldcat."列格式
  PERFORM form_layout.  "布局设置
  PERFORM form_showdata.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FORM_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM form_fieldcat ."列格式 传的参数参

  PERFORM frm_get_fieldcat USING:
*                 sel        TYPE  c LENGTH 3,  "选中标记
        'ZT'         '状态'               '' '' ,
        'SCDW'       '生产单位'           '' '' ,
        'YXTBM'      '原系统编码'         '' '' ,
        'KUNNR'      '客户编号'          'KNA1' 'KUNNR',
        'KTOKD'      '客户帐户组'        '' 'KTOKD',
        'ZHZMC'      '集团账户组名称'    '' 'TXT30',
        'NAME_ORG1 ' '客户名称'          '' '',
        'BU_SORT1  ' '客户简称(检索词)'  '' 'BU_SORT1',
        'LAND1'      '国家'              ''  'LAND1',
        'LANDX'      '国家名称'          ''  'LANDX',
        'REGIO'      '地区代码'          ''  'REGIO',
        'BEZEI'      '地区名称'          ''  'BEZEI',
        'MCOD3'      '城市名称'          ''  'ORT01_GP',
        'STRAS'      '注册地址'          ''  '',
        'PSTL2'      '邮政编码'          ''  'PSTL2',
        'DIANH'      '电话'              ''  'AD_TLNMBR1',
        'FENJI'      '电话分机号'        ''  'AD_TLXTNS1',
        'YDDHH'      '移动电话'          ''  'AD_TLNMBR1',
        'AD_FXNMBR1' '传真'              ''  ' AD_FXNMBR1',
        'AD_FXXTNS1' '传真分机号'        ''  'AD_FXXTNS1',
        'AD_SMTPADR' '电子邮件地址'      ''  'AD_SMTPADR',
        'KATR1'      '是否完成三证合一'  'KNA1' 'KATR1',
        'SWDJZ'      '税务登记证号'      '' '',
        'SYDJH '     '商业登记号'        ''  '',
        'ZZJGH '     '组织机构代码'      ''  '',
        'XYDMH '     '社会统一信用代码'  ''  '',
        'JYFW  '     '经营范围'         '' '',
        'ZCZB  '     '注册资本(单位:万元)' '' '' ,
        'ZCSJ  '     '注册时间'             ''  '',
        'FDDBR '     '法定代表人'           '' '',
        'FRSFZ '     '法人身份证'           ''  '' ,
        'MYHB  '     '贸易伙伴'             ''  '',
        'SSJTB '     '所属集团编码'          '' 'GPANR',
        'SSJTM '     '所属集团名称'         ''  '' ,
        'KUNNR2'     '终端编码'             '' 'GPANR',
        'ZNAME'      '终端名称'             '' 'NAME1',
        'BUKRS '     '公司代码'             '' 'BUKRS',
        'VTWEG '     '分销渠道'             ''  'VTWEG',
        'BZIRK '     '销售地区'             ''  'BZIRK' ,
        'VKBUR '     '销售办公室'           'KNVV' 'VKBUR' ,
        'KDGRP '     '客户组(abc等级)'    '' 'KDGRP',
        'VMIBZ '     'VMI业务标志'          'KNA1' 'KATR7'   ,
        'KALKS'      '价格类别'            'KNVV' 'KALKS',
        'VSBED '     '装运条件'            '' 'VSBED',
        'ZTERM '     '付款条件(账期)'      ''  ' DZTERM',
        'INCO1 '     '国贸条款'            ''  'INCO1',
        'INCO2_L'    '国际贸易条款位置 1' '' 'INCO2_L',
        'INCO3_L'    '国际贸易条款位置 2' '' 'INCO3_L',
        'XSZJM'      '销售总监姓名'  ''   '',
        'XSZJG'      '销售总监工号'       ''   'GPANR',
        'XSJLM'      '销售经理姓名'       ''   '',
        'XSJLG'      '销售经理工号'       ''   'GPANR',
        'XSYZM'      '业务助理姓名'       ''   '',
        'XSYZG'      '业务助理工号'       ''   'GPANR',
        'ZJS1M'      '中间商1名称'        ''  '',
        'ZJS1G'      '中间商1编号'        ''  'GPANR',
        'ZJS2M'      '中间商2名称'        ''  '',
        'ZJS2G'      '中间商2编号'        ''  'GPANR',
        'ZJS3M'      '中间商3名称'        ''  '',
        'ZJS3G'      '中间商3编号'        ''  'GPANR',
        'WAERS '     '币种'              '' ' WAERS',
        'NAME3 '     '客户名称(英文)'     'KNA1' 'NAME3'   ,
        'ZYDDM '     '客户联系人'       '' ''   ,
        'SCGC  '     '审厂工厂'           'LFA1' 'LIFNR'   ,
        'KURST '     '税率种类'           ''  'KURST',
        'BPKIND'     '经销/终销'          'BUT000' 'BPKIND',
        'GROUP_1'    '终端/非终端'        'BP001' 'GROUP_FEATURE',
        'DZRQ  '     '对帐日期'           '' '',
        'AKONT'      '总帐中的统驭科目'   'KNB1' 'AKONT',
        'KTGRD'      '此客户的账户分配组' '' 'KTGRD',
        'ZXY1'       '信用参数文件记分规则' 'UKMBP_CMS' 'LIMIT_RULE', "
        'ZXY2'       '信用段' 'UKMBP_CMS_SGM' 'CREDIT_SGMNT',  "
        'ZXY3'       '信用额度' 'UKMBP_CMS_SGM' 'CREDIT_LIMIT',   "
        'ZXY4'       '有效终止日期' 'UKMBP_CMS_SGM' 'LIMIT_VALID_DATE',
        'ZKHFXJG'    '客户风险警告'       '' '',
        'DRJG'       '导入结果'           ''  ''.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->pv_fieldname   text
*      -->pv_coltext   text
*      -->pv_ref_table   text
*      -->pv_ref_table   text
*----------------------------------------------------------------------*
FORM frm_get_fieldcat USING "列格式 传参形式
      pv_fieldname  TYPE any
      pv_coltext    TYPE any
      pv_ref_table  TYPE any
      pv_ref_field  TYPE any.

  CLEAR gs_fieldcat.
  gs_fieldcat-fieldname = pv_fieldname.
  gs_fieldcat-coltext = pv_coltext.
  gs_fieldcat-scrtext_l = pv_coltext.
  gs_fieldcat-ref_table = pv_ref_table.
  gs_fieldcat-ref_field = pv_ref_field.

  APPEND gs_fieldcat TO gt_fieldcat.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FORM_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM form_layout ."布局设置
  gs_layout-cwidth_opt = 'X'.
  gs_layout-zebra      = 'X'.
  gs_layout-box_fname  = 'SEL'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form OPEN_DIALOG
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM open_dialog .
  DATA:lt_file_table TYPE filetable.
  DATA:ls_file_table TYPE file_table.
  DATA:l_rc TYPE i.

  DATA: lv_filter   TYPE string.

  lv_filter = 'ALL FILES (*.*)|*.*|EXCEL FILES (*.XLS)|*.XLS|WORD FILES(*.DOC)|*.DOC'.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = '选择文件'
      default_filename        = '*.XLSX'  "默认excel文件"
      initial_directory       = 'D:\ '  "默认打开D盘,也可以默认空"
      multiselection          = ''   "文件单选"
    CHANGING
      file_table              = lt_file_table
      rc                      = l_rc
    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.
    EXIT.
  ELSE.
    "选择文件框的赋值 将选择的文件地址写入到地址栏"
    READ TABLE lt_file_table INTO ls_file_table INDEX 1.
    IF sy-subrc = 0.
      p_file =  ls_file_table-filename.
      REFRESH : lt_file_table.
      CLEAR:ls_file_table.
    ENDIF.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CHECK_FILE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM check_file .
  DATA: lv_s1 TYPE string,
        lv_s2 TYPE string.

  IF p_file IS NOT INITIAL.
*    SPLIT p_file AT '.' INTO lv_s1 lv_s2.
*    TRANSLATE lv_s2 TO UPPER CASE.
*    IF lv_s2 <> 'XLS' AND lv_s2 <> 'XLSX' AND lv_s2 <> 'TXT'.
*      MESSAGE '文件格式不对!' TYPE 'S' DISPLAY LIKE 'E'.
*      LEAVE  LIST-PROCESSING.
*    ENDIF.
  ELSE.
    MESSAGE '文件名不能为空!' TYPE 'S' DISPLAY LIKE 'E'.
    LEAVE  LIST-PROCESSING.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UPLOAD_DOCUMENT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM upload_document .

  "定义表格结构内表。"
  DATA: lt_excel TYPE TABLE OF zalsmex_tabline, "表格结构。"
        ls_excel TYPE zalsmex_tabline.

  "ALSMEX_TABLINE是具有Excel数据的表行,有三个组件,row col value 。"

  DATA:get_file TYPE rlgrap-filename."这里参照系统中的结构字段。"
  MOVE p_file TO get_file."将地址栏的值赋值给GET_FILE"


  "调用此函数,将Excel中的内容以类似坐标的形式存储到LT_EXCEL内表中。"
  "使用ALSM_EXCEL_TO_INTERNAL_TABLE函数导入数据,一个excel文件最大行数只可为9999,如果超出是无法全部读入内表中的,会丢失其余行。
  call function 'ZALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = get_file
      i_begin_col             = 1
      i_begin_row             = 6
      i_end_col               = 76
      i_end_row               = 65535
    TABLES
      intern                  = lt_excel
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.

  DELETE lt_excel WHERE row = 1."删除第一行抬头。如果excel文件中不存在抬头的话,可不写此句。"

  IF lt_excel IS INITIAL.
    CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
      EXPORTING
*       DEFAULTOPTION = 'Y'
        diagnosetext1 = '数据错误'
*       DIAGNOSETEXT2 = ' '
*       DIAGNOSETEXT3 = ' '
        textline1     = 'Excel表格中没有内容!'
        titel         = '提示'.
    RETURN.
  ENDIF.

  CLEAR:gt_out.
  FIELD-SYMBOLS:<fs>.
  SORT lt_excel BY row col.
  DATA:num_col TYPE i.

  "将转换后的EXCEL内表中数据按照导入模板顺序依次放入内表,
  "故应将EXCEL模板顺序和内表顺序保持一致
  LOOP AT lt_excel INTO ls_excel.
    num_col = ls_excel-col.
    ASSIGN COMPONENT  num_col  OF STRUCTURE gs_out TO <fs>.
    <fs> = ls_excel-value.
    AT END OF row.

      APPEND gs_out TO gt_out.
      CLEAR:gs_out.
    ENDAT.
    CLEAR:ls_excel.
  ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FORM_SHOWDATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM form_showdata .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_callback_program       = sy-repid
      is_layout_lvc            = gs_layout
      i_save                   = 'A'
      it_fieldcat_lvc          = gt_fieldcat[]
      i_callback_pf_status_set = 'FRM_SET_STATUS'
      i_callback_user_command  = 'USER_COMMAND'
    TABLES
      t_outtab                 = gt_out
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
ENDFORM.
*&---------------------------------------------------------------------*
*&      FORM  FRM_SET_STATUS
*&---------------------------------------------------------------------*
*       TEXT
*----------------------------------------------------------------------*
*      -->RT_EXTAB   TEXT
*----------------------------------------------------------------------*
FORM frm_set_status USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'STANDARD' .
ENDFORM. "FRM_SET_STATUS
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*--------------------------------------------------------------------*
*  -->  R_UCOMM                                                       *
*  -->  RS_SELFIELD                                                   *
*---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
      rs_selfield TYPE slis_selfield.

  DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = lr_grid.
  CALL METHOD lr_grid->check_changed_data.
  rs_selfield-refresh = 'X'.
  rs_selfield-col_stable = 'X'.
  rs_selfield-row_stable = 'X'.

  CASE r_ucomm.
    WHEN 'ZIMPORT'.
      PERFORM badi_daoru.
      CALL METHOD lr_grid->refresh_table_display.
    WHEN OTHERS.
  ENDCASE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form BADI_DAORU
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM badi_daoru .

  DATA:ls_cvis_bp_general             TYPE cvis_bp_general,
       lt_cvis_bp_general             LIKE TABLE OF ls_cvis_bp_general,
       ls_cvis_bp_role                TYPE cvis_bp_role,
       lt_cvis_bp_role                LIKE TABLE OF ls_cvis_bp_role,
*       ls_cvis_bp_tax_number    TYPE cvis_bp_tax_number,
*       lt_cvis_bp_tax_number    LIKE TABLE OF ls_cvis_bp_tax_number,
       ls_cvis_bp_address             TYPE cvis_bp_address,
       lt_cvis_bp_address             LIKE TABLE OF ls_cvis_bp_address,
       ls_cvis_bp_address_teleno      TYPE cvis_bp_address_teleno, "电话号码
       lt_cvis_bp_address_teleno      LIKE TABLE OF ls_cvis_bp_address_teleno,
       ls_cvis_bp_address_faxno       TYPE cvis_bp_address_faxno,
       lt_cvis_bp_address_faxno       LIKE TABLE OF ls_cvis_bp_address_faxno, "传真号码
       ls_cvis_bp_address_email       TYPE cvis_bp_address_email,
       lt_cvis_bp_address_email       LIKE TABLE OF ls_cvis_bp_address_email, "邮箱号码
       ls_cvis_bp_finserv             TYPE cvis_bp_finserv,
       lt_cvis_bp_finserv             LIKE TABLE OF cvis_bp_finserv, "分组字符
       ls_cvis_customer_company       TYPE cvis_customer_company,
       lt_cvis_customer_company       LIKE TABLE OF ls_cvis_customer_company, "公司代码
       ls_cvis_customer_sales         TYPE cvis_customer_sales,
       lt_cvis_customer_sales         LIKE TABLE OF ls_cvis_customer_sales, "销售视图相关
       ls_cvis_customer_sales_func    TYPE cvis_customer_sales_func,
       lt_cvis_customer_sales_func    LIKE TABLE OF ls_cvis_customer_sales_func, "伙伴功能
       ls_cvis_customer_tax_indicator TYPE cvis_customer_tax_indicator,
       lt_cvis_customer_tax_indicator LIKE TABLE OF ls_cvis_customer_tax_indicator, "销售视图税
       ls_cvis_customer_general       TYPE cvis_customer_general,
       lt_cvis_customer_general       LIKE TABLE OF ls_cvis_customer_general,
*       ls_cvis_supplier_general LIKE cvis_supplier_general,
*       lt_cvis_supplier_general LIKE TABLE OF ls_cvis_supplier_general,
*       ls_cvis_bp_ident_numbers LIKE cvis_bp_ident_numbers,
*       lt_cvis_bp_ident_numbers LIKE TABLE OF ls_cvis_bp_ident_numbers,
*       ls_cvis_bp_bank_details  LIKE cvis_bp_bank_details,
*       lt_cvis_bp_bank_details  LIKE TABLE OF ls_cvis_bp_bank_details,
       ls_cvis_bp_return              TYPE cvis_bp_return,
       lt_cvis_bp_return              LIKE  TABLE OF cvis_bp_return,
       lv_bpartner                    TYPE bu_partner,
       ls_tb003i                      TYPE tb003i,
       lt_tb003i                      LIKE TABLE OF ls_tb003i,
       lv_guid                        TYPE but000-partner_guid,
       lv_object_task                 TYPE bus_ei_object_task, "I为创建,U修改
       lv_bkvid                       TYPE bu_bkvid,
       lv_index                       TYPE sy-tabix,
       lv_category                    TYPE bu_id_category,
       lv_bezei                       TYPE bezei20,
       lv_run_id                      TYPE cvi_run_id,
       lv_lines                       TYPE i.

*长文本参数
  DATA:ls_line  TYPE tline,
       lt_line  TYPE TABLE OF tline,
       ls_thead TYPE thead-tdname,
       ls_fxjg  TYPE ty_out1.

  DATA:ls_strlen TYPE i,
       lv_strlen TYPE i,
       i_subruc  TYPE i.
*  CLEAR ls_header.
  LOOP AT gt_out ASSIGNING FIELD-SYMBOL(<fs_kunnr>) WHERE sel = 'X'.

    PERFORM frm_kunnr_alpha_input CHANGING <fs_kunnr>-kunnr.  "业务伙伴
    CLEAR lv_guid.
    SELECT SINGLE partner_guid INTO lv_guid
            FROM but000 WHERE partner = <fs_kunnr>-kunnr.
    IF sy-subrc = 0.
      lv_object_task = 'U'.  "修改BP
    ELSE.
      lv_object_task = 'I'.  "创建BP
    ENDIF.

    ls_cvis_bp_general-object_task = lv_object_task.
    IF lv_run_id IS INITIAL.
      lv_run_id = '1000000' .
    ELSE.
      lv_run_id = lv_run_id + 1.
    ENDIF.

*    PERFORM bp_general TABLES lt_cvis_bp_general USING <fs_kunnr> .
* bp_general
    ls_cvis_bp_general-run_id = lv_run_id.".'1000000'.
    ls_cvis_bp_general-category = '2'.
    IF lv_guid IS NOT INITIAL.
      ls_cvis_bp_general-bpartnerguid = lv_guid.
    ENDIF.

    IF <fs_kunnr>-kunnr IS NOT INITIAL.  "客户
      ls_cvis_bp_general-grouping = <fs_kunnr>-ktokd. "业务合作伙伴组
*        ls_cvis_bp_general-legalorg =  ls_header-nsrbskh. "法律实体
    ENDIF.
*    IF <fs_kunnr>-bpkind = '终销' OR <fs_kunnr>-bpkind = '终销客户'.
*      ls_cvis_bp_general-partnertype = 'Z002'.
*    ELSEIF <fs_kunnr>-bpkind = '经销' OR <fs_kunnr>-bpkind = '经销客户'.
*      ls_cvis_bp_general-partnertype = 'Z001'.
*    ELSE.
*      ls_cvis_bp_general-partnertype = 'Z003'.
*    ENDIF.
    ls_cvis_bp_general-partnertype = <fs_kunnr>-bpkind .

    ls_cvis_bp_general-bpartner = <fs_kunnr>-kunnr.
    ls_cvis_bp_general-title_key = '0003'."公司

    CLEAR: ls_strlen,lv_strlen .
    ls_strlen = strlen( <fs_kunnr>-name_org1 ).
    IF  ls_strlen LE 40.
      ls_cvis_bp_general-name1 = <fs_kunnr>-name_org1.
    ELSEIF ls_strlen GT 40 AND ls_strlen LE 80.
      ls_cvis_bp_general-name1 = <fs_kunnr>-name_org1+0(40).
      lv_strlen = ls_strlen - 40.
      ls_cvis_bp_general-name2 = <fs_kunnr>-name_org1+40(lv_strlen).
    ENDIF.

    CLEAR: ls_strlen,lv_strlen .
    ls_strlen = strlen( <fs_kunnr>-name3 ).
    IF  ls_strlen LE 40.
      ls_cvis_bp_general-name3 = <fs_kunnr>-name3."英文名
    ELSEIF ls_strlen GT 40 AND ls_strlen LE 80.
      ls_cvis_bp_general-name3 = <fs_kunnr>-name3+0(40).
      lv_strlen = ls_strlen - 40.
      ls_cvis_bp_general-name4 = <fs_kunnr>-name3+40(lv_strlen).
    ENDIF.

    ls_cvis_bp_general-searchterm1 = <fs_kunnr>-bu_sort1.

*    ls_cvis_bp_general-comm_type = 'TEL'.
    APPEND ls_cvis_bp_general TO lt_cvis_bp_general.
    CLEAR ls_cvis_bp_general.

*bp_address 地址数据
    ls_cvis_bp_address-run_id =  lv_run_id.                 "'1000000'.
    IF <fs_kunnr>-pstl2 IS NOT INITIAL.
      ls_cvis_bp_address-postl_cod1 = <fs_kunnr>-pstl2.
    ELSE.
      IF <fs_kunnr>-land1 = 'CN' OR <fs_kunnr>-land1 = 'HK' OR <fs_kunnr>-land1 = 'IN'
          OR <fs_kunnr>-land1 = 'SG' OR <fs_kunnr>-land1 = 'VN' OR <fs_kunnr>-land1 = 'RO'.
        ls_cvis_bp_address-postl_cod1 = '000000'.
      ELSEIF <fs_kunnr>-land1 = 'BE' OR <fs_kunnr>-land1 = 'HU' OR <fs_kunnr>-land1 = 'PH' OR <fs_kunnr>-land1 = 'TN' .
        ls_cvis_bp_address-postl_cod1 = '0000'.
      ELSEIF <fs_kunnr>-land1 = 'TW' OR  <fs_kunnr>-land1 = 'KR' OR <fs_kunnr>-land1 = 'US' OR <fs_kunnr>-land1 = 'TR' OR <fs_kunnr>-land1 = 'MY'
         OR <fs_kunnr>-land1 = 'MX' OR <fs_kunnr>-land1 = 'IT' OR <fs_kunnr>-land1 = 'FR' OR <fs_kunnr>-land1 = 'TH' OR <fs_kunnr>-land1 = 'DE'
        OR <fs_kunnr>-land1 = 'ID' OR <fs_kunnr>-land1 = 'FI' OR <fs_kunnr>-land1 = 'ES'.
        ls_cvis_bp_address-postl_cod1 = '00000'.
      ELSEIF <fs_kunnr>-land1 = 'BR'.
        ls_cvis_bp_address-postl_cod1 = '000000000'.
      ELSEIF <fs_kunnr>-land1 = 'JP'.
        ls_cvis_bp_address-postl_cod1 = '00000000'.
      ELSEIF <fs_kunnr>-land1 = 'PL'.
        ls_cvis_bp_address-postl_cod1 = '00-000'.
      ELSEIF <fs_kunnr>-land1 = 'VG' OR <fs_kunnr>-land1 = 'MO'.
        ls_cvis_bp_address-postl_cod1 = '0'.
      ELSEIF <fs_kunnr>-land1 = 'CZ'.
        ls_cvis_bp_address-postl_cod1 = '000 00'.
      ENDIF.
    ENDIF.

    ls_cvis_bp_address-city = <fs_kunnr>-mcod3.
*    ls_cvis_bp_address-district = <fs_kunnr>-bezei.
*    ls_cvis_bp_address-po_box = ls_header-po_box.
    ls_cvis_bp_address-country = <fs_kunnr>-land1.
    ls_cvis_bp_address-region  = <fs_kunnr>-regio.
*    CLEAR lv_bezei.
*    lv_bezei = <fs_kunnr>-bezei+0(2) && '%'.
*    SELECT SINGLE bland
*             FROM t005u
*             INTO ls_cvis_bp_address-region  "省份
*            WHERE spras = sy-langu
*              AND land1 = <fs_kunnr>-land1
*              AND bezei LIKE lv_bezei.

    IF <fs_kunnr>-land1 = 'BR'.
      ls_cvis_bp_address-region = 'AM' .
      ls_cvis_bp_address-taxjurcode = 'AM' .
    ENDIF.

*    ls_cvis_bp_address-region = <fs_kunnr>-regio.
    CLEAR: ls_strlen,lv_strlen .
    ls_strlen = strlen( <fs_kunnr>-stras ).
    IF ls_strlen LE 60 .
      ls_cvis_bp_address-street = <fs_kunnr>-stras.
    ELSEIF ls_strlen GT 60 AND ls_strlen LE 100.
      ls_cvis_bp_address-street     = <fs_kunnr>-stras+0(60).
      lv_strlen = ls_strlen - 60.
      ls_cvis_bp_address-str_suppl1 = <fs_kunnr>-stras+60(lv_strlen).
    ELSEIF ls_strlen GT 100 AND ls_strlen LE 140.
      ls_cvis_bp_address-street     = <fs_kunnr>-stras+0(60).
      ls_cvis_bp_address-str_suppl1 = <fs_kunnr>-stras+60(40).
      lv_strlen = ls_strlen - 100.
      ls_cvis_bp_address-str_suppl2 = <fs_kunnr>-stras+100(lv_strlen).
    ELSEIF ls_strlen GT 140 AND ls_strlen LE 180.
      ls_cvis_bp_address-street     = <fs_kunnr>-stras+0(60).
      ls_cvis_bp_address-str_suppl1 = <fs_kunnr>-stras+60(40).
      ls_cvis_bp_address-str_suppl2 = <fs_kunnr>-stras+100(40).
      lv_strlen = ls_strlen - 140.
      ls_cvis_bp_address-str_suppl3 = <fs_kunnr>-stras+140(lv_strlen).
    ELSEIF ls_strlen GT 180 AND ls_strlen LE 220.
      ls_cvis_bp_address-street     = <fs_kunnr>-stras+0(60).
      ls_cvis_bp_address-str_suppl1 = <fs_kunnr>-stras+60(40).
      ls_cvis_bp_address-str_suppl2 = <fs_kunnr>-stras+100(40).
      ls_cvis_bp_address-str_suppl3 = <fs_kunnr>-stras+140(40).
      lv_strlen = ls_strlen - 180.
      ls_cvis_bp_address-location   = <fs_kunnr>-stras+180(lv_strlen).
    ENDIF.

    ls_cvis_bp_address-comm_type = 'INT'.
*    ls_cvis_bp_address-house_no = ls_header-house_num1.
    ls_cvis_bp_address-langu    = sy-langu.
    ls_cvis_bp_address-c_o_name = <fs_kunnr>-zyddm.

    APPEND ls_cvis_bp_address TO lt_cvis_bp_address.
    CLEAR ls_cvis_bp_address.

    ls_cvis_bp_address_teleno-run_id    = lv_run_id. "电话号码
    ls_cvis_bp_address_teleno-country   = <fs_kunnr>-land1.
    ls_cvis_bp_address_teleno-telephone = <fs_kunnr>-dianh.       "电话
    ls_cvis_bp_address_teleno-extension = <fs_kunnr>-fenji.       "电话分机号
*      ls_cvis_bp_address_teleno-R_3_USER = '3'."是否移动电话
    APPEND ls_cvis_bp_address_teleno TO lt_cvis_bp_address_teleno .
    CLEAR ls_cvis_bp_address_teleno.

    IF <fs_kunnr>-yddhh IS NOT INITIAL.
      ls_cvis_bp_address_teleno-run_id    = lv_run_id. "电话号码
      ls_cvis_bp_address_teleno-country   = <fs_kunnr>-land1.
      ls_cvis_bp_address_teleno-telephone = <fs_kunnr>-yddhh.       "电话
      ls_cvis_bp_address_teleno-r_3_user  = '2'."是否移动电话
      APPEND ls_cvis_bp_address_teleno TO lt_cvis_bp_address_teleno .
      CLEAR ls_cvis_bp_address_teleno.
    ENDIF.

    ls_cvis_bp_address_faxno-run_id    = lv_run_id.
    ls_cvis_bp_address_faxno-country   = <fs_kunnr>-land1.
    ls_cvis_bp_address_faxno-fax       = <fs_kunnr>-ad_fxnmbr1.  "传真
    ls_cvis_bp_address_faxno-extension = <fs_kunnr>-ad_fxxtns1.  "传真分机号
    APPEND ls_cvis_bp_address_faxno TO lt_cvis_bp_address_faxno. "传真号码
    CLEAR ls_cvis_bp_address_faxno.

    ls_cvis_bp_address_email-run_id = lv_run_id.

    IF <fs_kunnr>-ad_smtpadr IS INITIAL.
      ls_cvis_bp_address_email-e_mail = 'TEST@126.COM'."<fs_kunnr>-ad_smtpadr.  "电子邮件地址
    ELSE.
      ls_cvis_bp_address_email-e_mail = <fs_kunnr>-ad_smtpadr.  "电子邮件地址
    ENDIF.


    APPEND ls_cvis_bp_address_email TO lt_cvis_bp_address_email. "邮箱号码
*    CLEAR ls_cvis_bp_address_email.
*    ls_cvis_bp_role-run_id = '1000000'.
*    ls_cvis_bp_role-data_key = '000000'." 'FLVN00'.
*    APPEND ls_cvis_bp_role TO lt_cvis_bp_role.
*    CLEAR ls_cvis_bp_role.

    IF  <fs_kunnr>-kunnr IS NOT INITIAL.  "客户

      ls_cvis_bp_role-run_id =  lv_run_id.                  "'1000000'.
      ls_cvis_bp_role-data_key = 'UKM000'." 'FLVN01'.
      APPEND ls_cvis_bp_role TO lt_cvis_bp_role.
      CLEAR ls_cvis_bp_role.

      ls_cvis_bp_role-run_id =  lv_run_id.                  "'1000000'.
      ls_cvis_bp_role-data_key = 'FLCU00'." 'FLVN00'.
      APPEND ls_cvis_bp_role TO lt_cvis_bp_role.
      CLEAR ls_cvis_bp_role.

      ls_cvis_bp_role-run_id =  lv_run_id.                  "'1000000'.
      ls_cvis_bp_role-data_key = 'FLCU01'." 'FLVN01'.
      APPEND ls_cvis_bp_role TO lt_cvis_bp_role.
      CLEAR ls_cvis_bp_role.

      ls_cvis_bp_finserv-run_id = lv_run_id.
*      IF <fs_kunnr>-group_1 = '终端'.
*        ls_cvis_bp_finserv-group_feature = 'Z01' .
*      ELSEIF <fs_kunnr>-group_1 = '非终端'.
*        ls_cvis_bp_finserv-group_feature = 'Z02' .
*      ELSEIF <fs_kunnr>-group_1 = '其他'.
*        ls_cvis_bp_finserv-group_feature = 'Z03' .
*      ENDIF.
      ls_cvis_bp_finserv-group_feature = <fs_kunnr>-group_1 .

      APPEND ls_cvis_bp_finserv TO lt_cvis_bp_finserv . "分组字符
      CLEAR ls_cvis_bp_finserv.

      ls_cvis_customer_general-object_task = lv_object_task.
      ls_cvis_customer_general-run_id =  lv_run_id.         "'1000000'.
      ls_cvis_customer_general-ktokd = <fs_kunnr>-ktokd.
      ls_cvis_customer_general-katr1 = <fs_kunnr>-katr1.       "是否完成三证合一
      ls_cvis_customer_general-katr7 = <fs_kunnr>-vmibz.       "VMI
      ls_cvis_customer_general-kunnr = <fs_kunnr>-kunnr.

      APPEND ls_cvis_customer_general TO lt_cvis_customer_general.
      CLEAR ls_cvis_customer_general.

      ls_cvis_customer_company-run_id = lv_run_id.
      ls_cvis_customer_company-bukrs  = <fs_kunnr>-bukrs. "公司代码
*      IF <fs_kunnr>-akont = '应收账款集团外'.
*        ls_cvis_customer_company-akont  = '1122020000'. "总帐中的统驭科目
*      ELSEIF <fs_kunnr>-akont = '应收账款集团内'.
*        ls_cvis_customer_company-akont  = '1122010000'. "总帐中的统驭科目
*      ENDIF.
      ls_cvis_customer_company-akont  = <fs_kunnr>-akont . "总帐中的统驭科目
      ls_cvis_customer_company-zterm  = <fs_kunnr>-zterm.
      APPEND ls_cvis_customer_company TO lt_cvis_customer_company . "公司代码
      CLEAR ls_cvis_customer_company.

      ls_cvis_customer_sales-run_id = lv_run_id.

      ls_cvis_customer_sales-vkorg = <fs_kunnr>-bukrs."销售组织.
      ls_cvis_customer_sales-vtweg = <fs_kunnr>-vtweg. "分销渠道
      ls_cvis_customer_sales-spart = '10'.            "产品组

      ls_cvis_customer_sales-kalks = <fs_kunnr>-kalks."用于定价过程确定的客户分类
      ls_cvis_customer_sales-konda = '01'."客户价格组
      ls_cvis_customer_sales-vwerk = <fs_kunnr>-bukrs."交货工厂 (自有或外部)

      ls_cvis_customer_sales-bzirk = <fs_kunnr>-bzirk. "销售地区
      ls_cvis_customer_sales-vkbur = <fs_kunnr>-vkbur. "销售办公室

      ls_cvis_customer_sales-inco1   = <fs_kunnr>-inco1. "国贸条款
      ls_cvis_customer_sales-inco2_l = <fs_kunnr>-inco2_l. "国际贸易条款位置 1
      ls_cvis_customer_sales-inco3_l = <fs_kunnr>-inco3_l. "国际贸易条款位置 2

      ls_cvis_customer_sales-ktgrd = <fs_kunnr>-ktgrd."此客户的账户分配组

      "客户组(ABC等级)
      IF <fs_kunnr>-kdgrp = 'A' OR <fs_kunnr>-kdgrp = 'ZA'.
        ls_cvis_customer_sales-kdgrp = 'A'.
      ELSEIF <fs_kunnr>-kdgrp = 'B' OR <fs_kunnr>-kdgrp = 'ZB'.
        ls_cvis_customer_sales-kdgrp = 'B'.
      ELSEIF <fs_kunnr>-kdgrp = 'C' OR <fs_kunnr>-kdgrp = 'ZC'.
        ls_cvis_customer_sales-kdgrp = 'C'.
      ENDIF.

      ls_cvis_customer_sales-vsbed = <fs_kunnr>-vsbed. "装运条件
      ls_cvis_customer_sales-zterm = <fs_kunnr>-zterm. "付款条件(账期)
      ls_cvis_customer_sales-waers = <fs_kunnr>-waers. "币种
      APPEND ls_cvis_customer_sales TO lt_cvis_customer_sales. "销售视图相关
      CLEAR ls_cvis_customer_sales.

      ls_cvis_customer_sales_func-run_id = lv_run_id.
      ls_cvis_customer_sales_func-vkorg = <fs_kunnr>-bukrs."销售组织.
      ls_cvis_customer_sales_func-vtweg = <fs_kunnr>-vtweg. "分销渠道
      ls_cvis_customer_sales_func-spart = '10'.            "产品组

      IF <fs_kunnr>-ktokd NE 'Z003'.
        ls_cvis_customer_sales_func-parvw   = 'WE'."伙伴功能
        ls_cvis_customer_sales_func-partner = <fs_kunnr>-kunnr.
        APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

      ENDIF.

      IF <fs_kunnr>-ktokd NE 'Z005'.

        ls_cvis_customer_sales_func-parvw   = 'AG'."伙伴功能
        ls_cvis_customer_sales_func-partner = <fs_kunnr>-kunnr.
        APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

        ls_cvis_customer_sales_func-parvw   = 'RG'."伙伴功能
        ls_cvis_customer_sales_func-partner = <fs_kunnr>-kunnr.
        APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

        ls_cvis_customer_sales_func-parvw   = 'RE'."伙伴功能
        ls_cvis_customer_sales_func-partner = <fs_kunnr>-kunnr.
        APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

        IF <fs_kunnr>-ktokd EQ 'Z002'.
          ls_cvis_customer_sales_func-parvw   = 'Z1'."伙伴功能
          ls_cvis_customer_sales_func-partner = <fs_kunnr>-kunnr.
          APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .
        ENDIF.

        IF <fs_kunnr>-ktokd EQ 'Z002' OR <fs_kunnr>-ktokd EQ 'Z001'.
          IF <fs_kunnr>-scgc IS NOT INITIAL.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                input  = <fs_kunnr>-scgc
              IMPORTING
                output = <fs_kunnr>-scgc.

            ls_cvis_customer_sales_func-parvw   = 'LW'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-scgc.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-ssjtb IS NOT INITIAL AND <fs_kunnr>-ktokd EQ 'Z001'.
            ls_cvis_customer_sales_func-parvw   = 'Z1'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-ssjtb.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-kunnr2 IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'Z2'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-kunnr2.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-xszjg IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'S1'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-xszjg.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-xsjlg IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'S2'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-xsjlg.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-xsyzg IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'VE'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-xsyzg.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-zjs1g IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'S3'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-zjs1g.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-zjs2g IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'S4'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-zjs2g.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

          IF <fs_kunnr>-zjs3g IS NOT INITIAL.
            ls_cvis_customer_sales_func-parvw   = 'S5'."伙伴功能
            ls_cvis_customer_sales_func-partner = <fs_kunnr>-zjs3g.
            APPEND ls_cvis_customer_sales_func TO lt_cvis_customer_sales_func .

          ENDIF.

        ENDIF.

      ENDIF.
      CLEAR  ls_cvis_customer_sales_func .

      ls_cvis_customer_tax_indicator-run_id = lv_run_id.
      IF <fs_kunnr>-bukrs = '3000' OR <fs_kunnr>-bukrs = '4000'.
        ls_cvis_customer_tax_indicator-aland  = 'HK'.
      ELSE.
        ls_cvis_customer_tax_indicator-aland  = 'CN'.
      ENDIF.
      ls_cvis_customer_tax_indicator-tatyp  = 'MWST'.
*      IF <fs_kunnr>-kurst = '记增值税16%'.
*        ls_cvis_customer_tax_indicator-taxkd  = '1'.
*      ELSE.
*        ls_cvis_customer_tax_indicator-taxkd  = '0'.
*      ENDIF.
      ls_cvis_customer_tax_indicator-taxkd  = <fs_kunnr>-kurst .
      APPEND  ls_cvis_customer_tax_indicator TO lt_cvis_customer_tax_indicator. "销售视图税
      CLEAR  ls_cvis_customer_tax_indicator.

    ENDIF.

*    IF ls_header-nwgsbs IS NOT INITIAL.  "供应商
*
*      ls_cvis_bp_role-run_id =  lv_run_id.                  "'1000000'.
*      ls_cvis_bp_role-data_key = 'FLVN00'." 'FLVN00'.
*      APPEND ls_cvis_bp_role TO lt_cvis_bp_role.
*      CLEAR ls_cvis_bp_role.
*
*      ls_cvis_supplier_general-object_task = lv_object_task.
*      ls_cvis_supplier_general-run_id =  lv_run_id.         "'1000000'.
*
*      ls_cvis_supplier_general-lifnr = ls_header-bpartner.
*
*      APPEND ls_cvis_supplier_general TO lt_cvis_supplier_general.
*      CLEAR ls_cvis_supplier_general.
*    ENDIF.

*    IF ls_header-idnumber IS NOT INITIAL.
*
*      ls_cvis_bp_ident_numbers-run_id =  lv_run_id.         "'1000000'.
*      ls_cvis_bp_ident_numbers-identificationcategory = 'BUP002'. "ID类型
*      ls_cvis_bp_ident_numbers-identificationnumber = ls_header-idnumber.
*
*      DO 2 TIMES.
*        REPLACE '-' INTO ls_header-bu_datefromstr_id WITH space.
*        CONDENSE ls_header-bu_datefromstr_id NO-GAPS.
*        REPLACE '-' INTO ls_header-bu_datetostr_id WITH space.
*        CONDENSE ls_header-bu_datetostr_id NO-GAPS.
*      ENDDO.
*      ls_cvis_bp_ident_numbers-idvalidfromdate = ls_header-bu_datefromstr_id.
*      ls_cvis_bp_ident_numbers-idvalidtodate = ls_header-bu_datetostr_id.
*      APPEND ls_cvis_bp_ident_numbers TO lt_cvis_bp_ident_numbers.
*      CLEAR ls_cvis_bp_ident_numbers.
*    ENDIF.

*    LOOP AT it_bank INTO ls_bank WHERE id = ls_header-id



*      AND bankl IS NOT INITIAL.
*      MOVE-CORRESPONDING ls_bank TO ls_zmmt00100.
*      lv_bkvid = lv_bkvid + 1.
*      CONDENSE lv_bkvid NO-GAPS.
*      lv_index = strlen( lv_bkvid ).
*      lv_index = 4 - lv_index.
*      DO lv_index TIMES.
*        lv_bkvid = '0' && lv_bkvid.
*      ENDDO.
*
*      ls_cvis_bp_bank_details-run_id =  lv_run_id.          "'1000000'.
*      ls_cvis_bp_bank_details-data_key = lv_bkvid.
*      IF ls_bank-banks IS INITIAL.
*        ls_cvis_bp_bank_details-bank_ctry = 'CN'.  "银行国家代码
*      ELSE.
*        ls_cvis_bp_bank_details-bank_ctry = ls_bank-banks.  "银行国家代码
*      ENDIF.
*
** ls_cvis_bp_bank_details- = ls_bank-BKDSC. "银行名称, 不用填
*      ls_cvis_bp_bank_details-bank_key = ls_bank-bankl.  "银行代码
*      ls_cvis_bp_bank_details-bank_acct = ls_bank-bankn.  "银行账号
*      IF strlen( ls_bank-bankn ) > 18.
*        ls_cvis_bp_bank_details-bank_ref = ls_bank-bankn+18(12).  "银行账号的参考明细
*      ENDIF.
*
*      ls_cvis_bp_bank_details-bankaccountname = ls_bank-accname."银行帐户的名称
*
*      APPEND ls_cvis_bp_bank_details TO lt_cvis_bp_bank_details.
*      ls_zmmt00100-bankn_1 = ls_bank-bankn.
*      APPEND ls_zmmt00100 TO lt_zmmt00100.
*      CLEAR:ls_zmmt00100, ls_cvis_bp_bank_details.
*    ENDLOOP.

    CALL FUNCTION 'RFC_CVI_EI_INBOUND_MAIN'
      EXPORTING
        iv_docommit             = 'X'
      TABLES
        it_bp_general           = lt_cvis_bp_general
        it_bp_role              = lt_cvis_bp_role
*       it_bp_tax_number        = lt_cvis_bp_tax_number
        it_bp_address_teleno    = lt_cvis_bp_address_teleno "电话号码
        it_bp_address_faxno     = lt_cvis_bp_address_faxno "传真号码
        it_bp_address_email     = lt_cvis_bp_address_email "邮箱号码
        it_bp_finserv           = lt_cvis_bp_finserv "分组字符
*       it_bp_ident_numbers     = lt_cvis_bp_ident_numbers
        it_cust_general         = lt_cvis_customer_general
        it_cust_company         = lt_cvis_customer_company "公司代码
        it_cust_sales           = lt_cvis_customer_sales "销售视图相关
        it_cust_sales_functions = lt_cvis_customer_sales_func  "伙伴功能
        it_cust_tax_indicator   = lt_cvis_customer_tax_indicator "销售视图税
*       it_sup_general          = lt_cvis_supplier_general
*       it_bp_bank_details      = lt_cvis_bp_bank_details
        it_bp_address           = lt_cvis_bp_address
        ct_return               = lt_cvis_bp_return.

    CLEAR ls_cvis_bp_return.
    LOOP AT lt_cvis_bp_return INTO ls_cvis_bp_return  WHERE type = 'E' OR type = 'A' .
      IF sy-subrc = 0.
        CONCATENATE ls_cvis_bp_return-message  sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                   INTO <fs_kunnr>-drjg.
        i_subruc = 1.
      ENDIF.
    ENDLOOP.

    IF  i_subruc = 0.

      IF lv_object_task = 'U'.  "修改BP.
        <fs_kunnr>-drjg = '修改成功'.
      ELSEIF lv_object_task = 'I'.  "创建BP.
        <fs_kunnr>-drjg = '创建成功'.
      ENDIF.
      ls_thead = <fs_kunnr>-kunnr.
      "长文本处理  税务登记证号
      IF <fs_kunnr>-swdjz IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-swdjz.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0001'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.

        IF sy-subrc <> 0.
          CONCATENATE '税务登记证号录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  商业登记号
      IF <fs_kunnr>-sydjh IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-sydjh.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0002'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '商业登记号录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  组织机构代码
      IF <fs_kunnr>-zzjgh IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-zzjgh.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0003'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '组织机构代码录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  社会统一信用代码
      IF <fs_kunnr>-xydmh IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-xydmh.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0004'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '社会统一信用代码失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  注册资本
      IF <fs_kunnr>-zczb IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-zczb.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0005'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.

          CONCATENATE '注册资本录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  注册时间
      IF <fs_kunnr>-zcsj IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-zcsj.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0006'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '注册时间录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.


      "长文本处理  对账日期
      IF <fs_kunnr>-dzrq IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-dzrq.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0007'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE   '对账日期录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  法定代表人
      IF <fs_kunnr>-fddbr IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-fddbr.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0008'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE  '法定代表人录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  法人身份证
      IF <fs_kunnr>-frsfz IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-frsfz.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0009'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE  '法人身份证录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  贸易伙伴
      IF <fs_kunnr>-myhb IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-myhb.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0010'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '贸易伙伴录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  经营范围
      IF <fs_kunnr>-jyfw IS NOT INITIAL.
        CLEAR:lt_line,ls_line.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-jyfw.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = '0011'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNA1'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '经营范围录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "长文本处理  客户风险警告
      IF <fs_kunnr>-zkhfxjg IS NOT INITIAL.
        CLEAR:lt_line,ls_line,ls_fxjg,ls_thead.

        ls_fxjg-kunnr = <fs_kunnr>-kunnr.
        ls_fxjg-vkorg = <fs_kunnr>-bukrs.
        ls_fxjg-vtweg = <fs_kunnr>-vtweg.
        ls_fxjg-spart =  '10'.

        ls_thead = ls_fxjg.

        ls_line-tdformat = '*' .
        ls_line-tdline   = <fs_kunnr>-zkhfxjg.
        APPEND ls_line TO lt_line.

        CALL FUNCTION 'CREATE_TEXT'
          EXPORTING
            fid         = 'Z001'
            flanguage   = sy-langu
            fname       = ls_thead
            fobject     = 'KNVV'
            save_direct = 'X'
*           FFORMAT     = '*'
          TABLES
            flines      = lt_line
          EXCEPTIONS
            no_init     = 1
            no_save     = 2
            OTHERS      = 3.
        IF sy-subrc <> 0.
          CONCATENATE '经营范围录入失败' <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg.
        ENDIF.
      ENDIF.

      "$. Region 信用段数据维护
      MOVE-CORRESPONDING <fs_kunnr> TO gs_out.
      PERFORM xinyongduan USING gs_out CHANGING return.
      LOOP AT  return INTO DATA(ls_return).
        CONCATENATE <fs_kunnr>-drjg ls_return-partner ls_return-msgty
        ls_return-msgv1 ls_return-msgv2 ls_return-msgv3
        ls_return-msgv4 ls_return-message INTO <fs_kunnr>-drjg.
      ENDLOOP.

      "$. Endregion 信用段数据维护

    ELSE.
*      ls_return-bp_number = ls_header-bpartner.
*      ls_return-type = 'E'.
      CONCATENATE '导入失败'  <fs_kunnr>-drjg INTO  <fs_kunnr>-drjg SEPARATED BY ':'.
      CLEAR i_subruc .
    ENDIF.

    REFRESH:lt_cvis_bp_general,
            lt_cvis_bp_role,
*            lt_cvis_bp_tax_number,
            lt_cvis_bp_address_teleno, "电话号码
            lt_cvis_bp_address_faxno, "传真号码
            lt_cvis_bp_address_email, "邮箱号码
            lt_cvis_bp_finserv, "分组字符
*            lt_cvis_bp_ident_numbers,
            lt_cvis_customer_general,
            lt_cvis_customer_company, "公司代码
            lt_cvis_customer_sales, "销售视图相关
            lt_cvis_customer_tax_indicator, "销售视图税
            lt_cvis_customer_sales_func,"伙伴功能
*            lt_cvis_supplier_general,
*            lt_cvis_bp_bank_details,
            lt_cvis_bp_address,
            lt_cvis_bp_return.
    CLEAR:lv_category, lv_bkvid,lv_index.


  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form XINYONGDUAN
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&      --> GS_OUT
*&      <-- RETURN
*&---------------------------------------------------------------------*
FORM xinyongduan USING p_gs_out TYPE ty_out
                  CHANGING p_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      =  p_gs_out-kunnr. "客户代码
  lv_credit_sgmnt =  p_gs_out-zxy2.     "信用段

  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      = ''. "风险类
  lwa_ukm_s_bp_cms-check_rule      = '01'. "检查规则
  lwa_ukm_s_bp_cms-limit_rule      = p_gs_out-zxy1."信用参数文件记分规则
*  lwa_ukm_s_bp_cms-rating_val_date = p_gs_out-zxy4.

  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     = p_gs_out-zxy3."信用额度
  lw_bp_credit_sgm-limit_valid_date = p_gs_out-zxy4.

  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 = p_return   ).


ENDFORM.

FORM frm_kunnr_alpha_input CHANGING cv_bpartner.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = cv_bpartner
    IMPORTING
      output = cv_bpartner.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form CONVERSION_EXIT_PARVW_INPUT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*d
*&      <-- LS_HEADER_PARVW
*&---------------------------------------------------------------------*
FORM conversion_exit_parvw_input CHANGING cv_parvw.

  CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
    EXPORTING
      input  = cv_parvw
    IMPORTING
      output = cv_parvw.

ENDFORM.

好了,分享使我快乐,我是寒武青锋!
在这里插入图片描述
记得点赞哟

### 回答1: 首先,您可以使用ABAP语言来编写一个程序,用于将物料数据批量导入系统。具体步骤如下: 1. 创建一个程序,设置输入和输出参数,并确定相应的数据结构。 2. 创建一个SQL语句,从Excel文件读取物料数据,并将其转换为ABAP内部表。 3. 使用ABAP指令将物料数据从内部表读取,并将其存储在系统。 4. 使用ABAP指令检查物料数据的正确性。 5. 将物料数据成功导入系统后,使用ABAP指令将其保存到相应的文件。 ### 回答2: 使用ABAP语言编写物料数据批量导入程序可以使用SAP内置的功能模块和数据对象来实现。 首先,我们可以创建一个ABAP报表程序,在其定义所需的变量和数据对象。例如,我们可以使用内置的数据对象LFA1来表示供应商数据,以及信息记录对象MAKT来表示物料描述。 接下来,我们可以使用内置的功能模块如BDC_OPEN_GROUP和BDC_INSERT来打开一个BDC(事务数据转换)会话组,并插入事务数据。 在导入过程,我们可以使用内置的函数模块如LSMW_OBJECT_READ、LSMW_DATA_READ和LSMW_DATA_WRITE来读取、处理和写入数据。 对于物料数据批量导入,我们可以先使用每个物料的一般信息(如物料号、物料类型、基本计量单位等)创建一个转换对象。然后,通过设置字段映射和转换规则来映射输入数据和SAP系统物料数据字段之间的关系。最后,将导入数据写入SAP系统。 在整个导入过程,我们可以使用内置的函数模块如BDC_CLOSE_GROUP来关闭BDC会话组,并提交数据。 另外,我们还可以使用BAPI_MATERIAL_SAVEDATA或BAPI_MATERIAL_MAINTAINDATA等内置的BAPI(业务应用编程接口)函数模块来实现物料数据批量导入。这些函数模块可以通过传递参数和结构体来实现物料数据的创建、修改和删除等操作。 总之,通过使用ABAP语言编写物料数据批量导入程序,我们可以利用SAP内置的功能模块和数据对象来实现高效、可靠和准确的物料数据导入。 ### 回答3: ABAP语言可以用来写一个物料数据批量导入的程序。 首先,我们可以利用ABAP数据导入技术,使用OPEN DATASET语句打开一个文本文件。然后,通过读取该文本文件的每一行,我们可以逐行解析物料数据的信息。在解析过程,我们可以使用字符串操作函数和正则表达式来提取需要的字段,如物料编码、物料描述、价格等。 接下来,我们可以使用INSERT语句将解析到的物料数据插入到物料数据。在插入之前,我们可以使用SELECT语句检查物料数据是否已存在相同的物料编码,以避免重复插入。 除了插入物料数据,我们还可以在导入过程进行一些额外的逻辑处理。例如,我们可以使用条件语句判断物料数据是否符合一些特定条件,如价格是否大于一定阈值、描述是否包含特定关键词等。根据判断的结果,我们可以选择不插入或者标记异常的物料数据。 在导入完成后,我们可以关闭文本文件,并进行一些后续处理。例如,我们可以输出导入结果的日志信息,统计成功和失败的记录数等数据。此外,我们还可以将导入结果保存到一个报表或者发送邮件给相关人员。 综上所述,使用ABAP语言编写一个物料数据批量导入的程序可通过数据导入、解析、插入和逻辑处理等步骤完成,同时可以进行后续处理和结果输出。这样的程序可以大大提高物料数据导入的效率和准确性。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值