REPORT zjp_emp_upload.
TABLES: sscrfields.
DATA:gt_excel_data TYPE TABLE OF zalsmex_tabline,
gs_excel_data TYPE zalsmex_tabline.
DATA: lv_filename TYPE string,
lt_file_table TYPE filetable,
gv_error TYPE flag,
gv_fail_flag TYPE flag,
gv_title TYPE lvc_title,
lv_rc TYPE i.
DATA: gt_zcrms0083 TYPE TABLE OF zcrms0083,
gs_zcrms0083 TYPE zcrms0083. DATA lt_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
DATA lt_output TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE. DATA: centraldataperson TYPE bapibus1006_central_person.
DATA: addressdata TYPE bapibus1006_address.
DATA: it_telefondata TYPE STANDARD TABLE OF bapiadtel,
wa_telefondata TYPE bapiadtel.
DATA: it_email TYPE STANDARD TABLE OF bapiadsmtp,
wa_email TYPE bapiadsmtp.
DATA: centraldata TYPE bapibus1006_central.
DATA: l_bpartner TYPE bu_partner,
l_partner_guid TYPE bapibus1006_head-partnguid,
l_guid_16 TYPE bu_partner_guid. *****************************alv
DATA: g_program TYPE syrepid VALUE sy-repid,
gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_fieldcat TYPE slis_fieldcat_alv,
gt_event TYPE slis_t_event,
gs_event TYPE slis_alv_event.
DATA lr_grid TYPE REF TO cl_gui_alv_grid.
*----------------------------------------------------------------------*
* MARCO DEFINE
*----------------------------------------------------------------------* DEFINE add_fieldcat.
clear gs_fieldcat.
gs_fieldcat-fieldname = & .
gs_fieldcat-seltext_m = & .
gs_fieldcat-outputlen = & .
append gs_fieldcat to gt_fieldcat.
END-OF-DEFINITION. SELECTION-SCREEN: FUNCTION KEY . PARAMETERS : f_name LIKE rlgrap-filename.
*PARAMETERS : f_land LIKE adrc-country DEFAULT 'JP' OBLIGATORY. INITIALIZATION. DATA: functxt TYPE smp_dyntxt.
functxt-icon_id = icon_export.
functxt-quickinfo = 'Template Export'.
functxt-icon_text = 'Template Export'.
sscrfields-functxt_01 = functxt. AT SELECTION-SCREEN OUTPUT. START-OF-SELECTION. IF f_name IS INITIAL.
MESSAGE 'Filename is null' TYPE 'S' DISPLAY LIKE 'E' .
RETURN.
ENDIF.
PERFORM frm_upload_excel_file.
CHECK gv_error IS INITIAL.
PERFORM frm_make_alv_fieldcat.
PERFORM frm_set_alv_layout.
PERFORM frm_display_data
TABLES
gt_zcrms0083
USING
gv_title 'ZEMP_STATUS' 'ZEMP_UCOMM'. AT SELECTION-SCREEN . *下载模板
CASE sscrfields-ucomm.
WHEN 'FC01'.
CALL FUNCTION 'ZCRM_DOWNLOAD_TEMPLATE'
EXPORTING
iv_objid = 'ZJP_EMP'
iv_filename = 'TVS Employee Upload Template'
iv_flag = 'X'.
WHEN OTHERS.
ENDCASE. AT SELECTION-SCREEN ON VALUE-REQUEST FOR f_name.
* Call popup for selecting the file
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_file_table
rc = lv_rc
EXCEPTIONS
file_open_dialog_failed =
cntl_error =
error_no_gui =
not_supported_by_gui =
OTHERS = . READ TABLE lt_file_table INTO lv_filename INDEX .
IF sy-subrc <> .
MESSAGE 'Fail to get FileName' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ELSE.
f_name = lv_filename.
ENDIF. *&---------------------------------------------------------------------*
*& Form FRM_UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_upload_excel_file . FIELD-SYMBOLS: <fs_excel> TYPE any,
<fs_field> TYPE any,
<fs_extract> TYPE any.
DATA: lv_count TYPE i VALUE ,
lv_pos TYPE i,
lv_str TYPE string,
lv_cnt TYPE i,
lv_edmk TYPE string,
lv_type TYPE string. * DATA: lt_crm0007 LIKE TABLE OF gw_crm0007.
REFRESH gt_excel_data.
CALL FUNCTION 'ZEXCEL_UPLOAD'
EXPORTING
filename = f_name
i_begin_col = '' "开始的列
i_begin_row = '' "开始的行
i_end_col = '' "结束的列
i_end_row = ''
TABLES
intern = gt_excel_data
EXCEPTIONS
inconsistent_parameters =
upload_ole =
OTHERS = . IF sy-subrc <> .
MESSAGE 'Upload Failed' TYPE 'S' DISPLAY LIKE 'E' .
RETURN .
ENDIF.
*解析excel导入的数据 写进内表 PERFORM frm_make_gt_upload TABLES gt_zcrms0083.
* CHECK gv_error IS INITIAL.
* PERFORM process_data. IF gt_zcrms0083[] IS INITIAL.
MESSAGE 'Excel date is null' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF. ENDFORM. " FRM_UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
*& Form FRM_MAKE_GT_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_make_gt_upload TABLES cv_tab TYPE table. DATA lv_fieldvalue TYPE fieldvalue. "字符值
DATA lv_fldname TYPE fieldname. "字段名
DATA lo_exception TYPE REF TO cx_root.
DATA lv_col TYPE i.
DATA lr_line TYPE REF TO data.
FIELD-SYMBOLS: <fs_field>,<line>.
CLEAR gv_error.
SORT gt_excel_data BY row col. CREATE DATA lr_line LIKE LINE OF cv_tab.
ASSIGN lr_line->* TO <line>. TRY .
LOOP AT gt_excel_data INTO gs_excel_data.
AT NEW row.
CLEAR <line>.
ENDAT.
lv_fieldvalue = gs_excel_data-value.
CONDENSE lv_fieldvalue NO-GAPS. ASSIGN COMPONENT gs_excel_data-col OF STRUCTURE <line> TO <fs_field>.
IF sy-subrc = .
<fs_field> = lv_fieldvalue.
ENDIF.
AT END OF row.
APPEND <line> TO cv_tab.
ENDAT.
ENDLOOP.
CATCH cx_root INTO lo_exception. CALL METHOD lo_exception->if_message~get_text
RECEIVING
result = gv_error. CONCATENATE gv_error ' Please Check import data'
INTO gv_error.
MESSAGE gv_error TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDTRY. ENDFORM. " FRM_MAKE_GT_UPLOAD
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_MAKE_ALV_FIELDCAT
*&---------------------------------------------------------------------*
* 设置ALV fieldcat
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_make_alv_fieldcat .
add_fieldcat:
'ICON' 'ICON' ,
'PARTNER' 'Business Partner' ,
'TITLE' 'Tittle' ,
'NAME_LAST' 'Last Name' ,
'NAME_FIRST' 'First Name' ,
'TEL_NUMBER' 'Tel Number' ,
'MOB_NUMBER' 'Mob Number' ,
'E_MAIL' 'Email' ,
'USERNAME' 'SAP User ID' ,
'COUNTRY' 'Country' ,
'REGION' 'Region' ,
'CITY1' 'City' ,
'POST_CODE1' 'Postal Code' ,
'MESSAGE' 'Error Message' . ENDFORM. " FRM_MAKE_ALV_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FRM_SET_ALV_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_set_alv_layout . CLEAR: gv_title,gs_layout.
gs_layout-zebra = 'X'. ENDFORM. " FRM_SET_ALV_LAYOUT
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_display_data TABLES it_tab USING iv_title TYPE lvc_title
iv_pf_status TYPE slis_formname
iv_user_comm TYPE slis_formname . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = iv_pf_status
i_callback_user_command = iv_user_comm
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_GRID_SETTINGS =
is_layout = gs_layout
it_fieldcat = gt_fieldcat
i_grid_title = iv_title
* IT_SORT =
* IT_FILTER =
* I_SAVE = ' '
* IS_VARIANT =
TABLES
t_outtab = it_tab[]
EXCEPTIONS
program_error =
OTHERS = .
ENDFORM. " FRM_DISPLAY_DATA
*&---------------------------------------------------------------------*
*& Form UCOMM_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IV_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM zemp_ucomm USING iv_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE iv_ucomm.
WHEN 'BACK' OR 'CANCEL' .
LEAVE TO SCREEN .
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'SAVE'.
PERFORM process_data. WHEN OTHERS.
ENDCASE.
ENDFORM. "UCOMM_UPLOAD
*&---------------------------------------------------------------------*
*& Form STATUS_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM zemp_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZEMP_STATUS' .
ENDFORM. "STATUS_UPLOAD
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_data .
LOOP AT gt_zcrms0083 INTO gs_zcrms0083.
CLEAR centraldata.
centraldata-title_key = gs_zcrms0083-title. "TITLE CLEAR: lt_return .
CLEAR:centraldataperson.
centraldataperson-firstname = gs_zcrms0083-name_first. "First Name
centraldataperson-lastname = gs_zcrms0083-name_last. "Last Name CLEAR:addressdata.
addressdata-postl_cod1 = gs_zcrms0083-post_code1 . "postal
addressdata-country = gs_zcrms0083-country . "county
addressdata-city = gs_zcrms0083-city1 . "city
addressdata-region = gs_zcrms0083-region . CLEAR:it_telefondata,wa_telefondata.
wa_telefondata-telephone = gs_zcrms0083-tel_number.
wa_telefondata-r_3_user = ''.
* wa_telefondata-country = f_land. "telephone
APPEND wa_telefondata TO it_telefondata.
wa_telefondata-telephone = gs_zcrms0083-mob_number.
wa_telefondata-r_3_user = ''.
* wa_telefondata-country = f_land. "MOBphone
APPEND wa_telefondata TO it_telefondata. CLEAR:it_email,wa_email.
wa_email-e_mail = gs_zcrms0083-e_mail. "E-Mail
APPEND wa_email TO it_email. CLEAR:lt_return,l_bpartner.
CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'
EXPORTING
partnercategory = ''
partnergroup = 'Z002'
centraldata = centraldata
centraldataperson = centraldataperson
addressdata = addressdata
* DUPLICATE_MESSAGE_TYPE =
* ACCEPT_ERROR = ' '
IMPORTING
businesspartner = l_bpartner
TABLES
telefondata = it_telefondata
e_maildata = it_email
return = lt_return. READ TABLE lt_return WITH KEY type = 'E'.
IF sy-subrc <> .
CLEAR lt_return.
CALL FUNCTION 'BUPA_ROLE_ADD_2'
EXPORTING
iv_partner = l_bpartner
* IV_PARTNER_GUID =
* IV_PARTNERROLECATEGORY =
* iv_x_all_partnerroles =
iv_partnerrole = 'BUP003'
* IV_DIFFTYPEVALUE =
* IV_VALIDFROM =
* IV_VALIDTO = '99991231'
* IV_X_SAVE = 'X'
* IV_CREATE_CP =
TABLES
et_return = lt_return. READ TABLE lt_return WITH KEY type = 'E'.
IF sy-subrc <> .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'. gs_zcrms0083-icon = '@5B@'.
gs_zcrms0083-partner = l_bpartner. CLEAR: l_partner_guid,l_guid_16.
CALL FUNCTION 'BAPI_BUPA_GET_NUMBERS'
EXPORTING
businesspartner = l_bpartner
IMPORTING
businesspartnerguidout = l_partner_guid. l_guid_16 = l_partner_guid.
CALL FUNCTION 'BP_BUPA_CREATECENTRALPERSON'
EXPORTING
iv_bu_partner_guid = l_guid_16
* IV_NAME =
* IV_EMPLOYEE_ID =
iv_user_id = gs_zcrms0083-username
* IV_NO_COMMIT = ' '
* IV_ASYNCHRON = ' '
* IV_BUFFER_MODE = ' '
* IS_BUS000 =
* IMPORTING
* EV_PERSON_ID =
EXCEPTIONS
buffer_mode_not_allowed =
OTHERS = .
IF sy-subrc <> .
gv_fail_flag = 'X'.
gs_zcrms0083-icon = '@5C@'.
gs_zcrms0083-message = 'Assign Username Failed'.
ENDIF.
ELSE.
gv_fail_flag = 'X'.
gs_zcrms0083-icon = '@5C@'.
gs_zcrms0083-message = lt_return-message.
ENDIF.
ELSE.
gv_fail_flag = 'X'.
gs_zcrms0083-icon = '@5C@'.
gs_zcrms0083-message = lt_return-message.
ENDIF. MODIFY gt_zcrms0083 FROM gs_zcrms0083.
ENDLOOP. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid. CALL METHOD lr_grid->refresh_table_display
EXCEPTIONS
finished =
OTHERS = . IF gv_fail_flag IS INITIAL.
MESSAGE 'All Record Create Successfully' TYPE 'S'.
ENDIF.
ENDFORM.

CRM 员工创建并分配用户的更多相关文章

  1. Oracle同义词创建及分配用户创建同义词权限

    (1)--授权某个用户crate synonym的权限,若用户名为scott grant create synonym to scott(2)--创建同义词 create [or replace] s ...

  2. C4C和CRM里获取当前登录用户分配的Organization Unit信息

    C4C 如何查看某个用户分配的组织单元ID: 在Employee的Organization Data区域内看到分配的组织名称,如下图红色下划线所示: 现在的需求就是使用ABSL获取当前登录用户分配的O ...

  3. SQLServer创建用户自定义数据库用户

    创建用户自定义数据库用户注意事项 如果已忽略 FOR LOGIN,则新的数据库用户将被映射到同名的SQL Server登录名. 默认架构将是服务器为此数据库用户解析对象名时将搜索的第一个架构. 除非另 ...

  4. MySQL创建数据库与用户

    root远程访问授权 mysql> SHOW DATABASES; +--------------------+ | Database           | +---------------- ...

  5. Oracle18C安装后首次创建数据库并用sql developer 创建连接和用户

    注意: SQL Developer 不能用于创建Oracle数据库,只能用来连接已经创建的数据库,数据库的建立要通过Database Configuration Assistant(DBCA)来完成. ...

  6. 使用PLSQL 创建Oracle数据库用户并设置权限

    转至https://blog.csdn.net/ying890/article/details/14083029?utm_medium=distribute.pc_relevant_download. ...

  7. ASP.NET MVC5+EF6+EasyUI 后台管理系统(27)-权限管理系统-分配用户给角色

    系列目录 分配用户给角色,跟分配角色给用户操作是基本一致的. 打开模块维护,展开SysRole模块添加一个操作码,并赋予权限 设置好之后将权限授权给管理员,在SysRole的index添加操作码与js ...

  8. 批量创建10个用户stu01-stu10

    1.批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell循环(例如:for,while等),只能用命令及管道实现. ##方法1: [root@server tmp]# ...

  9. Linux 创建修改删除用户和组

    200 ? "200px" : this.width)!important;} --> 介绍 在日常的维护过程中创建用户操作用的相对会多一些,但是在这个过程中涉及到的知识点就 ...

随机推荐

  1. sql server导出数据,本地数据库远程连接不上,怎样设置防火墙(自用)

    控制面板——>系统安全——>windows防火墙——>高级设置 新建入站规则: 将一下两个应用 允许入站: D:\Program Files (x86)\Microsoft SQL ...

  2. C# 弹出确定、取消窗口

    if (MessageBox.Show("确定要退出吗?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Qu ...

  3. 【JavaScript】数组

    [声明一个数组]var a=[1,1,1]; [定义数组的长度]var a=new Array(2); [特殊数组]arguments[0][可以不用声明,当数组内没有东西时可以直接通过方法的参数自动 ...

  4. Redis的持久化

    Redis的持久化有两种方式: RDB方式(默认支持):在指定的时间间隔内将内存中的数据集快照写入磁盘 优势 整个Redis数据库将只包含一个文件,对于文件备份来说是完美的,系统出现灾难性的故障时容易 ...

  5. mysql 批量导入

    load data LOCAL infile 'D:/user.txt' into table userssFIELDS TERMINATED BY ',' LINES TERMINATED BY ' ...

  6. 博客地址更改为csdn博客:https://blog.csdn.net/zysps1

    由于博客园不支持markdown的数学公式等语法,有时分享不方便,特更改阵地为csdn:https://blog.csdn.net/zysps1

  7. java0426 wen IO2

  8. 3、SpringBoot 集成Storm wordcount

    WordCountBolt public class WordCountBolt extends BaseBasicBolt { private Map<String,Integer> c ...

  9. 基于OpenCV做“三维重建”(3)--相机参数矩阵

    通过前面的相机标定,我们能够获得一些参数模型.但是这些相机的参数矩阵到底是什么意思?怎样才能够判断是否正确?误差都会来自哪里?这里就必须要通过具体实验来加深认识.采集带相机参数的图片具有一定难度,幸好 ...

  10. 单元测试系列之十一:Jmockit之mock特性详解

    本文是Jmockit学习过程中,根据官网所列的工具特性进行解读. 1.调用次数约束(Invocation count constraints) 可以通过调用计数约束来指定预期和/或允许匹配给定期望的调 ...