CRM 员工创建并分配用户
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 员工创建并分配用户的更多相关文章
- Oracle同义词创建及分配用户创建同义词权限
(1)--授权某个用户crate synonym的权限,若用户名为scott grant create synonym to scott(2)--创建同义词 create [or replace] s ...
- C4C和CRM里获取当前登录用户分配的Organization Unit信息
C4C 如何查看某个用户分配的组织单元ID: 在Employee的Organization Data区域内看到分配的组织名称,如下图红色下划线所示: 现在的需求就是使用ABSL获取当前登录用户分配的O ...
- SQLServer创建用户自定义数据库用户
创建用户自定义数据库用户注意事项 如果已忽略 FOR LOGIN,则新的数据库用户将被映射到同名的SQL Server登录名. 默认架构将是服务器为此数据库用户解析对象名时将搜索的第一个架构. 除非另 ...
- MySQL创建数据库与用户
root远程访问授权 mysql> SHOW DATABASES; +--------------------+ | Database | +---------------- ...
- Oracle18C安装后首次创建数据库并用sql developer 创建连接和用户
注意: SQL Developer 不能用于创建Oracle数据库,只能用来连接已经创建的数据库,数据库的建立要通过Database Configuration Assistant(DBCA)来完成. ...
- 使用PLSQL 创建Oracle数据库用户并设置权限
转至https://blog.csdn.net/ying890/article/details/14083029?utm_medium=distribute.pc_relevant_download. ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(27)-权限管理系统-分配用户给角色
系列目录 分配用户给角色,跟分配角色给用户操作是基本一致的. 打开模块维护,展开SysRole模块添加一个操作码,并赋予权限 设置好之后将权限授权给管理员,在SysRole的index添加操作码与js ...
- 批量创建10个用户stu01-stu10
1.批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell循环(例如:for,while等),只能用命令及管道实现. ##方法1: [root@server tmp]# ...
- Linux 创建修改删除用户和组
200 ? "200px" : this.width)!important;} --> 介绍 在日常的维护过程中创建用户操作用的相对会多一些,但是在这个过程中涉及到的知识点就 ...
随机推荐
- Oracle生成GUID
,),),),),) GUID FROM ( SELECT SYS_GUID() GUID FROM DUAL )
- wpf中插入winform控件并获取句柄
因工作需要使用wpf做界面,而有个开发包依赖picturebox控件,上网研究了一下,总算弄通了. 首先在项目中添加引用System.Windows.Forms与WindowsFormsIntegra ...
- java面向对象总结(一)
1. 对象的概念及面向对象的三个基本特征 面向对象的三大核心特性 面向对象开发模式更有利于人们开拓思维,在具体的开发过程中便于程序的划分,方便程序员分工合作,提高开发效率.面向对象程序设计有以下优点. ...
- 【shell】awk按域去除重复行
首先解释一下什么叫“按域去除重复行”: 有的时候我们需要去除的重复行并不是整行都重复,两行的其中一列的元素相同我们有的时候就需要认定这两行重复,因此有了今天的内容. 去除重复行shell有一个原生命令 ...
- Windows环境下最新OpenCV和Contribute代码的联合编译【20180926更新红字】
解决这个问题,目的在于获得并使用最新的完全版本的代码,主要方法是对CMake能够熟练使用,并且对编译等基础支持有所了解. 因为这篇博客经过多次修改,所以里面的内容和配图可能有不是完全比对的地方,但是只 ...
- CEF 支持的命令行参数
参考:https://peter.sh/experiments/chromium-command-line-switches/ List of Chromium Command Line Switch ...
- IDEA上的项目托管到码云步骤
IDEA上的项目托管到码云步骤:1.安装Git2.idea上配置Git Setting-Version Control-Git 把git.exe改为安装的Git的执行路径如:D:\Prog ...
- 02_计算机网络的OSI七层(应表会传网数物)
七层: 应用层 表示层 会话层 传输层 网络层 数据链路层 物理层 五层: 应用层 传输层 网络层 数据链路层 物理层 四层: 应用层 传输层 网络层 数据接口层 一.物理层(Physical Lay ...
- NPOI 的使用姿势
NPOI 正确的使用姿势 主要是需要注意公式和日期类型的单元格的读取. /// <summary> /// 打开指定 Excel 文件 /// </summary> /// & ...
- vue踩坑记
vue踩坑记 易错点 语法好难啊qwq 不要把'data'写成'date' 在v-html/v-bind中使用vue变量时不需要加变量名 在非vue事件中使用vue中变量时需要加变量名 正确 < ...