모듈 : BC
기능 설명 : 패스워드 이력 초기화
사용 예시 : RPA, 레거시 인터페이스 계정 등과 같이 같은 패스워드로 운영해야 하는 경우 사용
***********************************************************************
* Report : ZBC_PASSWD *
* Module/Sub-Module : BC *
* Description : Password history delete *
***********************************************************************
* MODIFICATION LOG *
* *
* DATE AUTHORS DESCRIPTION *
* ---------- ------------------ ------------------------------------- *
* YHJ Initial Release *
***********************************************************************
REPORT ZBC_PASSWD.
*----------------------------------------------------------------------*
* TYPE-POOLS
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS, ICON.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES: USRPWDHISTORY, USR02, SSCRFIELDS.
*----------------------------------------------------------------------*
* DATA
*----------------------------------------------------------------------*
DATA: GT_DATA LIKE TABLE OF USRPWDHISTORY WITH HEADER LINE.
DATA: TEMP_MSG(80) TYPE C.
DATA: FUNCTXT TYPE SMP_DYNTXT,
CPASS TYPE BAPIPWD.
DATA: LV_USERNAME LIKE BAPIBNAME,
LV_PASSWORD LIKE BAPIPWD,
LV_SUBRC LIKE SY-SUBRC,
LV_MSGTXT TYPE STRING,
LT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
DATA: IT_FIELDS TYPE STANDARD TABLE OF SVAL WITH HEADER LINE.
DATA: GT_USR02 LIKE TABLE OF USR02 WITH HEADER LINE.
*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: R_USER FOR USR02-BNAME.
PARAMETERS: P_INITP(12) TYPE C DEFAULT 'init1234!'.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN: FUNCTION KEY 1.
AT SELECTION-SCREEN.
DATA: IT_FIELDS LIKE SVAL OCCURS 0 WITH HEADER LINE.
DATA: LV_SUBRC LIKE SY-SUBRC,
LV_MSG(50) TYPE C.
CLEAR: CPASS, LV_SUBRC, LV_MSGTXT.
CASE SY-UCOMM.
WHEN 'FC01'.
IT_FIELDS-TABNAME = 'BAPIPWD'.
IT_FIELDS-FIELDNAME = 'BAPIPWD'.
IT_FIELDS-FIELDTEXT = 'Init Pass'.
APPEND IT_FIELDS.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
POPUP_TITLE = 'Change Initial Password'
TABLES
FIELDS = IT_FIELDS
EXCEPTIONS
ERROR_IN_FIELDS = 1
OTHERS = 2.
IF SY-SUBRC = 0 AND IT_FIELDS-VALUE IS NOT INITIAL.
CPASS = IT_FIELDS-VALUE.
CALL FUNCTION 'PASSWORD_FORMAL_CHECK'
EXPORTING
PASSWORD = CPASS
IMPORTING
RC = LV_SUBRC
MSGTEXT = LV_MSGTXT.
IF LV_SUBRC = 0.
P_INITP = IT_FIELDS-VALUE.
ELSE.
CLEAR: IT_FIELDS-VALUE.
MESSAGE LV_MSGTXT TYPE 'E'.
CALL SELECTION-SCREEN 1000.
ENDIF.
ENDIF.
IF P_INITP IS INITIAL.
MESSAGE 'No initial password has been set.' TYPE 'E'.
CALL SELECTION-SCREEN 1000.
ENDIF.
ENDCASE.
AT SELECTION-SCREEN OUTPUT.
%_R_USER_%_APP_%-TEXT = 'SAP ID'.
%_P_INITP_%_APP_%-TEXT = 'Init PASS'.
LOOP AT SCREEN.
IF SCREEN-NAME = 'P_INITP'.
SCREEN-INPUT = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
P_INITP = 'init1234!'.
FUNCTXT-ICON_ID = ICON_CHANGE_PASSWORD.
FUNCTXT-QUICKINFO = 'CHANG_INIT_PASS'.
FUNCTXT-ICON_TEXT = 'Change Init PASS'.
SSCRFIELDS-FUNCTXT_01 = FUNCTXT.
*----------------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------------*
START-OF-SELECTION.
CLEAR: GT_USR02, CPASS, LV_SUBRC, LV_MSGTXT.
REFRESH: GT_USR02.
CPASS = P_INITP.
CALL FUNCTION 'PASSWORD_FORMAL_CHECK'
EXPORTING
PASSWORD = CPASS
IMPORTING
RC = LV_SUBRC
MSGTEXT = LV_MSGTXT.
IF LV_SUBRC = 0.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_USR02
FROM USR02
WHERE BNAME = R_USER.
PERFORM PASS_INIT.
ELSE.
MESSAGE LV_MSGTXT TYPE 'E'.
CALL SELECTION-SCREEN 1000.
ENDIF.
*----------------------------------------------------------------------*
* END-OF-SELECTION.
*----------------------------------------------------------------------*
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& ZBC_HIST_DEL_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form PASS_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PASS_INIT .
CLEAR: TEMP_MSG.
LOOP AT R_USER.
LV_USERNAME = R_USER-LOW.
LV_PASSWORD = P_INITP.
CALL FUNCTION 'BAPI_USER_CHANGE'
EXPORTING
USERNAME = LV_USERNAME
PASSWORD = LV_PASSWORD
PASSWORDX = 'X'
TABLES
RETURN = LT_RETURN.
READ TABLE LT_RETURN INDEX 1.
IF LT_RETURN-TYPE = 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
PERFORM PASS_HIST_DEL.
READ TABLE GT_USR02 WITH KEY BNAME = R_USER.
IF GT_USR02-UFLAG = 128. PERFORM UNLOCK_USER USING R_USER. ENDIF.
ELSE.
CONCATENATE 'SAP ID ' R_USER-LOW ' Initialization failed! =>' LT_RETURN-MESSAGE INTO TEMP_MSG SEPARATED BY SPACE.
MESSAGE TEMP_MSG TYPE 'E'.
CALL SELECTION-SCREEN 1000.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form UNLOCK_USER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_0006T_SAPID text
*----------------------------------------------------------------------*
FORM UNLOCK_USER USING P_SAPID.
CLEAR: TEMP_MSG.
CALL FUNCTION 'BAPI_USER_UNLOCK'
EXPORTING
USERNAME = P_SAPID
TABLES
RETURN = LT_RETURN.
READ TABLE LT_RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
ELSE .
CONCATENATE 'SAP ID ' R_USER-LOW ' Unlock failed! =>' LT_RETURN-MESSAGE INTO TEMP_MSG SEPARATED BY SPACE.
MESSAGE TEMP_MSG TYPE 'E'.
CALL SELECTION-SCREEN 1000.
ENDIF.
ENDFORM. " LOCK_USER
*&---------------------------------------------------------------------*
*& Form PASS_HIST_DEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PASS_HIST_DEL .
REFRESH: GT_DATA. CLEAR: GT_DATA, TEMP_MSG.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM USRPWDHISTORY
WHERE BNAME IN R_USER.
IF GT_DATA[] IS NOT INITIAL.
LOOP AT R_USER.
DELETE FROM USRPWDHISTORY WHERE BNAME = R_USER-LOW.
ENDLOOP.
ENDIF.
CONCATENATE 'SAP ID ' R_USER-LOW ' Password Initialization completed!' INTO TEMP_MSG SEPARATED BY SPACE.
MESSAGE TEMP_MSG TYPE 'S'.
ENDFORM.
'SAP BC-프로그램' 카테고리의 다른 글
Oracle DB 테이블스페이스 기록 및 알람 프로그램 (0) | 2024.03.11 |
---|---|
ABAP - 마스터 패스워드 관리 프로그램 (2) | 2024.03.11 |
일일 간편 시스템 모니터링 프로그램 (0) | 2024.03.09 |
사용자 일괄 수정/복사 프로그램 (0) | 2024.03.09 |
Tcode 사용 기록 검색 프로그램 (0) | 2024.03.09 |