BPC权限批导

   1 *&---------------------------------------------------------------------*
   2 *& Report ZUJE_MASS_USER_MGMT
   3 *&---------------------------------------------------------------------*
   4 *&
   5 *&---------------------------------------------------------------------*
   6 REPORT ZUJE_MASS_USER_MGMT.
   7 *&---------------------------------------------------------------------*
   8 *& Report  ZUJE_MASS_USER_MGMT
   9 *&
  10 *& Version: 10.0 SP3 and higher
  11 *&
  12 *&---------------------------------------------------------------------*
  13 *& Created By: zhengsq
  14 *& Created On: 31/08/2016
  15 *&---------------------------------------------------------------------*
  16 *REPORT  zuje_mass_user_mgmt.
  17 
  18 TYPE-POOLS: ABAP, VRM.
  19 
  20 *----------------------------------------------------------------------*
  21 *       CLASS lcl_application DEFINITION
  22 *----------------------------------------------------------------------*
  23 CLASS LCL_APPLICATION DEFINITION FINAL.
  24 
  25   PUBLIC SECTION.
  26 
  27     CONSTANTS: LC_COMMA TYPE CHAR01 VALUE ',',
  28                LC_PIPE TYPE CHAR01 VALUE '|',
  29                LC_TAB TYPE CHAR10 VALUE 'TAB'.
  30 
  31     TYPES: BEGIN OF T_APPLDIM,
  32             APPL_ID TYPE UJ_APPL_ID,
  33             DIMENSION TYPE UJ_DIM_NAME,
  34           END OF T_APPLDIM.
  35 
  36     TYPES: BEGIN OF T_APPLDIMMEMBERS,
  37             APPL_ID TYPE UJ_APPL_ID,
  38             DIMENSION TYPE UJ_DIM_NAME,
  39             MEMBER TYPE UJ_DIM_MEMBER,
  40           END OF T_APPLDIMMEMBERS.
  41 
  42     CLASS-METHODS: FILE_F4 RETURNING VALUE(R_FILE) TYPE STRING,
  43                    DIRECTORY_F4 RETURNING VALUE(R_PATH) TYPE STRING,
  44                    GET_INITIAL_DIRECTORY RETURNING VALUE(R_PATH) TYPE STRING,
  45                    SET_DELIMITER_LISTBOX,
  46                    SET_DELIMITER,
  47                    EXPORT_USERS_TO_FILE,
  48                    IMPORT_USERS_FROM_FILE,
  49                    EXPORT_TEAMS_TO_FILE,
  50                    IMPORT_TEAMS_FROM_FILE,
  51                    EXPORT_TEAM_ASSIGN_TO_FILE,
  52                    IMPORT_TEAM_ASSIGN_FROM_FILE,
  53                    EXPORT_TASK_PROFILES_TO_FILE,
  54                    IMPORT_TASK_PROFILES_FROM_FILE,
  55                    EXPORT_DATA_PROFILES_TO_FILE,
  56                    IMPORT_DATA_PROFILES_FROM_FILE,
  57                    EXPORT_TAP_ASSIGN_TO_FILE,
  58                    IMPORT_TAP_ASSIGN_FROM_FILE,
  59                    EXPORT_DAP_ASSIGN_TO_FILE,
  60                    IMPORT_DAP_ASSIGN_FROM_FILE,
  61                    GET_BPC_COMPONENT_VERSION,
  62                    CHECK_BPC_COMPONENT_IS_VALID RETURNING VALUE(R_VALID) TYPE ABAP_BOOL,
  63                    GET_ENVIRONMENT_DATA IMPORTING I_ENVIRONMENT_ID TYPE UJ_APPSET_ID
  64                                         EXCEPTIONS ENVIRONMENT_NOT_FOUND
  65                                                    UJ_EXCEPTION_ERROR.
  66 
  67   PRIVATE SECTION.
  68 
  69     CLASS-DATA: LV_ENVIRONMENT_ID TYPE UJA_S_APPSET_INFO-APPSET_ID.
  70     CLASS-DATA: LV_DELIMITER TYPE STRING.
  71     CLASS-DATA: LV_RELEASE TYPE SAPRELEASE.
  72     CLASS-DATA: LV_SPLEVEL TYPE SAPPATCHLV.
  73     CLASS-DATA: LS_ENVIRONMENT_INFO TYPE UJA_S_APPSET_INFO.
  74 
  75     CLASS-DATA: LT_APPL_INFO TYPE UJA_T_APPL_INFO.
  76     CLASS-DATA: LT_APPL_DIM TYPE TABLE OF T_APPLDIM.
  77     CLASS-DATA: LT_MEMBERS TYPE TABLE OF T_APPLDIMMEMBERS.
  78     CLASS-DATA: LT_TEAMS_LIST TYPE UJE_T_TEAMDETAIL.
  79     CLASS-DATA: LT_USERS_LIST TYPE UJE_T_USER.
  80     CLASS-DATA: LT_USER_DETAIL TYPE UJE_T_USERINFO_DETAIL.
  81     CLASS-DATA: LT_TASK_PROFILES TYPE UJE_T_TASK_PROF_DETAIL.
  82     CLASS-DATA: LT_DATA_ACCESS_PROFILES TYPE UJE_T_MBR_PROF_APP.
  83     CLASS-DATA: LT_SYSTASKS TYPE UJE_T_ROLE_TSKASG.
  84 
  85     CLASS-DATA: LO_UJE_EXCEPTION TYPE REF TO CX_UJE_EXCEPTION.
  86     CLASS-DATA: LO_CONTEXT TYPE REF TO IF_UJ_CONTEXT.
  87     CLASS-DATA: LT_ALV_MESSAGES TYPE UJ0_T_MESSAGE.
  88 
  89     CLASS-METHODS: SET_GLOBAL_CONTEXT,
  90                    RENDER_ALV,
  91                    ADD_EXCEPTION_TO_MESSAGE_TABLE
  92                            IMPORTING IO_EXCEPTION TYPE REF TO CX_UJ_STATIC_CHECK,
  93                    ADD_MESSAGE_TO_MESSAGE_TABLE
  94                            IMPORTING I_MSGID TYPE SYMSGID
  95                                      I_MSGTY TYPE SYMSGTY
  96                                      I_MSGNO TYPE SYMSGNO
  97                                      I_MESSAGE TYPE BAPI_MSG,
  98                    UPLOAD IMPORTING I_FILEPATH TYPE ANY
  99                           RETURNING VALUE(RT_STRTAB) TYPE STRINGTAB,
 100                    DOWNLOAD IMPORTING I_FILEPATH TYPE ANY
 101                                      IT_DATATAB TYPE STANDARD TABLE,
 102                    USER_IS_VALID IMPORTING I_USER_ID TYPE ANY
 103                                  RETURNING VALUE(R_BOOLEAN) TYPE ABAP_BOOL,
 104                    TEAM_IS_VALID IMPORTING I_TEAM_ID TYPE ANY
 105                                  RETURNING VALUE(R_BOOLEAN) TYPE ABAP_BOOL,
 106                    TPROFILE_IS_VALID IMPORTING I_PROFILE_ID TYPE ANY
 107                                      RETURNING VALUE(R_BOOLEAN) TYPE ABAP_BOOL,
 108                    DPROFILE_IS_VALID IMPORTING I_PROFILE_ID TYPE ANY
 109                                      RETURNING VALUE(R_BOOLEAN) TYPE ABAP_BOOL,
 110                    TASK_IS_VALID IMPORTING I_TASK_ID TYPE ANY
 111                                  RETURNING VALUE(R_BOOLEAN) TYPE ABAP_BOOL,
 112                    NW_USER_EXISTS IMPORTING I_USER_ID TYPE ANY
 113                                   RETURNING VALUE(R_BOOLEAN) TYPE ABAP_BOOL.
 114 
 115 ENDCLASS.                    "lcl_application DEFINITION
 116 
 117 SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
 118 PARAMETERS: P_EXPORT RADIOBUTTON GROUP GRP1 DEFAULT 'X' USER-COMMAND CHK.
 119 PARAMETERS: P_IMPORT RADIOBUTTON GROUP GRP1.
 120 SELECTION-SCREEN END OF BLOCK B1.
 121 SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
 122 PARAMETERS: P_ENV  TYPE UJA_APPSET_INFO-APPSET_ID.
 123 PARAMETERS: P_FILE TYPE STRING LOWER CASE.
 124 PARAMETERS: P_DELMT TYPE CHAR10 AS LISTBOX VISIBLE LENGTH 20
 125                        DEFAULT LCL_APPLICATION=>LC_COMMA.  "delimiter
 126 SELECTION-SCREEN END OF BLOCK B2.
 127 SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
 128 PARAMETERS: P_EUSERS RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 129 PARAMETERS: P_ETEAMS RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 130 PARAMETERS: P_ETEAMA RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 131 PARAMETERS: P_ETPROF RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 132 PARAMETERS: P_EDPROF RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 133 PARAMETERS: P_ETPRFA RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 134 PARAMETERS: P_EDPRFA RADIOBUTTON GROUP GRP2 MODIF ID EXP.
 135 SELECTION-SCREEN END OF BLOCK B3.
 136 SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.
 137 PARAMETERS: P_IUSERS RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 138 PARAMETERS: P_ITEAMS RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 139 PARAMETERS: P_ITEAMA RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 140 PARAMETERS: P_ITPROF RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 141 PARAMETERS: P_IDPROF RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 142 PARAMETERS: P_ITPRFA RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 143 PARAMETERS: P_IDPRFA RADIOBUTTON GROUP GRP3 MODIF ID IMP.
 144 SELECTION-SCREEN END OF BLOCK B4.
 145 
 146 INITIALIZATION.
 147 
 148   P_FILE = LCL_APPLICATION=>GET_INITIAL_DIRECTORY( ).
 149   LCL_APPLICATION=>SET_DELIMITER_LISTBOX( ).
 150   LCL_APPLICATION=>GET_BPC_COMPONENT_VERSION( ).
 151 
 152 *  IF LCL_APPLICATION=>CHECK_BPC_COMPONENT_IS_VALID( ) = ABAP_FALSE.
 153 *    MESSAGE I001(00) WITH 'BPC Component version must be 800 or 810'.
 154 *  ENDIF.
 155 
 156 AT SELECTION-SCREEN OUTPUT.
 157 
 158   LOOP AT SCREEN.
 159     IF P_EXPORT = ABAP_TRUE AND SCREEN-GROUP1 = 'IMP'.
 160       SCREEN-ACTIVE = '0'.
 161     ENDIF.
 162     IF P_IMPORT = ABAP_TRUE AND SCREEN-GROUP1 = 'EXP'.
 163       SCREEN-ACTIVE = '0'.
 164     ENDIF.
 165     MODIFY SCREEN.
 166   ENDLOOP.
 167 
 168 AT SELECTION-SCREEN.
 169   CASE ABAP_TRUE.
 170     WHEN P_EXPORT.
 171       CLEAR: P_IUSERS, P_ITEAMS, P_ITEAMA, P_ITPROF,
 172              P_IDPROF, P_ITPRFA, P_IDPRFA.
 173     WHEN P_IMPORT.
 174       CLEAR: P_EUSERS, P_ETEAMS, P_ETEAMA, P_ETPROF,
 175              P_EDPROF, P_ETPRFA, P_EDPRFA.
 176   ENDCASE.
 177 
 178   IF SY-UCOMM <> 'CHK'.
 179 *    IF LCL_APPLICATION=>CHECK_BPC_COMPONENT_IS_VALID( ) = ABAP_FALSE.
 180 *       MESSAGE E001(00) WITH 'BPC Component version must be 800'.
 181 *    ENDIF.
 182     IF P_ENV IS INITIAL.
 183       MESSAGE E001(00) WITH 'Please enter an Environment Id'.
 184     ENDIF.
 185     IF P_FILE IS INITIAL.
 186       MESSAGE E001(00) WITH 'Please enter a valid directory or file'.
 187     ENDIF.
 188     IF P_DELMT IS INITIAL.
 189       MESSAGE E001(00) WITH 'Please specify a delimiter'.
 190     ENDIF.
 191   ENDIF.
 192 
 193 AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
 194 
 195   CASE ABAP_TRUE.
 196     WHEN P_EXPORT.  P_FILE = LCL_APPLICATION=>DIRECTORY_F4( ).
 197     WHEN P_IMPORT.  P_FILE = LCL_APPLICATION=>FILE_F4( ).
 198   ENDCASE.
 199 
 200 START-OF-SELECTION.
 201 
 202   LCL_APPLICATION=>SET_DELIMITER( ).
 203 
 204   LCL_APPLICATION=>GET_ENVIRONMENT_DATA(
 205               EXPORTING  I_ENVIRONMENT_ID =  P_ENV
 206               EXCEPTIONS ENVIRONMENT_NOT_FOUND  = 1 ).
 207   IF SY-SUBRC <> 0.
 208     RETURN.
 209   ENDIF.
 210 
 211   CASE ABAP_TRUE.
 212     WHEN P_EUSERS.  LCL_APPLICATION=>EXPORT_USERS_TO_FILE( ).
 213     WHEN P_IUSERS.  LCL_APPLICATION=>IMPORT_USERS_FROM_FILE( ).
 214     WHEN P_ETEAMS.  LCL_APPLICATION=>EXPORT_TEAMS_TO_FILE( ).
 215     WHEN P_ITEAMS.  LCL_APPLICATION=>IMPORT_TEAMS_FROM_FILE( ).
 216     WHEN P_ETEAMA.  LCL_APPLICATION=>EXPORT_TEAM_ASSIGN_TO_FILE( ).
 217     WHEN P_ITEAMA.  LCL_APPLICATION=>IMPORT_TEAM_ASSIGN_FROM_FILE( ).
 218     WHEN P_ETPROF.  LCL_APPLICATION=>EXPORT_TASK_PROFILES_TO_FILE( ).
 219     WHEN P_ITPROF.  LCL_APPLICATION=>IMPORT_TASK_PROFILES_FROM_FILE( ).
 220     WHEN P_EDPROF.  LCL_APPLICATION=>EXPORT_DATA_PROFILES_TO_FILE( ).
 221     WHEN P_IDPROF.  LCL_APPLICATION=>IMPORT_DATA_PROFILES_FROM_FILE( ).
 222     WHEN P_ETPRFA.  LCL_APPLICATION=>EXPORT_TAP_ASSIGN_TO_FILE( ).
 223     WHEN P_ITPRFA.  LCL_APPLICATION=>IMPORT_TAP_ASSIGN_FROM_FILE( ).
 224     WHEN P_EDPRFA.  LCL_APPLICATION=>EXPORT_DAP_ASSIGN_TO_FILE( ).
 225     WHEN P_IDPRFA.  LCL_APPLICATION=>IMPORT_DAP_ASSIGN_FROM_FILE( ).
 226   ENDCASE.
 227 
 228 *----------------------------------------------------------------------*
 229 *       CLASS lcl_application IMPLEMENTATION
 230 *----------------------------------------------------------------------*
 231 CLASS LCL_APPLICATION IMPLEMENTATION.
 232 
 233   METHOD FILE_F4.
 234 
 235     DATA: LT_FILE_TABLE TYPE FILETABLE.
 236     DATA: LS_FILE_TABLE LIKE LINE OF LT_FILE_TABLE.
 237 
 238     DATA: LV_RC TYPE SY-SUBRC.
 239 
 240     CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG(
 241       CHANGING
 242         FILE_TABLE = LT_FILE_TABLE
 243         RC         = LV_RC ).
 244     CLEAR LS_FILE_TABLE .
 245     READ TABLE LT_FILE_TABLE INTO LS_FILE_TABLE INDEX 1.
 246     IF SY-SUBRC  = 0.
 247       R_FILE = LS_FILE_TABLE-FILENAME.
 248     ENDIF.
 249 
 250   ENDMETHOD.                                                "file_f4
 251 
 252   METHOD DIRECTORY_F4.
 253 
 254     CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE(
 255         CHANGING
 256           SELECTED_FOLDER      = R_PATH
 257         EXCEPTIONS
 258           OTHERS               = 4 ).
 259 
 260   ENDMETHOD.                    "directory_f4
 261 
 262   METHOD UPLOAD.
 263 
 264     CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD(
 265           EXPORTING
 266             FILENAME = I_FILEPATH
 267           CHANGING
 268             DATA_TAB = RT_STRTAB
 269           EXCEPTIONS
 270             OTHERS   = 19 ).
 271     IF SY-SUBRC <> 0.
 272       MESSAGE I001(00) WITH 'File not found, check file path and name'.
 273     ENDIF.
 274 
 275     DELETE RT_STRTAB WHERE TABLE_LINE IS INITIAL.
 276 
 277   ENDMETHOD.                    "upload
 278 
 279   METHOD DOWNLOAD.
 280 
 281     DATA: LT_DATATAB TYPE STRINGTAB.
 282     DATA: LS_DATATAB LIKE LINE OF LT_DATATAB.
 283 
 284     FIELD-SYMBOLS: <LS_DATA> TYPE ANY.
 285     FIELD-SYMBOLS: <LV_FIELD> TYPE ANY.
 286 
 287 * Convert table to delimited string table
 288     LOOP AT IT_DATATAB ASSIGNING <LS_DATA>.
 289       CLEAR LS_DATATAB.
 290       DO.
 291         ASSIGN COMPONENT SY-INDEX
 292                          OF STRUCTURE <LS_DATA> TO <LV_FIELD>.
 293         IF SY-SUBRC <> 0.
 294           EXIT.
 295         ENDIF.
 296         IF LS_DATATAB IS INITIAL.
 297           LS_DATATAB = <LV_FIELD>.
 298         ELSE.
 299           CONCATENATE LS_DATATAB <LV_FIELD>
 300                           INTO LS_DATATAB SEPARATED BY LCL_APPLICATION=>LV_DELIMITER.
 301         ENDIF.
 302       ENDDO.
 303       APPEND LS_DATATAB TO LT_DATATAB.
 304     ENDLOOP.
 305 
 306     CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD(
 307        EXPORTING
 308          FILENAME = I_FILEPATH
 309        CHANGING
 310          DATA_TAB = LT_DATATAB
 311        EXCEPTIONS
 312          OTHERS   = 24 ).
 313     IF SY-SUBRC <> 0.
 314       MESSAGE I001(00)
 315           WITH 'File not downloaded, check file path and name'.
 316     ENDIF.
 317 
 318   ENDMETHOD.                    "download
 319 
 320   METHOD GET_INITIAL_DIRECTORY.
 321 
 322     CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY(
 323       CHANGING
 324         DESKTOP_DIRECTORY    = R_PATH ).
 325     CL_GUI_CFW=>FLUSH( ).
 326 
 327     CONCATENATE R_PATH '\*.csv' INTO R_PATH.
 328 
 329   ENDMETHOD.                    "get_initial_directory
 330 
 331   METHOD EXPORT_USERS_TO_FILE.
 332 
 333     TYPES: BEGIN OF T_OUTPUT,
 334             USER_ID TYPE UJE_USER-USER_ID,
 335            END OF T_OUTPUT.
 336 
 337     DATA: LS_USERS TYPE UJE_S_USERINFO.
 338 
 339     DATA: LT_OUTPUT TYPE TABLE OF T_OUTPUT.
 340     DATA: LS_OUTPUT LIKE LINE OF LT_OUTPUT.
 341 
 342     REFRESH LT_OUTPUT.
 343     LOOP AT LCL_APPLICATION=>LT_USERS_LIST INTO LS_USERS.
 344       LS_OUTPUT-USER_ID = LS_USERS-USER_ID.
 345       APPEND LS_OUTPUT TO LT_OUTPUT.
 346     ENDLOOP.
 347 
 348 * Download table
 349     LCL_APPLICATION=>DOWNLOAD(
 350                     EXPORTING I_FILEPATH = P_FILE
 351                               IT_DATATAB = LT_OUTPUT ).
 352 
 353   ENDMETHOD.                    "export_users_to_file
 354 
 355   METHOD IMPORT_USERS_FROM_FILE.
 356 
 357     DATA: LV_USER_ID TYPE UJ_USER_ID.
 358     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
 359 
 360     DATA: LT_USERS TYPE UJE_T_USER_ID.
 361     DATA: LS_USERS LIKE LINE OF LT_USERS.
 362 
 363     DATA: LT_STRTAB TYPE STRINGTAB.
 364     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
 365 
 366     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
 367 
 368     LOOP AT LT_STRTAB INTO LS_STRTAB.
 369 
 370       LV_USER_ID = LS_STRTAB.  "should only be the user id
 371 
 372       IF LCL_APPLICATION=>NW_USER_EXISTS( LV_USER_ID ) = ABAP_FALSE.
 373         CONCATENATE 'User ID' LV_USER_ID
 374                     'does not exist as a NetWeaver user in SU01'
 375                             INTO LV_MESSAGE SEPARATED BY SPACE.
 376         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 377                                       I_MESSAGE = LV_MESSAGE ).
 378         CONTINUE.  "Skip, do not process
 379       ENDIF.
 380 
 381 * Check if user already exists, if so, issue warning and continue.
 382       IF LCL_APPLICATION=>USER_IS_VALID( LV_USER_ID ) = ABAP_TRUE.
 383         CONCATENATE 'User ID' LV_USER_ID
 384                     'has already been added to environment' LV_ENVIRONMENT_ID
 385                             INTO LV_MESSAGE SEPARATED BY SPACE.
 386         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `W` I_MSGNO = `001`
 387                                       I_MESSAGE = LV_MESSAGE ).
 388         CONTINUE.  "Skip, do not process
 389       ENDIF.
 390 
 391       TRY.
 392           CLEAR LS_USERS. REFRESH LT_USERS.
 393           LS_USERS = LV_USER_ID.
 394           APPEND LS_USERS TO LT_USERS.
 395 
 396           CL_UJE_USER=>ADD_USERS(
 397                         EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 398                                   IT_USERS = LT_USERS ).
 399           CONCATENATE 'User ID' LV_USER_ID
 400                       'has been added successfully'
 401                               INTO LV_MESSAGE SEPARATED BY SPACE.
 402           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
 403                                         I_MESSAGE = LV_MESSAGE ).
 404 
 405         CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
 406           ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
 407           CONCATENATE 'User ID'  LV_USER_ID
 408                       'not added due to error'
 409                                INTO LV_MESSAGE SEPARATED BY SPACE.
 410           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 411                                         I_MESSAGE = LV_MESSAGE ).
 412       ENDTRY.
 413 
 414     ENDLOOP.
 415 
 416     LCL_APPLICATION=>RENDER_ALV( ).
 417 
 418   ENDMETHOD.                    "create_users_from_file
 419 
 420   METHOD EXPORT_TEAMS_TO_FILE.
 421 
 422     TYPES: BEGIN OF T_OUTPUT,
 423             TEAM_ID TYPE UJE_S_TEAM-TEAM_ID,
 424             DESCRIPTION TYPE UJE_S_TEAM-DESCRIPTION,
 425            END OF T_OUTPUT.
 426     DATA: LS_TEAMS TYPE UJE_S_TEAMDETAIL.
 427 
 428     DATA: LT_OUTPUT TYPE TABLE OF T_OUTPUT.
 429     DATA: LS_OUTPUT LIKE LINE OF LT_OUTPUT.
 430 
 431     REFRESH LT_OUTPUT.
 432     LOOP AT LCL_APPLICATION=>LT_TEAMS_LIST INTO LS_TEAMS.
 433       MOVE-CORRESPONDING LS_TEAMS TO LS_OUTPUT.
 434       APPEND LS_OUTPUT TO LT_OUTPUT.
 435     ENDLOOP.
 436 
 437 * Download table
 438     LCL_APPLICATION=>DOWNLOAD( EXPORTING I_FILEPATH = P_FILE
 439                                          IT_DATATAB = LT_OUTPUT ).
 440 
 441   ENDMETHOD.                    "export_teams_to_file
 442 
 443   METHOD IMPORT_TEAMS_FROM_FILE.
 444 
 445     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
 446 
 447     DATA: LT_TEAM TYPE UJE_T_TEAM.
 448     DATA: LS_TEAM TYPE UJE_S_TEAM.
 449 
 450     DATA: LT_STRTAB TYPE STRINGTAB.
 451     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
 452 
 453     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
 454 
 455     LOOP AT LT_STRTAB INTO LS_STRTAB.
 456 
 457       CLEAR LS_TEAM. REFRESH LT_TEAM.
 458       SPLIT LS_STRTAB AT LCL_APPLICATION=>LV_DELIMITER INTO LS_TEAM-TEAM_ID
 459                                   LS_TEAM-DESCRIPTION.
 460       APPEND LS_TEAM TO LT_TEAM.
 461 
 462       TRY.
 463 * Check if team is already a valid team, if so, update.
 464           IF LCL_APPLICATION=>TEAM_IS_VALID( LS_TEAM-TEAM_ID ) = ABAP_FALSE.
 465             CL_UJE_TEAM=>CREATE_TEAMS(
 466              EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 467                        IT_TEAMS = LT_TEAM ).
 468           ELSE.
 469             CL_UJE_TEAM=>UPDATE_TEAMS(
 470              EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 471                        IT_TEAMS = LT_TEAM ).
 472           ENDIF.
 473 
 474           CONCATENATE 'Team' LS_TEAM-TEAM_ID
 475                        'has been created/updated successfully'
 476                            INTO LV_MESSAGE SEPARATED BY SPACE.
 477           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
 478                                         I_MESSAGE = LV_MESSAGE ).
 479         CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
 480           ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
 481           CONCATENATE 'Team' LS_TEAM-TEAM_ID
 482                       'not created/updated due to error'
 483                             INTO LV_MESSAGE SEPARATED BY SPACE.
 484           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 485                                         I_MESSAGE = LV_MESSAGE ).
 486       ENDTRY.
 487 
 488     ENDLOOP.
 489 
 490     LCL_APPLICATION=>RENDER_ALV( ).
 491 
 492   ENDMETHOD.                    "create_teams_from_file
 493 
 494   METHOD EXPORT_TEAM_ASSIGN_TO_FILE.
 495 
 496     TYPES: BEGIN OF T_USER_ASSIGN,
 497             USER_ID TYPE UJE_S_USER_TEAM-USER_ID,
 498             TEAM_ID TYPE UJE_S_USER_TEAM-TEAM_ID,
 499             TEAMLEADER TYPE UJE_S_USER_TEAM-TEAMLEADER,
 500            END OF T_USER_ASSIGN.
 501 
 502     DATA: LT_TEAM_ASSIGN TYPE TABLE OF T_USER_ASSIGN.
 503     DATA: LS_TEAM_ASSIGN LIKE LINE OF LT_TEAM_ASSIGN.
 504 
 505     DATA: LS_USER_TEAM TYPE UJE_S_TEAM.
 506     DATA: LS_USER_DETAIL LIKE LINE OF LT_USER_DETAIL.
 507 
 508 * Loop through users, then through assigned teams,
 509 * check table for team leader and set flag.
 510     LOOP AT LCL_APPLICATION=>LT_USER_DETAIL INTO LS_USER_DETAIL.
 511       CLEAR LS_TEAM_ASSIGN.
 512       LS_TEAM_ASSIGN-USER_ID = LS_USER_DETAIL-USER_ID.
 513       LOOP AT LS_USER_DETAIL-TEAMS INTO LS_USER_TEAM.
 514         LS_TEAM_ASSIGN-TEAM_ID = LS_USER_TEAM-TEAM_ID.
 515         READ TABLE LS_USER_DETAIL-LEADING_TEAMS
 516                  TRANSPORTING NO FIELDS
 517                       WITH KEY TEAM_ID = LS_USER_TEAM-TEAM_ID.
 518         IF SY-SUBRC = 0.
 519           LS_TEAM_ASSIGN-TEAMLEADER  = ABAP_TRUE.
 520         ENDIF.
 521         APPEND LS_TEAM_ASSIGN TO LT_TEAM_ASSIGN.
 522       ENDLOOP.
 523     ENDLOOP.
 524 
 525 * Download table
 526     LCL_APPLICATION=>DOWNLOAD( EXPORTING I_FILEPATH = P_FILE
 527                                          IT_DATATAB = LT_TEAM_ASSIGN ).
 528 
 529   ENDMETHOD.                    "export_team_assign_to_file
 530 
 531   METHOD IMPORT_TEAM_ASSIGN_FROM_FILE.
 532 
 533     TYPES: BEGIN OF T_USER_ASSIGN,
 534             USER_ID TYPE UJE_S_USER_TEAM-USER_ID,
 535             TEAM_ID TYPE UJE_S_USER_TEAM-TEAM_ID,
 536             TEAMLEADER TYPE UJE_S_USER_TEAM-TEAMLEADER,
 537            END OF T_USER_ASSIGN.
 538 
 539     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
 540 
 541     DATA: LT_USER_TEAM TYPE UJE_T_USER_TEAM.
 542     DATA: LS_USER_TEAM TYPE UJE_S_USER_TEAM.
 543 
 544     DATA: LS_TEAM_ASSIGN TYPE UJE_S_USER_TEAM.
 545 
 546     DATA: LT_MESSAGES TYPE UJ0_T_MESSAGE.
 547     DATA: LS_ALV_MESSAGES LIKE LINE OF LT_ALV_MESSAGES.
 548 
 549     DATA: LT_STRTAB TYPE STRINGTAB.
 550     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
 551 
 552     DATA: LS_USER_LIST TYPE UJE_S_USERINFO.
 553     DATA: LS_TEAMS_LIST LIKE LINE OF LT_TEAMS_LIST.
 554 
 555     DATA: LT_USERS TYPE UJE_T_USER_ACTION.
 556     DATA: LS_USERS LIKE LINE OF LT_USERS.
 557 
 558     DATA: LT_TEAMS TYPE UJE_T_TEAM.
 559     DATA: LS_TEAMS TYPE UJE_S_TEAM.
 560 
 561     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
 562 
 563     LOOP AT LT_STRTAB INTO LS_STRTAB.
 564 
 565       SPLIT LS_STRTAB AT LCL_APPLICATION=>LV_DELIMITER INTO LS_TEAM_ASSIGN-USER_ID
 566                                   LS_TEAM_ASSIGN-TEAM_ID
 567                                   LS_TEAM_ASSIGN-TEAMLEADER.
 568 
 569       CLEAR LS_USER_TEAM.
 570       LS_USER_TEAM-USER_ID = LS_TEAM_ASSIGN-USER_ID.
 571       LS_USER_TEAM-TEAM_ID = LS_TEAM_ASSIGN-TEAM_ID.
 572       LS_USER_TEAM-TEAMLEADER = LS_TEAM_ASSIGN-TEAMLEADER.
 573       TRANSLATE LS_USER_TEAM-TEAMLEADER USING 'YXyX1XxXN n 0 '. "Translate to X or space
 574       APPEND LS_USER_TEAM TO LT_USER_TEAM.
 575 
 576       IF LCL_APPLICATION=>TEAM_IS_VALID( LS_TEAM_ASSIGN-TEAM_ID ) = ABAP_FALSE.
 577         CONCATENATE 'Team' LS_TEAM_ASSIGN-TEAM_ID 'does not yet exist.'
 578                     'No user assigments done.'
 579                           INTO LV_MESSAGE SEPARATED BY SPACE.
 580         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 581                                       I_MESSAGE = LV_MESSAGE ).
 582         LCL_APPLICATION=>RENDER_ALV( ).
 583         RETURN.
 584       ENDIF.
 585 
 586       IF LCL_APPLICATION=>USER_IS_VALID( LS_TEAM_ASSIGN-USER_ID ) = ABAP_FALSE.
 587         CONCATENATE 'User' LS_TEAM_ASSIGN-USER_ID 'does not yet exist.'
 588                     'No user assigments done.'
 589                           INTO LV_MESSAGE SEPARATED BY SPACE.
 590         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 591                                       I_MESSAGE = LV_MESSAGE ).
 592         LCL_APPLICATION=>RENDER_ALV( ).
 593         RETURN.
 594       ENDIF.
 595 
 596     ENDLOOP.
 597 
 598 * Loop through existing teams, all updates for each team
 599 * will be done at one time.
 600     LOOP AT LCL_APPLICATION=>LT_TEAMS_LIST INTO LS_TEAMS_LIST.
 601 
 602 * Check that there is data for team assignment from file, otherwise skip
 603       READ TABLE LT_USER_TEAM TRANSPORTING NO FIELDS
 604                         WITH KEY TEAM_ID = LS_TEAMS_LIST-TEAM_ID.
 605       IF SY-SUBRC <> 0.
 606         CONTINUE.
 607       ENDIF.
 608 
 609 * Add existing team details to table.
 610       CLEAR LS_TEAMS. REFRESH LT_TEAMS.
 611       MOVE-CORRESPONDING LS_TEAMS_LIST TO LS_TEAMS.
 612       APPEND LS_TEAMS TO LT_TEAMS.
 613 
 614 * Add existing users to table
 615       REFRESH LT_USERS.
 616       LOOP AT LS_TEAMS_LIST-USERS INTO LS_USER_LIST.
 617         LS_USERS-USER_ID = LS_USER_LIST-USER_ID.
 618         READ TABLE LS_TEAMS_LIST-TEAM_LEADERS
 619                      TRANSPORTING NO FIELDS
 620                               WITH KEY USER_ID = LS_USER_LIST-USER_ID.
 621         IF SY-SUBRC = 0.
 622           LS_USERS-IS_LEADER = ABAP_TRUE.
 623         ENDIF.
 624         APPEND LS_USERS TO LT_USERS.
 625       ENDLOOP.
 626 
 627 * add new user to table, if already exists, update leader flag
 628       LOOP AT LT_USER_TEAM INTO LS_USER_TEAM
 629                        WHERE TEAM_ID = LS_TEAMS_LIST-TEAM_ID.
 630         READ TABLE LT_USERS INTO LS_USERS
 631                            WITH KEY  USER_ID = LS_USER_TEAM-USER_ID.
 632         IF SY-SUBRC = 0.
 633           LS_USERS-IS_LEADER = LS_USER_TEAM-TEAMLEADER.
 634           LS_USERS-ACTION = 'M'.
 635           MODIFY LT_USERS FROM LS_USERS INDEX SY-TABIX.
 636         ELSE.
 637           CLEAR LS_USERS.
 638           LS_USERS-USER_ID = LS_USER_TEAM-USER_ID.
 639           LS_USERS-IS_LEADER = LS_USER_TEAM-TEAMLEADER.
 640           LS_USERS-ACTION = 'I'.
 641           APPEND LS_USERS TO LT_USERS.
 642         ENDIF.
 643       ENDLOOP.
 644 
 645 * now update the user/team assignments
 646       TRY.
 647           CL_UJE_TEAM=>UPDATE_TEAMS(
 648                        EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 649                                  IT_TEAMS = LT_TEAMS
 650                                  IT_USERS = LT_USERS ).
 651           CONCATENATE 'Team' LS_TEAMS_LIST-TEAM_ID 'user assignments'
 652                       'have been updated successfully'
 653                            INTO LV_MESSAGE SEPARATED BY SPACE.
 654           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
 655                                         I_MESSAGE = LV_MESSAGE ).
 656         CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
 657           ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
 658           CONCATENATE 'Team' LS_TEAMS_LIST-TEAM_ID 'user assignments'
 659           'not updated due to error'
 660                INTO LV_MESSAGE SEPARATED BY SPACE.
 661           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 662                                         I_MESSAGE = LV_MESSAGE ).
 663       ENDTRY.
 664 
 665     ENDLOOP.
 666 
 667     LCL_APPLICATION=>RENDER_ALV( ).
 668 
 669   ENDMETHOD.                    "import_team_assign_from_file
 670 
 671   METHOD EXPORT_TASK_PROFILES_TO_FILE.
 672 
 673     TYPES: BEGIN OF T_OUTPUT,
 674             IDENTIFIER TYPE CHAR01, " Row Identifer
 675             PROFILE TYPE UJ_PROFILE_ID,
 676             VALUES TYPE STRING,
 677            END OF T_OUTPUT.
 678 
 679     DATA: LT_OUTPUT TYPE TABLE OF T_OUTPUT.
 680     DATA: LS_OUTPUT LIKE LINE OF LT_OUTPUT.
 681 
 682     DATA: LS_TASK_PROFILES LIKE LINE OF LCL_APPLICATION=>LT_TASK_PROFILES.
 683 
 684     DATA: LS_TASKS TYPE UJE_S_TASK_INFO.
 685     DATA: LS_USERS TYPE UJE_S_USERINFO.
 686     DATA: LS_TEAMS TYPE UJE_S_TEAM.
 687 
 688     LOOP AT LCL_APPLICATION=>LT_TASK_PROFILES INTO LS_TASK_PROFILES.
 689 
 690 * Write Header row
 691       CLEAR LS_OUTPUT.
 692       LS_OUTPUT-IDENTIFIER = 'H'.
 693       LS_OUTPUT-PROFILE  = LS_TASK_PROFILES-PROFILE_ID.
 694       LS_OUTPUT-VALUES = LS_TASK_PROFILES-DESCRIPTION.
 695       APPEND LS_OUTPUT TO LT_OUTPUT.
 696 
 697 * Write task assigments
 698       CLEAR LS_OUTPUT.
 699       LS_OUTPUT-IDENTIFIER = 'K'.
 700       LS_OUTPUT-PROFILE  = LS_TASK_PROFILES-PROFILE_ID.
 701       LOOP AT LS_TASK_PROFILES-TASKS INTO LS_TASKS.
 702         LS_OUTPUT-VALUES = LS_TASKS-TASK_ID.
 703         APPEND LS_OUTPUT TO LT_OUTPUT.
 704       ENDLOOP.
 705 
 706 * Write User Assignment
 707       CLEAR LS_OUTPUT.
 708       LS_OUTPUT-IDENTIFIER = 'U'.
 709       LS_OUTPUT-PROFILE  = LS_TASK_PROFILES-PROFILE_ID.
 710       LOOP AT LS_TASK_PROFILES-USERS INTO LS_USERS.
 711         LS_OUTPUT-VALUES = LS_USERS-USER_ID.
 712         APPEND LS_OUTPUT TO LT_OUTPUT.
 713       ENDLOOP.
 714 
 715 * Write Team Assignement
 716       CLEAR LS_OUTPUT.
 717       LS_OUTPUT-IDENTIFIER = 'T'.
 718       LS_OUTPUT-PROFILE  = LS_TASK_PROFILES-PROFILE_ID.
 719       LOOP AT LS_TASK_PROFILES-TEAMS INTO LS_TEAMS.
 720         LS_OUTPUT-VALUES = LS_TEAMS-TEAM_ID.
 721         APPEND LS_OUTPUT TO LT_OUTPUT.
 722       ENDLOOP.
 723 
 724     ENDLOOP.
 725 
 726 * Download table
 727     LCL_APPLICATION=>DOWNLOAD( EXPORTING I_FILEPATH = P_FILE
 728                                          IT_DATATAB = LT_OUTPUT ).
 729 
 730   ENDMETHOD.                    "export_task_profiles_to_file
 731 
 732   METHOD IMPORT_TASK_PROFILES_FROM_FILE.
 733 
 734     TYPES: BEGIN OF T_INPUT,
 735             IDENTIFIER TYPE CHAR01, " Row Identifer
 736             PROFILE TYPE UJ_PROFILE_ID,
 737             VALUES TYPE STRING,
 738            END OF T_INPUT.
 739 
 740     TYPES: BEGIN OF T_TASK_PROFILE,
 741             PROFILE TYPE UJE_S_PROFILE,
 742             TASK_INFO TYPE UJE_T_TASK_INFO,
 743             USERS_ASIN TYPE UJE_T_API_USER_ID,
 744             TEAMS_ASIN TYPE UJE_T_API_TEAM_ID,
 745            END OF T_TASK_PROFILE.
 746 
 747     DATA: LT_TASK_PROFILE TYPE TABLE OF T_TASK_PROFILE.
 748     DATA: LS_TASK_PROFILE LIKE LINE OF LT_TASK_PROFILE.
 749 
 750     DATA: LV_LAST_PROFILE TYPE UJ_PROFILE_ID.
 751 
 752     DATA: LS_USERS_ASIN TYPE UJE_S_API_USER_ID.
 753     DATA: LS_TEAMS_ASIN TYPE UJE_S_API_TEAM_ID.
 754     DATA: LS_TEAMS_LIST LIKE LINE OF LT_TEAMS_LIST.
 755 
 756     DATA: LT_TASK_INFO TYPE  UJE_T_TASK_INFO.
 757     DATA: LS_TASK_INFO LIKE LINE OF LT_TASK_INFO.
 758 
 759     DATA: LT_STRTAB TYPE STRINGTAB.
 760     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
 761 
 762     DATA: LT_INPUT TYPE TABLE OF T_INPUT.
 763     DATA: LS_INPUT LIKE LINE OF LT_INPUT.
 764 
 765     DATA: LT_TASKS TYPE UJE_T_TASK_ID.
 766     DATA: LS_TASKS LIKE LINE OF LT_TASKS.
 767 
 768     DATA: LT_PROFS TYPE UJE_T_PROFILE_ACTION.
 769     DATA: LS_PROFS LIKE LINE OF LT_PROFS.
 770 
 771     DATA: LT_TEAMS TYPE UJE_T_TEAM.
 772     DATA: LS_TEAMS LIKE LINE OF LT_TEAMS.
 773 
 774     DATA: LT_USERS TYPE UJE_T_USER_ID.
 775     DATA: LS_USERS LIKE LINE OF LT_USERS.
 776 
 777     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
 778     DATA: LV_OBJECT_ID TYPE STRING.
 779 
 780     DATA: LO_TASK_PROFILE_MGR TYPE REF TO CL_UJE_PROFILE_TASK.
 781 
 782 * Upload file
 783     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
 784 
 785 * Rip import file into internal table
 786     LOOP AT LT_STRTAB INTO LS_STRTAB.
 787       CLEAR LS_INPUT.
 788       SPLIT LS_STRTAB AT LCL_APPLICATION=>LV_DELIMITER INTO LS_INPUT-IDENTIFIER
 789                                   LS_INPUT-PROFILE
 790                                   LS_INPUT-VALUES.
 791       APPEND LS_INPUT TO LT_INPUT.
 792     ENDLOOP.
 793 
 794 * Build profile table containing all associated data
 795     SORT LT_INPUT STABLE ASCENDING BY PROFILE IDENTIFIER VALUES.
 796 
 797     LOOP AT LT_INPUT INTO LS_INPUT.
 798 
 799       IF LS_INPUT-PROFILE <> LV_LAST_PROFILE
 800           AND LV_LAST_PROFILE IS NOT INITIAL.
 801         APPEND LS_TASK_PROFILE TO LT_TASK_PROFILE.
 802         CLEAR LS_TASK_PROFILE.
 803       ENDIF.
 804 
 805 * Based on record identifier
 806       CASE LS_INPUT-IDENTIFIER.
 807         WHEN 'H'.  " Header
 808           LS_TASK_PROFILE-PROFILE-PROFILE_ID  = LS_INPUT-PROFILE.
 809           LS_TASK_PROFILE-PROFILE-DESCRIPTION = LS_INPUT-VALUES.
 810         WHEN 'K'.  " Task info
 811           LS_TASK_INFO-TASK_ID = LS_INPUT-VALUES.
 812           IF LCL_APPLICATION=>TASK_IS_VALID( LS_TASK_INFO-TASK_ID ) = ABAP_FALSE.
 813             CONCATENATE 'Task ID' LS_TASK_INFO-TASK_ID  'is not valid.'
 814                         'No task profile updates done.'
 815                                 INTO LV_MESSAGE SEPARATED BY SPACE.
 816             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 817                                           I_MESSAGE = LV_MESSAGE ).
 818             LCL_APPLICATION=>RENDER_ALV( ).
 819             RETURN.
 820           ENDIF.
 821           APPEND LS_TASK_INFO TO LS_TASK_PROFILE-TASK_INFO.
 822         WHEN 'U'.  " Users Assignments
 823           LS_USERS_ASIN  = LS_INPUT-VALUES.
 824           IF LCL_APPLICATION=>USER_IS_VALID( LS_USERS_ASIN ) = ABAP_FALSE.
 825             CONCATENATE 'User' LS_USERS_ASIN  'does not exist.'
 826                         'No task profile updates done.'
 827                                 INTO LV_MESSAGE SEPARATED BY SPACE.
 828             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 829                                           I_MESSAGE = LV_MESSAGE ).
 830             LCL_APPLICATION=>RENDER_ALV( ).
 831             RETURN.
 832           ENDIF.
 833           APPEND LS_USERS_ASIN  TO LS_TASK_PROFILE-USERS_ASIN.
 834         WHEN 'T'.  " Team Assignments
 835           LS_TEAMS_ASIN  = LS_INPUT-VALUES.
 836           IF LCL_APPLICATION=>TEAM_IS_VALID( LS_TEAMS_ASIN ) = ABAP_FALSE.
 837             CONCATENATE 'Team' LS_TEAMS_ASIN 'does not exist.'
 838                         'No task profile updates done.'
 839                                 INTO LV_MESSAGE SEPARATED BY SPACE.
 840             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 841                                           I_MESSAGE = LV_MESSAGE ).
 842             LCL_APPLICATION=>RENDER_ALV( ).
 843             RETURN.
 844           ENDIF.
 845           APPEND LS_TEAMS_ASIN  TO LS_TASK_PROFILE-TEAMS_ASIN.
 846       ENDCASE.
 847 
 848       LV_LAST_PROFILE = LS_INPUT-PROFILE.
 849 
 850       AT LAST.
 851         APPEND LS_TASK_PROFILE TO LT_TASK_PROFILE.
 852       ENDAT.
 853 
 854     ENDLOOP.
 855 
 856 * Now for each profile, call API to create/update
 857     LOOP AT LT_TASK_PROFILE INTO LS_TASK_PROFILE.
 858 
 859       REFRESH LT_TASKS.
 860       LOOP AT LS_TASK_PROFILE-TASK_INFO INTO LS_TASK_INFO.
 861         CLEAR LS_TASKS.
 862         LS_TASKS = LS_TASK_INFO-TASK_ID.
 863         APPEND LS_TASKS TO LT_TASKS.
 864       ENDLOOP.
 865 
 866       TRY.
 867 * Create the task profile.
 868           LV_OBJECT_ID = LS_TASK_PROFILE-PROFILE-PROFILE_ID.
 869           LO_TASK_PROFILE_MGR ?= CL_UJE_USER_MGR=>CREATE_OBJ(
 870                        I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 871                        I_OBJECT_ID = LV_OBJECT_ID
 872                        I_OBJECT_TYPE = 'CL_UJE_PROFILE_TASK' ).
 873           IF LCL_APPLICATION=>TPROFILE_IS_VALID( LS_TASK_PROFILE-PROFILE-PROFILE_ID ) = ABAP_FALSE.
 874             LO_TASK_PROFILE_MGR->CREATE(
 875                           EXPORTING I_TASK_PROF_DESC = LS_TASK_PROFILE-PROFILE-DESCRIPTION
 876                                     IT_TASKS = LT_TASKS ).
 877           ELSE.
 878             LO_TASK_PROFILE_MGR->UPDATE(
 879                            EXPORTING I_TASK_PROF_DESC = LS_TASK_PROFILE-PROFILE-DESCRIPTION
 880                                      IT_TASKS = LT_TASKS ).
 881           ENDIF.
 882 
 883 * Assign users
 884           LOOP AT LS_TASK_PROFILE-USERS_ASIN INTO LS_USERS_ASIN.
 885 
 886             CLEAR LS_USERS. REFRESH LT_USERS.
 887             LS_USERS = LS_USERS_ASIN-USER_ID.
 888             APPEND LS_USERS TO LT_USERS.
 889 
 890             CLEAR LS_PROFS. REFRESH LT_PROFS.
 891             LS_PROFS-PROFILE_ID = LS_TASK_PROFILE-PROFILE-PROFILE_ID.
 892             LS_PROFS-ACTION = 'I'.
 893             APPEND LS_PROFS TO LT_PROFS.
 894 
 895             TRY.
 896                 CL_UJE_USER=>UPDATE_USERS(
 897                   EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 898                             IT_USERS = LT_USERS
 899                             IT_TASK_PROFS = LT_PROFS ).
 900               CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
 901                 ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
 902                 CONCATENATE 'Task Profile' LS_TASK_PROFILE-PROFILE-PROFILE_ID
 903                             'not created/updated due to error'
 904                                  INTO LV_MESSAGE SEPARATED BY SPACE.
 905                 ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 906                                               I_MESSAGE = LV_MESSAGE ).
 907             ENDTRY.
 908 
 909           ENDLOOP.
 910 
 911 * Assign teams
 912           LOOP AT LS_TASK_PROFILE-TEAMS_ASIN INTO LS_TEAMS_ASIN.
 913 
 914             REFRESH LT_TEAMS.
 915             READ TABLE LT_TEAMS_LIST INTO LS_TEAMS_LIST
 916                             WITH KEY TEAM_ID = LS_TEAMS_ASIN-TEAM_ID.
 917             IF SY-SUBRC = 0.
 918               MOVE-CORRESPONDING LS_TEAMS_LIST TO LS_TEAMS.
 919               APPEND LS_TEAMS TO LT_TEAMS.
 920             ENDIF.
 921 
 922             CLEAR LS_PROFS. REFRESH LT_PROFS.
 923             LS_PROFS-PROFILE_ID = LS_TASK_PROFILE-PROFILE-PROFILE_ID.
 924             LS_PROFS-ACTION = 'I'.
 925             APPEND LS_PROFS TO LT_PROFS.
 926 
 927             TRY.
 928                 CL_UJE_TEAM=>UPDATE_TEAMS(
 929                              EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
 930                                        IT_TEAMS = LT_TEAMS
 931                                        IT_TASK_PROFS = LT_PROFS ).
 932               CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
 933                 ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
 934                 CONCATENATE 'Task Profile' LS_TASK_PROFILE-PROFILE-PROFILE_ID
 935                             'not created/updated due to error'
 936                                  INTO LV_MESSAGE SEPARATED BY SPACE.
 937                 ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 938                                               I_MESSAGE = LV_MESSAGE ).
 939             ENDTRY.
 940           ENDLOOP.
 941 
 942           CONCATENATE 'Task Profile' LS_TASK_PROFILE-PROFILE-PROFILE_ID
 943                       'has been created/updated successfully'
 944                            INTO LV_MESSAGE SEPARATED BY SPACE.
 945           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
 946                                         I_MESSAGE = LV_MESSAGE ).
 947 
 948         CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
 949           ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
 950           CONCATENATE 'Task Profile' LS_TASK_PROFILE-PROFILE-PROFILE_ID
 951                       'not created/updated due to error'
 952                            INTO LV_MESSAGE SEPARATED BY SPACE.
 953           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
 954                                         I_MESSAGE = LV_MESSAGE ).
 955       ENDTRY.
 956 
 957     ENDLOOP.
 958 
 959 * Display ALV
 960     LCL_APPLICATION=>RENDER_ALV( ).
 961 
 962   ENDMETHOD.                    "import_task_profiles_from_file
 963 
 964   METHOD EXPORT_DATA_PROFILES_TO_FILE.
 965 
 966     TYPES: BEGIN OF T_OUTPUT,
 967             IDENTIFIER TYPE CHAR01, " Row Identifer
 968             PROFILE TYPE UJ_PROFILE_ID,
 969             VALUES TYPE STRING,
 970            END OF T_OUTPUT.
 971 
 972     DATA: LT_OUTPUT TYPE TABLE OF T_OUTPUT.
 973     DATA: LS_OUTPUT LIKE LINE OF LT_OUTPUT.
 974 
 975     DATA: LT_DATA_PROF_DET TYPE UJE_T_MBR_PROF_DET.
 976     DATA: LS_DATA_PROF_DET LIKE LINE OF LT_DATA_PROF_DET.
 977 
 978     DATA: LT_USERS TYPE UJE_T_USER.
 979     DATA: LS_USERS LIKE LINE OF LT_USERS.
 980 
 981     DATA: LT_TEAMS TYPE UJE_T_TEAM.
 982     DATA: LS_TEAMS LIKE LINE OF LT_TEAMS.
 983 
 984     DATA: LS_DATA_ACCESS_PROFILES TYPE UJE_S_MBR_PROF_APP.
 985     DATA: LS_CUBE_ACC TYPE UJE_S_CUBEACC_DET.
 986     DATA: LS_DIMACC_DET TYPE UJE_S_DIMACC_DET.
 987     DATA: LS_MBRACC_DET  TYPE UJE_S_MBRACC_DET.
 988     DATA: LS_MEMBER TYPE UJE_S_MBR.
 989 
 990     DATA: LS_CUBE_MATRIX_ACC TYPE UJE_S_CUBEACC_MATRIX_DET.
 991     DATA: LS_DIMENSIONS TYPE UJ_DIM_NAME.
 992     DATA: LS_RIGHTS TYPE UJE_S_DIMACC_MATRIX_DET.
 993     DATA: LS_MEMBERS TYPE UJ_DIM_MEMBER.
 994 
 995     DATA: LO_PROFILE_DAO TYPE REF TO CL_UJE_PROFILE_DAO.
 996     DATA: LO_DATA_ACCESS_PROFILE_MGR TYPE REF TO CL_UJE_PROFILE_MEMACCESS.
 997 
 998     CREATE OBJECT LO_PROFILE_DAO
 999       EXPORTING
1000         I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID.
1001 
1002     CREATE OBJECT LO_DATA_ACCESS_PROFILE_MGR
1003       EXPORTING
1004         I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID.
1005 
1006     LOOP AT LCL_APPLICATION=>LT_DATA_ACCESS_PROFILES INTO LS_DATA_ACCESS_PROFILES.
1007 
1008       REFRESH: LT_DATA_PROF_DET.
1009       LO_DATA_ACCESS_PROFILE_MGR->GET_DETAILS(
1010                  EXPORTING
1011                        I_PROFILE_ID       = LS_DATA_ACCESS_PROFILES-PROFILE_ID
1012                  IMPORTING
1013                        ET_MBR_PROF_DETAIL = LT_DATA_PROF_DET ).
1014 
1015       REFRESH: LT_USERS, LT_TEAMS.
1016       LO_PROFILE_DAO->GET_DETAILS( EXPORTING I_PROFILE_ID = LS_DATA_ACCESS_PROFILES-PROFILE_ID
1017                                              I_PROFILE_CLASS = `MBR`
1018                                    IMPORTING ET_USERS = LT_USERS
1019                                              ET_TEAMS = LT_TEAMS ).
1020 
1021       CLEAR LS_DATA_PROF_DET.
1022       READ TABLE LT_DATA_PROF_DET INTO LS_DATA_PROF_DET
1023                      WITH KEY PROFILE_AGR_NAME = LS_DATA_ACCESS_PROFILES-PROFILE_ID. "Should only be 1 row
1024       IF SY-SUBRC <> 0.
1025       ENDIF.
1026 
1027 * Write Header row
1028       CLEAR LS_OUTPUT.
1029       LS_OUTPUT-IDENTIFIER = 'H'.
1030       LS_OUTPUT-PROFILE  = LS_DATA_PROF_DET-PROFILE_AGR_NAME.
1031       LS_OUTPUT-VALUES  = LS_DATA_PROF_DET-DESCRIPTION.
1032       APPEND LS_OUTPUT TO LT_OUTPUT.
1033 
1034 * Write Member detail data.
1035       LOOP AT LT_DATA_PROF_DET INTO LS_DATA_PROF_DET.
1036 
1037         CLEAR LS_OUTPUT.
1038         LS_OUTPUT-IDENTIFIER = 'M'.
1039         LS_OUTPUT-PROFILE  = LS_DATA_ACCESS_PROFILES-PROFILE_ID.
1040 
1041         IF LS_DATA_PROF_DET-CUBE_ACC IS NOT INITIAL.
1042           LOOP AT LS_DATA_PROF_DET-CUBE_ACC INTO LS_CUBE_ACC.
1043             LOOP AT LS_CUBE_ACC-DIMACC_DET INTO LS_DIMACC_DET.
1044               LOOP AT LS_DIMACC_DET-MBRACC_DET INTO LS_MBRACC_DET.
1045                 LOOP AT LS_MBRACC_DET-MEMBER INTO LS_MEMBER.
1046                   CONCATENATE LS_DIMACC_DET-DIMENSION
1047                               LS_CUBE_ACC-APPLICATION_ID
1048                              "ls_cube_acc-matrix   " Not needed
1049                               LS_MEMBER-MBR_ID
1050                               LS_MBRACC_DET-RWD
1051                                  INTO LS_OUTPUT-VALUES SEPARATED BY LCL_APPLICATION=>LV_DELIMITER.
1052                   APPEND LS_OUTPUT TO LT_OUTPUT.
1053                 ENDLOOP.
1054               ENDLOOP.
1055             ENDLOOP.
1056           ENDLOOP.
1057         ENDIF.
1058 
1059       ENDLOOP.
1060 
1061 * Write User and Team assignments.
1062       LOOP AT LT_USERS INTO LS_USERS.
1063         CLEAR LS_OUTPUT.
1064         LS_OUTPUT-IDENTIFIER = 'U'.
1065         LS_OUTPUT-PROFILE  = LS_DATA_ACCESS_PROFILES-PROFILE_ID.
1066         LS_OUTPUT-VALUES = LS_USERS-USER_ID.
1067         APPEND LS_OUTPUT TO LT_OUTPUT.
1068       ENDLOOP.
1069 
1070       LOOP AT LT_TEAMS INTO LS_TEAMS.
1071         CLEAR LS_OUTPUT.
1072         LS_OUTPUT-IDENTIFIER = 'T'.
1073         LS_OUTPUT-PROFILE  = LS_DATA_ACCESS_PROFILES-PROFILE_ID.
1074         LS_OUTPUT-VALUES = LS_TEAMS-TEAM_ID.
1075         APPEND LS_OUTPUT TO LT_OUTPUT.
1076       ENDLOOP.
1077 
1078     ENDLOOP.
1079 
1080 * Download table
1081     LCL_APPLICATION=>DOWNLOAD( EXPORTING I_FILEPATH = P_FILE
1082                                          IT_DATATAB = LT_OUTPUT ).
1083 
1084   ENDMETHOD.                    "export_mem_profiles_to_file
1085 
1086   METHOD IMPORT_DATA_PROFILES_FROM_FILE.
1087 
1088     TYPES: BEGIN OF T_INPUT,
1089             IDENTIFIER TYPE CHAR01, " Row Identifer
1090             PROFILE TYPE UJ_PROFILE_ID,
1091             VALUES TYPE STRING,
1092            END OF T_INPUT.
1093 
1094     TYPES: BEGIN OF T_DATAACC_PROFILE,
1095             PROFILE TYPE UJE_S_PROFILE,
1096             DATAACC TYPE UJE_T_MEMACCESS,
1097             USERS_ASIN TYPE UJE_T_API_USER_ID,
1098             TEAMS_ASIN TYPE UJE_T_API_TEAM_ID,
1099            END OF T_DATAACC_PROFILE.
1100 
1101     DATA: LT_DATAACC_PROFILE TYPE TABLE OF T_DATAACC_PROFILE.
1102     DATA: LS_DATAACC_PROFILE LIKE LINE OF LT_DATAACC_PROFILE.
1103 
1104     DATA: LV_LAST_PROFILE TYPE UJ_PROFILE_ID.
1105 
1106     DATA: LT_DATAACCESS TYPE UJE_T_MEMACCESS.
1107     DATA: LS_DATAACCESS LIKE LINE OF LT_DATAACCESS.
1108 
1109     DATA: LT_STRTAB TYPE STRINGTAB.
1110     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
1111 
1112     DATA: LT_INPUT TYPE TABLE OF T_INPUT.
1113     DATA: LS_INPUT LIKE LINE OF LT_INPUT.
1114 
1115     DATA: LT_DATA_PROF TYPE UJE_T_MBR_PROF_DET.
1116     DATA: LS_DATA_PROF TYPE UJE_S_MBR_PROF_DET.
1117 
1118     DATA: LT_PROFS TYPE UJE_T_PROFILE_ACTION.
1119     DATA: LS_PROFS LIKE LINE OF LT_PROFS.
1120 
1121     DATA: LT_TEAMS TYPE UJE_T_TEAM.
1122     DATA: LS_TEAMS LIKE LINE OF LT_TEAMS.
1123 
1124     DATA: LT_USERS TYPE UJE_T_USER_ID.
1125     DATA: LS_USERS LIKE LINE OF LT_USERS.
1126 
1127     DATA: LS_USERS_ASIN TYPE UJE_S_API_USER_ID.
1128     DATA: LS_TEAMS_ASIN TYPE UJE_S_API_TEAM_ID.
1129     DATA: LS_CUBEACC TYPE UJE_S_CUBEACC_DET.
1130     DATA: LS_DIMACC_DET TYPE UJE_S_DIMACC_DET.
1131     DATA: LS_DATAACC_DET TYPE UJE_S_MBRACC_DET.
1132     DATA: LS_MEMBER_LIST TYPE UJE_S_MBR.
1133     DATA: LS_TEAMS_LIST LIKE LINE OF LT_TEAMS_LIST.
1134 
1135     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
1136 
1137 * Upload file
1138     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
1139 
1140 * Rip import file into internal table
1141     LOOP AT LT_STRTAB INTO LS_STRTAB.
1142       CLEAR LS_INPUT.
1143       SPLIT LS_STRTAB AT LCL_APPLICATION=>LV_DELIMITER INTO LS_INPUT-IDENTIFIER
1144                                   LS_INPUT-PROFILE
1145                                   LS_INPUT-VALUES.
1146       APPEND LS_INPUT TO LT_INPUT.
1147     ENDLOOP.
1148 
1149 * Build profile table containing all associated data
1150     SORT LT_INPUT STABLE ASCENDING BY PROFILE IDENTIFIER VALUES.
1151 
1152     LOOP AT LT_INPUT INTO LS_INPUT.
1153 
1154       IF LS_INPUT-PROFILE <> LV_LAST_PROFILE
1155           AND LV_LAST_PROFILE IS NOT INITIAL.
1156         APPEND LS_DATAACC_PROFILE TO LT_DATAACC_PROFILE.
1157         CLEAR LS_DATAACC_PROFILE.
1158       ENDIF.
1159 
1160 * Based on record identifier
1161       CASE LS_INPUT-IDENTIFIER.
1162         WHEN 'H'.  " Header
1163           LS_DATAACC_PROFILE-PROFILE-PROFILE_ID = LS_INPUT-PROFILE.
1164           LS_DATAACC_PROFILE-PROFILE-DESCRIPTION = LS_INPUT-VALUES.
1165         WHEN 'M'.  " Data Access info
1166           LS_DATAACCESS-PROFILE_ID = LS_INPUT-PROFILE.
1167           SPLIT LS_INPUT-VALUES AT LCL_APPLICATION=>LV_DELIMITER INTO LS_DATAACCESS-DIMENSION
1168                                             LS_DATAACCESS-APPLICATION_ID
1169                                             LS_DATAACCESS-MEMBER
1170                                             LS_DATAACCESS-RWD.
1171 * Check APPLICATION_ID
1172           READ TABLE LCL_APPLICATION=>LT_APPL_INFO
1173                  TRANSPORTING NO FIELDS
1174                       WITH KEY APPLICATION_ID = LS_DATAACCESS-APPLICATION_ID.
1175           IF SY-SUBRC <> 0.
1176             CONCATENATE 'Application ID' LS_DATAACCESS-APPLICATION_ID
1177                        'not valid for this Application Set'
1178                            INTO LV_MESSAGE SEPARATED BY SPACE.
1179             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1180                                           I_MESSAGE = LV_MESSAGE ).
1181             CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1182                        'not created/updated due to error'
1183                            INTO LV_MESSAGE SEPARATED BY SPACE.
1184             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1185                                           I_MESSAGE = LV_MESSAGE ).
1186           ENDIF.
1187 
1188 * Check DIMENSION
1189           READ TABLE LCL_APPLICATION=>LT_APPL_DIM
1190                TRANSPORTING NO FIELDS
1191                        WITH KEY APPL_ID  = LS_DATAACCESS-APPLICATION_ID
1192                                DIMENSION = LS_DATAACCESS-DIMENSION.
1193           IF SY-SUBRC <> 0.
1194             CONCATENATE 'Dimension' LS_DATAACCESS-DIMENSION
1195                         'not valid for Application'
1196                          LS_DATAACCESS-APPLICATION_ID
1197                             INTO LV_MESSAGE SEPARATED BY SPACE.
1198             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1199                                           I_MESSAGE = LV_MESSAGE ).
1200             CONCATENATE 'Data Access Profile'
1201                         LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1202                         'not created/updated due to error'
1203                             INTO LV_MESSAGE SEPARATED BY SPACE.
1204             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1205                                           I_MESSAGE = LV_MESSAGE ).
1206           ENDIF.
1207 
1208 * Check MEMBER
1209           READ TABLE LCL_APPLICATION=>LT_MEMBERS
1210                TRANSPORTING NO FIELDS
1211                       WITH KEY APPL_ID   = LS_DATAACCESS-APPLICATION_ID
1212                                DIMENSION = LS_DATAACCESS-DIMENSION
1213                                MEMBER    = LS_DATAACCESS-MEMBER.
1214           IF SY-SUBRC <> 0 AND LS_DATAACCESS-MEMBER <> '[ALL]'.
1215             CONCATENATE 'Member' LS_DATAACCESS-MEMBER
1216                        'not valid for Dimension' LS_DATAACCESS-DIMENSION
1217                            INTO LV_MESSAGE SEPARATED BY SPACE.
1218             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1219                                           I_MESSAGE = LV_MESSAGE ).
1220             CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1221                        'not created/updated due to error'
1222                            INTO LV_MESSAGE SEPARATED BY SPACE.
1223             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1224                                           I_MESSAGE = LV_MESSAGE ).
1225           ENDIF.
1226           APPEND LS_DATAACCESS TO LS_DATAACC_PROFILE-DATAACC.
1227         WHEN 'U'.  " Users Assignments
1228           LS_USERS_ASIN  = LS_INPUT-VALUES.
1229           IF LCL_APPLICATION=>USER_IS_VALID( LS_USERS_ASIN ) = ABAP_FALSE.
1230             CONCATENATE 'User' LS_USERS_ASIN  'does not exist.'
1231                         'No data access profile updates done.'
1232                             INTO LV_MESSAGE SEPARATED BY SPACE.
1233             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1234                                           I_MESSAGE = LV_MESSAGE ).
1235           ENDIF.
1236           APPEND LS_USERS_ASIN  TO LS_DATAACC_PROFILE-USERS_ASIN.
1237         WHEN 'T'.  " Team Assignments
1238           LS_TEAMS_ASIN  = LS_INPUT-VALUES.
1239           IF LCL_APPLICATION=>TEAM_IS_VALID( LS_TEAMS_ASIN ) = ABAP_FALSE.
1240             CONCATENATE 'Team' LS_TEAMS_ASIN 'does not exist.'
1241                         'No data access profile updates done.'
1242                             INTO LV_MESSAGE SEPARATED BY SPACE.
1243             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1244                                           I_MESSAGE = LV_MESSAGE ).
1245           ENDIF.
1246           APPEND LS_TEAMS_ASIN  TO LS_DATAACC_PROFILE-TEAMS_ASIN.
1247       ENDCASE.
1248 
1249       LV_LAST_PROFILE = LS_INPUT-PROFILE.
1250 
1251       AT LAST.
1252         APPEND LS_DATAACC_PROFILE TO LT_DATAACC_PROFILE.
1253       ENDAT.
1254 
1255     ENDLOOP.
1256 
1257 * If any message during check, then render now, and do not process anything.
1258     IF LT_ALV_MESSAGES IS NOT INITIAL.
1259       LCL_APPLICATION=>RENDER_ALV( ).
1260       RETURN.
1261     ENDIF.
1262 
1263 * Now for each profile, call API to create/update
1264     LOOP AT LT_DATAACC_PROFILE INTO LS_DATAACC_PROFILE.
1265 
1266       CLEAR LS_DATA_PROF.  REFRESH LT_DATA_PROF.
1267       LS_DATA_PROF-PROFILE_AGR_NAME = LS_DATAACC_PROFILE-PROFILE-PROFILE_ID.
1268       LS_DATA_PROF-DESCRIPTION = LS_DATAACC_PROFILE-PROFILE-DESCRIPTION.
1269 
1270       LOOP AT LS_DATAACC_PROFILE-DATAACC INTO LS_DATAACCESS.
1271 
1272         CLEAR LS_MEMBER_LIST.
1273         CLEAR LS_DATAACC_DET.
1274         CLEAR LS_DIMACC_DET.
1275         CLEAR LS_CUBEACC.
1276 
1277         LS_MEMBER_LIST-MBR_ID = LS_DATAACCESS-MEMBER.
1278         APPEND LS_MEMBER_LIST TO LS_DATAACC_DET-MEMBER.
1279         LS_DATAACC_DET-RWD = LS_DATAACCESS-RWD.
1280         APPEND LS_DATAACC_DET TO LS_DIMACC_DET-MBRACC_DET.
1281         LS_DIMACC_DET-DIMENSION = LS_DATAACCESS-DIMENSION.
1282 
1283         LS_CUBEACC-APPLICATION_ID = LS_DATAACCESS-APPLICATION_ID.
1284         APPEND LS_DIMACC_DET TO LS_CUBEACC-DIMACC_DET.
1285 
1286         APPEND LS_CUBEACC TO LS_DATA_PROF-CUBE_ACC.
1287 
1288       ENDLOOP.
1289 
1290       APPEND LS_DATA_PROF TO LT_DATA_PROF.
1291 
1292 * Determine if the data access profile is new, call correct API.
1293       TRY.
1294           IF LCL_APPLICATION=>DPROFILE_IS_VALID( LS_DATAACC_PROFILE-PROFILE-PROFILE_ID ) = ABAP_FALSE.
1295             CL_UJE_PROFILE_MEMACCESS=>CREATE_MBR_PROFILES(
1296                     EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1297                               IT_MBR_PROF_DET = LT_DATA_PROF ).
1298           ELSE.
1299             CL_UJE_PROFILE_MEMACCESS=>UPDATE_MBR_PROFILES(
1300                     EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1301                               IT_MBR_PROF_DET = LT_DATA_PROF ).
1302           ENDIF.
1303 
1304 * Assign users
1305           LOOP AT LS_DATAACC_PROFILE-USERS_ASIN INTO LS_USERS_ASIN.
1306 
1307             CLEAR LS_USERS. REFRESH LT_USERS.
1308             LS_USERS = LS_USERS_ASIN-USER_ID.
1309             APPEND LS_USERS TO LT_USERS.
1310 
1311             CLEAR LS_PROFS. REFRESH LT_PROFS.
1312             LS_PROFS-PROFILE_ID = LS_DATAACC_PROFILE-PROFILE-PROFILE_ID.
1313             LS_PROFS-ACTION = 'I'.
1314             APPEND LS_PROFS TO LT_PROFS.
1315 
1316             TRY.
1317                 CL_UJE_USER=>UPDATE_USERS(
1318                   EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1319                             IT_USERS = LT_USERS
1320                             IT_MBR_PROFS = LT_PROFS ).
1321               CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1322                 ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1323                 CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1324                             'not created/updated due to error'
1325                                  INTO LV_MESSAGE SEPARATED BY SPACE.
1326                 ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1327                                               I_MESSAGE = LV_MESSAGE ).
1328             ENDTRY.
1329 
1330           ENDLOOP.
1331 
1332 * Assign teams
1333           LOOP AT LS_DATAACC_PROFILE-TEAMS_ASIN INTO LS_TEAMS_ASIN.
1334 
1335             REFRESH LT_TEAMS.
1336             READ TABLE LT_TEAMS_LIST INTO LS_TEAMS_LIST
1337                             WITH KEY TEAM_ID = LS_TEAMS_ASIN-TEAM_ID.
1338             IF SY-SUBRC = 0.
1339               MOVE-CORRESPONDING LS_TEAMS_LIST TO LS_TEAMS.
1340               APPEND LS_TEAMS TO LT_TEAMS.
1341             ENDIF.
1342 
1343             CLEAR LS_PROFS. REFRESH LT_PROFS.
1344             LS_PROFS-PROFILE_ID = LS_DATAACC_PROFILE-PROFILE-PROFILE_ID.
1345             LS_PROFS-ACTION = 'I'.
1346             APPEND LS_PROFS TO LT_PROFS.
1347 
1348             TRY.
1349                 CL_UJE_TEAM=>UPDATE_TEAMS(
1350                              EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1351                                        IT_TEAMS = LT_TEAMS
1352                                        IT_MBR_PROFS = LT_PROFS ).
1353               CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1354                 ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1355                 CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1356                             'not created/updated due to error'
1357                                  INTO LV_MESSAGE SEPARATED BY SPACE.
1358                 ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1359                                               I_MESSAGE = LV_MESSAGE ).
1360             ENDTRY.
1361           ENDLOOP.
1362 
1363           CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1364                       'has been created/updated successfully'
1365                           INTO LV_MESSAGE SEPARATED BY SPACE.
1366           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1367                                         I_MESSAGE = LV_MESSAGE ).
1368         CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1369           ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1370           CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1371                       'not created/updated due to error'
1372                           INTO LV_MESSAGE SEPARATED BY SPACE.
1373           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1374                                       I_MESSAGE = LV_MESSAGE ).
1375       ENDTRY.
1376 
1377     ENDLOOP.
1378 
1379 * Display ALV
1380     LCL_APPLICATION=>RENDER_ALV( ).
1381 
1382   ENDMETHOD.                    "import_mem_profiles_from_file
1383 
1384   METHOD EXPORT_TAP_ASSIGN_TO_FILE.
1385 
1386     TYPES: BEGIN OF T_OUTPUT,
1387              IDENTIFIER TYPE CHAR01, " Row Identifer
1388              PROFILE TYPE UJ_PROFILE_ID,
1389              ID TYPE UJ_USER_ID,  "User ID or Team ID
1390             END OF T_OUTPUT.
1391 
1392     DATA: LT_OUTPUT TYPE TABLE OF T_OUTPUT.
1393     DATA: LS_OUTPUT LIKE LINE OF LT_OUTPUT.
1394 
1395     DATA: LS_TASK_PROFILES LIKE LINE OF LCL_APPLICATION=>LT_TASK_PROFILES.
1396 
1397     DATA: LS_TASKS TYPE UJE_S_TASK_INFO.
1398     DATA: LS_USERS TYPE UJE_S_USERINFO.
1399     DATA: LS_TEAMS TYPE UJE_S_TEAM.
1400 
1401     LOOP AT LCL_APPLICATION=>LT_TASK_PROFILES INTO LS_TASK_PROFILES.
1402 
1403 * Write User Assignment
1404       CLEAR LS_OUTPUT.
1405       LS_OUTPUT-IDENTIFIER = 'U'.
1406       LS_OUTPUT-PROFILE  = LS_TASK_PROFILES-PROFILE_ID.
1407       LOOP AT LS_TASK_PROFILES-USERS INTO LS_USERS.
1408         LS_OUTPUT-ID  = LS_USERS-USER_ID.
1409         APPEND LS_OUTPUT TO LT_OUTPUT.
1410       ENDLOOP.
1411 
1412 * Write Team Assignement
1413       CLEAR LS_OUTPUT.
1414       LS_OUTPUT-IDENTIFIER = 'T'.
1415       LS_OUTPUT-PROFILE  = LS_TASK_PROFILES-PROFILE_ID.
1416       LOOP AT LS_TASK_PROFILES-TEAMS INTO LS_TEAMS.
1417         LS_OUTPUT-ID  = LS_TEAMS-TEAM_ID.
1418         APPEND LS_OUTPUT TO LT_OUTPUT.
1419       ENDLOOP.
1420 
1421     ENDLOOP.
1422 
1423 * Download table
1424     LCL_APPLICATION=>DOWNLOAD( EXPORTING I_FILEPATH = P_FILE
1425                                          IT_DATATAB = LT_OUTPUT ).
1426 
1427   ENDMETHOD.                    "export_tap_assign_to_file
1428 
1429   METHOD IMPORT_TAP_ASSIGN_FROM_FILE.
1430 
1431     TYPES: BEGIN OF T_INPUT,
1432             IDENTIFIER TYPE CHAR01, "Identifer, U or T
1433             PROFILE TYPE UJ_PROFILE_ID,
1434             ID TYPE UJ_USER_ID,  "User ID or Team ID
1435            END OF T_INPUT.
1436 
1437     TYPES: BEGIN OF T_TASK_PROFILE,
1438             PROFILE TYPE UJE_S_PROFILE,
1439             USERS_ASIN TYPE UJE_T_API_USER_ID,
1440             TEAMS_ASIN TYPE UJE_T_API_TEAM_ID,
1441            END OF T_TASK_PROFILE.
1442 
1443     DATA: LT_TASK_PROFILE TYPE TABLE OF T_TASK_PROFILE.
1444     DATA: LS_TASK_PROFILE LIKE LINE OF LT_TASK_PROFILE.
1445 
1446     DATA: LT_STRTAB TYPE STRINGTAB.
1447     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
1448 
1449     DATA: LT_INPUT TYPE TABLE OF T_INPUT.
1450     DATA: LS_INPUT LIKE LINE OF LT_INPUT.
1451 
1452     DATA: LT_PROFS TYPE UJE_T_PROFILE_ACTION.
1453     DATA: LS_PROFS LIKE LINE OF LT_PROFS.
1454 
1455     DATA: LT_TEAMS TYPE UJE_T_TEAM.
1456     DATA: LS_TEAMS LIKE LINE OF LT_TEAMS.
1457 
1458     DATA: LT_USERS TYPE UJE_T_USER_ID.
1459     DATA: LS_USERS LIKE LINE OF LT_USERS.
1460 
1461     DATA: LS_USERS_ASIN TYPE UJE_S_API_USER_ID.
1462     DATA: LS_TEAMS_ASIN TYPE UJE_S_API_TEAM_ID.
1463     DATA: LS_TEAMS_LIST LIKE LINE OF LT_TEAMS_LIST.
1464 
1465     DATA: LV_LAST_PROFILE TYPE UJ_PROFILE_ID.
1466     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
1467 
1468 * Upload file
1469     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
1470 
1471 * Rip import file into internal table
1472     LOOP AT LT_STRTAB INTO LS_STRTAB.
1473       CLEAR LS_INPUT.
1474       SPLIT LS_STRTAB AT LCL_APPLICATION=>LV_DELIMITER INTO LS_INPUT-IDENTIFIER
1475                                   LS_INPUT-PROFILE
1476                                   LS_INPUT-ID.
1477       APPEND LS_INPUT TO LT_INPUT.
1478     ENDLOOP.
1479 
1480 * Build profile table containing all associated data
1481     SORT LT_INPUT STABLE ASCENDING BY PROFILE IDENTIFIER ID.
1482 
1483     LOOP AT LT_INPUT INTO LS_INPUT.
1484 
1485       IF LS_INPUT-PROFILE <> LV_LAST_PROFILE
1486           AND LV_LAST_PROFILE IS NOT INITIAL.
1487         APPEND LS_TASK_PROFILE TO LT_TASK_PROFILE.
1488         CLEAR LS_TASK_PROFILE.
1489       ENDIF.
1490 
1491       IF LCL_APPLICATION=>TPROFILE_IS_VALID( LS_INPUT-PROFILE ) = ABAP_FALSE.
1492         CONCATENATE 'Profile' LS_INPUT-PROFILE 'does not yet exist.'
1493                     'No task profile assigments done.'
1494                        INTO LV_MESSAGE SEPARATED BY SPACE.
1495         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1496                                     I_MESSAGE = LV_MESSAGE ).
1497       ENDIF.
1498 
1499       CASE LS_INPUT-IDENTIFIER.
1500 
1501         WHEN 'T'.
1502           IF LCL_APPLICATION=>TEAM_IS_VALID( LS_INPUT-ID ) = ABAP_FALSE.
1503             CONCATENATE 'Team' LS_INPUT-ID 'does not yet exist.'
1504                         'No task profile assigments done.'
1505                           INTO LV_MESSAGE SEPARATED BY SPACE.
1506             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1507                                         I_MESSAGE = LV_MESSAGE ).
1508           ENDIF.
1509           LS_TASK_PROFILE-PROFILE-PROFILE_ID  = LS_INPUT-PROFILE.
1510           APPEND LS_INPUT-ID TO LS_TASK_PROFILE-TEAMS_ASIN.
1511 
1512 
1513         WHEN 'U'.
1514           IF LCL_APPLICATION=>USER_IS_VALID( LS_INPUT-ID ) = ABAP_FALSE.
1515             CONCATENATE 'User' LS_INPUT-ID 'does not yet exist.'
1516                         'No task profile assigments done.'
1517                            INTO LV_MESSAGE SEPARATED BY SPACE.
1518             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1519                                         I_MESSAGE = LV_MESSAGE ).
1520           ENDIF.
1521           LS_TASK_PROFILE-PROFILE-PROFILE_ID  = LS_INPUT-PROFILE.
1522           APPEND LS_INPUT-ID TO LS_TASK_PROFILE-USERS_ASIN.
1523       ENDCASE.
1524 
1525       LV_LAST_PROFILE = LS_INPUT-PROFILE.
1526 
1527       AT LAST.
1528         APPEND LS_TASK_PROFILE TO LT_TASK_PROFILE.
1529       ENDAT.
1530 
1531     ENDLOOP.
1532 
1533 * If there are errors, render, and do not process anything
1534     IF LT_ALV_MESSAGES IS NOT INITIAL.
1535       LCL_APPLICATION=>RENDER_ALV( ).
1536       RETURN.
1537     ENDIF.
1538 
1539 * UPdate teams and uses with the assignments.
1540     LOOP AT LT_TASK_PROFILE INTO LS_TASK_PROFILE.
1541 
1542 * Assign users
1543       LOOP AT LS_TASK_PROFILE-USERS_ASIN INTO LS_USERS_ASIN.
1544 
1545         CLEAR LS_USERS. REFRESH LT_USERS.
1546         LS_USERS = LS_USERS_ASIN-USER_ID.
1547         APPEND LS_USERS TO LT_USERS.
1548 
1549         CLEAR LS_PROFS. REFRESH LT_PROFS.
1550         LS_PROFS-PROFILE_ID = LS_TASK_PROFILE-PROFILE-PROFILE_ID.
1551         LS_PROFS-ACTION = 'I'.
1552         APPEND LS_PROFS TO LT_PROFS.
1553 
1554         TRY.
1555             CL_UJE_USER=>UPDATE_USERS(
1556               EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1557                         IT_USERS = LT_USERS
1558                         IT_TASK_PROFS = LT_PROFS ).
1559             CONCATENATE 'User' LS_USERS_ASIN-USER_ID 'task profile assignments'
1560                         'have been updated successfully'
1561                            INTO LV_MESSAGE SEPARATED BY SPACE.
1562             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1563                                           I_MESSAGE = LV_MESSAGE ).
1564           CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1565             ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1566             CONCATENATE 'User' LS_USERS_ASIN-USER_ID 'task profile assignments'
1567                         'not updated due to error'
1568                            INTO LV_MESSAGE SEPARATED BY SPACE.
1569             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1570                                           I_MESSAGE = LV_MESSAGE ).
1571         ENDTRY.
1572 
1573       ENDLOOP.
1574 
1575 * Assign teams
1576       LOOP AT LS_TASK_PROFILE-TEAMS_ASIN INTO LS_TEAMS_ASIN.
1577 
1578         REFRESH LT_TEAMS.
1579         READ TABLE LT_TEAMS_LIST INTO LS_TEAMS_LIST
1580                         WITH KEY TEAM_ID = LS_TEAMS_ASIN-TEAM_ID.
1581         IF SY-SUBRC = 0.
1582           MOVE-CORRESPONDING LS_TEAMS_LIST TO LS_TEAMS.
1583           APPEND LS_TEAMS TO LT_TEAMS.
1584         ENDIF.
1585 
1586         CLEAR LS_PROFS. REFRESH LT_PROFS.
1587         LS_PROFS-PROFILE_ID = LS_TASK_PROFILE-PROFILE-PROFILE_ID.
1588         LS_PROFS-ACTION = 'I'.
1589         APPEND LS_PROFS TO LT_PROFS.
1590 
1591         TRY.
1592             CL_UJE_TEAM=>UPDATE_TEAMS(
1593                          EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1594                                    IT_TEAMS = LT_TEAMS
1595                                    IT_TASK_PROFS = LT_PROFS ).
1596             CONCATENATE 'Team' LS_TEAMS_ASIN-TEAM_ID 'task profile assignments'
1597                        'have been updated successfully'
1598                           INTO LV_MESSAGE SEPARATED BY SPACE.
1599             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1600                                           I_MESSAGE = LV_MESSAGE ).
1601           CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1602             ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1603             CONCATENATE 'Team' LS_TEAMS_ASIN-TEAM_ID 'task profile assignments'
1604                         'not updated due to error'
1605                            INTO LV_MESSAGE SEPARATED BY SPACE.
1606             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1607                                           I_MESSAGE = LV_MESSAGE ).
1608         ENDTRY.
1609       ENDLOOP.
1610 
1611       CONCATENATE 'Task Profile' LS_TASK_PROFILE-PROFILE-PROFILE_ID
1612                   'assignments have been updated successfully'
1613                        INTO LV_MESSAGE SEPARATED BY SPACE.
1614       ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1615                                     I_MESSAGE = LV_MESSAGE ).
1616 
1617     ENDLOOP.
1618 
1619     LCL_APPLICATION=>RENDER_ALV( ).
1620 
1621   ENDMETHOD.                    "import_tap_assign_from_file
1622 
1623   METHOD EXPORT_DAP_ASSIGN_TO_FILE.
1624 
1625     TYPES: BEGIN OF T_OUTPUT,
1626             IDENTIFIER TYPE CHAR01, "Identifer, U or T
1627             PROFILE TYPE UJ_PROFILE_ID,
1628             ID TYPE UJ_USER_ID,  "User ID or Team ID
1629            END OF T_OUTPUT.
1630 
1631     DATA: LT_OUTPUT TYPE TABLE OF T_OUTPUT.
1632     DATA: LS_OUTPUT LIKE LINE OF LT_OUTPUT.
1633 
1634     DATA: LT_USERS TYPE UJE_T_USER.
1635     DATA: LS_USERS LIKE LINE OF LT_USERS.
1636 
1637     DATA: LT_TEAMS TYPE UJE_T_TEAM.
1638     DATA: LS_TEAMS LIKE LINE OF LT_TEAMS.
1639 
1640     DATA: LS_DATA_ACCESS_PROFILES TYPE UJE_S_MBR_PROF_APP.
1641 
1642     DATA: LO_PROFILE_DAO TYPE REF TO CL_UJE_PROFILE_DAO.
1643 
1644     CREATE OBJECT LO_PROFILE_DAO
1645       EXPORTING
1646         I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID.
1647 
1648     LOOP AT LCL_APPLICATION=>LT_DATA_ACCESS_PROFILES INTO LS_DATA_ACCESS_PROFILES.
1649 
1650       REFRESH: LT_USERS, LT_TEAMS.
1651       LO_PROFILE_DAO->GET_DETAILS( EXPORTING I_PROFILE_ID = LS_DATA_ACCESS_PROFILES-PROFILE_ID
1652                                              I_PROFILE_CLASS = `MBR`
1653                                    IMPORTING ET_USERS = LT_USERS
1654                                              ET_TEAMS = LT_TEAMS ).
1655 
1656 * Write User and Team assignments.
1657       LOOP AT LT_USERS INTO LS_USERS.
1658         CLEAR LS_OUTPUT.
1659         LS_OUTPUT-IDENTIFIER = 'U'.
1660         LS_OUTPUT-PROFILE  = LS_DATA_ACCESS_PROFILES-PROFILE_ID.
1661         LS_OUTPUT-ID = LS_USERS-USER_ID.
1662         APPEND LS_OUTPUT TO LT_OUTPUT.
1663       ENDLOOP.
1664 
1665       LOOP AT LT_TEAMS INTO LS_TEAMS.
1666         CLEAR LS_OUTPUT.
1667         LS_OUTPUT-IDENTIFIER = 'T'.
1668         LS_OUTPUT-PROFILE  = LS_DATA_ACCESS_PROFILES-PROFILE_ID.
1669         LS_OUTPUT-ID = LS_TEAMS-TEAM_ID.
1670         APPEND LS_OUTPUT TO LT_OUTPUT.
1671       ENDLOOP.
1672 
1673     ENDLOOP.
1674 
1675 * Download table
1676     LCL_APPLICATION=>DOWNLOAD( EXPORTING I_FILEPATH = P_FILE
1677                                          IT_DATATAB = LT_OUTPUT ).
1678 
1679   ENDMETHOD.                    "export_map_assign_to_file
1680 
1681   METHOD IMPORT_DAP_ASSIGN_FROM_FILE.
1682 
1683     TYPES: BEGIN OF T_INPUT,
1684             IDENTIFIER TYPE CHAR01, " Row Identifer
1685             PROFILE TYPE UJ_PROFILE_ID,
1686             VALUES TYPE STRING,
1687            END OF T_INPUT.
1688 
1689     TYPES: BEGIN OF T_DATAACC_PROFILE,
1690             PROFILE TYPE UJE_S_PROFILE,
1691             USERS_ASIN TYPE UJE_T_API_USER_ID,
1692             TEAMS_ASIN TYPE UJE_T_API_TEAM_ID,
1693            END OF T_DATAACC_PROFILE.
1694 
1695     DATA: LT_DATAACC_PROFILE TYPE TABLE OF T_DATAACC_PROFILE.
1696     DATA: LS_DATAACC_PROFILE LIKE LINE OF LT_DATAACC_PROFILE.
1697 
1698     DATA: LV_LAST_PROFILE TYPE UJ_PROFILE_ID.
1699 
1700     DATA: LT_DATAACCESS TYPE UJE_T_MEMACCESS.
1701     DATA: LS_DATAACCESS LIKE LINE OF LT_DATAACCESS.
1702 
1703     DATA: LT_STRTAB TYPE STRINGTAB.
1704     DATA: LS_STRTAB LIKE LINE OF LT_STRTAB.
1705 
1706     DATA: LT_INPUT TYPE TABLE OF T_INPUT.
1707     DATA: LS_INPUT LIKE LINE OF LT_INPUT.
1708 
1709     DATA: LT_PROFS TYPE UJE_T_PROFILE_ACTION.
1710     DATA: LS_PROFS LIKE LINE OF LT_PROFS.
1711 
1712     DATA: LT_TEAMS TYPE UJE_T_TEAM.
1713     DATA: LS_TEAMS LIKE LINE OF LT_TEAMS.
1714 
1715     DATA: LT_USERS TYPE UJE_T_USER_ID.
1716     DATA: LS_USERS LIKE LINE OF LT_USERS.
1717 
1718     DATA: LS_USERS_ASIN TYPE UJE_S_API_USER_ID.
1719     DATA: LS_TEAMS_ASIN TYPE UJE_S_API_TEAM_ID.
1720     DATA: LS_TEAMS_LIST LIKE LINE OF LT_TEAMS_LIST.
1721 
1722     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
1723 
1724 * Upload file
1725     LT_STRTAB = LCL_APPLICATION=>UPLOAD( P_FILE ).
1726 
1727 * Rip import file into internal table
1728     LOOP AT LT_STRTAB INTO LS_STRTAB.
1729       CLEAR LS_INPUT.
1730       SPLIT LS_STRTAB AT LCL_APPLICATION=>LV_DELIMITER INTO LS_INPUT-IDENTIFIER
1731                                   LS_INPUT-PROFILE
1732                                   LS_INPUT-VALUES.
1733       APPEND LS_INPUT TO LT_INPUT.
1734     ENDLOOP.
1735 
1736 * Build profile table containing all associated data
1737     SORT LT_INPUT STABLE ASCENDING BY PROFILE IDENTIFIER VALUES.
1738 
1739     LOOP AT LT_INPUT INTO LS_INPUT.
1740 
1741       IF LS_INPUT-PROFILE <> LV_LAST_PROFILE
1742           AND LV_LAST_PROFILE IS NOT INITIAL.
1743         APPEND LS_DATAACC_PROFILE TO LT_DATAACC_PROFILE.
1744         CLEAR LS_DATAACC_PROFILE.
1745       ENDIF.
1746 
1747 * Based on record identifier
1748       CASE LS_INPUT-IDENTIFIER.
1749         WHEN 'U'.  " Users Assignments
1750           LS_USERS_ASIN  = LS_INPUT-VALUES.
1751           IF LCL_APPLICATION=>USER_IS_VALID( LS_USERS_ASIN-USER_ID ) = ABAP_FALSE.
1752             CONCATENATE 'User' LS_USERS_ASIN  'does not exist.'
1753                         'No data access profile updates done.'
1754                             INTO LV_MESSAGE SEPARATED BY SPACE.
1755             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1756                                           I_MESSAGE = LV_MESSAGE ).
1757           ENDIF.
1758           LS_DATAACC_PROFILE-PROFILE-PROFILE_ID = LS_INPUT-PROFILE.
1759           APPEND LS_USERS_ASIN  TO LS_DATAACC_PROFILE-USERS_ASIN.
1760         WHEN 'T'.  " Team Assignments
1761           LS_TEAMS_ASIN  = LS_INPUT-VALUES.
1762           IF LCL_APPLICATION=>TEAM_IS_VALID( LS_TEAMS_ASIN-TEAM_ID ) = ABAP_FALSE.
1763             CONCATENATE 'Team' LS_TEAMS_ASIN 'does not exist.'
1764                         'No data access profile updates done.'
1765                             INTO LV_MESSAGE SEPARATED BY SPACE.
1766             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1767                                           I_MESSAGE = LV_MESSAGE ).
1768           ENDIF.
1769           LS_DATAACC_PROFILE-PROFILE-PROFILE_ID = LS_INPUT-PROFILE.
1770           APPEND LS_TEAMS_ASIN  TO LS_DATAACC_PROFILE-TEAMS_ASIN.
1771       ENDCASE.
1772 
1773       LV_LAST_PROFILE = LS_INPUT-PROFILE.
1774 
1775       AT LAST.
1776         APPEND LS_DATAACC_PROFILE TO LT_DATAACC_PROFILE.
1777       ENDAT.
1778 
1779     ENDLOOP.
1780 
1781 * If any message during check, then render now, and do not process anything.
1782     IF LT_ALV_MESSAGES IS NOT INITIAL.
1783       LCL_APPLICATION=>RENDER_ALV( ).
1784       RETURN.
1785     ENDIF.
1786 
1787 * Now for each profile, call API to create/update
1788     LOOP AT LT_DATAACC_PROFILE INTO LS_DATAACC_PROFILE.
1789 
1790 * Assign users
1791       LOOP AT LS_DATAACC_PROFILE-USERS_ASIN INTO LS_USERS_ASIN.
1792 
1793         CLEAR LS_USERS. REFRESH LT_USERS.
1794         LS_USERS = LS_USERS_ASIN-USER_ID.
1795         APPEND LS_USERS TO LT_USERS.
1796 
1797         CLEAR LS_PROFS. REFRESH LT_PROFS.
1798         LS_PROFS-PROFILE_ID = LS_DATAACC_PROFILE-PROFILE-PROFILE_ID.
1799         LS_PROFS-ACTION = 'I'.
1800         APPEND LS_PROFS TO LT_PROFS.
1801 
1802         TRY.
1803             CL_UJE_USER=>UPDATE_USERS(
1804               EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1805                         IT_USERS = LT_USERS
1806                         IT_MBR_PROFS = LT_PROFS ).
1807             CONCATENATE 'User' LS_USERS_ASIN-USER_ID 'data access profile assignments'
1808                         'have been updated successfully'
1809                            INTO LV_MESSAGE SEPARATED BY SPACE.
1810             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1811                                           I_MESSAGE = LV_MESSAGE ).
1812           CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1813             ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1814             CONCATENATE 'User' LS_USERS_ASIN-USER_ID 'data access profile assignments'
1815                         'not updated due to error'
1816                            INTO LV_MESSAGE SEPARATED BY SPACE.
1817             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1818                                           I_MESSAGE = LV_MESSAGE ).
1819         ENDTRY.
1820 
1821       ENDLOOP.
1822 
1823 * Assign teams
1824       LOOP AT LS_DATAACC_PROFILE-TEAMS_ASIN INTO LS_TEAMS_ASIN.
1825 
1826         REFRESH LT_TEAMS.
1827         READ TABLE LT_TEAMS_LIST INTO LS_TEAMS_LIST
1828                         WITH KEY TEAM_ID = LS_TEAMS_ASIN-TEAM_ID.
1829         IF SY-SUBRC = 0.
1830           MOVE-CORRESPONDING LS_TEAMS_LIST TO LS_TEAMS.
1831           APPEND LS_TEAMS TO LT_TEAMS.
1832         ENDIF.
1833 
1834         CLEAR LS_PROFS. REFRESH LT_PROFS.
1835         LS_PROFS-PROFILE_ID = LS_DATAACC_PROFILE-PROFILE-PROFILE_ID.
1836         LS_PROFS-ACTION = 'I'.
1837         APPEND LS_PROFS TO LT_PROFS.
1838 
1839         TRY.
1840             CL_UJE_TEAM=>UPDATE_TEAMS(
1841                          EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1842                                    IT_TEAMS = LT_TEAMS
1843                                    IT_MBR_PROFS = LT_PROFS ).
1844             CONCATENATE 'Team' LS_TEAMS_ASIN-TEAM_ID 'data access profile assignments'
1845                         'have been updated successfully'
1846                            INTO LV_MESSAGE SEPARATED BY SPACE.
1847             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1848                                           I_MESSAGE = LV_MESSAGE ).
1849           CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
1850             ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
1851             CONCATENATE 'Team' LS_TEAMS_ASIN-TEAM_ID 'data access profile assignments'
1852                         'not updated due to error'
1853                            INTO LV_MESSAGE SEPARATED BY SPACE.
1854             ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
1855                                           I_MESSAGE = LV_MESSAGE ).
1856         ENDTRY.
1857 
1858       ENDLOOP.
1859 
1860       CONCATENATE 'Data Access Profile' LS_DATAACC_PROFILE-PROFILE-PROFILE_ID
1861                   'has been updated successfully'
1862                       INTO LV_MESSAGE SEPARATED BY SPACE.
1863       ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `S` I_MSGNO = `001`
1864                                     I_MESSAGE = LV_MESSAGE ).
1865 
1866     ENDLOOP.
1867 
1868 * Display ALV
1869     LCL_APPLICATION=>RENDER_ALV( ).
1870 
1871   ENDMETHOD.                    "import_map_assign_from_file
1872 
1873   METHOD SET_GLOBAL_CONTEXT.
1874 
1875     DATA: LS_USER  TYPE UJ0_S_USER.
1876     "DATA: lv_value TYPE uj_value.
1877     "DATA: lv_value TYPE string.  by shangrj
1878     DATA: LV_VALUE TYPE UJ_STRING.
1879 
1880 
1881     DATA: LO_SRV_MGR_DAO TYPE REF TO CL_UJA3_SVRMGR_DAO.
1882 
1883 * GEt the system admin user id
1884     CREATE OBJECT LO_SRV_MGR_DAO.
1885     LO_SRV_MGR_DAO->READ_SYSADMIN_ID( IMPORTING E_SYSADMIN_ID = LV_VALUE ).
1886     LS_USER-USER_ID = LV_VALUE.
1887 
1888 * Set the context
1889     TRY.
1890         CL_UJ_CONTEXT=>SET_CUR_CONTEXT(
1891                         EXPORTING  I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
1892                                    IS_USER     = LS_USER ).
1893       CATCH CX_UJ_OBJ_NOT_FOUND .
1894     ENDTRY.
1895 
1896 * Get it
1897     LO_CONTEXT = CL_UJ_CONTEXT=>GET_CUR_CONTEXT( ).
1898 * Set user to system admin
1899     LO_CONTEXT->SWITCH_TO_SRVADMIN( ).
1900 
1901   ENDMETHOD.                    "set_global_context
1902 
1903   METHOD SET_DELIMITER_LISTBOX.
1904 
1905 * set delimiter listbox.
1906     DATA: LT_VRM_VALUES TYPE VRM_VALUES.
1907     DATA: LS_VRM_VALUES LIKE LINE OF LT_VRM_VALUES.
1908     DATA: LV_NAME TYPE VRM_ID  VALUE 'P_DELMT'.
1909 
1910     REFRESH LT_VRM_VALUES.
1911 
1912     LS_VRM_VALUES-KEY = LCL_APPLICATION=>LC_COMMA.
1913     LS_VRM_VALUES-TEXT = 'Comma'.
1914     APPEND LS_VRM_VALUES TO LT_VRM_VALUES.
1915 
1916     LS_VRM_VALUES-KEY = LCL_APPLICATION=>LC_TAB.
1917     LS_VRM_VALUES-TEXT = 'Tab'.
1918     APPEND LS_VRM_VALUES TO LT_VRM_VALUES.
1919 
1920     LS_VRM_VALUES-KEY = LCL_APPLICATION=>LC_PIPE.
1921     LS_VRM_VALUES-TEXT = 'Pipe'.
1922     APPEND LS_VRM_VALUES TO LT_VRM_VALUES.
1923 
1924     CALL FUNCTION 'VRM_SET_VALUES'
1925       EXPORTING
1926         ID     = LV_NAME
1927         VALUES = LT_VRM_VALUES.
1928 
1929   ENDMETHOD.                    "set_delimiter_listbox
1930 
1931   METHOD SET_DELIMITER.
1932 
1933     IF P_DELMT = LCL_APPLICATION=>LC_TAB.
1934       LCL_APPLICATION=>LV_DELIMITER = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
1935     ELSE.
1936       LCL_APPLICATION=>LV_DELIMITER = P_DELMT.
1937     ENDIF.
1938 
1939   ENDMETHOD.                    "set_delimiter
1940 
1941   METHOD RENDER_ALV.
1942 
1943     TYPE-POOLS: ICON.
1944 
1945     TYPES: BEGIN OF T_ALV,
1946             ICON    TYPE ICON-ID,
1947             MSGID   TYPE UJ0_S_MESSAGE-MSGID,
1948             MSGTY   TYPE UJ0_S_MESSAGE-MSGTY,
1949             MSGNO   TYPE UJ0_S_MESSAGE-MSGNO,
1950             MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE,
1951            END OF T_ALV.
1952 
1953     DATA: LT_ALV TYPE TABLE OF T_ALV.
1954     DATA: LO_TABLE     TYPE REF TO CL_SALV_TABLE.
1955     DATA: LO_COLUMNS   TYPE REF TO CL_SALV_COLUMNS_TABLE.
1956     DATA: LO_COLUMN    TYPE REF TO CL_SALV_COLUMN_TABLE.
1957     DATA: LO_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS.
1958 
1959     FIELD-SYMBOLS: <LS_ALV> LIKE LINE OF LT_ALV,
1960                    <LS_ALV_MESSAGES> LIKE LINE OF LT_ALV_MESSAGES.
1961 
1962     IF LT_ALV_MESSAGES IS INITIAL.
1963       RETURN.
1964     ENDIF.
1965 
1966 * Convert messages from API to ALV output
1967     LOOP AT LT_ALV_MESSAGES ASSIGNING <LS_ALV_MESSAGES>.
1968       APPEND INITIAL LINE TO LT_ALV ASSIGNING <LS_ALV>.
1969       MOVE-CORRESPONDING <LS_ALV_MESSAGES> TO <LS_ALV>.
1970       CASE <LS_ALV>-MSGTY.
1971         WHEN 'E'. WRITE ICON_MESSAGE_ERROR_SMALL AS ICON TO <LS_ALV>-ICON.
1972         WHEN 'W'. WRITE ICON_MESSAGE_WARNING_SMALL AS ICON TO <LS_ALV>-ICON.
1973         WHEN 'I'. WRITE ICON_MESSAGE_INFORMATION_SMALL  AS ICON TO <LS_ALV>-ICON.
1974         WHEN 'S'. WRITE ICON_CHECKED AS ICON TO <LS_ALV>-ICON.
1975       ENDCASE.
1976     ENDLOOP.
1977 
1978 * Show messages
1979     TRY.
1980         CL_SALV_TABLE=>FACTORY( IMPORTING R_SALV_TABLE  = LO_TABLE
1981                                  CHANGING T_TABLE       = LT_ALV ).
1982       CATCH CX_SALV_MSG.
1983     ENDTRY.
1984 
1985     LO_FUNCTIONS = LO_TABLE->GET_FUNCTIONS( ).
1986     LO_FUNCTIONS->SET_ALL( ABAP_TRUE ).
1987 
1988     TRY.
1989         LO_COLUMNS = LO_TABLE->GET_COLUMNS( ).
1990         LO_COLUMN ?= LO_COLUMNS->GET_COLUMN( 'ICON' ).
1991         LO_COLUMN->SET_ICON( ABAP_TRUE ).
1992         LO_COLUMN ?= LO_COLUMNS->GET_COLUMN( 'MSGNO' ).
1993         LO_COLUMN->SET_LEADING_ZERO( ABAP_TRUE ).
1994       CATCH CX_SALV_NOT_FOUND.
1995     ENDTRY.
1996 
1997     LO_TABLE->DISPLAY( ).
1998 
1999   ENDMETHOD.                    "render_alv
2000 
2001   METHOD GET_ENVIRONMENT_DATA.
2002 
2003     DATA: LS_UJA_APPL_INFO TYPE UJA_S_APPL_INFO.
2004     DATA: LT_UJA_APPL_DIM TYPE UJA_T_APPL_DIM.
2005     DATA: LS_UJA_APPL_DIM LIKE LINE OF LT_UJA_APPL_DIM.
2006 
2007     DATA: LS_MEMBERS LIKE LINE OF LT_MEMBERS.
2008     DATA: LS_APPL_DIM  LIKE LINE OF LT_APPL_DIM.
2009 
2010     DATA: LT_APPL_LIST TYPE UJA_T_APPL_ID.
2011     DATA: LS_APPL_LIST LIKE LINE OF LT_APPL_LIST.
2012 
2013     DATA: LO_APPSET_DAO TYPE REF TO CL_UJA_APPSET_DAO.
2014     DATA: LO_APPLICATION_DAO TYPE REF TO CL_UJA_APPLICATION_DAO.
2015     DATA: LO_DIM TYPE REF TO CL_UJA_DIM.
2016     DATA: LO_DATA_ACCESS_PROFILE_MGR TYPE REF TO CL_UJE_PROFILE_MEMACCESS.
2017 
2018     DATA: LT_MEMBER_LIST TYPE UJA_T_DIM_MEMBER.
2019     DATA: LS_MEMBER_LIST LIKE LINE OF LT_MEMBER_LIST.
2020 
2021     DATA: LV_MESSAGE TYPE UJ0_S_MESSAGE-MESSAGE.
2022 
2023     LCL_APPLICATION=>LV_ENVIRONMENT_ID  =  I_ENVIRONMENT_ID.
2024 
2025     TRY.
2026 
2027 * Get the appset info, need the prefix
2028         CREATE OBJECT LO_APPSET_DAO
2029           EXPORTING
2030             I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID.
2031 
2032         LO_APPSET_DAO->GET_APPSET_INFO(
2033               EXPORTING
2034                   I_APPSET_ID    = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2035               IMPORTING
2036                   ES_APPSET_INFO = LCL_APPLICATION=>LS_ENVIRONMENT_INFO ).
2037 
2038 * Get the list of applications for this appset, need the application prefixes
2039         LO_APPSET_DAO->GET_APPL_LIST(
2040               IMPORTING
2041                   ET_APPL_LIST = LT_APPL_LIST ).
2042 
2043       CATCH CX_UJ_DB_ERROR.
2044 * Do not raise exception here
2045     ENDTRY.
2046 
2047 * Check environment to make sure it is valid
2048     IF LCL_APPLICATION=>LS_ENVIRONMENT_INFO IS INITIAL.
2049       CONCATENATE 'Environment' LCL_APPLICATION=>LV_ENVIRONMENT_ID 'does not exist.'
2050                   INTO LV_MESSAGE SEPARATED BY SPACE.
2051       ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
2052                                     I_MESSAGE = LV_MESSAGE ).
2053       LCL_APPLICATION=>RENDER_ALV( ).
2054       RAISE ENVIRONMENT_NOT_FOUND .
2055     ENDIF.
2056 
2057     LCL_APPLICATION=>SET_GLOBAL_CONTEXT( ).
2058 
2059 * Loop applications, get application info, add to internal table
2060     LOOP AT LT_APPL_LIST INTO LS_APPL_LIST.
2061 
2062       TRY.
2063 
2064           CREATE OBJECT LO_APPLICATION_DAO
2065             EXPORTING
2066               I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID.
2067 
2068           LO_APPLICATION_DAO->GET_APPLICATION_INFO(
2069                 EXPORTING
2070                   I_APPLICATION_ID = LS_APPL_LIST
2071                 IMPORTING
2072                   ES_APPL_INFO = LS_UJA_APPL_INFO ).
2073 
2074           APPEND LS_UJA_APPL_INFO TO LCL_APPLICATION=>LT_APPL_INFO.
2075 
2076 * Get dimension list for each application
2077           LO_APPLICATION_DAO->GET_DIM_LIST(
2078                  EXPORTING
2079                    I_APPLICATION_ID = LS_APPL_LIST
2080                  IMPORTING
2081                    ET_APPL_DIM = LT_UJA_APPL_DIM ).
2082           LOOP AT LT_UJA_APPL_DIM INTO LS_UJA_APPL_DIM.
2083             LS_APPL_DIM-APPL_ID = LS_APPL_LIST.
2084             LS_APPL_DIM-DIMENSION = LS_UJA_APPL_DIM-DIMENSION.
2085             COLLECT LS_APPL_DIM INTO LCL_APPLICATION=>LT_APPL_DIM.
2086           ENDLOOP.
2087 
2088 * Get members for each dimension
2089           LOOP AT LT_UJA_APPL_DIM INTO LS_UJA_APPL_DIM.
2090             CREATE OBJECT LO_DIM
2091               EXPORTING
2092                 I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2093                 I_DIMENSION = LS_UJA_APPL_DIM-DIMENSION.
2094 
2095             REFRESH LT_MEMBER_LIST.
2096             LO_DIM->GET_MEMBER_LIST(
2097                    IMPORTING
2098                         ET_MEMBER =  LT_MEMBER_LIST  ).
2099 
2100             LOOP AT LT_MEMBER_LIST INTO LS_MEMBER_LIST.
2101               LS_MEMBERS-APPL_ID = LS_APPL_LIST.
2102               LS_MEMBERS-DIMENSION = LS_UJA_APPL_DIM-DIMENSION.
2103               LS_MEMBERS-MEMBER = LS_MEMBER_LIST.
2104               COLLECT LS_MEMBERS INTO LCL_APPLICATION=>LT_MEMBERS.
2105             ENDLOOP.
2106 
2107           ENDLOOP.
2108 
2109         CATCH: CX_UJ_DB_ERROR, CX_UJA_ADMIN_ERROR, CX_UJ_STATIC_CHECK.
2110           LV_MESSAGE = 'CX_UJ* Exception occured when reading environment metadata'.
2111           ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
2112                                         I_MESSAGE = LV_MESSAGE ).
2113           LCL_APPLICATION=>RENDER_ALV( ).
2114           RAISE UJ_EXCEPTION_ERROR .
2115       ENDTRY.
2116 
2117     ENDLOOP.
2118 
2119     TRY.
2120 
2121         CL_UJE_USER=>GET_ALL_USER_DETAILS(
2122                    EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2123                    IMPORTING ET_USER_DETAILS = LCL_APPLICATION=>LT_USERS_LIST ).
2124 
2125         CL_UJE_TEAM=>GET_ALL_TEAM_DETAILS(
2126                     EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2127                     IMPORTING ET_TEAMS = LCL_APPLICATION=>LT_TEAMS_LIST ).
2128 
2129         CL_UJE_USER=>GET_ALL_USER_DETAILS2(
2130                    EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2131                    IMPORTING ET_USERS = LCL_APPLICATION=>LT_USER_DETAIL ).
2132 
2133         CL_UJE_PROFILE_TASK=>GET_ALL_TASK_PROFILES(
2134                     EXPORTING I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2135                     IMPORTING ET_TASK_PROFILES = LT_TASK_PROFILES ).
2136 
2137       CATCH CX_UJE_EXCEPTION INTO LO_UJE_EXCEPTION.
2138         ADD_EXCEPTION_TO_MESSAGE_TABLE( LO_UJE_EXCEPTION ).
2139         LV_MESSAGE = 'CX_UJE Exception occured when reading environment metadata'.
2140         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
2141                                       I_MESSAGE = LV_MESSAGE ).
2142         LCL_APPLICATION=>RENDER_ALV( ).
2143         RAISE UJ_EXCEPTION_ERROR .
2144     ENDTRY.
2145 
2146     TRY.
2147 
2148         CREATE OBJECT LO_DATA_ACCESS_PROFILE_MGR
2149           EXPORTING
2150             I_APPSET_ID = LCL_APPLICATION=>LV_ENVIRONMENT_ID.
2151 
2152         LO_DATA_ACCESS_PROFILE_MGR->GET_ALL_MBR_PROFILES(
2153             EXPORTING
2154               I_APPSET_ID     = LCL_APPLICATION=>LV_ENVIRONMENT_ID
2155             IMPORTING
2156               ET_MBR_PROFILES = LCL_APPLICATION=>LT_DATA_ACCESS_PROFILES ).
2157 
2158       CATCH CX_UJ_STATIC_CHECK.
2159         LV_MESSAGE = 'CX_UJ* Exception occured when reading environment metadata'.
2160         ADD_MESSAGE_TO_MESSAGE_TABLE( I_MSGID = `00` I_MSGTY = `E` I_MSGNO = `001`
2161                                       I_MESSAGE = LV_MESSAGE ).
2162         LCL_APPLICATION=>RENDER_ALV( ).
2163         RAISE UJ_EXCEPTION_ERROR .
2164     ENDTRY.
2165 
2166 *    CALL FUNCTION 'UJE_API_GET_ROLE_TSKASG'
2167 *      IMPORTING
2168 *        ET_TASKASGN = LCL_APPLICATION=>LT_SYSTASKS.
2169 
2170   ENDMETHOD.                    "get_supporting_Data
2171 
2172   METHOD USER_IS_VALID.
2173 
2174     READ TABLE LCL_APPLICATION=>LT_USERS_LIST
2175               TRANSPORTING NO FIELDS
2176                          WITH KEY USER_ID = I_USER_ID.
2177     IF SY-SUBRC = 0.
2178       R_BOOLEAN = ABAP_TRUE.
2179     ELSE.
2180       R_BOOLEAN = ABAP_FALSE.
2181     ENDIF.
2182 
2183   ENDMETHOD.                    "user_id_valid
2184 
2185   METHOD TEAM_IS_VALID.
2186 
2187     READ TABLE LCL_APPLICATION=>LT_TEAMS_LIST
2188                TRANSPORTING NO FIELDS
2189                           WITH KEY TEAM_ID = I_TEAM_ID.
2190     IF SY-SUBRC = 0.
2191       R_BOOLEAN = ABAP_TRUE.
2192     ELSE.
2193       R_BOOLEAN = ABAP_FALSE.
2194     ENDIF.
2195 
2196   ENDMETHOD.                    "team_id_valid
2197 
2198   METHOD TPROFILE_IS_VALID.
2199 
2200     READ TABLE LCL_APPLICATION=>LT_TASK_PROFILES
2201                TRANSPORTING NO FIELDS
2202                         WITH KEY PROFILE_ID = I_PROFILE_ID.
2203     IF SY-SUBRC = 0.
2204       R_BOOLEAN = ABAP_TRUE.
2205     ELSE.
2206       R_BOOLEAN = ABAP_FALSE.
2207     ENDIF.
2208 
2209   ENDMETHOD.                    "tprofile_is_valid
2210 
2211   METHOD DPROFILE_IS_VALID.
2212 
2213     READ TABLE LCL_APPLICATION=>LT_DATA_ACCESS_PROFILES
2214                TRANSPORTING NO FIELDS
2215                       WITH KEY PROFILE_ID = I_PROFILE_ID.
2216     IF SY-SUBRC = 0.
2217       R_BOOLEAN = ABAP_TRUE.
2218     ELSE.
2219       R_BOOLEAN = ABAP_FALSE.
2220     ENDIF.
2221 
2222   ENDMETHOD.                    "dprofile_is_valid
2223 
2224   METHOD TASK_IS_VALID.
2225 
2226     READ TABLE LCL_APPLICATION=>LT_SYSTASKS
2227                TRANSPORTING NO FIELDS
2228                         WITH KEY TASK_ID = I_TASK_ID.
2229     IF SY-SUBRC = 0.
2230       R_BOOLEAN = ABAP_TRUE.
2231     ELSE.
2232       R_BOOLEAN = ABAP_FALSE.
2233     ENDIF.
2234 
2235   ENDMETHOD.                    "task_is_valid
2236 
2237   METHOD NW_USER_EXISTS.
2238 
2239     DATA: LV_BNAME TYPE BAPIBNAME-BAPIBNAME.
2240     DATA: LS_RETURN TYPE BAPIRET2.
2241 
2242     LV_BNAME = I_USER_ID.
2243     CALL FUNCTION 'BAPI_USER_EXISTENCE_CHECK'
2244       EXPORTING
2245         USERNAME = LV_BNAME
2246       IMPORTING
2247         RETURN   = LS_RETURN.
2248     IF LS_RETURN-NUMBER = '088'.  " Success message
2249       R_BOOLEAN = ABAP_TRUE.
2250     ELSEIF LS_RETURN-NUMBER = '124'.  " Error message
2251       R_BOOLEAN = ABAP_FALSE.
2252     ENDIF.
2253 
2254   ENDMETHOD.                    "nw_user_exists
2255 
2256   METHOD GET_BPC_COMPONENT_VERSION.
2257 
2258     DATA: LS_CVERS TYPE CVERS.
2259 
2260     CALL FUNCTION 'UPG_GET_SINGLE_COMPREL'
2261       EXPORTING
2262         IV_COMPONENT = `CPMBPC`
2263       IMPORTING
2264         EV_VERSION   = LS_CVERS
2265       EXCEPTIONS
2266         OTHERS       = 4.
2267     IF SY-SUBRC = 0.
2268       LV_RELEASE = LS_CVERS-RELEASE.
2269       LV_SPLEVEL = LS_CVERS-EXTRELEASE.
2270     ENDIF.
2271 
2272   ENDMETHOD.                    "get_bpc_component_version
2273 
2274   METHOD CHECK_BPC_COMPONENT_IS_VALID.
2275 
2276 *    IF LCL_APPLICATION=>LV_RELEASE <> '800' AND LCL_APPLICATION=>LV_RELEASE <> '810'.  " BPC NW 10.0
2277 *      R_VALID = ABAP_FALSE.
2278 *    ELSE.
2279 *      R_VALID = ABAP_TRUE.
2280 *    ENDIF.
2281 
2282   ENDMETHOD.                    "check_BPC_component_version
2283 
2284   METHOD ADD_EXCEPTION_TO_MESSAGE_TABLE.
2285 
2286     FIELD-SYMBOLS: <LS_MESSAGE> TYPE UJ0_S_MESSAGE.
2287 
2288     APPEND INITIAL LINE TO LT_ALV_MESSAGES ASSIGNING <LS_MESSAGE>.
2289     <LS_MESSAGE>-MSGID   = IO_EXCEPTION->IF_T100_MESSAGE~T100KEY-MSGID.
2290     <LS_MESSAGE>-MSGTY   = 'E'.
2291     <LS_MESSAGE>-MSGNO   = IO_EXCEPTION->IF_T100_MESSAGE~T100KEY-MSGNO.
2292     <LS_MESSAGE>-MSGV1   = IO_EXCEPTION->IF_T100_MESSAGE~T100KEY-ATTR1.
2293     <LS_MESSAGE>-MSGV2   = IO_EXCEPTION->IF_T100_MESSAGE~T100KEY-ATTR2.
2294     <LS_MESSAGE>-MSGV3   = IO_EXCEPTION->IF_T100_MESSAGE~T100KEY-ATTR3.
2295     <LS_MESSAGE>-MSGV4   = IO_EXCEPTION->IF_T100_MESSAGE~T100KEY-ATTR4.
2296     <LS_MESSAGE>-MESSAGE = IO_EXCEPTION->GET_TEXT( ).
2297 
2298   ENDMETHOD.                    "add_exception_to_message_table
2299 
2300   METHOD ADD_MESSAGE_TO_MESSAGE_TABLE.
2301 
2302     FIELD-SYMBOLS: <LS_MESSAGE> TYPE UJ0_S_MESSAGE.
2303 
2304     APPEND INITIAL LINE TO LT_ALV_MESSAGES ASSIGNING <LS_MESSAGE>.
2305     <LS_MESSAGE>-MSGID = I_MSGID.
2306     <LS_MESSAGE>-MSGTY = I_MSGTY.
2307     <LS_MESSAGE>-MSGNO = I_MSGNO.
2308     <LS_MESSAGE>-MESSAGE = I_MESSAGE.
2309 
2310   ENDMETHOD.                    "add_message_to_message_table
2311 
2312 ENDCLASS.                    "lcl_application IMPLEMENTATION
View Code
posted @ 2020-01-19 20:06  蜡哲图  阅读(422)  评论(1编辑  收藏  举报
目录内容