*&---------------------------------------------------------------------*
*& Report ZUJE_MASS_USER_MGMT
*&
*&---------------------------------------------------------------------*
*& Created By: Rich Heilman SAP Labs, LLC
*& Modified By: James Lim SAP Americas
*& Created On: 08/2/2010
*& Modified On: 12/6/2013
*&---------------------------------------------------------------------*
REPORT ZUJE_MASS_USER_DELETE.
TYPE-POOLS: abap, vrm.
*----------------------------------------------------------------------*
* CLASS lcl_application DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_application DEFINITION FINAL.
PUBLIC SECTION.
CONSTANTS: lc_comma TYPE char01 VALUE ',',
lc_pipe TYPE char01 VALUE '|',
lc_tab TYPE char10 VALUE 'TAB'.
TYPES: BEGIN OF t_appldim,
appl_id TYPE uj_appl_id,
dimension TYPE uj_dim_name,
END OF t_appldim.
TYPES: BEGIN OF t_appldimmembers,
appl_id TYPE uj_appl_id,
dimension TYPE uj_dim_name,
member TYPE uj_dim_member,
END OF t_appldimmembers.
CLASS-METHODS: file_f4 RETURNING value(r_file) TYPE string,
directory_f4 RETURNING value(r_path) TYPE string,
get_initial_directory RETURNING value(r_path) TYPE string,
set_delimiter_listbox,
set_delimiter,
export_users_to_file,
import_users_from_file,
export_teams_to_file,
import_teams_from_file,
export_team_assign_to_file,
import_team_assign_from_file,
export_task_profiles_to_file,
import_task_profiles_from_file,
export_mem_profiles_to_file,
import_mem_profiles_from_file,
export_tap_assign_to_file,
import_tap_assign_from_file,
export_map_assign_to_file,
import_map_assign_from_file,
delete_users_from_file,
delete_teams_from_file,
delete_task_profiles_from_file, "TSK
delete_mem_profiles_from_file, "MBR
get_bpc_component_version,
get_appset_data IMPORTING i_appset_id TYPE uj_appset_id
EXCEPTIONS appset_not_found .
PRIVATE SECTION.
CLASS-DATA: lv_appset_id TYPE uja_s_appset_info-appset_id.
CLASS-DATA: lv_delimiter TYPE string.
CLASS-DATA: lv_release TYPE saprelease.
CLASS-DATA: lv_splevel TYPE sappatchlv.
CLASS-DATA: ls_appset_info TYPE uja_s_appset_info.
CLASS-DATA: lt_appl_info TYPE uja_t_appl_info.
CLASS-DATA: lt_appl_dim TYPE TABLE OF t_appldim.
CLASS-DATA: lt_members TYPE TABLE OF t_appldimmembers.
CLASS-DATA: lt_teams_list TYPE uje_t_team.
CLASS-DATA: lt_users_list TYPE uje_t_user.
CLASS-DATA: lt_tprofs TYPE uje_t_api_profile_id.
CLASS-DATA: lt_mprofs TYPE uje_t_api_profile_id.
CLASS-DATA: lt_mprofs_tmp TYPE uje_t_profile.
CLASS-DATA: lt_tasks TYPE uje_t_role_tskasg.
CLASS-DATA: lt_roles TYPE uje_t_role.
CLASS-DATA: lo_context TYPE REF TO if_uj_context.
CLASS-DATA: lt_alv_messages TYPE uj0_t_message.
CLASS-METHODS: set_global_context,
render_alv,
upload IMPORTING i_filepath TYPE any
RETURNING value(rt_strtab) TYPE stringtab,
download IMPORTING i_filepath TYPE any
it_datatab TYPE STANDARD TABLE,
user_is_valid IMPORTING i_user_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
team_is_valid IMPORTING i_team_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
tprofile_is_valid IMPORTING i_profile_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
mprofile_is_valid IMPORTING i_profile_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
role_is_valid IMPORTING i_role_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool,
task_is_valid IMPORTING i_task_id TYPE any
RETURNING value(r_boolean) TYPE abap_bool.
ENDCLASS. "lcl_application DEFINITION
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_export RADIOBUTTON GROUP grp1 DEFAULT 'X' USER-COMMAND chk.
PARAMETERS: p_import RADIOBUTTON GROUP grp1.
PARAMETERS: p_delete RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_appset TYPE uja_appset_info-appset_id.
PARAMETERS: p_file TYPE string LOWER CASE.
PARAMETERS: p_delmt TYPE char10 AS LISTBOX VISIBLE LENGTH 20
DEFAULT lcl_application=>lc_comma. "delimiter
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_eusers RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_eteams RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_eteama RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_etprof RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_emprof RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_etprfa RADIOBUTTON GROUP grp2 MODIF ID exp.
PARAMETERS: p_emprfa RADIOBUTTON GROUP grp2 MODIF ID exp.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.
PARAMETERS: p_iusers RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_iteams RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_iteama RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_itprof RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_improf RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_itprfa RADIOBUTTON GROUP grp3 MODIF ID imp.
PARAMETERS: p_imprfa RADIOBUTTON GROUP grp3 MODIF ID imp.
SELECTION-SCREEN END OF BLOCK b4.
SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-005.
PARAMETERS: p_dusers RADIOBUTTON GROUP grp4 MODIF ID del.
PARAMETERS: p_dteams RADIOBUTTON GROUP grp4 MODIF ID del.
PARAMETERS: p_dtprof RADIOBUTTON GROUP grp4 MODIF ID del.
PARAMETERS: p_dmprof RADIOBUTTON GROUP grp4 MODIF ID del.
SELECTION-SCREEN END OF BLOCK b5.
INITIALIZATION.
p_file = lcl_application=>get_initial_directory( ).
lcl_application=>set_delimiter_listbox( ).
lcl_application=>get_bpc_component_version( ).
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF p_export = abap_true.
IF screen-group1 = 'IMP' OR screen-group1 = 'DEL'.
screen-active = '0'.
ENDIF.
ENDIF.
IF p_import = abap_true.
IF screen-group1 = 'EXP' OR screen-group1 = 'DEL'.
screen-active = '0'.
ENDIF.
ENDIF.
IF p_delete = abap_true.
IF screen-group1 = 'IMP' OR screen-group1 = 'EXP'.
screen-active = '0'.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
AT SELECTION-SCREEN.
CASE abap_true.
WHEN p_export.
CLEAR: p_iusers, p_iteams, p_iteama, p_itprof,
p_improf, p_itprfa, p_imprfa,
p_dusers, p_dteams, p_dtprof,p_dmprof.
WHEN p_import.
CLEAR: p_eusers, p_eteams, p_eteama, p_etprof,
p_emprof, p_etprfa, p_emprfa,
p_dusers, p_dteams, p_dtprof,p_dmprof.
WHEN p_delete.
CLEAR: p_eusers, p_eteams, p_eteama, p_etprof,
p_emprof, p_etprfa, p_emprfa,
p_iusers, p_iteams, p_iteama, p_itprof,
p_improf, p_itprfa, p_imprfa.
ENDCASE.
IF sy-ucomm <> 'CHK'.
IF p_appset IS INITIAL.
MESSAGE e001(00) WITH 'Please enter an AppSet Id'.
ENDIF.
IF p_file IS INITIAL.
MESSAGE e001(00) WITH 'Please enter a valid directory or file'.
ENDIF.
IF p_delmt IS INITIAL.
MESSAGE e001(00) WITH 'Please specify a delimiter'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CASE abap_true.
WHEN p_export. p_file = lcl_application=>directory_f4( ).
WHEN p_import. p_file = lcl_application=>file_f4( ).
WHEN p_delete. p_file = lcl_application=>file_f4( ). "import and delete based on file
ENDCASE.
START-OF-SELECTION.
lcl_application=>set_delimiter( ).
lcl_application=>get_appset_data(
EXPORTING
i_appset_id = p_appset
EXCEPTIONS
appset_not_found = 1 ).
IF sy-subrc <> 0.
RETURN.
ENDIF.
CASE abap_true.
WHEN p_eusers. lcl_application=>export_users_to_file( ).
WHEN p_iusers. lcl_application=>import_users_from_file( ).
WHEN p_eteams. lcl_application=>export_teams_to_file( ).
WHEN p_iteams. lcl_application=>import_teams_from_file( ).
WHEN p_eteama. lcl_application=>export_team_assign_to_file( ).
WHEN p_iteama. lcl_application=>import_team_assign_from_file( ).
WHEN p_etprof. lcl_application=>export_task_profiles_to_file( ).
WHEN p_itprof. lcl_application=>import_task_profiles_from_file( ).
WHEN p_emprof. lcl_application=>export_mem_profiles_to_file( ).
WHEN p_improf. lcl_application=>import_mem_profiles_from_file( ).
WHEN p_etprfa. lcl_application=>export_tap_assign_to_file( ).
WHEN p_itprfa. lcl_application=>import_tap_assign_from_file( ).
WHEN p_emprfa. lcl_application=>export_map_assign_to_file( ).
WHEN p_imprfa. lcl_application=>import_map_assign_from_file( ).
" for delete functions
WHEN p_dusers. lcl_application=>delete_users_from_file( ).
WHEN p_dteams. lcl_application=>delete_teams_from_file( ).
WHEN p_dtprof. lcl_application=>delete_task_profiles_from_file( ).
WHEN p_dmprof. lcl_application=>delete_mem_profiles_from_file( ).
ENDCASE.
*----------------------------------------------------------------------*
* CLASS lcl_application IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION.
METHOD file_f4.
DATA: lt_file_table TYPE filetable.
DATA: ls_file_table LIKE LINE OF lt_file_table.
DATA: lv_rc TYPE sy-subrc.
cl_gui_frontend_services=>file_open_dialog(
CHANGING
file_table = lt_file_table
rc = lv_rc ).
CLEAR ls_file_table .
READ TABLE lt_file_table INTO ls_file_table INDEX 1.
IF sy-subrc = 0.
r_file = ls_file_table-filename.
ENDIF.
ENDMETHOD. "file_f4
METHOD directory_f4.
cl_gui_frontend_services=>directory_browse(
CHANGING
selected_folder = r_path
EXCEPTIONS
OTHERS = 4 ).
ENDMETHOD. "directory_f4
METHOD upload.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = i_filepath
CHANGING
data_tab = rt_strtab
EXCEPTIONS
OTHERS = 19 ).
IF sy-subrc <> 0.
MESSAGE e001(00) WITH 'File not found, check file path and name'.
ENDIF.
DELETE rt_strtab WHERE table_line IS INITIAL.
ENDMETHOD. "upload
METHOD download.
DATA: lt_datatab TYPE stringtab.
DATA: ls_datatab LIKE LINE OF lt_datatab.
FIELD-SYMBOLS: <ls_data> TYPE ANY.
FIELD-SYMBOLS: <lv_field> TYPE ANY.
* Convert table to delimited string table
LOOP AT it_datatab ASSIGNING <ls_data>.
CLEAR ls_datatab.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <ls_data> TO <lv_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF ls_datatab IS INITIAL.
ls_datatab = <lv_field>.
ELSE.
CONCATENATE ls_datatab <lv_field>
INTO ls_datatab SEPARATED BY lcl_application=>lv_delimiter.
ENDIF.
ENDDO.
APPEND ls_datatab TO lt_datatab.
ENDLOOP.
cl_gui_frontend_services=>gui_download(
EXPORTING
filename = i_filepath
CHANGING
data_tab = lt_datatab
EXCEPTIONS
OTHERS = 24 ).
IF sy-subrc <> 0.
MESSAGE e001(00)
WITH 'File not downloaded, check file path and name'.
ENDIF.
ENDMETHOD. "download
METHOD get_initial_directory.
cl_gui_frontend_services=>get_desktop_directory(
CHANGING
desktop_directory = r_path ).
cl_gui_cfw=>flush( ).
CONCATENATE r_path '\*.csv' INTO r_path.
ENDMETHOD. "get_initial_directory
METHOD export_users_to_file.
TYPES: BEGIN OF t_output,
user_id TYPE uje_user-user_id,
fullname TYPE uje_user-fullname,
email TYPE uje_user-email,
END OF t_output.
DATA: lt_user_id TYPE uje_t_api_user_id.
DATA: lt_users TYPE uje_t_user.
DATA: ls_users LIKE LINE OF lt_users.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
lcl_application=>set_global_context( ).
CALL FUNCTION 'UJE_API_GET_LIST_USERS'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
it_user_id = lt_user_id
IMPORTING
et_user = lt_users.
REFRESH lt_output.
LOOP AT lt_users INTO ls_users.
MOVE-CORRESPONDING ls_users TO ls_output.
APPEND ls_output TO lt_output.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_users_to_file
METHOD import_users_from_file.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: ls_user_info TYPE uje_s_userinfo.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_team_asin TYPE uje_t_user_team.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_user_info-user_id
ls_user_info-fullname
ls_user_info-email.
* Check if user already exists, and set action accordingly.
IF lcl_application=>user_is_valid( ls_user_info-user_id ) = abap_false.
lv_action = 'I'.
ELSE.
lv_action = 'M'.
ENDIF.
CALL FUNCTION 'UJE_API_MANAGE_USER2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_user_info = ls_user_info
i_action = lv_action
it_team_asin = lt_team_asin
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User ID' ls_user_info-user_id
'has been created/updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User ID' ls_user_info-user_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "create_users_from_file
METHOD delete_users_from_file.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: ls_user_info TYPE uje_s_userinfo.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_team_asin TYPE uje_t_user_team.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_user_info-user_id
ls_user_info-fullname
ls_user_info-email.
CALL FUNCTION 'UJE_API_DELETE_USER'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_user_id = ls_user_info-user_id
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User ID' ls_user_info-user_id
'has been removed successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User ID' ls_user_info-user_id
'could not be removed due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "delete_users_from_file
METHOD export_teams_to_file.
TYPES: BEGIN OF t_output,
team_id TYPE uje_s_team-team_id,
description TYPE uje_s_team-description,
END OF t_output.
DATA: lt_teams TYPE uje_t_team.
DATA: ls_teams LIKE LINE OF lt_teams.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
CALL FUNCTION 'UJE_API_GET_TEAMS'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_team = lt_teams.
REFRESH lt_output.
LOOP AT lt_teams INTO ls_teams.
MOVE-CORRESPONDING ls_teams TO ls_output.
APPEND ls_output TO lt_output.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_teams_to_file
METHOD import_teams_from_file.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: ls_team TYPE uje_s_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_users TYPE uje_t_user_team.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_team-team_id
ls_team-description.
* Check if team is already a valid team, set action appropriatly
IF lcl_application=>team_is_valid( ls_team-team_id ) = abap_false.
lv_action = 'I'.
ELSE.
lv_action = 'M'.
ENDIF.
CALL FUNCTION 'UJE_API_MANAGE_TEAM2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_team = ls_team
i_action = lv_action
it_users = lt_users
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team-team_id
'has been created/updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team-team_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "create_teams_from_file
METHOD delete_teams_from_file.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: ls_team TYPE uje_s_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_users TYPE uje_t_user_team.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_team-team_id
ls_team-description.
CALL FUNCTION 'UJE_API_DELETE_TEAM'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_team_id = ls_team-team_id
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team-team_id
'has been removed successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team-team_id
'could not be removed due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "delete_teams_from_file
METHOD export_team_assign_to_file.
TYPES: BEGIN OF t_user_assign,
user_id TYPE uje_s_user_team-user_id,
team_id TYPE uje_s_user_team-team_id,
teamleader TYPE uje_s_user_team-teamleader,
END OF t_user_assign.
DATA: lt_user_det TYPE uje_t_user_detail.
DATA: ls_user_det LIKE LINE OF lt_user_det.
DATA: ls_user_team TYPE uje_s_user_team.
DATA: lt_team_assign TYPE TABLE OF t_user_assign.
DATA: ls_team_assign LIKE LINE OF lt_team_assign.
CALL FUNCTION 'UJE_API_GET_USERDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_user = lt_user_det.
LOOP AT lt_user_det INTO ls_user_det.
LOOP AT ls_user_det-t_team_id INTO ls_user_team.
MOVE-CORRESPONDING ls_user_team TO ls_team_assign.
APPEND ls_team_assign TO lt_team_assign.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_team_assign ).
ENDMETHOD. "export_team_assign_to_file
METHOD import_team_assign_from_file.
TYPES: BEGIN OF t_user_assign,
user_id TYPE uje_s_user_team-user_id,
team_id TYPE uje_s_user_team-team_id,
teamleader TYPE uje_s_user_team-teamleader,
END OF t_user_assign.
DATA: lv_success TYPE uj_bool.
DATA: lt_user_team_temp TYPE uje_t_user_team.
DATA: ls_user_team_temp TYPE uje_s_user_team.
DATA: lt_user_team TYPE uje_t_user_team.
DATA: ls_user_team TYPE uje_s_user_team.
DATA: ls_team_assign TYPE uje_s_user_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: ls_tprofiles LIKE LINE OF lt_tprofiles.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: ls_mprofiles LIKE LINE OF lt_mprofiles.
DATA: lt_tprofile_ids TYPE uje_t_api_profile_id.
DATA: ls_tprofile_ids LIKE LINE OF lt_tprofile_ids.
DATA: lt_mprofile_ids TYPE uje_t_api_profile_id.
DATA: ls_mprofile_ids LIKE LINE OF lt_mprofile_ids.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: ls_teams_list LIKE LINE OF lt_teams_list.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_team_assign-user_id
ls_team_assign-team_id
ls_team_assign-teamleader.
CLEAR ls_user_team.
ls_user_team-user_id = ls_team_assign-user_id.
ls_user_team-team_id = ls_team_assign-team_id.
ls_user_team-teamleader = ls_team_assign-teamleader.
TRANSLATE ls_user_team-teamleader USING 'YXyX1XxXN n 0 '. "Translate to X or space
APPEND ls_user_team TO lt_user_team.
IF lcl_application=>team_is_valid( ls_team_assign-team_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_team_assign-team_id 'does not yet exist.'
'No user assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
IF lcl_application=>user_is_valid( ls_team_assign-user_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_team_assign-user_id 'does not yet exist.'
'No user assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
ENDLOOP.
LOOP AT lcl_application=>lt_teams_list INTO ls_teams_list.
REFRESH lt_user_team_temp.
REFRESH lt_tprofile_ids.
REFRESH lt_mprofile_ids.
* Check that there is data for team assignment, otherwise skip
READ TABLE lt_user_team TRANSPORTING NO FIELDS
WITH KEY team_id = ls_teams_list-team_id.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
* Get existing team data for this team.
CALL FUNCTION 'UJE_API_GET_TEAMDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_team_id = ls_teams_list-team_id
IMPORTING
et_user_team = lt_user_team_temp
et_tprofile_id = lt_tprofile_ids
et_mprofile_id = lt_mprofile_ids.
* Update with new users.
LOOP AT lt_user_team INTO ls_user_team
WHERE team_id = ls_teams_list-team_id.
MOVE-CORRESPONDING ls_user_team TO ls_user_team_temp.
APPEND ls_user_team_temp TO lt_user_team_temp.
ENDLOOP.
* Keep existing profiles.
REFRESH lt_tprofiles.
LOOP AT lt_tprofile_ids INTO ls_tprofile_ids.
ls_tprofiles-profile_id = ls_tprofile_ids-profile_id.
APPEND ls_tprofiles TO lt_tprofiles.
ENDLOOP.
REFRESH lt_mprofiles.
LOOP AT lt_mprofile_ids INTO ls_mprofile_ids.
ls_mprofiles-profile_id = ls_mprofile_ids-profile_id.
APPEND ls_mprofiles TO lt_mprofiles.
ENDLOOP.
* now update the user/team assignments
CALL FUNCTION 'UJE_API_MANAGE_TEAM2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_team = ls_teams_list
i_action = 'M'
it_users = lt_user_team_temp
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'user assignments'
'have been updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'user assignments'
'not updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "import_team_assign_from_file
METHOD export_task_profiles_to_file.
TYPES: BEGIN OF t_output,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_output.
DATA: ls_tprofs LIKE LINE OF lt_tprofs.
DATA: lv_profile TYPE uj_profile_id.
DATA: ls_profile TYPE uje_s_profile.
DATA: lt_role_id TYPE uje_t_api_role_id.
DATA: ls_role_id LIKE LINE OF lt_role_id.
DATA: lt_task_info TYPE uje_t_task_info.
DATA: ls_task_info LIKE LINE OF lt_task_info.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
LOOP AT lcl_application=>lt_tprofs INTO ls_tprofs.
lv_profile = ls_tprofs-profile_id.
* Get relevant data for task profile
CLEAR ls_profile.
REFRESH: lt_role_id, lt_task_info, lt_users_asin, lt_teams_asin.
CALL FUNCTION 'UJE_API_GET_TPROFILEDATA2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = lv_profile
IMPORTING
es_profile = ls_profile
et_role_id = lt_role_id
et_task_info = lt_task_info
et_user_id = lt_users_asin
et_team_id = lt_teams_asin.
* Write Header row
CLEAR ls_output.
ls_output-identifier = 'H'.
ls_output-profile = lv_profile.
ls_output-values = ls_profile-description.
APPEND ls_output TO lt_output.
* Write task assigments
CLEAR ls_output.
ls_output-identifier = 'K'.
ls_output-profile = lv_profile.
LOOP AT lt_task_info INTO ls_task_info.
ls_output-values = ls_task_info-task_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write role assigments
CLEAR ls_output.
ls_output-identifier = 'R'.
ls_output-profile = lv_profile.
LOOP AT lt_role_id INTO ls_role_id.
ls_output-values = ls_role_id-role_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write user assignments
CLEAR ls_output.
ls_output-identifier = 'U'.
ls_output-profile = lv_profile.
LOOP AT lt_users_asin INTO ls_users_asin.
ls_output-values = ls_users_asin-user_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write team assignments
CLEAR ls_output.
ls_output-identifier = 'T'.
ls_output-profile = lv_profile.
LOOP AT lt_teams_asin INTO ls_teams_asin.
ls_output-values = ls_teams_asin-team_id.
APPEND ls_output TO lt_output.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_task_profiles_to_file
METHOD import_task_profiles_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_input.
TYPES: BEGIN OF t_task_profile,
profile TYPE uje_s_profile,
roles TYPE uje_t_api_role_id,
task_info TYPE uje_t_task_info,
users_asin TYPE uje_t_api_user_id,
teams_asin TYPE uje_t_api_team_id,
END OF t_task_profile.
DATA: lt_task_profile TYPE TABLE OF t_task_profile.
DATA: ls_task_profile LIKE LINE OF lt_task_profile.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_messages TYPE uj0_t_message.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: lv_last_profile TYPE uj_profile_id.
DATA: lt_role_id TYPE uje_t_api_role_id.
DATA: ls_role_id LIKE LINE OF lt_role_id.
DATA: lt_task_info TYPE uje_t_task_info.
DATA: ls_task_info LIKE LINE OF lt_task_info.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_obj_asin TYPE uje_t_profile_asin.
DATA: ls_obj_asin LIKE LINE OF lt_obj_asin.
DATA: lt_task_asin TYPE uje_t_task_id_act.
DATA: ls_task_asin LIKE LINE OF lt_task_asin.
* Upload file
lt_strtab = lcl_application=>upload( p_file ).
* Rip import file into internal table
LOOP AT lt_strtab INTO ls_strtab.
CLEAR ls_input.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-values.
APPEND ls_input TO lt_input.
ENDLOOP.
* Build profile table containing all associated data
SORT lt_input STABLE ASCENDING BY profile identifier values.
LOOP AT lt_input INTO ls_input.
IF ls_input-profile <> lv_last_profile
AND lv_last_profile IS NOT INITIAL.
APPEND ls_task_profile TO lt_task_profile.
CLEAR ls_task_profile.
ENDIF.
* Based on record identifier
CASE ls_input-identifier.
WHEN 'H'. " Header
ls_task_profile-profile-profile_id = ls_input-profile.
ls_task_profile-profile-description = ls_input-values.
WHEN 'K'. " Task info
SPLIT ls_input-values AT lcl_application=>lv_delimiter INTO ls_task_info-task_id
ls_task_info-description.
IF lcl_application=>task_is_valid( ls_task_info-task_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Task ID' ls_task_info-task_id 'is not valid.'
'No task profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_task_info TO ls_task_profile-task_info.
WHEN 'R'. " Roles
ls_role_id = ls_input-values.
IF lcl_application=>role_is_valid( ls_role_id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Role ID' ls_role_id 'is not valid.'
'No task profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_role_id TO ls_task_profile-roles.
WHEN 'U'. " Users Assignments
ls_users_asin = ls_input-values.
IF lcl_application=>user_is_valid( ls_users_asin ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_users_asin 'does not exist.'
'No task profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_users_asin TO ls_task_profile-users_asin.
WHEN 'T'. " Team Assignments
ls_teams_asin = ls_input-values.
IF lcl_application=>team_is_valid( ls_teams_asin ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_asin 'does not exist.'
'No task profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_teams_asin TO ls_task_profile-teams_asin.
ENDCASE.
lv_last_profile = ls_input-profile.
AT LAST.
APPEND ls_task_profile TO lt_task_profile.
ENDAT.
ENDLOOP.
* Now for each profile, call API to create/update
LOOP AT lt_task_profile INTO ls_task_profile.
* Determine if the task profile is new, set action accordingly.
IF lcl_application=>tprofile_is_valid( ls_task_profile-profile ) = abap_false.
lv_action = 'I'.
ELSE.
lv_action = 'M'.
ENDIF.
* Move data to API tables
REFRESH lt_obj_asin.
LOOP AT ls_task_profile-roles INTO ls_role_id.
ls_obj_asin-object_id = ls_role_id.
ls_obj_asin-profile_id = ls_task_profile-profile.
ls_obj_asin-object_type = 'R'.
APPEND ls_obj_asin TO lt_obj_asin.
ENDLOOP.
LOOP AT ls_task_profile-users_asin INTO ls_users_asin.
ls_obj_asin-object_id = ls_users_asin.
ls_obj_asin-profile_id = ls_task_profile-profile.
ls_obj_asin-object_type = 'U'.
APPEND ls_obj_asin TO lt_obj_asin.
ENDLOOP.
LOOP AT ls_task_profile-teams_asin INTO ls_teams_asin.
ls_obj_asin-object_id = ls_teams_asin.
ls_obj_asin-profile_id = ls_task_profile-profile.
ls_obj_asin-object_type = 'T'.
APPEND ls_obj_asin TO lt_obj_asin.
ENDLOOP.
REFRESH lt_task_asin.
LOOP AT ls_task_profile-task_info INTO ls_task_info.
ls_task_asin-task_id = ls_task_info-task_id.
APPEND ls_task_asin TO lt_task_asin.
ENDLOOP.
* Call API
CALL FUNCTION 'UJE_API_MANAGE_TPROFILE2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_action = lv_action
is_profile = ls_task_profile-profile
it_obj_asin = lt_obj_asin
it_task_asin = lt_task_asin
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Task Profile' ls_task_profile-profile-profile_id
'has been created/updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Task Profile' ls_task_profile-profile-profile_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
* Display ALV
lcl_application=>render_alv( ).
ENDMETHOD. "import_task_profiles_from_file
METHOD Delete_task_profiles_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_input.
TYPES: BEGIN OF t_task_profile,
profile TYPE uje_s_profile,
roles TYPE uje_t_api_role_id,
task_info TYPE uje_t_task_info,
users_asin TYPE uje_t_api_user_id,
teams_asin TYPE uje_t_api_team_id,
END OF t_task_profile.
DATA: lt_task_profile TYPE TABLE OF t_task_profile.
DATA: ls_task_profile LIKE LINE OF lt_task_profile.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_messages TYPE uj0_t_message.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: lv_last_profile TYPE uj_profile_id.
DATA: lt_role_id TYPE uje_t_api_role_id.
DATA: ls_role_id LIKE LINE OF lt_role_id.
DATA: lt_task_info TYPE uje_t_task_info.
DATA: ls_task_info LIKE LINE OF lt_task_info.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_obj_asin TYPE uje_t_profile_asin.
DATA: ls_obj_asin LIKE LINE OF lt_obj_asin.
DATA: lt_task_asin TYPE uje_t_task_id_act.
DATA: ls_task_asin LIKE LINE OF lt_task_asin.
* Upload file
lt_strtab = lcl_application=>upload( p_file ).
* Rip import file into internal table
LOOP AT lt_strtab INTO ls_strtab.
CLEAR ls_input.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-values.
APPEND ls_input TO lt_input.
ENDLOOP.
* Build profile table containing all associated data
SORT lt_input STABLE ASCENDING BY profile identifier values.
LOOP AT lt_input INTO ls_input.
IF ls_input-profile <> lv_last_profile
AND lv_last_profile IS NOT INITIAL.
APPEND ls_task_profile TO lt_task_profile.
CLEAR ls_task_profile.
ENDIF.
* Based on record identifier
CASE ls_input-identifier.
WHEN 'H'. " Header
ls_task_profile-profile-profile_id = ls_input-profile.
ls_task_profile-profile-description = ls_input-values.
ENDCASE.
lv_last_profile = ls_input-profile.
AT LAST.
APPEND ls_task_profile TO lt_task_profile.
ENDAT.
ENDLOOP.
* Now for each profile, call API to create/update
LOOP AT lt_task_profile INTO ls_task_profile.
CALL FUNCTION 'UJE_API_DELETE_PROFILE'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = ls_task_profile-profile-profile_id
i_profile_class = 'TSK'
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Task Profile' ls_task_profile-profile-profile_id
'has been deleted successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Task Profile' ls_task_profile-profile-profile_id
'could not be deleted due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
* Display ALV
lcl_application=>render_alv( ).
ENDMETHOD. "import_task_profiles_from_file
METHOD export_mem_profiles_to_file.
TYPES: BEGIN OF t_output,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_output.
DATA: ls_profile TYPE uje_s_profile.
DATA: lv_profile TYPE uj_profile_id.
DATA: lt_memaccess TYPE uje_t_memaccess.
DATA: ls_memaccess LIKE LINE OF lt_memaccess.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: ls_mprofs LIKE LINE OF lt_mprofs.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
LOOP AT lcl_application=>lt_mprofs INTO ls_mprofs.
lv_profile = ls_mprofs-profile_id.
* Get relevant data for task profile
CLEAR ls_profile.
REFRESH: lt_memaccess, lt_users_asin, lt_teams_asin.
CALL FUNCTION 'UJE_API_GET_MPROFILEDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = lv_profile
IMPORTING
es_profile = ls_profile
et_memaccess = lt_memaccess
et_user_id = lt_users_asin
et_team_id = lt_teams_asin.
* Write Header row
CLEAR ls_output.
ls_output-identifier = 'H'.
ls_output-profile = lv_profile.
ls_output-values = ls_profile-description.
APPEND ls_output TO lt_output.
* Write member access
CLEAR ls_output.
ls_output-identifier = 'M'.
ls_output-profile = lv_profile.
LOOP AT lt_memaccess INTO ls_memaccess.
ls_memaccess-profile_id = lv_profile.
CONCATENATE ls_memaccess-dimension
ls_memaccess-application_id
ls_memaccess-member
ls_memaccess-rwd
INTO ls_output-values SEPARATED BY lcl_application=>lv_delimiter.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write user assignments
CLEAR ls_output.
ls_output-identifier = 'U'.
ls_output-profile = lv_profile.
LOOP AT lt_users_asin INTO ls_users_asin.
ls_output-values = ls_users_asin-user_id.
APPEND ls_output TO lt_output.
ENDLOOP.
* Write team assignments
CLEAR ls_output.
ls_output-identifier = 'T'.
ls_output-profile = lv_profile.
LOOP AT lt_teams_asin INTO ls_teams_asin.
ls_output-values = ls_teams_asin-team_id.
APPEND ls_output TO lt_output.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_mem_profiles_to_file
METHOD import_mem_profiles_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_input.
TYPES: BEGIN OF t_memacc_profile,
profile TYPE uje_s_profile,
memacc TYPE uje_t_memaccess,
users_asin TYPE uje_t_api_user_id,
teams_asin TYPE uje_t_api_team_id,
END OF t_memacc_profile.
DATA: lt_memacc_profile TYPE TABLE OF t_memacc_profile.
DATA: ls_memacc_profile LIKE LINE OF lt_memacc_profile.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_messages TYPE uj0_t_message.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: lv_last_profile TYPE uj_profile_id.
DATA: lt_memaccess TYPE uje_t_memaccess.
DATA: ls_memaccess LIKE LINE OF lt_memaccess.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_obj_asin TYPE uje_t_profile_asin.
DATA: ls_obj_asin LIKE LINE OF lt_obj_asin.
* Upload file
lt_strtab = lcl_application=>upload( p_file ).
* Rip import file into internal table
LOOP AT lt_strtab INTO ls_strtab.
CLEAR ls_input.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-values.
APPEND ls_input TO lt_input.
ENDLOOP.
* Build profile table containing all associated data
SORT lt_input STABLE ASCENDING BY profile identifier values.
LOOP AT lt_input INTO ls_input.
IF ls_input-profile <> lv_last_profile
AND lv_last_profile IS NOT INITIAL.
APPEND ls_memacc_profile TO lt_memacc_profile.
CLEAR ls_memacc_profile.
ENDIF.
* Based on record identifier
CASE ls_input-identifier.
WHEN 'H'. " Header
ls_memacc_profile-profile-profile_id = ls_input-profile.
ls_memacc_profile-profile-description = ls_input-values.
WHEN 'M'. " Member Access info
ls_memaccess-profile_id = ls_input-profile.
SPLIT ls_input-values AT lcl_application=>lv_delimiter INTO ls_memaccess-dimension
ls_memaccess-application_id
ls_memaccess-member
ls_memaccess-rwd.
* Check APPLICATION_ID
READ TABLE lcl_application=>lt_appl_info
TRANSPORTING NO FIELDS
WITH KEY application_id = ls_memaccess-application_id.
IF sy-subrc <> 0.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Application ID' ls_memaccess-application_id
'not valid for this Application Set'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
CONCATENATE 'Member Access Profile' ls_memacc_profile-profile-profile_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
* Check DIMENSION
READ TABLE lcl_application=>lt_appl_dim
TRANSPORTING NO FIELDS
WITH KEY appl_id = ls_memaccess-application_id
dimension = ls_memaccess-dimension.
IF sy-subrc <> 0.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Dimension' ls_memaccess-dimension
'not valid for Application'
ls_memaccess-application_id
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
CONCATENATE 'Member Access Profile'
ls_memacc_profile-profile-profile_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
* Check MEMBER
READ TABLE lcl_application=>lt_members
TRANSPORTING NO FIELDS
WITH KEY appl_id = ls_memaccess-application_id
dimension = ls_memaccess-dimension
member = ls_memaccess-member.
IF sy-subrc <> 0 AND ls_memaccess-member <> '[ALL]'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Member' ls_memaccess-member
'not valid for Dimension' ls_memaccess-dimension
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
CONCATENATE 'Member Access Profile' ls_memacc_profile-profile-profile_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_memaccess TO ls_memacc_profile-memacc.
WHEN 'U'. " Users Assignments
ls_users_asin = ls_input-values.
IF lcl_application=>user_is_valid( ls_users_asin ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_users_asin 'does not exist.'
'No member access profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_users_asin TO ls_memacc_profile-users_asin.
WHEN 'T'. " Team Assignments
ls_teams_asin = ls_input-values.
IF lcl_application=>team_is_valid( ls_teams_asin ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_asin 'does not exist.'
'No member access profile updates done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
APPEND ls_teams_asin TO ls_memacc_profile-teams_asin.
ENDCASE.
lv_last_profile = ls_input-profile.
AT LAST.
APPEND ls_memacc_profile TO lt_memacc_profile.
ENDAT.
ENDLOOP.
* Now for each profile, call API to create/update
LOOP AT lt_memacc_profile INTO ls_memacc_profile.
* Determine if the task profile is new, set action accordingly.
IF lcl_application=>mprofile_is_valid( ls_memacc_profile-profile ) = abap_false.
lv_action = 'I'.
ELSE.
lv_action = 'M'.
ENDIF.
* Move data to API tables
REFRESH lt_obj_asin.
LOOP AT ls_memacc_profile-users_asin INTO ls_users_asin.
ls_obj_asin-object_id = ls_users_asin.
ls_obj_asin-profile_id = ls_memacc_profile-profile.
ls_obj_asin-object_type = 'U'.
APPEND ls_obj_asin TO lt_obj_asin.
ENDLOOP.
LOOP AT ls_memacc_profile-teams_asin INTO ls_teams_asin.
ls_obj_asin-object_id = ls_teams_asin.
ls_obj_asin-profile_id = ls_memacc_profile-profile.
ls_obj_asin-object_type = 'T'.
APPEND ls_obj_asin TO lt_obj_asin.
ENDLOOP.
* Move member access data to table.
REFRESH lt_memaccess.
LOOP AT ls_memacc_profile-memacc INTO ls_memaccess.
APPEND ls_memaccess TO lt_memaccess.
ENDLOOP.
* Call API
CALL FUNCTION 'UJE_API_MANAGE_MPROFILE2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_action = lv_action
is_profile = ls_memacc_profile-profile
it_memaccess = lt_memaccess
it_obj_asin = lt_obj_asin
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Member Access Profile' ls_memacc_profile-profile-profile_id
'has been created/updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Member Access Profile' ls_memacc_profile-profile-profile_id
'not created/updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
* Display ALV
lcl_application=>render_alv( ).
ENDMETHOD. "import_mem_profiles_from_file
METHOD delete_mem_profiles_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, " Row Identifer
profile TYPE uj_profile_id,
values TYPE string,
END OF t_input.
TYPES: BEGIN OF t_memacc_profile,
profile TYPE uje_s_profile,
memacc TYPE uje_t_memaccess,
users_asin TYPE uje_t_api_user_id,
teams_asin TYPE uje_t_api_team_id,
END OF t_memacc_profile.
DATA: lt_memacc_profile TYPE TABLE OF t_memacc_profile.
DATA: ls_memacc_profile LIKE LINE OF lt_memacc_profile.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_messages TYPE uj0_t_message.
DATA: lv_action TYPE uj_action.
DATA: lv_success TYPE uj_bool.
DATA: lv_last_profile TYPE uj_profile_id.
DATA: lt_memaccess TYPE uje_t_memaccess.
DATA: ls_memaccess LIKE LINE OF lt_memaccess.
DATA: lt_users_asin TYPE uje_t_api_user_id.
DATA: ls_users_asin LIKE LINE OF lt_users_asin.
DATA: lt_teams_asin TYPE uje_t_api_team_id.
DATA: ls_teams_asin LIKE LINE OF lt_teams_asin.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_obj_asin TYPE uje_t_profile_asin.
DATA: ls_obj_asin LIKE LINE OF lt_obj_asin.
* Upload file
lt_strtab = lcl_application=>upload( p_file ).
* Rip import file into internal table
LOOP AT lt_strtab INTO ls_strtab.
CLEAR ls_input.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-values.
APPEND ls_input TO lt_input.
ENDLOOP.
* Build profile table containing all associated data
SORT lt_input STABLE ASCENDING BY profile identifier values.
LOOP AT lt_input INTO ls_input.
IF ls_input-profile <> lv_last_profile
AND lv_last_profile IS NOT INITIAL.
APPEND ls_memacc_profile TO lt_memacc_profile.
CLEAR ls_memacc_profile.
ENDIF.
* Based on record identifier
CASE ls_input-identifier.
WHEN 'H'. " Header
ls_memacc_profile-profile-profile_id = ls_input-profile.
ls_memacc_profile-profile-description = ls_input-values.
ENDCASE.
lv_last_profile = ls_input-profile.
AT LAST.
APPEND ls_memacc_profile TO lt_memacc_profile.
ENDAT.
ENDLOOP.
* Now for each profile, call API to create/update
LOOP AT lt_memacc_profile INTO ls_memacc_profile.
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_APPSET_ID) TYPE UJ_APPSET_ID
*" VALUE(IS_USER) TYPE UJ0_S_USER
*" VALUE(I_PROFILE_ID) TYPE UJ_PROFILE_ID
*" VALUE(I_PROFILE_CLASS) TYPE UJ_PROFILE_CLASS
*" EXPORTING
*" VALUE(E_SUCCESS) TYPE UJ_BOOL
*" VALUE(ET_MESSAGE_LINES) TYPE UJ0_T_MESSAGE
* Call API
CALL FUNCTION 'UJE_API_DELETE_PROFILE'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = ls_memacc_profile-profile-profile_id
i_profile_class = 'MBR'
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Member Access Profile' ls_memacc_profile-profile-profile_id
'has been deleted successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Member Access Profile' ls_memacc_profile-profile-profile_id
'could not be deleted due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
* Display ALV
lcl_application=>render_alv( ).
ENDMETHOD. "delete_mem_profiles_from_file
METHOD export_tap_assign_to_file.
TYPES: BEGIN OF t_output,
identifier TYPE char01, "Identifer, U or T
profile TYPE uj_profile_id,
id TYPE uj_user_id, "User ID or Team ID
END OF t_output.
DATA: ls_tprofs LIKE LINE OF lt_tprofs.
DATA: lv_profile TYPE uj_profile_id.
DATA: lt_user_assign TYPE uje_t_api_user_id.
DATA: ls_user_assign LIKE LINE OF lt_user_assign.
DATA: lt_team_assign TYPE uje_t_api_team_id.
DATA: ls_team_assign LIKE LINE OF lt_team_assign.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
LOOP AT lcl_application=>lt_tprofs INTO ls_tprofs.
lv_profile = ls_tprofs-profile_id.
CALL FUNCTION 'UJE_API_GET_TPROFILEDATA2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = lv_profile
IMPORTING
et_user_id = lt_user_assign
et_team_id = lt_team_assign.
LOOP AT lt_user_assign INTO ls_user_assign.
CLEAR ls_output.
ls_output-identifier = 'U'.
ls_output-profile = lv_profile.
ls_output-id = ls_user_assign-user_id.
APPEND ls_output TO lt_output.
ENDLOOP.
LOOP AT lt_team_assign INTO ls_team_assign.
CLEAR ls_output.
ls_output-identifier = 'T'.
ls_output-profile = lv_profile.
ls_output-id = ls_team_assign-team_id.
APPEND ls_output TO lt_output.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_tap_assign_to_file
METHOD import_tap_assign_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, "Identifer, U or T
profile TYPE uj_profile_id,
id TYPE uj_user_id, "User ID or Team ID
END OF t_input.
DATA: lv_success TYPE uj_bool.
DATA: lt_user_team TYPE uje_t_user_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: ls_tprofiles LIKE LINE OF lt_tprofiles.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: ls_mprofiles LIKE LINE OF lt_mprofiles.
DATA: lt_tprofile_ids TYPE uje_t_api_profile_id.
DATA: lt_mprofile_ids TYPE uje_t_api_profile_id.
DATA: ls_mprofile_ids LIKE LINE OF lt_mprofile_ids.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: ls_teams_list LIKE LINE OF lt_teams_list.
DATA: ls_users_list LIKE LINE OF lt_users_list.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_user_data TYPE uje_t_user_detail.
DATA: ls_user_data LIKE LINE OF lt_user_data.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-id.
IF lcl_application=>tprofile_is_valid( ls_input-profile ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Profile' ls_input-profile 'does not yet exist.'
'No task profile assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
CASE ls_input-identifier.
WHEN 'T'.
IF lcl_application=>team_is_valid( ls_input-id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_input-id 'does not yet exist.'
'No task profile assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
WHEN 'U'.
IF lcl_application=>user_is_valid( ls_input-id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_input-id 'does not yet exist.'
'No task profile assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
ENDCASE.
APPEND ls_input TO lt_input.
ENDLOOP.
LOOP AT lcl_application=>lt_users_list INTO ls_users_list.
CALL FUNCTION 'UJE_API_GET_USERDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_user_id = ls_users_list-user_id
IMPORTING
et_user = lt_user_data.
CLEAR ls_user_data.
READ TABLE lt_user_data INTO ls_user_data
WITH KEY user_info-user_id = ls_users_list-user_id.
IF sy-subrc = 0.
lt_user_team = ls_user_data-t_team_id.
lt_tprofiles = ls_user_data-t_tprofile_id.
lt_mprofiles = ls_user_data-t_mprofile_id.
ENDIF.
REFRESH lt_tprofiles.
LOOP AT lt_input INTO ls_input
WHERE identifier = 'U'
AND id = ls_users_list-user_id.
ls_tprofiles-profile_id = ls_input-profile.
APPEND ls_tprofiles TO lt_tprofiles.
ENDLOOP.
IF lt_tprofiles IS INITIAL.
CONTINUE.
ENDIF.
CALL FUNCTION 'UJE_API_MANAGE_USER2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_user_info = ls_users_list
i_action = 'M'
it_team_asin = lt_user_team
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_users_list-user_id 'task profile assignments'
'have been updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_users_list-user_id 'task profile assignments'
'not updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
LOOP AT lcl_application=>lt_teams_list INTO ls_teams_list.
REFRESH lt_tprofile_ids.
REFRESH lt_mprofile_ids.
* Get existing team data for this team.
CALL FUNCTION 'UJE_API_GET_TEAMDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_team_id = ls_teams_list-team_id
IMPORTING
et_user_team = lt_user_team
et_tprofile_id = lt_tprofile_ids
et_mprofile_id = lt_mprofile_ids.
REFRESH lt_tprofiles.
LOOP AT lt_input INTO ls_input
WHERE identifier = 'T'
AND id = ls_teams_list-team_id.
ls_tprofiles-profile_id = ls_input-profile.
APPEND ls_tprofiles TO lt_tprofiles.
ENDLOOP.
IF lt_tprofiles IS INITIAL.
CONTINUE.
ENDIF.
* Keep existing member access profiles.
REFRESH lt_mprofiles.
LOOP AT lt_mprofile_ids INTO ls_mprofile_ids.
ls_mprofiles-profile_id = ls_mprofile_ids-profile_id.
APPEND ls_mprofiles TO lt_mprofiles.
ENDLOOP.
CALL FUNCTION 'UJE_API_MANAGE_TEAM2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_team = ls_teams_list
i_action = 'M'
it_users = lt_user_team
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'task profile assignments'
'have been updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'task profile assignments'
'not updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "import_tap_assign_from_file
METHOD export_map_assign_to_file.
TYPES: BEGIN OF t_output,
identifier TYPE char01, "Identifer, U or T
profile TYPE uj_profile_id,
id TYPE uj_user_id, "User ID or Team ID
END OF t_output.
DATA: ls_mprofs LIKE LINE OF lt_mprofs.
DATA: lv_profile TYPE uj_profile_id.
DATA: lt_user_assign TYPE uje_t_api_user_id.
DATA: ls_user_assign LIKE LINE OF lt_user_assign.
DATA: lt_team_assign TYPE uje_t_api_team_id.
DATA: ls_team_assign LIKE LINE OF lt_team_assign.
DATA: lt_output TYPE TABLE OF t_output.
DATA: ls_output LIKE LINE OF lt_output.
LOOP AT lcl_application=>lt_mprofs INTO ls_mprofs.
lv_profile = ls_mprofs-profile_id.
CALL FUNCTION 'UJE_API_GET_MPROFILEDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_profile_id = lv_profile
IMPORTING
et_user_id = lt_user_assign
et_team_id = lt_team_assign.
LOOP AT lt_user_assign INTO ls_user_assign.
CLEAR ls_output.
ls_output-identifier = 'U'.
ls_output-profile = lv_profile.
ls_output-id = ls_user_assign-user_id.
APPEND ls_output TO lt_output.
ENDLOOP.
LOOP AT lt_team_assign INTO ls_team_assign.
CLEAR ls_output.
ls_output-identifier = 'T'.
ls_output-profile = lv_profile.
ls_output-id = ls_team_assign-team_id.
APPEND ls_output TO lt_output.
ENDLOOP.
ENDLOOP.
* Download table
lcl_application=>download( EXPORTING i_filepath = p_file
it_datatab = lt_output ).
ENDMETHOD. "export_map_assign_to_file
METHOD import_map_assign_from_file.
TYPES: BEGIN OF t_input,
identifier TYPE char01, "Identifer, U or T
profile TYPE uj_profile_id,
id TYPE uj_user_id, "User ID or Team ID
END OF t_input.
DATA: lv_success TYPE uj_bool.
DATA: lt_user_team TYPE uje_t_user_team.
DATA: lt_messages TYPE uj0_t_message.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
DATA: lt_tprofiles TYPE uje_t_profile_id_act.
DATA: ls_tprofiles LIKE LINE OF lt_tprofiles.
DATA: lt_mprofiles TYPE uje_t_profile_id_act.
DATA: ls_mprofiles LIKE LINE OF lt_mprofiles.
DATA: lt_tprofile_ids TYPE uje_t_api_profile_id.
DATA: ls_tprofile_ids LIKE LINE OF lt_tprofile_ids.
DATA: lt_mprofile_ids TYPE uje_t_api_profile_id.
DATA: lt_strtab TYPE stringtab.
DATA: ls_strtab LIKE LINE OF lt_strtab.
DATA: ls_teams_list LIKE LINE OF lt_teams_list.
DATA: ls_users_list LIKE LINE OF lt_users_list.
DATA: lt_input TYPE TABLE OF t_input.
DATA: ls_input LIKE LINE OF lt_input.
DATA: lt_user_data TYPE uje_t_user_detail.
DATA: ls_user_data LIKE LINE OF lt_user_data.
lt_strtab = lcl_application=>upload( p_file ).
LOOP AT lt_strtab INTO ls_strtab.
SPLIT ls_strtab AT lcl_application=>lv_delimiter INTO ls_input-identifier
ls_input-profile
ls_input-id.
IF lcl_application=>mprofile_is_valid( ls_input-profile ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Profile' ls_input-profile 'does not yet exist.'
'No member profile assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
CASE ls_input-identifier.
WHEN 'T'.
IF lcl_application=>team_is_valid( ls_input-id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_input-id 'does not yet exist.'
'No member profile assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
WHEN 'U'.
IF lcl_application=>user_is_valid( ls_input-id ) = abap_false.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_input-id 'does not yet exist.'
'No member profile assigments done.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RETURN.
ENDIF.
ENDCASE.
APPEND ls_input TO lt_input.
ENDLOOP.
LOOP AT lcl_application=>lt_users_list INTO ls_users_list.
* Get Existing data
CALL FUNCTION 'UJE_API_GET_USERDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_user_id = ls_users_list-user_id
IMPORTING
et_user = lt_user_data.
CLEAR ls_user_data.
READ TABLE lt_user_data INTO ls_user_data
WITH KEY user_info-user_id = ls_users_list-user_id.
IF sy-subrc = 0.
lt_user_team = ls_user_data-t_team_id.
lt_tprofiles = ls_user_data-t_tprofile_id.
lt_mprofiles = ls_user_data-t_mprofile_id.
ENDIF.
* Overwrite the member access profile data
REFRESH lt_mprofiles.
LOOP AT lt_input INTO ls_input
WHERE identifier = 'U'
AND id = ls_users_list-user_id.
ls_mprofiles-profile_id = ls_input-profile.
APPEND ls_mprofiles TO lt_mprofiles.
ENDLOOP.
IF lt_mprofiles IS INITIAL.
CONTINUE.
ENDIF.
* Update user
CALL FUNCTION 'UJE_API_MANAGE_USER2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_user_info = ls_users_list
i_action = 'M'
it_team_asin = lt_user_team
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_users_list-user_id 'member profile assignments'
'have been updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'User' ls_users_list-user_id 'member profile assignments'
'not updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
LOOP AT lcl_application=>lt_teams_list INTO ls_teams_list.
REFRESH lt_tprofile_ids.
REFRESH lt_mprofile_ids.
* Get existing team data for this team.
CALL FUNCTION 'UJE_API_GET_TEAMDATA'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
i_team_id = ls_teams_list-team_id
IMPORTING
et_user_team = lt_user_team
et_tprofile_id = lt_tprofile_ids
et_mprofile_id = lt_mprofile_ids.
* Overwrite member access profile data
REFRESH lt_mprofiles.
LOOP AT lt_input INTO ls_input
WHERE identifier = 'T'
AND id = ls_teams_list-team_id.
ls_mprofiles-profile_id = ls_input-profile.
APPEND ls_mprofiles TO lt_mprofiles.
ENDLOOP.
IF lt_mprofiles IS INITIAL.
CONTINUE.
ENDIF.
* Keep assigned task profiles
REFRESH lt_tprofiles.
LOOP AT lt_tprofile_ids INTO ls_tprofile_ids.
ls_tprofiles-profile_id = ls_tprofile_ids-profile_id.
APPEND ls_tprofiles TO lt_tprofiles.
ENDLOOP.
* UPdate Team
CALL FUNCTION 'UJE_API_MANAGE_TEAM2'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
is_team = ls_teams_list
i_action = 'M'
it_users = lt_user_team
it_tprofile_id = lt_tprofiles
it_mprofile_id = lt_mprofiles
IMPORTING
e_success = lv_success
et_message_lines = lt_messages.
IF lv_success = 'Y'.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'S'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'member profile assignments'
'have been updated successfully'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ELSE.
APPEND LINES OF lt_messages TO lt_alv_messages.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'Team' ls_teams_list-team_id 'member profile assignments'
'not updated due to error'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
ENDIF.
ENDLOOP.
lcl_application=>render_alv( ).
ENDMETHOD. "import_map_assign_from_file
METHOD set_global_context.
DATA: ls_user TYPE uj0_s_user.
DATA: lv_value TYPE uj_value.
DATA: lo_srv_mgr_dao TYPE REF TO cl_uja3_svrmgr_dao.
* GEt the system admin user id
CREATE OBJECT lo_srv_mgr_dao.
lo_srv_mgr_dao->read_sysadmin_id( IMPORTING e_sysadmin_id = lv_value ).
ls_user-user_id = lv_value.
* Set the context
TRY.
cl_uj_context=>set_cur_context(
EXPORTING i_appset_id = lcl_application=>lv_appset_id
is_user = ls_user ).
CATCH cx_uj_obj_not_found .
ENDTRY.
* Get it
lo_context = cl_uj_context=>get_cur_context( ).
* Set user to system admin
lo_context->switch_to_srvadmin( ).
ENDMETHOD. "set_global_context
METHOD set_delimiter_listbox.
* set delimiter listbox.
DATA: lt_vrm_values TYPE vrm_values.
DATA: ls_vrm_values LIKE LINE OF lt_vrm_values.
DATA: lv_name TYPE vrm_id VALUE 'P_DELMT'.
REFRESH lt_vrm_values.
ls_vrm_values-key = lcl_application=>lc_comma.
ls_vrm_values-text = 'Comma'.
APPEND ls_vrm_values TO lt_vrm_values.
ls_vrm_values-key = lcl_application=>lc_tab.
ls_vrm_values-text = 'Tab'.
APPEND ls_vrm_values TO lt_vrm_values.
ls_vrm_values-key = lcl_application=>lc_pipe.
ls_vrm_values-text = 'Pipe'.
APPEND ls_vrm_values TO lt_vrm_values.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = lv_name
values = lt_vrm_values.
ENDMETHOD. "set_delimiter_listbox
METHOD set_delimiter.
IF p_delmt = lcl_application=>lc_tab.
lcl_application=>lv_delimiter = cl_abap_char_utilities=>horizontal_tab.
ELSE.
lcl_application=>lv_delimiter = p_delmt.
ENDIF.
ENDMETHOD. "set_delimiter
METHOD render_alv.
TYPE-POOLS: icon.
TYPES: BEGIN OF t_alv,
icon TYPE icon-id,
msgid TYPE uj0_s_message-msgid,
msgty TYPE uj0_s_message-msgty,
msgno TYPE uj0_s_message-msgno,
message TYPE uj0_s_message-message,
END OF t_alv.
DATA: lt_alv TYPE TABLE OF t_alv.
DATA: lo_table TYPE REF TO cl_salv_table.
DATA: lo_columns TYPE REF TO cl_salv_columns_table.
DATA: lo_column TYPE REF TO cl_salv_column_table.
DATA: lo_functions TYPE REF TO cl_salv_functions.
FIELD-SYMBOLS: <ls_alv> LIKE LINE OF lt_alv,
<ls_alv_messages> LIKE LINE OF lt_alv_messages.
* Convert messages from API to ALV output
LOOP AT lt_alv_messages ASSIGNING <ls_alv_messages>.
APPEND INITIAL LINE TO lt_alv ASSIGNING <ls_alv>.
MOVE-CORRESPONDING <ls_alv_messages> TO <ls_alv>.
CASE <ls_alv>-msgty.
WHEN 'E'. WRITE icon_message_error_small AS ICON TO <ls_alv>-icon.
WHEN 'W'. WRITE icon_message_warning_small AS ICON TO <ls_alv>-icon.
WHEN 'I'. WRITE icon_message_information_small AS ICON TO <ls_alv>-icon.
WHEN 'S'. WRITE icon_checked AS ICON TO <ls_alv>-icon.
ENDCASE.
ENDLOOP.
* Show messages
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = lo_table
CHANGING t_table = lt_alv ).
CATCH cx_salv_msg.
ENDTRY.
lo_functions = lo_table->get_functions( ).
lo_functions->set_all( abap_true ).
TRY.
lo_columns = lo_table->get_columns( ).
lo_column ?= lo_columns->get_column( 'ICON' ).
lo_column->set_icon( abap_true ).
lo_column ?= lo_columns->get_column( 'MSGNO' ).
lo_column->set_leading_zero( abap_true ).
CATCH cx_salv_not_found.
ENDTRY.
lo_table->display( ).
ENDMETHOD. "render_alv
METHOD get_appset_data.
DATA: ls_uja_appl_info TYPE uja_s_appl_info.
DATA: lt_uja_appl_dim TYPE uja_t_appl_dim.
DATA: ls_uja_appl_dim LIKE LINE OF lt_uja_appl_dim.
DATA: ls_members LIKE LINE OF lt_members.
DATA: ls_appl_dim LIKE LINE OF lt_appl_dim.
DATA: lt_appl_list TYPE uja_t_appl_id.
DATA: ls_appl_list LIKE LINE OF lt_appl_list.
DATA: lo_appset_dao TYPE REF TO cl_uja_appset_dao.
DATA: lo_application_dao TYPE REF TO cl_uja_application_dao.
DATA: lo_dim TYPE REF TO cl_uja_dim.
DATA: lt_member_field TYPE uja_t_mbr_field.
DATA: ls_member_field LIKE LINE OF lt_member_field.
DATA: ls_alv_messages LIKE LINE OF lt_alv_messages.
lcl_application=>lv_appset_id = i_appset_id.
TRY.
* Get the appset info, need the prefix
CREATE OBJECT lo_appset_dao
EXPORTING
i_appset_id = lcl_application=>lv_appset_id.
lo_appset_dao->get_appset_info(
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
IMPORTING
es_appset_info = lcl_application=>ls_appset_info ).
* Get the list of applications for this appset, need the application prefixes
lo_appset_dao->get_appl_list(
IMPORTING
et_appl_list = lt_appl_list ).
CATCH cx_uj_db_error.
* Do not raise exception here
ENDTRY.
* Check Appset to make sure it is valid
IF lcl_application=>ls_appset_info IS INITIAL.
CLEAR ls_alv_messages.
ls_alv_messages-msgid = '00'.
ls_alv_messages-msgty = 'E'.
ls_alv_messages-msgno = '001'.
CONCATENATE 'AppSet' lcl_application=>lv_appset_id 'does not exist.'
INTO ls_alv_messages-message SEPARATED BY space.
APPEND ls_alv_messages TO lt_alv_messages.
lcl_application=>render_alv( ).
RAISE appset_not_found .
ENDIF.
lcl_application=>set_global_context( ).
* Loop applications, get application info, add to internal table
LOOP AT lt_appl_list INTO ls_appl_list.
TRY.
CREATE OBJECT lo_application_dao
EXPORTING
i_appset_id = lcl_application=>lv_appset_id.
lo_application_dao->get_application_info(
EXPORTING
i_application_id = ls_appl_list
IMPORTING
es_appl_info = ls_uja_appl_info ).
APPEND ls_uja_appl_info TO lcl_application=>lt_appl_info.
* Get dimension list for each application
lo_application_dao->get_dim_list(
EXPORTING
i_application_id = ls_appl_list
IMPORTING
et_appl_dim = lt_uja_appl_dim ).
LOOP AT lt_uja_appl_dim INTO ls_uja_appl_dim.
ls_appl_dim-appl_id = ls_appl_list.
ls_appl_dim-dimension = ls_uja_appl_dim-dimension.
COLLECT ls_appl_dim INTO lcl_application=>lt_appl_dim.
ENDLOOP.
* Get members for each dimension
LOOP AT lt_uja_appl_dim INTO ls_uja_appl_dim.
CREATE OBJECT lo_dim
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
i_dimension = ls_uja_appl_dim-dimension.
REFRESH lt_member_field.
lo_dim->read_dim_mbr_field(
EXPORTING
i_attr_name = 'ID'
f_uppercase = abap_false "<-- Get in correct case
IMPORTING
et_member = lt_member_field ).
LOOP AT lt_member_field INTO ls_member_field.
ls_members-appl_id = ls_appl_list.
ls_members-dimension = ls_uja_appl_dim-dimension.
ls_members-member = ls_member_field-member.
COLLECT ls_members INTO lcl_application=>lt_members.
ENDLOOP.
ENDLOOP.
CATCH: cx_uj_db_error, cx_uja_admin_error, cx_uj_static_check.
* Do not raise exception here
ENDTRY.
ENDLOOP.
CALL FUNCTION 'UJE_API_GET_USERS'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_user = lcl_application=>lt_users_list.
CALL FUNCTION 'UJE_API_GET_TEAMS'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_team = lcl_application=>lt_teams_list.
CALL FUNCTION 'UJE_API_GET_TPROFILES'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_profile_id = lcl_application=>lt_tprofs.
* The interface for this FM has changed in 7.5 SP5 so we need to
* handle for both the old function interface as well as the new.
* Also, handle for 7.5 releases on newer NW stacks(NW 7.3 and higher).
IF ( lv_release = '750' AND lv_splevel >= '0005' )
or ( lv_release >= '753' ).
DATA: ls_mprofs LIKE LINE OF lcl_application=>lt_mprofs.
DATA: ls_mprofs_tmp LIKE LINE OF lcl_application=>lt_mprofs_tmp.
CALL FUNCTION 'UJE_API_GET_MPROFILES'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_profile = lcl_application=>lt_mprofs_tmp.
REFRESH lcl_application=>lt_mprofs.
LOOP AT lt_mprofs_tmp INTO ls_mprofs_tmp.
ls_mprofs-profile_id = ls_mprofs_tmp-profile_id.
APPEND ls_mprofs TO lt_mprofs.
ENDLOOP.
ELSE. " Release 7.0 and release 7.5 <= SP4
CALL FUNCTION 'UJE_API_GET_MPROFILES'
EXPORTING
i_appset_id = lcl_application=>lv_appset_id
is_user = lcl_application=>lo_context->ds_user
IMPORTING
et_profile_id = lcl_application=>lt_mprofs.
ENDIF.
CALL FUNCTION 'UJE_API_GET_ROLE_TSKASG'
IMPORTING
et_taskasgn = lcl_application=>lt_tasks.
CALL FUNCTION 'UJE_API_GET_ROLES'
IMPORTING
et_role = lcl_application=>lt_roles.
ENDMETHOD. "get_supporting_Data
METHOD user_is_valid.
READ TABLE lcl_application=>lt_users_list
TRANSPORTING NO FIELDS
WITH KEY user_id = i_user_id.
IF sy-subrc = 0.
r_boolean = abap_true.
ELSE.
r_boolean = abap_false.
ENDIF.
ENDMETHOD. "user_id_valid
METHOD team_is_valid.
READ TABLE lcl_application=>lt_teams_list
TRANSPORTING NO FIELDS
WITH KEY team_id = i_team_id.
IF sy-subrc = 0.
r_boolean = abap_true.
ELSE.
r_boolean = abap_false.
ENDIF.
ENDMETHOD. "team_id_valid
METHOD tprofile_is_valid.
READ TABLE lcl_application=>lt_tprofs
TRANSPORTING NO FIELDS
WITH KEY profile_id = i_profile_id.
IF sy-subrc = 0.
r_boolean = abap_true.
ELSE.
r_boolean = abap_false.
ENDIF.
ENDMETHOD. "tprofile_is_valid
METHOD mprofile_is_valid.
READ TABLE lcl_application=>lt_mprofs
TRANSPORTING NO FIELDS
WITH KEY profile_id = i_profile_id.
IF sy-subrc = 0.
r_boolean = abap_true.
ELSE.
r_boolean = abap_false.
ENDIF.
ENDMETHOD. "mprofile_is_valid
METHOD role_is_valid.
READ TABLE lcl_application=>lt_roles
TRANSPORTING NO FIELDS
WITH KEY role_id = i_role_id.
IF sy-subrc = 0.
r_boolean = abap_true.
ELSE.
r_boolean = abap_false.
ENDIF.
ENDMETHOD. "role_is_valid
METHOD task_is_valid.
READ TABLE lcl_application=>lt_tasks
TRANSPORTING NO FIELDS
WITH KEY task_id = i_task_id.
IF sy-subrc = 0.
r_boolean = abap_true.
ELSE.
r_boolean = abap_false.
ENDIF.
ENDMETHOD. "task_is_valid
METHOD get_bpc_component_version.
DATA: ls_cvers TYPE cvers.
CALL FUNCTION 'UPG_GET_SINGLE_COMPREL'
EXPORTING
iv_component = `CPMBPC`
IMPORTING
ev_version = ls_cvers
EXCEPTIONS
OTHERS = 4.
IF sy-subrc = 0.
lv_release = ls_cvers-release.
lv_splevel = ls_cvers-extrelease.
ENDIF.
ENDMETHOD. "get_bpc_component_version
ENDCLASS. "lcl_application IMPLEMENTATION
Note: This ABAP program needs to add text element as below
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |