모듈 : BC
기능 설명 : SAP ID 정보 일괄 수정/ 일괄 복사 프로그램
사용 예시 : 입력된 엑셀 데이터에 따라 사용자 정보 일괄 수정 및 복사에 사용(시스템 신규 오픈, 신규 법인 추가 등등)
1. 소스 코드
***********************************************************************
* Report : ZBC_MASS_USER_CTRL *
* Module/Sub-Module : BC *
* Description : Mass User Control *
***********************************************************************
* MODIFICATION LOG *
* *
* DATE AUTHORS DESCRIPTION *
* ---------- ------------------ ------------------------------------- *
* YHJ Initial Release *
***********************************************************************
REPORT ZBC_MASS_USER_CTRL.
*----------------------------------------------------------------------*
* TYPE-POOLS
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
* TABLES: .
*----------------------------------------------------------------------*
* DATA
*----------------------------------------------------------------------*
"### ALV Internal Table
DATA: BEGIN OF GT_DATA_CHAG OCCURS 0,
SAPID LIKE SY-UNAME,
FNAME LIKE BAPIADDR3-FIRSTNAME,
LNAME LIKE BAPIADDR3-LASTNAME,
DEPT LIKE BAPIADDR3-DEPARTMENT,
CC LIKE BAPIDEFAUL-KOSTL,
END OF GT_DATA_CHAG.
DATA: BEGIN OF GT_LOG_CHAG OCCURS 0,
ICON(4),
SAPID LIKE SY-UNAME,
MSG LIKE BAPIRET2-MESSAGE,
END OF GT_LOG_CHAG.
DATA: BEGIN OF GT_DATA_COPY OCCURS 0,
COPY_SAPID LIKE SY-UNAME,
FNAME LIKE BAPIADDR3-FIRSTNAME,
LNAME LIKE BAPIADDR3-LASTNAME,
ORIG_SAPID LIKE SY-UNAME,
END OF GT_DATA_COPY.
DATA: BEGIN OF GT_LOG_COPY OCCURS 0,
ICON(4),
SAPID LIKE SY-UNAME,
MSG LIKE BAPIRET2-MESSAGE,
END OF GT_LOG_COPY.
DATA: GT_COUNT(6) TYPE N.
*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b6 WITH FRAME TITLE t10.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: C_CHAG RADIOBUTTON GROUP RAD1 DEFAULT 'X' USER-COMMAND FLAG.
SELECTION-SCREEN COMMENT (15) t11 FOR FIELD C_CHAG.
PARAMETERS: C_COPY RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (15) t12 FOR FIELD C_COPY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b6.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t2.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. "OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE t3.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R_FNAME AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (5) t31 FOR FIELD R_FNAME.
PARAMETERS: R_LNAME AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (5) t32 FOR FIELD R_LNAME.
PARAMETERS: R_DEPT AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (8) t33 FOR FIELD R_DEPT.
PARAMETERS: R_CC AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (5) t34 FOR FIELD R_CC.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN OUTPUT.
%_P_FILE_%_APP_%-TEXT = 'Base Excel File'.
LOOP AT SCREEN.
IF C_COPY = 'X'.
IF SCREEN-NAME CP 'R_*'.
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM FIND_FOLDER USING P_FILE.
*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.
* FUNCTXT-ICON_ID = ICON_CHANGE_PASSWORD.
* FUNCTXT-QUICKINFO = 'CHANG_INIT_PASS'.
* FUNCTXT-ICON_TEXT = 'Change Init PASS'.
* SSCRFIELDS-FUNCTXT_01 = FUNCTXT.
MOVE 'Mass User Change' TO t1.
MOVE 'Mode Select' TO t10.
MOVE 'User Info Change' TO t11.
MOVE 'User Copy' TO t12.
MOVE 'Excel File' TO t2.
MOVE 'Chang Object' TO t3.
MOVE 'Last Name' TO t31.
MOVE 'First Name' TO t32.
MOVE 'Department' TO t33.
MOVE 'CostCenter' TO t34.
*---------------------------------------------------------------------*
* START-OF-SELECTION.
*---------------------------------------------------------------------*
START-OF-SELECTION.
IF P_FILE IS INITIAL.
MESSAGE '엑셀파일은 필수 입력입니다.' TYPE 'S'.
REJECT.
ENDIF.
"### 1. 대량 유저 정보 변경
IF C_CHAG = 'X'.
PERFORM UPLOAD_XLS.
PERFORM USER_INFO_CHANGE.
PERFORM RESULT_VIEW_CHAG.
"### 2. 대량 유저 카피
ELSEIF C_COPY = 'X'.
PERFORM UPLOAD_XLS.
PERFORM USER_COPY.
PERFORM RESULT_VIEW_COPY.
ENDIF.
*---------------------------------------------------------------------*
* END-OF-SELECTION.
*---------------------------------------------------------------------*
END-OF-SELECTION.
*&--------------------------------------------------------------------*
*& ZBC_MASS_USER_CTRL_F01
*&--------------------------------------------------------------------*
*&--------------------------------------------------------------------*
*& Form FIND_FOLDER
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* --> p1 text* <-- p2 text
*---------------------------------------------------------------------*
FORM FIND_FOLDER USING PV_FILE.
* DATA: LT_FILE TYPE FILETABLE,
* LV_RC TYPE I.
*
* REFRESH: LT_FILE.
*
* CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
* EXPORTING
* WINDOW_TITLE = 'Select File'
** DEFAULT_FILENAME = '*.xls'
*FILE_FILTER = 'EXCEL FILES (*.XLS)|*.XLS|EXCEL FILES
*(*.XLSX)|*.XLSX|'
* INITIAL_DIRECTORY = 'C:\'
* MULTISELECTION = ' ' "No multiple selection
* CHANGING
* FILE_TABLE = LT_FILE
* RC = LV_RC.
*
* LOOP AT LT_FILE INTO P_FILE. ENDLOOP.
CLEAR PV_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = ''
DYNPRO_NUMBER = ''
FIELD_NAME = 'FILENAME'
IMPORTING
FILE_NAME = PV_FILE.
* IF PV_FILE IS INITIAL.
* MESSAGE E016(Z000CAM).
* ENDIF.
ENDFORM. " FIND_FOLDER
*&--------------------------------------------------------------------*
*& Form UPLOAD_XLS
*&--------------------------------------------------------------------*
*& text
*&--------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&--------------------------------------------------------------------*
FORM UPLOAD_XLS .
DATA: XLS_DATA1 LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE,
FNAME TYPE STRING.
DATA: BEGIN OF LT_INDEX OCCURS 0 ,
FNAME TYPE CHAR10 ,
POS TYPE NUM4 ,
END OF LT_INDEX.
FIELD-SYMBOLS: <LFS>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 100
I_END_ROW = 9999
TABLES
INTERN = XLS_DATA1
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
*** COLUMNS
LOOP AT XLS_DATA1 WHERE ROW = 1.
LT_INDEX-FNAME = XLS_DATA1-VALUE.
LT_INDEX-POS = XLS_DATA1-COL.
APPEND LT_INDEX.
ENDLOOP.
DELETE XLS_DATA1 WHERE ROW = 1.
LOOP AT XLS_DATA1.
CLEAR LT_INDEX.
READ TABLE LT_INDEX WITH KEY POS = XLS_DATA1-COL.
IF C_CHAG = 'X'.
"### 유저 대량 변경 모드인데, 첫 컬럼 이름이 SAPID 가 아니라면,
"### 잘못된 양식을 사용한것이므로, 작업을 롤백한다.
AT FIRST.
IF LT_INDEX-FNAME <> 'SAPID'.
MESSAGE '잘못된 엑셀 양식 사용으로 인해 작업을 중단합니다. 양식을 확인하세요.' TYPE 'S'.
REJECT.
ENDIF.
ENDAT.
CONCATENATE 'GT_DATA_CHAG-' LT_INDEX-FNAME INTO FNAME.
ELSEIF C_COPY = 'X'.
"### 유저 복사 모드인데, 첫 컬럼 이름이 COPY_SAPID 가 아니라면,
"### 잘못된 양식을 사용한것이므로, 작업을 롤백한다.
AT FIRST.
IF LT_INDEX-FNAME <> 'COPY_SAPID'.
MESSAGE '잘못된 엑셀 양식 사용으로 인해 작업을 중단합니다. 양식을 확인하세요.' TYPE 'S'.
REJECT.
ENDIF.
ENDAT.
CONCATENATE 'GT_DATA_COPY-' LT_INDEX-FNAME INTO FNAME.
ENDIF.
ASSIGN (FNAME) TO <LFS>.
<LFS> = XLS_DATA1-VALUE.
AT END OF ROW.
IF C_CHAG = 'X'.
APPEND GT_DATA_CHAG.
CLEAR: GT_DATA_CHAG.
ELSEIF C_COPY = 'X'.
APPEND GT_DATA_COPY.
CLEAR: GT_DATA_COPY.
ENDIF.
ENDAT.
ENDLOOP.
ENDFORM.
*&--------------------------------------------------------------------*
*& Form USER_INFO_CHANGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM USER_INFO_CHANGE .
DATA: LT_ADDR TYPE BAPIADDR3,
LT_ADDRX TYPE BAPIADDR3X,
LT_DEFT TYPE BAPIDEFAUL,
LT_DEFTX TYPE BAPIDEFAX,
LT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
DATA: LV_USER LIKE SY-UNAME.
* SORT GT_DATA_CHAG BY SAPID.
CLEAR: GT_COUNT.
GT_COUNT = LINES( GT_DATA_CHAG ).
LOOP AT GT_DATA_CHAG.
CLEAR: LT_ADDR, LT_ADDRX, LT_DEFT, LT_DEFTX, LT_RETURN.
REFRESH: LT_RETURN.
LV_USER = GT_DATA_CHAG-SAPID.
IF R_FNAME = 'X'. LT_ADDRX-FIRSTNAME = 'X'. ENDIF.
IF R_LNAME = 'X'. LT_ADDRX-LASTNAME = 'X'. ENDIF.
IF R_DEPT = 'X'. LT_ADDRX-DEPARTMENT = 'X'. ENDIF.
IF R_CC = 'X'. LT_DEFTX-KOSTL = 'X'. ENDIF.
IF R_FNAME = 'X'. LT_ADDR-FIRSTNAME = GT_DATA_CHAG-FNAME. ENDIF.
IF R_LNAME = 'X'. LT_ADDR-LASTNAME = GT_DATA_CHAG-LNAME. ENDIF.
IF R_DEPT = 'X'. LT_ADDR-DEPARTMENT = GT_DATA_CHAG-DEPT. ENDIF.
IF R_CC = 'X'. LT_DEFT-KOSTL = GT_DATA_CHAG-CC. ENDIF.
CALL FUNCTION 'BAPI_USER_CHANGE'
EXPORTING
USERNAME = LV_USER
DEFAULTS = LT_DEFT
DEFAULTSX = LT_DEFTX
ADDRESS = LT_ADDR
ADDRESSX = LT_ADDRX
TABLES
RETURN = LT_RETURN.
READ TABLE LT_RETURN INDEX 1.
IF SY-SUBRC = 0.
IF LT_RETURN-TYPE = 'S'.
GT_LOG_CHAG-ICON = '@5B@'.
GT_LOG_CHAG-SAPID = LV_USER.
GT_LOG_CHAG-MSG = LT_RETURN-MESSAGE.
ELSE.
GT_LOG_CHAG-ICON = '@5C@'.
GT_LOG_CHAG-SAPID = LV_USER.
GT_LOG_CHAG-MSG = LT_RETURN-MESSAGE.
ENDIF.
APPEND GT_LOG_CHAG.
ENDIF.
ENDLOOP.
ENDFORM. " USER_INFO_CHANGE
*&--------------------------------------------------------------------*
*& Form RESULT_VIEW
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM RESULT_VIEW_CHAG .
DATA: LT_FIELDCAT type SLIS_T_FIELDCAT_ALV with header line.
LT_FIELDCAT-FIELDNAME = 'ICON'.
LT_FIELDCAT-SELTEXT_M = 'RC'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 3.
LT_FIELDCAT-COL_POS = 0.
append LT_FIELDCAT to LT_FIELDCAT.
clear LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'SAPID'.
LT_FIELDCAT-SELTEXT_M = 'USER'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 12.
LT_FIELDCAT-COL_POS = 1.
append LT_FIELDCAT to LT_FIELDCAT.
clear LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'MSG'.
LT_FIELDCAT-SELTEXT_M = 'MESSAGE'.
LT_FIELDCAT-OUTPUTLEN = 60.
LT_FIELDCAT-COL_POS = 2.
append LT_FIELDCAT to LT_FIELDCAT.
clear LT_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE_CHAG'
IT_FIELDCAT = LT_FIELDCAT[]
TABLES
T_OUTTAB = GT_LOG_CHAG.
ENDFORM. " RESULT_VIEW
*&--------------------------------------------------------------------*
*& Form RESULT_VIEW
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM RESULT_VIEW_COPY .
DATA: LT_FIELDCAT type SLIS_T_FIELDCAT_ALV with header line.
LT_FIELDCAT-FIELDNAME = 'ICON'.
LT_FIELDCAT-SELTEXT_M = 'RC'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 3.
LT_FIELDCAT-COL_POS = 0.
append LT_FIELDCAT to LT_FIELDCAT.
clear LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'SAPID'.
LT_FIELDCAT-SELTEXT_M = 'USER'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 12.
LT_FIELDCAT-COL_POS = 1.
append LT_FIELDCAT to LT_FIELDCAT.
clear LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'MSG'.
LT_FIELDCAT-SELTEXT_M = 'MESSAGE'.
LT_FIELDCAT-OUTPUTLEN = 60.
LT_FIELDCAT-COL_POS = 2.
append LT_FIELDCAT to LT_FIELDCAT.
clear LT_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE_COPY'
IT_FIELDCAT = LT_FIELDCAT[]
TABLES
T_OUTTAB = GT_LOG_COPY.
ENDFORM. " RESULT_VIEW
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE1_CHAG *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
FORM TOP-OF-PAGE_CHAG.
*ALV Header declarations
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE WA_HEADER-INFO.
* Title
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = '계정 정보 변경 완료'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = GT_COUNT
IMPORTING
OUTPUT = GT_COUNT.
* Total No. of Records Selected
CONCATENATE '총 변경 계정 수: ' GT_COUNT INTO T_LINE SEPARATED BY SPACE.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = T_LINE.
APPEND WA_HEADER TO T_HEADER.
CLEAR: WA_HEADER, T_LINE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. "TOP-OF-PAGE.
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE1_COPY *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
FORM TOP-OF-PAGE_COPY.
*ALV Header declarations
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER,
T_LINE LIKE WA_HEADER-INFO.
* Title
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = '계정 복사 완료'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = GT_COUNT
IMPORTING
OUTPUT = GT_COUNT.
* Total No. of Records Selected
CONCATENATE '총 카피 계정 수: ' GT_COUNT INTO T_LINE SEPARATED BY SPACE.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = T_LINE.
APPEND WA_HEADER TO T_HEADER.
CLEAR: WA_HEADER, T_LINE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. "TOP-OF-PAGE.
*&---------------------------------------------------------------------*
*& Form USER_COPY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM USER_COPY .
DATA: LV_LOGONDATA LIKE BAPILOGOND,
LV_DEFAULTS LIKE BAPIDEFAUL,
LV_ADDRESS LIKE BAPIADDR3,
LV_COMPANY LIKE BAPIUSCOMP,
LV_SNC LIKE BAPISNCU,
LV_REF_USER LIKE BAPIREFUS,
LV_ALIAS LIKE BAPIALIAS,
LV_UCLASS TYPE BAPIUCLASS,
LV_LASTMODIFIED TYPE BAPIMODDAT,
LV_ISLOCKED TYPE BAPISLOCKD,
LV_PARAMETER TYPE TABLE OF BAPIPARAM WITH HEADER LINE,
LV_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE,
LV_ADDTEL TYPE TABLE OF BAPIADTEL WITH HEADER LINE,
LV_ADDFAX TYPE TABLE OF BAPIADFAX WITH HEADER LINE,
LV_ADDTTX TYPE TABLE OF BAPIADTTX WITH HEADER LINE,
LV_ADDTLX TYPE TABLE OF BAPIADTLX WITH HEADER LINE,
LV_ADDSMTP TYPE TABLE OF BAPIADSMTP WITH HEADER LINE,
LV_ADDRML TYPE TABLE OF BAPIADRML WITH HEADER LINE,
LV_ADDX400 TYPE TABLE OF BAPIADX400 WITH HEADER LINE,
LV_ADDRFC TYPE TABLE OF BAPIADRFC WITH HEADER LINE,
LV_ADDPRT TYPE TABLE OF BAPIADPRT WITH HEADER LINE,
LV_ADDSSF TYPE TABLE OF BAPIADSSF WITH HEADER LINE,
LV_ADDURI TYPE TABLE OF BAPIADURI WITH HEADER LINE,
LV_ADDPAG TYPE TABLE OF BAPIADPAG WITH HEADER LINE,
LV_ADDCOMREM TYPE TABLE OF BAPICOMREM WITH HEADER LINE,
LV_PARAMETER1 TYPE TABLE OF BAPIPARAM1 WITH HEADER LINE,
LV_GROUPS TYPE TABLE OF BAPIGROUPS WITH HEADER LINE,
LV_UCLASSSYS TYPE TABLE OF BAPIUCLASSSYS WITH HEADER LINE,
LV_EXTIDHEAD TYPE TABLE OF BAPIUSEXTIDHEAD WITH HEADER LINE,
LV_EXTIDPART TYPE TABLE OF BAPIUSEXTIDPART WITH HEADER LINE,
LV_SYSTEMS TYPE TABLE OF BAPIRCVSYS WITH HEADER LINE,
LV_PROFILES TYPE TABLE OF BAPIPROF WITH HEADER LINE,
LV_ACTIVITYGROUPS TYPE TABLE OF BAPIAGR WITH HEADER LINE.
CLEAR: GT_COUNT.
GT_COUNT = LINES( GT_DATA_COPY ).
LOOP AT GT_DATA_COPY.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = GT_DATA_COPY-ORIG_SAPID
IMPORTING
LOGONDATA = LV_LOGONDATA
DEFAULTS = LV_DEFAULTS
ADDRESS = LV_ADDRESS
COMPANY = LV_COMPANY
SNC = LV_SNC
REF_USER = LV_REF_USER
ALIAS = LV_ALIAS
UCLASS = LV_UCLASS
LASTMODIFIED = LV_LASTMODIFIED
ISLOCKED = LV_ISLOCKED
TABLES
PARAMETER = LV_PARAMETER
ADDTEL = LV_ADDTEL
ADDFAX = LV_ADDFAX
ADDTTX = LV_ADDTTX
ADDTLX = LV_ADDTLX
ADDSMTP = LV_ADDSMTP
ADDRML = LV_ADDRML
ADDX400 = LV_ADDX400
ADDRFC = LV_ADDRFC
ADDPRT = LV_ADDPRT
ADDSSF = LV_ADDSSF
ADDURI = LV_ADDURI
ADDPAG = LV_ADDPAG
ADDCOMREM = LV_ADDCOMREM
GROUPS = LV_GROUPS
PARAMETER1 = LV_PARAMETER1
EXTIDHEAD = LV_EXTIDHEAD
EXTIDPART = LV_EXTIDPART
PROFILES = LV_PROFILES
ACTIVITYGROUPS = LV_ACTIVITYGROUPS
RETURN = LV_RETURN.
DATA: LV_USERNAME LIKE BAPIBNAME,
LV_PASSWORD LIKE BAPIPWD.
LV_USERNAME = GT_DATA_COPY-COPY_SAPID .
LV_PASSWORD = 'init1234!@'.
LV_ADDRESS-FIRSTNAME = GT_DATA_COPY-FNAME.
LV_ADDRESS-LASTNAME = GT_DATA_COPY-LNAME.
CLEAR: LV_ADDRESS-E_MAIL, LV_ADDRESS-TEL1_NUMBR, LV_ADDRESS-TEL1_EXT, LV_ADDRESS-FAX_NUMBER, LV_ADDRESS-FAX_EXTENS.
CALL FUNCTION 'BAPI_USER_CREATE1'
EXPORTING
USERNAME = LV_USERNAME
LOGONDATA = LV_LOGONDATA
PASSWORD = LV_PASSWORD
DEFAULTS = LV_DEFAULTS
ADDRESS = LV_ADDRESS
COMPANY = LV_COMPANY
SNC = LV_SNC
REF_USER = LV_REF_USER
ALIAS = LV_ALIAS
UCLASS = LV_UCLASS
TABLES
PARAMETER = LV_PARAMETER
ADDTEL = LV_ADDTEL
ADDFAX = LV_ADDFAX
ADDTTX = LV_ADDTTX
ADDTLX = LV_ADDTLX
ADDSMTP = LV_ADDSMTP
ADDRML = LV_ADDRML
ADDX400 = LV_ADDX400
ADDRFC = LV_ADDRFC
ADDPRT = LV_ADDPRT
ADDSSF = LV_ADDSSF
ADDURI = LV_ADDURI
ADDPAG = LV_ADDPAG
ADDCOMREM = LV_ADDCOMREM
GROUPS = LV_GROUPS
PARAMETER1 = LV_PARAMETER1
EXTIDHEAD = LV_EXTIDHEAD
EXTIDPART = LV_EXTIDPART
RETURN = LV_RETURN.
READ TABLE LV_RETURN WITH KEY TYPE = 'S'.
IF SY-SUBRC = 0. GT_LOG_COPY-ICON = '@5B@'. ENDIF.
READ TABLE LV_RETURN WITH KEY TYPE = 'W'.
IF SY-SUBRC = 0. GT_LOG_COPY-ICON = '@5D@'. ENDIF.
READ TABLE LV_RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0. GT_LOG_COPY-ICON = '@5C@'. ENDIF.
GT_LOG_COPY-SAPID = GT_DATA_COPY-COPY_SAPID.
GT_LOG_COPY-MSG = LV_RETURN-MESSAGE.
APPEND GT_LOG_COPY. CLEAR GT_LOG_COPY.
CALL FUNCTION 'BAPI_USER_PROFILES_ASSIGN'
EXPORTING
USERNAME = LV_USERNAME
TABLES
PROFILES = LV_PROFILES
RETURN = LV_RETURN.
CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
USERNAME = LV_USERNAME
TABLES
ACTIVITYGROUPS = LV_ACTIVITYGROUPS
RETURN = LV_RETURN.
*********************************************************************
DATA: LT_FAC LIKE TABLE OF SMEN_BUFFC WITH HEADER LINE,
RT_FAC LIKE TABLE OF SMEN_BUFFC WITH HEADER LINE.
SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_FAC
FROM SMEN_BUFFC
WHERE UNAME = GT_DATA_COPY-ORIG_SAPID.
LOOP AT LT_FAC.
LT_FAC-UNAME = GT_DATA_COPY-COPY_SAPID.
MOVE-CORRESPONDING LT_FAC TO RT_FAC. APPEND RT_FAC.
ENDLOOP.
MODIFY SMEN_BUFFC FROM TABLE RT_FAC .
*********************************************************************
DATA: LT_FAI LIKE TABLE OF SMEN_BUFFI WITH HEADER LINE,
RT_FAI LIKE TABLE OF SMEN_BUFFI WITH HEADER LINE.
SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_FAI
FROM SMEN_BUFFI
WHERE UNAME = GT_DATA_COPY-ORIG_SAPID.
LOOP AT LT_FAI.
LT_FAI-UNAME = GT_DATA_COPY-COPY_SAPID.
MOVE-CORRESPONDING LT_FAI TO RT_FAI. APPEND RT_FAI.
ENDLOOP.
MODIFY SMEN_BUFFI FROM TABLE RT_FAI .
*********************************************************************
ENDLOOP.
ENDFORM.
'SAP BC-프로그램' 카테고리의 다른 글
Oracle DB 테이블스페이스 기록 및 알람 프로그램 (0) | 2024.03.11 |
---|---|
ABAP - 마스터 패스워드 관리 프로그램 (2) | 2024.03.11 |
일일 간편 시스템 모니터링 프로그램 (0) | 2024.03.09 |
Tcode 사용 기록 검색 프로그램 (0) | 2024.03.09 |
패스워드 이력 초기화 프로그램 (0) | 2024.03.09 |