모듈 : BC
기능 설명 : 시스템 별 패스워드 관리 마스터 프로그램
사용 예시 : 여러 시스템의 각기 다른 패스워드를 한군데에서 일괄 관리하는 프로그램
1. 소스 코드
***********************************************************************
* Report : ZBC_MASTER_PASSWORD *
* Module/Sub-Module : BC *
* Description : Master Password Management *
***********************************************************************
* MODIFICATION LOG *
* *
* DATE AUTHORS DESCRIPTION *
* ---------- ------------------ ------------------------------------- *
* YHJ Initial Release *
***********************************************************************
REPORT ZBC_MASTER_PASSWORD.
*----------------------------------------------------------------------*
* TYPE-POOLS
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS, ICON.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES: SSCRFIELDS.
TABLES: ZBC_MASTER_PW.
*----------------------------------------------------------------------*
* DATA
*----------------------------------------------------------------------*
*DATA: GT_DATA LIKE TABLE OF ZBC_MASTER_PW WITH HEADER LINE.
DATA: BEGIN OF GT_DATA OCCURS 0,
SEL(1) TYPE C,
LINECOLOR(4) TYPE C.
INCLUDE STRUCTURE ZBC_MASTER_PW.
DATA: END OF GT_DATA.
DATA: TEMP_DATA LIKE TABLE OF GT_DATA WITH HEADER LINE.
DATA: GV_SET_SYS(5) TYPE C,
GV_SET_SID(3) TYPE C,
GV_SET_ROLE(3) TYPE C,
GV_SET_TAG1(10) TYPE C,
GV_SET_TAG2(10) TYPE C.
DATA: GV_ALV_HEADER TYPE LVC_TITLE.
DATA: GV_FLAG(1) TYPE C,
SEARCH_MOD(1) TYPE C,
SAVE_CHECK(1) TYPE C,
POPUP_RET(1) TYPE C,
VIEW_ALL(1) TYPE C.
DATA: FUNCTXT TYPE SMP_DYNTXT.
DATA: IT_FIELDS LIKE SVAL OCCURS 0 WITH HEADER LINE.
"### 마스터 패스워드 형태 지정 ####################################
"### _ 표시는 시퀸셜 위치 (ex. Password1! - Password2! - Password3! ...)
DATA: BEGIN OF MASTER_PASSWORD_SHAPE OCCURS 0,
PWD_SHAPE(20) TYPE C VALUE 'Password_!'.
DATA: END OF MASTER_PASSWORD_SHAPE.
"############################################################
"### 패스워드 정책 #############################################
"### SECPOL 설정 정책에 따라 자동으로 값 설정
DATA: BEGIN OF PWD_POLICY OCCURS 0,
LINECOLOR(4) TYPE C,
PARAM(15) TYPE C,
VALUE(10) TYPE C.
DATA: END OF PWD_POLICY.
*CONSTANTS : UPPER_CASE(1) VALUE 1.
*CONSTANTS : LOWER_CASE(1) VALUE 1.
*CONSTANTS : SPECIALS(1) VALUE 1.
*CONSTANTS : DIGITS(1) VALUE 1.
*CONSTANTS : LENGTH(2) VALUE 10.
"############################################################
*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t001.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t002.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE t003.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: C_SYS1 RADIOBUTTON GROUP RAD3 DEFAULT 'X' USER-COMMAND FLAG.
SELECTION-SCREEN COMMENT (15) t301 FOR FIELD C_SYS1.
PARAMETERS: C_SYS2 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t302 FOR FIELD C_SYS2.
PARAMETERS: C_SYS3 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t303 FOR FIELD C_SYS3.
PARAMETERS: C_SYS4 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t304 FOR FIELD C_SYS4.
PARAMETERS: C_SYS5 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t305 FOR FIELD C_SYS5.
PARAMETERS: C_SYS6 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t306 FOR FIELD C_SYS6.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: C_SYS7 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t307 FOR FIELD C_SYS7.
PARAMETERS: C_SYS8 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t308 FOR FIELD C_SYS8.
PARAMETERS: C_SYS9 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t309 FOR FIELD C_SYS9.
PARAMETERS: C_SYS10 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t310 FOR FIELD C_SYS10.
PARAMETERS: C_SYS11 RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t311 FOR FIELD C_SYS11.
PARAMETERS: C_ETC RADIOBUTTON GROUP RAD3.
SELECTION-SCREEN COMMENT (15) t312 FOR FIELD C_ETC.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE t003.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: R_ALL RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT (15) t041 FOR FIELD R_ALL.
PARAMETERS: R_ABAP RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (15) t042 FOR FIELD R_ABAP.
PARAMETERS: R_JAVA RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (15) t043 FOR FIELD R_JAVA.
PARAMETERS: R_OS RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (15) t044 FOR FIELD R_OS.
PARAMETERS: R_DB RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN COMMENT (15) t045 FOR FIELD R_DB.
* PARAMETERS: R_ETC RADIOBUTTON GROUP RAD1.
* SELECTION-SCREEN COMMENT (15) t046 FOR FIELD R_ETC.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b4.
SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE t005.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: C2_ALL RADIOBUTTON GROUP RAD2 DEFAULT 'X'.
SELECTION-SCREEN COMMENT (15) t041 FOR FIELD C2_ALL.
PARAMETERS: C2_PRD RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN COMMENT (15) t052 FOR FIELD C2_PRD.
PARAMETERS: C2_QAS RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN COMMENT (15) t053 FOR FIELD C2_QAS.
PARAMETERS: C2_DEV RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN COMMENT (15) t054 FOR FIELD C2_DEV.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b5.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b6 WITH FRAME TITLE t006.
SELECT-OPTIONS: S_SID FOR ZBC_MASTER_PW-SID,
S_UID FOR ZBC_MASTER_PW-ID,
S_IP FOR ZBC_MASTER_PW-IP,
S_HN FOR ZBC_MASTER_PW-HOSTNAME,
S_VC FOR ZBC_MASTER_PW-PW_VC,
S_TAG1 FOR ZBC_MASTER_PW-TAG1,
S_TAG2 FOR ZBC_MASTER_PW-TAG2.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK b6.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN: FUNCTION KEY 1, FUNCTION KEY 2, FUNCTION KEY 3, FUNCTION KEY 4, FUNCTION KEY 5.
AT SELECTION-SCREEN.
PERFORM MENU_SELECT.
AT SELECTION-SCREEN OUTPUT.
PERFORM MODIFY_SCREEN.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
PERFORM MENU_BAR.
PERFORM SET_PWD_POLICY.
MOVE 'SAP Password Master' TO t001.
MOVE 'Simple Search' TO t002.
MOVE 'ERP' TO t003.
MOVE 'SYS1' TO t301.
MOVE 'SYS2' TO t302.
MOVE 'SYS3' TO t303.
MOVE 'SYS4' TO t304.
MOVE 'SYS5' TO t305.
MOVE 'SYS6' TO t306.
MOVE 'SYS7' TO t307.
MOVE 'SYS8' TO t308.
MOVE 'SYS9' TO t309.
MOVE 'SYS10' TO t310.
MOVE 'SYS11' TO t311.
MOVE 'Etc System' TO t312.
MOVE 'System' TO t004.
MOVE 'ALL' TO t041.
MOVE 'ABAP' TO t042.
MOVE 'JAVA' TO t043.
MOVE 'OS' TO t044.
MOVE 'DB' TO t045.
MOVE 'ETC' TO t046.
MOVE 'Role' TO t005.
*MOVE 'ALL' TO t041.
MOVE 'Prd' TO t052.
MOVE 'Qas' TO t053.
MOVE 'Dev' TO t054.
MOVE 'Deep Search' TO t006.
*----------------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------------*
START-OF-SELECTION.
"### 배치잡 수행일때 동작
IF SY-BATCH = 'X'.
"### 프론트 수행일떄 동작
ELSE.
"### 1. 조회 조건 값을 DB에서 읽을 수 있게, 값 세팅
PERFORM SET_CONDITION.
"### 2. 데이터 조회 전, 전체 데이터에 대해서 클리닝 작업
PERFORM DATA_CLEANING.
"### 3. 세팅된 조회값으로 DB에서 데이터 셀렉트
PERFORM SELECT_DATA.
"### 4. 셀렉트된 데이터를 기반으로 ALV 리스트 출력
PERFORM RESULT_VIEW TABLES GT_DATA.
ENDIF.
*----------------------------------------------------------------------*
* END-OF-SELECTION.
*----------------------------------------------------------------------*
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& ZBC_MASTER_PASSWORD_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form MODIFY_SCREEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MODIFY_SCREEN .
%_S_SID_%_APP_%-TEXT = 'SID'.
%_S_UID_%_APP_%-TEXT = 'SAP ID'.
%_S_IP_%_APP_%-TEXT = 'IP'.
%_S_HN_%_APP_%-TEXT = 'HostName'.
%_S_VC_%_APP_%-TEXT = 'Vaild Check'.
%_S_TAG1_%_APP_%-TEXT = 'Tag_1'.
%_S_TAG2_%_APP_%-TEXT = 'Tag_2'.
LOOP AT SCREEN.
IF C_ETC = 'X'.
IF ( SCREEN-NAME CP 'R_*' ) OR ( SCREEN-NAME CP 'C2_*' ).
IF SCREEN-NAME = 'R_ALL'. CLEAR: R_ALL, R_ABAP, R_JAVA, R_OS, R_DB. R_ALL = 'X'. ENDIF.
IF SCREEN-NAME = 'C2_ALL'. CLEAR: C2_ALL, C2_PRD, C2_QAS, C2_DEV. C2_ALL = 'X'. ENDIF.
SCREEN-INPUT = 0.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SET_CONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_CONDITION .
DATA: CK_ERP(20) TYPE C,
CK_ROL(5) TYPE C.
CLEAR: GV_SET_SYS, GV_SET_ROLE, GV_SET_SID, GV_ALV_HEADER, SEARCH_MOD.
"### 간편 검색인지, 상세 검색인지 체크
"### 상세 검색의 모든 필드에 값이 없다면, 간편 검색으로 인식.
IF S_SID IS INITIAL AND S_UID IS INITIAL AND
S_IP IS INITIAL AND S_HN IS INITIAL AND
S_VC IS INITIAL AND S_TAG1 IS INITIAL AND S_TAG2 IS INITIAL.
"### SELECT_DATA 폼에서 쓸 서치모드 A 설정(간편 검색)
SEARCH_MOD = 'A'.
"### SYS 키값 세팅
IF R_ALL = 'X'.
GV_SET_SYS = '%'.
ELSEIF R_ABAP = 'X'.
GV_SET_SYS = 'ABAP'.
ELSEIF R_JAVA = 'X'.
GV_SET_SYS = 'JAVA'.
ELSEIF R_OS = 'X'.
GV_SET_SYS = 'OS'.
ELSEIF R_DB = 'X'.
GV_SET_SYS = 'DB'.
ENDIF.
"### ERP /ROLE 키값 세팅
"### ERP 의 ROLE 개발/품질/운영에 따라 SID 값 세팅
IF C_SYS1 = 'X'.
CK_ERP = 'SYSTEM1 ERP'.
GV_SET_TAG1 = 'G01'.
GV_SET_TAG2 = 'SY1'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS2 = 'X'.
CK_ERP = 'SYSTEM2 ERP'.
GV_SET_TAG1 = 'G01'.
GV_SET_TAG2 = 'SY2'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS3 = 'X'.
CK_ERP = 'SYSTEM3 ERP'.
GV_SET_TAG1 = 'G01'.
GV_SET_TAG2 = 'SY3'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS4 = 'X'.
CK_ERP = 'SYSTEM4 ERP'.
GV_SET_TAG1 = 'G01'.
GV_SET_TAG2 = 'SY4'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS5 = 'X'.
CK_ERP = 'SYSTEM5 ERP'.
GV_SET_TAG1 = 'G01'.
GV_SET_TAG2 = 'SY5'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS6 = 'X'.
CK_ERP = 'SYSTEM6 ERP'.
GV_SET_TAG1 = 'G01'.
GV_SET_TAG2 = 'SY6'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS7 = 'X'.
CK_ERP = 'SYSTEM7 ERP'.
GV_SET_TAG1 = 'G02'.
GV_SET_TAG2 = '%'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS8 = 'X'.
CK_ERP = 'SYSTEM8 ERP'.
GV_SET_TAG1 = 'G03'.
GV_SET_TAG2 = '%'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS9 = 'X'.
CK_ERP = 'SYSTEM9 ERP'.
GV_SET_TAG1 = 'G04'.
GV_SET_TAG2 = '%'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS10 = 'X'.
CK_ERP = 'SYSTEM10 ERP'.
GV_SET_TAG1 = 'G05'.
GV_SET_TAG2 = '%'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_SYS11 = 'X'.
CK_ERP = 'SYSTEM11 ERP'.
GV_SET_TAG1 = 'G06'.
GV_SET_TAG2 = '%'.
IF C2_PRD = 'X'. GV_SET_ROLE = 'PRD'. ENDIF.
IF C2_QAS = 'X'. GV_SET_ROLE = 'QAS'. ENDIF.
IF C2_DEV = 'X'. GV_SET_ROLE = 'DEV'. ENDIF.
ELSEIF C_ETC = 'X'.
CK_ERP = '기타 시스템'.
ENDIF.
CASE GV_SET_ROLE.
WHEN 'PRD'. CK_ROL = '운영'.
WHEN 'QAS'. CK_ROL = '품질'.
WHEN 'DEV'. CK_ROL = '개발'.
WHEN OTHERS. CK_ROL = 'ALL'.
ENDCASE.
"### 선택된 조회 조건을 조합하여, ALV 리스트 헤더값 생성 (조회조건 출력)
CONCATENATE 'SYSTEM :' GV_SET_SYS '| ERP :' CK_ERP '| ROLE :' CK_ROL INTO GV_ALV_HEADER SEPARATED BY SPACE.
"### 상세 검색 필드 중 하나라도 값이 들어가 있다면 상세 검색으로 인식, 간편 검색 조건은 무시
ELSE.
"### SELECT_DATA 폼에서 쓸 서치모드 B 설정(상세 검색)
SEARCH_MOD = 'B'.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SELECT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SELECT_DATA .
REFRESH: GT_DATA, TEMP_DATA. CLEAR: GT_DATA, TEMP_DATA.
"### 간편 검색 데이터 SELECT 구문
IF SEARCH_MOD = 'A'.
"### 전체 역할 조회의 경우, 데이터 정렬을 DEV-QAS-PRD 순으로 맞추기 위해, 각각의 순서대로 데이터 셀렉트 후, 이어붙이기
IF C2_ALL = 'X'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE TEMP_DATA
FROM ZBC_MASTER_PW
WHERE SYS LIKE GV_SET_SYS
AND ROLE = 'DEV'
AND TAG1 = GV_SET_TAG1
AND TAG2 LIKE GV_SET_TAG2.
GT_DATA[] = TEMP_DATA[].
REFRESH: TEMP_DATA. CLEAR: TEMP_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE TEMP_DATA
FROM ZBC_MASTER_PW
WHERE SYS LIKE GV_SET_SYS
AND ROLE = 'QAS'
AND TAG1 = GV_SET_TAG1
AND TAG2 LIKE GV_SET_TAG2.
LOOP AT TEMP_DATA. MOVE-CORRESPONDING TEMP_DATA TO GT_DATA. APPEND GT_DATA. CLEAR GT_DATA. ENDLOOP.
REFRESH: TEMP_DATA. CLEAR: TEMP_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE TEMP_DATA
FROM ZBC_MASTER_PW
WHERE SYS LIKE GV_SET_SYS
AND ROLE = 'PRD'
AND TAG1 = GV_SET_TAG1
AND TAG2 LIKE GV_SET_TAG2.
LOOP AT TEMP_DATA. MOVE-CORRESPONDING TEMP_DATA TO GT_DATA. APPEND GT_DATA. CLEAR GT_DATA. ENDLOOP.
REFRESH: TEMP_DATA. CLEAR: TEMP_DATA.
"### 개별 역활 조회의 경우, 추가 로직(TAG2 활용)을 통해 데이터 조회
ELSE.
"### TAG1, 2 를 사용하여 검색 깊이를 높여서 검색
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM ZBC_MASTER_PW
WHERE SYS LIKE GV_SET_SYS
AND ROLE = GV_SET_ROLE
AND ( ROLE = 'DEV' OR ROLE = 'QAS' OR ROLE = 'PRD' )
AND TAG1 = GV_SET_TAG1
AND TAG2 LIKE GV_SET_TAG2.
ENDIF.
"### 기타 시스템 조회를 메뉴바에서 간편검색 라디오 버튼으로 변경.
IF C_ETC = 'X'.
REFRESH: GT_DATA. CLEAR: GT_DATA, VIEW_ALL.
VIEW_ALL = 'X'.
"### 입력된 나머지 조건은 전부 무시하고, TAG1 ETC 시스템만 전체 조회
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM ZBC_MASTER_PW
WHERE TAG1 = 'ETC'.
SORT GT_DATA BY SYS SID ROLE TYPE ID.
ENDIF.
"### 상세 검색 데이터 SELECT 구문
ELSEIF SEARCH_MOD = 'B'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM ZBC_MASTER_PW
WHERE SID IN S_SID
AND ID IN S_UID
AND IP IN S_IP
AND HOSTNAME IN S_HN
AND PW_VC IN S_VC
AND TAG1 IN S_TAG1
AND TAG2 IN S_TAG2.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form RESULT_VIEW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_DATA text
*----------------------------------------------------------------------*
FORM RESULT_VIEW TABLES P_GT_DATA .
DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
LT_LAYOUT TYPE SLIS_LAYOUT_ALV,
LT_EVENT TYPE SLIS_T_EVENT.
"### ALV Field Catalog 설정 (Table 에 맞게 순서와 너비 등등을 설정)
LT_FIELDCAT-FIELDNAME = 'SYS'.
LT_FIELDCAT-SELTEXT_M = 'SYS'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 5.
LT_FIELDCAT-COL_POS = 0.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'SID'.
LT_FIELDCAT-SELTEXT_M = 'SID'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 5.
LT_FIELDCAT-COL_POS = 1.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'ROLE'.
LT_FIELDCAT-SELTEXT_M = 'ROLE'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 5.
LT_FIELDCAT-COL_POS = 2.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'TYPE'.
LT_FIELDCAT-SELTEXT_M = 'TYPE'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 10.
LT_FIELDCAT-COL_POS = 3.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'ID'.
LT_FIELDCAT-SELTEXT_M = 'ID'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 15.
LT_FIELDCAT-COL_POS = 4.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'PASSWORD'.
LT_FIELDCAT-SELTEXT_M = 'PASSWORD'.
LT_FIELDCAT-LOWERCASE = 'X'.
LT_FIELDCAT-OUTPUTLEN = 12.
LT_FIELDCAT-COL_POS = 5.
"### Password 값을 선택에 따라, 변경할 수 있도록 세팅 (GV_FLAG 값으로 확인)
IF GV_FLAG = 'E'. LT_FIELDCAT-EDIT = 'X'. LT_FIELDCAT-INPUT = 'X'. ENDIF.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'IP'.
LT_FIELDCAT-SELTEXT_M = 'IP'.
LT_FIELDCAT-OUTPUTLEN = 14.
LT_FIELDCAT-COL_POS = 6.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'HOSTNAME'.
LT_FIELDCAT-SELTEXT_M = 'HOSTNAME'.
LT_FIELDCAT-OUTPUTLEN = 12.
LT_FIELDCAT-COL_POS = 7.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'DESC_LOG'.
LT_FIELDCAT-SELTEXT_M = 'DESC_LOG'.
LT_FIELDCAT-OUTPUTLEN = 30.
LT_FIELDCAT-COL_POS = 8.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'PW_VC'.
LT_FIELDCAT-SELTEXT_M = 'VC'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 3.
LT_FIELDCAT-COL_POS = 9.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'AENAM'.
LT_FIELDCAT-SELTEXT_M = 'NAME'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 10.
LT_FIELDCAT-COL_POS = 10.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'AEDAT'.
LT_FIELDCAT-SELTEXT_M = 'DATE'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 10.
LT_FIELDCAT-COL_POS = 11.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'AEZET'.
LT_FIELDCAT-SELTEXT_M = 'TIME'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 10.
LT_FIELDCAT-COL_POS = 12.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'TAG1'.
LT_FIELDCAT-SELTEXT_M = 'TAG1'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 5.
LT_FIELDCAT-COL_POS = 13.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'TAG2'.
LT_FIELDCAT-SELTEXT_M = 'TAG2'.
LT_FIELDCAT-JUST = 'C'.
LT_FIELDCAT-OUTPUTLEN = 5.
LT_FIELDCAT-COL_POS = 14.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'URL'.
LT_FIELDCAT-SELTEXT_M = 'URL'.
LT_FIELDCAT-OUTPUTLEN = 50.
LT_FIELDCAT-COL_POS = 15.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
"### ALV Layout 설정
LT_LAYOUT-ZEBRA = 'X'.
LT_LAYOUT-BOX_FIELDNAME = 'SEL'.
LT_LAYOUT-BOX_TABNAME = 'P_GT_DATA'.
LT_LAYOUT-INFO_FIELDNAME = 'LINECOLOR'.
SAVE_CHECK = 'X'.
"### 위에 설정된 Field Catalog 와 Layout 을 사용하여 ALV 리스트 출력 펑션 콜
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_GRID_TITLE = GV_ALV_HEADER
* I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
IT_FIELDCAT = LT_FIELDCAT[]
IS_LAYOUT = LT_LAYOUT
* I_SAVE = 'A'
TABLES
T_OUTTAB = P_GT_DATA.
CLEAR: GV_FLAG.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form MENU_BAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MENU_BAR .
FUNCTXT-ICON_ID = ICON_DISPLAY_TEXT.
FUNCTXT-QUICKINFO = 'ALL List'.
FUNCTXT-ICON_TEXT = 'ALL List'.
SSCRFIELDS-FUNCTXT_01 = FUNCTXT.
FUNCTXT-ICON_ID = ICON_REPORT.
FUNCTXT-QUICKINFO = 'Password Policy'.
FUNCTXT-ICON_TEXT = 'Password policy'.
SSCRFIELDS-FUNCTXT_02 = FUNCTXT.
FUNCTXT-ICON_ID = ICON_PATIENT_SMARTCARD.
FUNCTXT-QUICKINFO = 'Master PWD Shape'.
FUNCTXT-ICON_TEXT = 'Master PWD Shape'.
SSCRFIELDS-FUNCTXT_03 = FUNCTXT.
FUNCTXT-ICON_ID = ICON_SAP_LOGON_GROUP_SSO.
FUNCTXT-QUICKINFO = 'ABAP PWD VC'.
FUNCTXT-ICON_TEXT = 'ABAP PWD VC'.
SSCRFIELDS-FUNCTXT_04 = FUNCTXT.
FUNCTXT-ICON_ID = ICON_SAP.
FUNCTXT-QUICKINFO = 'SAP SUSER'.
FUNCTXT-ICON_TEXT = 'SAP SUSER'.
SSCRFIELDS-FUNCTXT_05 = FUNCTXT.
ENDFORM.
*------------------------------------------------------------------*
* FORM SET_PF_STATUS
*------------------------------------------------------------------*
FORM SET_PF_STATUS USING PI_EXTAB TYPE SLIS_T_EXTAB.
DATA: BEGIN OF LT_EXCL OCCURS 0,
MENU(20) TYPE C.
DATA: END OF LT_EXCL.
REFRESH: LT_EXCL. CLEAR: LT_EXCL.
"### F8 기본 실행 시,
IF SY-UCOMM IS INITIAL.
IF R_ABAP = 'X'.
LT_EXCL-MENU = 'REMOTE_JV'. APPEND LT_EXCL.
SET PF-STATUS 'S100' EXCLUDING LT_EXCL.
ELSEIF R_JAVA = 'X'.
LT_EXCL-MENU = 'REMOTE_C'. APPEND LT_EXCL.
SET PF-STATUS 'S100' EXCLUDING LT_EXCL.
ELSEIF R_OS = 'X' OR R_DB = 'X'.
LT_EXCL-MENU = 'REMOTE_JV'. APPEND LT_EXCL.
LT_EXCL-MENU = 'REMOTE_C'. APPEND LT_EXCL.
SET PF-STATUS 'S100' EXCLUDING LT_EXCL.
ELSE.
SET PF-STATUS 'S100' EXCLUDING LT_EXCL.
ENDIF.
ELSEIF SY-UCOMM = 'FC01'.
LT_EXCL-MENU = 'CHG_PWD'. APPEND LT_EXCL.
SET PF-STATUS 'S100' EXCLUDING LT_EXCL.
ELSEIF SY-UCOMM = 'FC05'.
LT_EXCL-MENU = 'CHG_PWD'. APPEND LT_EXCL.
LT_EXCL-MENU = 'SEQ_UP'. APPEND LT_EXCL.
LT_EXCL-MENU = 'REMOTE_JV'. APPEND LT_EXCL.
LT_EXCL-MENU = 'REMOTE_C'. APPEND LT_EXCL.
SET PF-STATUS 'S100' EXCLUDING LT_EXCL.
ELSE.
ENDIF.
* IF SY-UCOMM = 'FC01'.
* SET PF-STATUS 'S200' EXCLUDING PI_EXTAB.
* ELSE.
* SET PF-STATUS 'S100' EXCLUDING PI_EXTAB.
* ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form MENU_SELECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MENU_SELECT .
"### DATA - FC02, FC03
DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA: LT_EXCL TYPE SLIS_T_EXTAB WITH HEADER LINE.
"### DATA - FC04
DATA: LT_SPOPLI LIKE TABLE OF SPOPLI WITH HEADER LINE.
DATA: LV_ANSWER(1) TYPE C,
VC_SYSTEM(80) TYPE C.
CASE SY-UCOMM.
"### 메뉴_01 : 테이블 전체 리스트 조회
WHEN 'FC01'.
REFRESH: GT_DATA. CLEAR: GT_DATA, VIEW_ALL.
VIEW_ALL = 'X'.
"### 조건 없이 전체 데이터 셀렉트
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM ZBC_MASTER_PW.
SORT GT_DATA BY SYS SID ROLE TYPE ID.
PERFORM RESULT_VIEW TABLES GT_DATA.
"### 메뉴_02 : 패스워드 정책 조회 (Tcode-SECPOL 정책 설정 : ZSECPOL)
WHEN 'FC02'.
REFRESH: LT_FIELDCAT. CLEAR: LT_FIELDCAT.
"### ALV Field Catalog 설정 (Table 에 맞게 순서와 너비 등등을 설정)
LT_FIELDCAT-FIELDNAME = 'PARAM'.
LT_FIELDCAT-SELTEXT_M = 'PARAM'.
LT_FIELDCAT-KEY = 'X'.
LT_FIELDCAT-OUTPUTLEN = 20.
LT_FIELDCAT-COL_POS = 0.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
LT_FIELDCAT-FIELDNAME = 'VALUE'.
LT_FIELDCAT-SELTEXT_M = 'VALUE'.
LT_FIELDCAT-OUTPUTLEN = 10.
LT_FIELDCAT-COL_POS = 1.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
"### 팝업 ALV 에서 불필요한 펑션코드 제거
LT_EXCL-FCODE = '&NT1'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&ETA'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&OUP'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&ODN'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&ILT'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&OL0'. APPEND LT_EXCL.
LT_EXCL-FCODE = '%SC'. APPEND LT_EXCL.
LT_EXCL-FCODE = '%SC+'. APPEND LT_EXCL.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'Password Policy'
I_TABNAME = 'PWD_POLICY'
I_LINEMARK_FIELDNAME = 'LINECOLOR'
IT_FIELDCAT = LT_FIELDCAT[]
IT_EXCLUDING = LT_EXCL[]
TABLES
T_OUTTAB = PWD_POLICY.
"### 메뉴_03 : 마스터 패스워드 형태 확인
WHEN 'FC03'.
REFRESH: LT_FIELDCAT. CLEAR: LT_FIELDCAT.
APPEND MASTER_PASSWORD_SHAPE.
"### ALV Field Catalog 설정 (Table 에 맞게 순서와 너비 등등을 설정)
LT_FIELDCAT-FIELDNAME = 'PWD_SHAPE'.
LT_FIELDCAT-SELTEXT_M = 'Master Password Shape'.
LT_FIELDCAT-OUTPUTLEN = 30.
LT_FIELDCAT-COL_POS = 0.
APPEND LT_FIELDCAT. CLEAR LT_FIELDCAT.
"### 팝업 ALV 에서 불필요한 펑션코드 제거
LT_EXCL-FCODE = '&NT1'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&ETA'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&OUP'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&ODN'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&ILT'. APPEND LT_EXCL.
LT_EXCL-FCODE = '&OL0'. APPEND LT_EXCL.
LT_EXCL-FCODE = '%SC'. APPEND LT_EXCL.
LT_EXCL-FCODE = '%SC+'. APPEND LT_EXCL.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'Master Password SHAPE'
I_TABNAME = 'MASTER_PASSWORD_SHAPE'
IT_FIELDCAT = LT_FIELDCAT[]
IT_EXCLUDING = LT_EXCL[]
TABLES
T_OUTTAB = MASTER_PASSWORD_SHAPE.
"### 메뉴_04 : ABAP서버 패스워드 유효성 검사(VC)
WHEN 'FC04'.
REFRESH: LT_SPOPLI. CLEAR: LT_SPOPLI.
"### 시스템 역할이 전체 선택이라면, 에러 메세지 출력 후 액션 롤백.
IF C2_ALL = 'X'.
MESSAGE '패스워드 유효성 검사는 전체 역할에 대해 사용 불가능합니다. 역할을 지정해주세요.' TYPE 'S'.
REJECT.
ENDIF.
PERFORM SET_CONDITION.
"### SYSTEM 이 ABAP 일 경우에만 진행 가능.
IF R_ABAP = 'X'.
CONCATENATE ' => Select : ' GV_ALV_HEADER INTO VC_SYSTEM SEPARATED BY SPACE.
LT_SPOPLI-VAROPTION = '<< 패스워드 유효성 검사 진행 >>'. "# ALL
APPEND LT_SPOPLI. CLEAR LT_SPOPLI.
LT_SPOPLI-VAROPTION = '작업 취소'. "# DEV/QAS/PRD
APPEND LT_SPOPLI. CLEAR LT_SPOPLI.
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
TITEL = 'Password VC Check - Server Select'
TEXTLINE1 = '해당 기능 사용 시, 유효성 검사(VC) 실패 시스템에 대해서 계정이 잠길수 있습니다.'
TEXTLINE2 = '필요한 경우에만 사용하시고, VC 실패 시스템에 대해서 즉시 패스워드를 업데이트 해주세요.'
TEXTLINE3 = VC_SYSTEM
IMPORTING
ANSWER = LV_ANSWER
TABLES
T_SPOPLI = LT_SPOPLI.
IF SY-SUBRC = 0.
CASE LV_ANSWER.
WHEN '1'. PERFORM ABAP_VC_CHECK.
WHEN '2'. REJECT.
WHEN 'A'. REJECT.
ENDCASE.
ENDIF.
ELSE.
MESSAGE 'ABAP 시스템에 대해서만 패스워드 유효성 검사(VC)가 가능합니다.' TYPE 'S'.
REJECT.
ENDIF.
"### 메뉴_05 : SAP SUSER 조회
"### (이전 기타시스템 조회기능은 간편검색으로 변경)
WHEN 'FC05'.
REFRESH: GT_DATA. CLEAR: GT_DATA, VIEW_ALL.
VIEW_ALL = 'X'.
"### 조건 없이 전체 데이터 셀렉트
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA
FROM ZBC_MASTER_PW
WHERE SYS = 'SAP'.
SORT GT_DATA BY SYS SID ROLE TYPE ID.
PERFORM RESULT_VIEW TABLES GT_DATA.
ENDCASE.
ENDFORM.
*------------------------------------------------------------------*
* FORM USER_COMMAND
*------------------------------------------------------------------*
FORM USER_COMMAND USING PI_UCOMM LIKE SY-UCOMM
PI_SELFIELD TYPE SLIS_SELFIELD.
"### DATA - &1C1
TYPES: TXT(2000) TYPE C,
TEMP_TXT TYPE TABLE OF TXT.
DATA: LT_TXT TYPE TEMP_TXT WITH HEADER LINE.
DATA: LV_RC TYPE I.
"### DATA - SAVE
DATA: P_REF TYPE REF TO CL_GUI_ALV_GRID.
DATA: P_EDITED(1) TYPE C.
DATA: CPASS TYPE BAPIPWD,
LV_SUBRC LIKE SY-SUBRC,
LV_MSGTXT TYPE STRING.
DATA: RC_SUM(4) TYPE N.
"### DATA - S_CHG_PWD
DATA: LT_FIELDS LIKE SVAL OCCURS 0 WITH HEADER LINE.
DATA: TEMP_COUNT(5) TYPE N.
"### DATA - REMOTE_C
DATA: RFC_ERR_TXT LIKE RFCDES-RFCOPTIONS.
"### DATA - REMOTE_JV
DATA: URL_GET_PARAM TYPE STRING.
"### DATA - SEQ_UP
DATA: SEQ_POS(2) TYPE N,
SEQ_VAL(1) TYPE N,
TMP_POS(2) TYPE N,
TMP_LEN(2) TYPE N,
NUM_CHK(4) TYPE C,
SEQ_PASS(20) TYPE C,
TMP_PASS1(20) TYPE C,
TMP_PASS2(20) TYPE C.
"### DATA - ADD_SYSTEM
DATA: IT_FIELDS LIKE SVAL OCCURS 0 WITH HEADER LINE.
"### ALV 전체 행에 대해서 라인컬러 초기화
* LOOP AT GT_DATA.
* GT_DATA-LINECOLOR = ''. MODIFY GT_DATA.
* ENDLOOP.
CASE PI_UCOMM.
"### UserCommand_Double Click
WHEN '&IC1'. " SAP standard code for double-clicking
REFRESH: LT_TXT. CLEAR: LT_TXT, LV_RC.
"### 유저가 더블클릭한 필드가 ID 또는 PASSWORD 라면, 해당 값을 사용자 클립보드로 복사
IF PI_SELFIELD-FIELDNAME = 'ID' OR PI_SELFIELD-FIELDNAME = 'PASSWORD'.
READ TABLE GT_DATA INDEX PI_SELFIELD-TABINDEX.
LT_TXT = GT_DATA-PASSWORD. APPEND LT_TXT.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_EXPORT
IMPORTING
DATA = LT_TXT[]
CHANGING
RC = LV_RC
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
MESSAGE 'Copy' TYPE 'S'.
ENDIF.
"### UserCommand_BACK/EXIT/CANC
WHEN 'BACK1' OR 'EXIT' OR 'CANC'.
"### 수정 모드에서 화면을 빠져 나갈시,
IF GV_FLAG = 'E'.
"### 락 오브젝트 강제 해제
PERFORM DEQUEUE_OBJECT.
"### 세이브가 안된 데이터에 대해서, 기존 데이터(TEMP_DATA)로 롤백
GT_DATA[] = TEMP_DATA[].
ENDIF.
"### BACK, EXIT, CANC 를 할때, 저장 여부 확인.
IF SAVE_CHECK IS INITIAL.
CLEAR: POPUP_RET.
PERFORM ASK_SAVE_CHECK.
IF SY-SUBRC = 0 AND POPUP_RET = 2.
REJECT.
ENDIF.
ENDIF.
CLEAR: SAVE_CHECK.
LEAVE TO SCREEN 0.
"### UserCommand_SAVE
WHEN 'SAVE'.
CLEAR: P_REF, CPASS, LV_SUBRC, LV_MSGTXT.
"### ALV 상에서 변경된 값을 확인하여 리프레시
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = P_REF.
CALL METHOD P_REF->CHECK_CHANGED_DATA
IMPORTING
E_VALID = P_EDITED.
"### 현재 조회모드(GV_FLAG)
"### = E : 패스워드 대량수정모드
"### = S : 패스워드 싱글수정모드
"### = U : 패스워드 시퀸셜업모드
IF GV_FLAG = 'E' OR GV_FLAG = 'S' OR GV_FLAG = 'U'.
"### ALV 전체 행에 대해서 라인컬러 초기화
LOOP AT GT_DATA.
GT_DATA-LINECOLOR = ''. MODIFY GT_DATA.
ENDLOOP.
"### 조회 리스트 전체 값에 대해서, Password 정책 검사
LOOP AT GT_DATA.
"### 패스워드가 변경된 행을 찾는 로직
"### 변경 전, 원본 데이터인 TEMP_DATA 와, 변경된 현재 테이블 GT_DATA 의 같은 인덱스를 읽어와서 PASSWORD 가 불일치 할 경우, 변경된 행.
READ TABLE TEMP_DATA INDEX SY-TABIX.
IF SY-SUBRC = 0 AND ( TEMP_DATA-PASSWORD NE GT_DATA-PASSWORD ).
"### 변경된 패스워드에 대해서, Password 정책 검사
"### => 시스템 TAG1 이 ETC 인 기타 시스템에 대해서는 패스워드 정책 검사를 적용하지 않고, 패스 처리.
IF GT_DATA-TAG1 = 'ETC'.
LV_SUBRC = 0.
ELSE.
CPASS = GT_DATA-PASSWORD.
CALL FUNCTION 'PASSWORD_FORMAL_CHECK'
EXPORTING
PASSWORD = CPASS
SECURITY_POLICY = 'BC_MASTER'
IMPORTING
RC = LV_SUBRC
MSGTEXT = LV_MSGTXT.
ENDIF.
RC_SUM = RC_SUM + LV_SUBRC.
"### Password 정책 검사 성공 시,
IF LV_SUBRC = 0.
GT_DATA-AENAM = SY-UNAME.
GT_DATA-AEDAT = SY-DATUM.
GT_DATA-AEZET = SY-UZEIT.
MODIFY GT_DATA.
"### Password 정책 검사 실패 시,
ELSE.
CLEAR: CPASS.
"### 패스워드 정책 검사 실패 항목에 대해서, 빨간색 하이라이트 표시
GT_DATA-LINECOLOR = 'C600'. MODIFY GT_DATA.
"### 패스워드 정책 검사 실패 사유 메세지 표시
MESSAGE LV_MSGTXT TYPE 'S'.
* REJECT.
ENDIF.
ENDIF.
ENDLOOP.
"### Password 정책 검사를 통과 했다면, 변경된 데이터를 데이블로 저장
IF RC_SUM = 0.
SAVE_CHECK = 'X'.
"### 데이터 저장 완료 후, 원본 임시 보관 테이블 TEMP_DATA 를 저장된 데이터로 업데이트
TEMP_DATA[] = GT_DATA[].
"### 데이터 저장 완료 후, 조회 오브젝트 락 해제
PERFORM DEQUEUE_OBJECT.
PERFORM SAVE_DATA.
CLEAR: GV_FLAG.
ENDIF.
ENDIF.
"### UserCommand_CHG_PWD : 패스워드 대량수정모드
WHEN 'CHG_PWD'.
"### 전체리스트 조회에서는 대량수정모드를 사용할수 없도록 제한
IF VIEW_ALL = 'X'.
CLEAR: VIEW_ALL.
MESSAGE '전체 리스트 조회모드의 대량 패스워드 변경은 SM30 티코드를 사용해주세요.' TYPE 'S'.
REJECT.
ENDIF.
"### 해당 버튼 토글 설정, 현재 대량수정모드가 아니라면 대량수정모드로 변경.
IF GV_FLAG IS INITIAL.
REFRESH: TEMP_DATA. CLEAR: TEMP_DATA.
"### 대량수정모드 시, 수정 롤백을 위한 임시 테이블. GT_DATA 그대로 TEMP_DATA로 카피.
TEMP_DATA[] = GT_DATA[].
"### 조회 오브젝트 중복 수정방지를 위한 락 설정
PERFORM ENQUEUE_OBJECT.
GV_FLAG = 'E'.
"### 대량수정모드로 GV_FLAG 값 전달 후, ALV 재출력
PERFORM RESULT_VIEW TABLES GT_DATA.
"### 대량수정모드라면, 일반조회모드로 변경
ELSE.
"### 일반조회모드 변경 시, 데이터 변경 여부와 관계없이 저장 여부 확인
CLEAR: POPUP_RET.
PERFORM ASK_SAVE_CHECK.
IF SY-SUBRC = 0 AND POPUP_RET = 2.
REJECT.
ENDIF.
CLEAR: GV_FLAG.
SAVE_CHECK = 'X'.
"### 수정->조회 모드 변경 시, 락 오브젝트 해제
PERFORM DEQUEUE_OBJECT.
"### 세이브가 안된 데이터에 대해서, 기존 데이터(TEMP_DATA)로 롤백
GT_DATA[] = TEMP_DATA[].
"### 일반조회모드로 GV_FLAG 값 초기화 후, ALV 재출력
LEAVE TO SCREEN 0.
PERFORM RESULT_VIEW TABLES GT_DATA.
ENDIF.
"### userCommand_S_CHG_PWD : 패스워드 단일수정기능
WHEN 'S_CHG_PWD'.
REFRESH: LT_FIELDS. CLEAR: LT_FIELDS, TEMP_COUNT.
"### 선택한 행이 몇 개인지 확인하는 로직. 싱글수정기능은 행을 한 개만 선택해야 함.
LOOP AT GT_DATA WHERE SEL = 'X'.
TEMP_COUNT = TEMP_COUNT + 1. ENDLOOP.
"### 선택한 행이 한개가 맞다면,
IF TEMP_COUNT = 1.
IF GV_FLAG <> 'E'.
LT_FIELDS-TABNAME = 'BAPIPWD'.
LT_FIELDS-FIELDNAME = 'BAPIPWD'.
LT_FIELDS-FIELDTEXT = 'Password'.
APPEND LT_FIELDS.
"### 팝업을 통해서, 변경할 패스워드를 입력받는다.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
POPUP_TITLE = 'Change Password'
TABLES
FIELDS = LT_FIELDS
EXCEPTIONS
ERROR_IN_FIELDS = 1
OTHERS = 2.
"### 변경할 패스워드 값을 제대로 입력받았다면,
IF SY-SUBRC = 0 AND LT_FIELDS-VALUE IS NOT INITIAL.
"### 단일수정모드 시, 수정 롤백을 위한 임시 테이블. GT_DATA 그대로 TEMP_DATA로 카피.
TEMP_DATA[] = GT_DATA[].
GV_FLAG = 'S'.
CLEAR: SAVE_CHECK.
"### 선택한 행에 대해서, GT_DATA-PASSWORD 값을 변경할 패스워드로 수정한 다음, MODIRY 한다.
LOOP AT GT_DATA WHERE SEL = 'X'.
GT_DATA-PASSWORD = LT_FIELDS-VALUE.
GT_DATA-LINECOLOR = 'C300'.
MODIFY GT_DATA.
ENDLOOP.
ENDIF.
ELSE.
MESSAGE '대량수정모드 사용 중에는, 해당 기능을 사용할 수 없습니다. 대량수정모드 종료 후 다시 시도해주세요.' TYPE 'S'.
ENDIF.
ELSE.
MESSAGE '한 개의 행을 선택해주세요.' TYPE 'S'.
ENDIF.
"### UserCommnad_REMOTE_C : ABAP 시스템 원격로그인기능
WHEN 'REMOTE_C'.
CLEAR: RFC_ERR_TXT, TEMP_COUNT.
"### 선택한 행이 몇 개인지 확인하는 로직. 싱글수정기능은 행을 한 개만 선택해야 함.
LOOP AT GT_DATA WHERE SEL = 'X'.
TEMP_COUNT = TEMP_COUNT + 1. ENDLOOP.
"### 선택한 행이 한개가 맞다면,
IF TEMP_COUNT = 1.
IF GV_FLAG <> 'E'.
"### 선택한 행의 데이터를 인터널 테이블 헤더로 읽어온다.
READ TABLE GT_DATA INDEX PI_SELFIELD-TABINDEX.
"### 선택한 행의 SYSTEM 이 ABAP 이라면,
IF GT_DATA-SYS = 'ABAP'.
"### 원격로그인을 위한 임시 RFC 목적지(ZBC_TEMP_RFC_DEST)를 생성
PERFORM CREATE_RFC_DEST USING 'ZBC_TEMP_RFC_DEST'
GT_DATA-SID GT_DATA-TYPE GT_DATA-ID GT_DATA-PASSWORD.
"### 임시 RFC 목적지를 사용하여, 시스템 원격로그인
CALL FUNCTION 'SYSTEM_REMOTE_LOGIN'
EXPORTING
DESTINATION = 'ZBC_TEMP_RFC_DEST'
IMPORTING
ERROR_MESSAGE = RFC_ERR_TXT.
"### 원격로그인 실패로 인해, ERROR 메세지가 리턴되었다면, ERROR 메세지 출력
IF RFC_ERR_TXT IS NOT INITIAL.
MESSAGE RFC_ERR_TXT TYPE 'S'.
ENDIF.
"### 원격로그인 완료 후, 임시 RFC 목적지는 삭제
PERFORM DELETE_RFC_DEST USING 'ZBC_TEMP_RFC_DEST'.
ELSE.
MESSAGE 'Remote Login 기능은 ABAP 시스템만 지원됩니다.' TYPE 'S'.
ENDIF.
ELSE.
MESSAGE '대량수정모드 사용 중에는, 해당 기능을 사용할 수 없습니다. 대량수정모드 종료 후 다시 시도해주세요.' TYPE 'S'.
ENDIF.
ELSE.
MESSAGE '한 개의 행을 선택해주세요.' TYPE 'S'.
ENDIF.
"### UserCommnad_REMOTE_JV : JAVA 시스템 URL 접속기능
WHEN 'REMOTE_JV'.
CLEAR: URL_GET_PARAM.
"### 선택한 행이 몇 개인지 확인하는 로직. 행을 한 개만 선택해야 함.
LOOP AT GT_DATA WHERE SEL = 'X'.
TEMP_COUNT = TEMP_COUNT + 1. ENDLOOP.
"### 선택한 행이 한개가 맞다면,
IF TEMP_COUNT = 1.
CONCATENATE GT_DATA-URL
'/webdynpro/resources/sap.com/tc~lm~itsam~ui~mainframe~wd/FloorPlanApp?home=true&j_username='
GT_DATA-ID
'&j_password='
GT_DATA-PASSWORD INTO URL_GET_PARAM.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
APPLICATION = 'chrome.exe'
PARAMETER = URL_GET_PARAM.
ELSE.
MESSAGE '한 개의 행을 선택해주세요.' TYPE 'S'.
ENDIF.
"### UserCommnad_SEQ_UP : 패스워드 시퀸셜 업 모드
WHEN 'SEQ_UP'.
CLEAR: SEQ_POS, TMP_POS, SEQ_VAL, NUM_CHK, TMP_PASS1, TMP_PASS2.
"### 선택한 행이 몇 개인지 확인하는 로직. 싱글수정기능은 행을 한 개만 선택해야 함.
LOOP AT GT_DATA WHERE SEL = 'X'.
TEMP_COUNT = TEMP_COUNT + 1. ENDLOOP.
"### 선택한 행이 한개가 맞다면,
IF TEMP_COUNT = 1.
"### 대량수정모드 시에는 시퀸셜업모드 사용 불가.
IF GV_FLAG <> 'E'.
"### 선택한 행의 데이터를 인터널 테이블 헤더로 읽어온다.
READ TABLE GT_DATA INDEX PI_SELFIELD-TABINDEX.
"### 마스터 패스워드 형태에서 시퀸셜 위치를 찾음
SEARCH MASTER_PASSWORD_SHAPE-PWD_SHAPE FOR '_'.
IF SY-SUBRC = 0. SEQ_POS = SY-FDPOS. ENDIF.
"### 선택된 행의 패스워드에서 마스터패스워드 시퀸셜 위치를 찾아, 숫자가 맞는지 확인
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = GT_DATA-PASSWORD+SEQ_POS(1)
IMPORTING
HTYPE = NUM_CHK.
"### 시퀸셜 위치의 값이 숫자가 맞다면, 해당 위치가 시퀸셜 위치라고 인식.
IF NUM_CHK = 'NUMC'.
"### 해당 패스워드의 시퀸셜 위치의 시퀸셜 값을 찾는다.
SEQ_VAL = GT_DATA-PASSWORD+SEQ_POS(1).
"### 다만, 현재 시퀸셜 값이 9 미만 일때만, 시퀸셜 값을 증가시킨다.
IF SEQ_VAL < 9.
SEQ_VAL = SEQ_VAL + 1.
"### 시퀸셜 위치 기준 마스터 패스워드 앞부분 슬라이싱
CLEAR: TMP_POS. TMP_POS = SEQ_POS.
TMP_PASS1 = MASTER_PASSWORD_SHAPE-PWD_SHAPE(TMP_POS).
"### 시퀸셜 위치 기준 마스터 패스워드 뒷부분 슬라이싱
CLEAR: TMP_POS, TMP_LEN. TMP_POS = SEQ_POS + 1.
TMP_LEN = STRLEN( MASTER_PASSWORD_SHAPE-PWD_SHAPE ) - TMP_POS.
TMP_PASS2 = MASTER_PASSWORD_SHAPE-PWD_SHAPE+TMP_POS(TMP_LEN).
"### 마스터 패스워드의 스퀸셜 위치 기준 ,
"### 앞부분 + 스퀸셜 값 + 뒷부분 조합하여, 다음 스퀸셜 값 패스워드 생성.
CONCATENATE TMP_PASS1 SEQ_VAL TMP_PASS2 INTO SEQ_PASS.
"### 시퀸셜업모드 시, 수정 롤백을 위한 임시 테이블. GT_DATA 그대로 TEMP_DATA로 카피.
TEMP_DATA[] = GT_DATA[].
GV_FLAG = 'U'.
CLEAR: SAVE_CHECK.
LOOP AT GT_DATA WHERE SEL = 'X'.
GT_DATA-PASSWORD = SEQ_PASS.
GT_DATA-LINECOLOR = 'C500'.
MODIFY GT_DATA.
ENDLOOP.
"### 시퀸셜 값이 9라면, 해당 요청을 REJECT 하고, 오류 메세지를 출력
ELSE.
MESSAGE '시퀸셜 값이 9이므로, 더 이상 올릴수 없습니다.' TYPE 'S'.
REJECT.
ENDIF.
"### 숫자가 아니라면, 해당 요청을 REJECT 하고, 오류 메세지 출력
ELSE.
MESSAGE '마스터 패스워드 형태의 시퀸셜 위치가 다릅니다.' TYPE 'S'.
REJECT.
ENDIF.
ELSE.
MESSAGE '대량수정모드 사용 중에는, 해당 기능을 사용할 수 없습니다. 대량수정모드 종료 후 다시 시도해주세요.' TYPE 'S'.
ENDIF.
ELSE.
MESSAGE '한 개의 행을 선택해주세요.' TYPE 'S'.
ENDIF.
"### UserCommnad_VC_MCHG : VC 값 수동 변경
WHEN 'VC_MCHG'.
"### VC 값 수동 변경을 위해, 선택한 행에 대해서 변경 처리
LOOP AT GT_DATA WHERE SEL = 'X'.
GV_FLAG = 'V'.
"### 만약 VC 값이 없다면 디폴트로 X 처리.
IF GT_DATA-PW_VC IS INITIAL.
GT_DATA-PW_VC = 'X'.
ELSEIF GT_DATA-PW_VC = 'O'.
GT_DATA-PW_VC = 'X'.
ELSEIF GT_DATA-PW_VC = 'X'.
GT_DATA-PW_VC = 'O'.
ENDIF.
MODIFY GT_DATA.
PERFORM SAVE_DATA.
CLEAR: GV_FLAG.
ENDLOOP.
WHEN 'ADD_SYSTEM'.
DATA: ADD_DATA LIKE TABLE OF ZBC_MASTER_PW WITH HEADER LINE.
DATA: LOC_DATA LIKE TABLE OF ZBC_MASTER_PW WITH HEADER LINE.
DATA: LT_SUBRC TYPE C.
CLEAR: IT_FIELDS, ADD_DATA.
REFRESH: IT_FIELDS, ADD_DATA.
"### 신규 시스템 정보를 받아올 팝업 임시 테이블
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'SYS'.
IT_FIELDS-FIELDTEXT = 'SYS'.
IT_FIELDS-FIELD_OBL = 'X'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'SID'.
IT_FIELDS-FIELDTEXT = 'SID'.
IT_FIELDS-FIELD_OBL = 'X'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'ROLE'.
IT_FIELDS-FIELDTEXT = 'ROLE'.
IT_FIELDS-FIELD_OBL = 'X'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'TYPE'.
IT_FIELDS-FIELDTEXT = 'TYPE'.
IT_FIELDS-FIELD_OBL = 'X'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'ID'.
IT_FIELDS-FIELDTEXT = 'ID'.
IT_FIELDS-FIELD_OBL = 'X'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'PASSWORD'.
IT_FIELDS-FIELDTEXT = '#PASSWORD'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'IP'.
IT_FIELDS-FIELDTEXT = '#IP'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'HOSTNAME'.
IT_FIELDS-FIELDTEXT = '#HOSTNAME'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
IT_FIELDS-FIELDNAME = 'DESC_LOG'.
IT_FIELDS-FIELDTEXT = '#DESC_LOG'.
APPEND IT_FIELDS. CLEAR IT_FIELDS.
* IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
* IT_FIELDS-FIELDNAME = 'TAG1'.
* IT_FIELDS-FIELDTEXT = 'TAG1'.
* IT_FIELDS-FIELD_OBL = 'X'.
* APPEND IT_FIELDS. CLEAR IT_FIELDS.
* IT_FIELDS-TABNAME = 'ZBC_MASTER_PW'.
* IT_FIELDS-FIELDNAME = 'TAG2'.
* IT_FIELDS-FIELDTEXT = '#TAG2'.
* APPEND IT_FIELDS.
CALL FUNCTION 'POPUP_GET_VALUES_USER_HELP'
EXPORTING
POPUP_TITLE = 'ADD SYSTEM'
IMPORTING
RETURNCODE = LT_SUBRC
TABLES
FIELDS = IT_FIELDS
EXCEPTIONS
ERROR_IN_FIELDS = 1
OTHERS = 2.
IF LT_SUBRC IS INITIAL.
"### 팝업으로 입력된 데이터를 필드에 맞게 정리
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'SYS'. ADD_DATA-SYS = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'SID'. ADD_DATA-SID = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'ROLE'. ADD_DATA-ROLE = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'TYPE'. ADD_DATA-TYPE = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'ID'. ADD_DATA-ID = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'PASSWORD'. ADD_DATA-PASSWORD = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'IP'. ADD_DATA-IP = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'HOSTNAME'. ADD_DATA-HOSTNAME = IT_FIELDS-VALUE.
READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'DESC_LOG'. ADD_DATA-DESC_LOG = IT_FIELDS-VALUE.
* READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'TAG1'. ADD_DATA-TAG1 = IT_FIELDS-VALUE.
* READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'TAG2'. ADD_DATA-TAG2 = IT_FIELDS-VALUE.
ADD_DATA-PW_VC = 'O'.
ADD_DATA-AENAM = SY-UNAME.
ADD_DATA-AEDAT = SY-DATUM.
ADD_DATA-AEZET = SY-UZEIT.
"### 자동 태깅 기능 추가
PERFORM AUTO_TAGGING TABLES ADD_DATA.
APPEND ADD_DATA.
"### 기존 데이터와 중복값 체크를 위한, 기존 테이블 데이터 셀렉트.
SELECT * INTO CORRESPONDING FIELDS OF TABLE LOC_DATA
FROM ZBC_MASTER_PW
WHERE SYS = ADD_DATA-SYS
AND SID = ADD_DATA-SID
AND ROLE = ADD_DATA-ROLE
AND TYPE = ADD_DATA-TYPE
AND ID = ADD_DATA-ID.
"### 키값으로 조회를 하는데, 셀렉트된 데이터가 없다면, 신규값이므로 데이터 모디파이
IF SY-SUBRC <> 0.
MODIFY ZBC_MASTER_PW FROM TABLE ADD_DATA.
MESSAGE '입력한 시스템/유저가 정상적으로 등록되었습니다.' TYPE 'S'.
ELSE.
MESSAGE '입력한 시스템/유저은 기등록된 시스템/유저입니다.' TYPE 'E'.
ENDIF.
ENDIF.
ENDCASE.
"### ALV 리프레시 설정
PI_SELFIELD-REFRESH = 'X'.
PI_SELFIELD-COL_STABLE = 'X'.
PI_SELFIELD-ROW_STABLE = 'X'.
* LEAVE TO SCREEN 0.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SAVE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SAVE_DATA.
"### 인터널 테이블의 KEY가 중복되는지 체크할 것
"### 중복이 없다면 테이블에 KEY를 단위로 UPDATE할 것
DATA: LT_DATA LIKE TABLE OF ZBC_MASTER_PW WITH HEADER LINE.
"### GT_DATA 를 로컬 인터널 테이블 LT_DATA 로 복사
LOOP AT GT_DATA.
MOVE-CORRESPONDING GT_DATA TO LT_DATA .
APPEND LT_DATA.
ENDLOOP.
"### 중복값 제거 작업을 위한 SORT 실시
SORT LT_DATA BY SYS SID ROLE TYPE ID.
"### 키값을 기준으로 중복값 제거
DELETE ADJACENT DUPLICATES FROM LT_DATA COMPARING SYS SID ROLE TYPE ID.
IF LINES( LT_DATA ) NE LINES( GT_DATA ) .
MESSAGE '중복값 에러 발생' TYPE 'S'. EXIT.
ENDIF.
"### 중복값이 없다면, 인터널 테이블 데이터를 테이블로 저장
MODIFY ZBC_MASTER_PW FROM TABLE LT_DATA .
IF SY-SUBRC = 0 .
IF GV_FLAG NE 'V'.
MESSAGE '저장 완료' TYPE 'S'.
ENDIF.
IF GV_FLAG = 'E'. LEAVE TO SCREEN 0. ENDIF.
ENDIF.
ENDFORM. " SAVE_DATA
*&---------------------------------------------------------------------*
*& Form ENQUEUE_OBJECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ENQUEUE_OBJECT .
LOOP AT GT_DATA.
CALL FUNCTION 'ENQUEUE_EZBC_MASTER_PW'
EXPORTING
MODE_ZBC_MASTER_PW = 'E'
SYS = GV_SET_SYS
SID = GV_SET_SID
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DEQUEUE_OBJECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DEQUEUE_OBJECT .
LOOP AT GT_DATA.
CALL FUNCTION 'DEQUEUE_EZBC_MASTER_PW'
EXPORTING
MODE_ZBC_MASTER_PW = 'E'
SYS = GV_SET_SYS
SID = GV_SET_SID.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_RFC_DEST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_RFC_DEST USING F_RFC_DEST_NAME
F_SET_SID
F_SET_TYPE
F_SET_ID
F_SET_PASSWORD.
DATA: LT_DATA LIKE TABLE OF ZBC_MASTER_PW WITH HEADER LINE.
DATA: F_SYSTEMID LIKE RFCOPT-RFCSYSID,
F_SERVER LIKE RFCDISPLAY-RFCHOST,
F_CLIENT LIKE RFCDISPLAY-RFCCLIENT,
F_USER LIKE RFCDISPLAY-RFCUSER,
F_PASSWORD LIKE RFCDISPLAY-RFCAUTH,
F_ACTION LIKE RFCDISPLAY-RFCTRACE.
"### Remote Login 서버 IP주소 검색
SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_DATA
FROM ZBC_MASTER_PW
WHERE SYS = 'OS'
AND SID = F_SET_SID.
READ TABLE LT_DATA INDEX 1.
F_SYSTEMID = F_SET_SID.
F_SERVER = LT_DATA-IP.
F_CLIENT = F_SET_TYPE.
F_USER = F_SET_ID.
F_PASSWORD = F_SET_PASSWORD.
F_ACTION = 'I'.
CALL FUNCTION 'RFC_MODIFY_R3_DESTINATION'
EXPORTING
DESTINATION = F_RFC_DEST_NAME
ACTION = F_ACTION
AUTHORITY_CHECK = 'X'
SYSTEMID = F_SYSTEMID
SYSTEMNR = '00'
SERVER = F_SERVER
CLIENT = F_CLIENT
USER = F_USER
PASSWORD = F_PASSWORD
DESCRIPTION = 'TEMP RFC Destination By.ZBC_MASTER_PASSWORD'
EXCEPTIONS
AUTHORITY_NOT_AVAILABLE = 1
DESTINATION_ALREADY_EXIST = 2
DESTINATION_NOT_EXIST = 3
DESTINATION_ENQUEUE_REJECT = 4
INFORMATION_FAILURE = 5
TRFC_ENTRY_INVALID = 6
INTERNAL_FAILURE = 7
SNC_INFORMATION_FAILURE = 8
SNC_INTERNAL_FAILURE = 9
DESTINATION_IS_LOCKED = 10
OTHERS = 11.
IF SY-SUBRC <> 0.
IF SY-SUBRC = 2.
PERFORM DELETE_RFC_DEST USING F_RFC_DEST_NAME.
MESSAGE 'RFC Destinaion 중복 오류. 기존 RFC Dest 를 삭제하였으니 재시도 해주세요.' TYPE 'S'.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DELETE_RFC_DEST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DELETE_RFC_DEST USING F_RFC_DEST_NAME.
CALL FUNCTION 'RFC_MODIFY_R3_DESTINATION'
EXPORTING
DESTINATION = F_RFC_DEST_NAME
ACTION = 'D'
EXCEPTIONS
AUTHORITY_NOT_AVAILABLE = 1
DESTINATION_ALREADY_EXIST = 2
DESTINATION_NOT_EXIST = 3
DESTINATION_ENQUEUE_REJECT = 4
INFORMATION_FAILURE = 5
TRFC_ENTRY_INVALID = 6
INTERNAL_FAILURE = 7
SNC_INFORMATION_FAILURE = 8
SNC_INTERNAL_FAILURE = 9
DESTINATION_IS_LOCKED = 10
OTHERS = 11.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SET_PWD_POLICY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_PWD_POLICY .
DATA: LT_SECPOL_DATA LIKE TABLE OF SEC_POLICY_RT WITH HEADER LINE.
SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_SECPOL_DATA
FROM SEC_POLICY_RT
WHERE NAME = 'ZSECPOL'.
PWD_POLICY-PARAM = 'Security Policy'.
PWD_POLICY-VALUE = 'ZSECPOL'.
PWD_POLICY-LINECOLOR = 'C510'.
APPEND PWD_POLICY.
CLEAR PWD_POLICY.
READ TABLE LT_SECPOL_DATA WITH KEY ATTRIB_KEY = 'MIN_PASSWORD_UPPERCASE'.
PWD_POLICY-PARAM = 'UPPER_CASE'.
PWD_POLICY-VALUE = LT_SECPOL_DATA-ATTRIB_VALUE.
APPEND PWD_POLICY. CLEAR: PWD_POLICY.
READ TABLE LT_SECPOL_DATA WITH KEY ATTRIB_KEY = 'MIN_PASSWORD_LOWERCASE'.
PWD_POLICY-PARAM = 'LOWER_CASE'.
PWD_POLICY-VALUE = LT_SECPOL_DATA-ATTRIB_VALUE.
APPEND PWD_POLICY. CLEAR PWD_POLICY.
READ TABLE LT_SECPOL_DATA WITH KEY ATTRIB_KEY = 'MIN_PASSWORD_SPECIALS'.
PWD_POLICY-PARAM = 'SPECIALS'.
PWD_POLICY-VALUE = LT_SECPOL_DATA-ATTRIB_VALUE.
APPEND PWD_POLICY. CLEAR PWD_POLICY.
READ TABLE LT_SECPOL_DATA WITH KEY ATTRIB_KEY = 'MIN_PASSWORD_DIGITS'.
PWD_POLICY-PARAM = 'DIGITS'.
PWD_POLICY-VALUE = LT_SECPOL_DATA-ATTRIB_VALUE.
APPEND PWD_POLICY. CLEAR PWD_POLICY.
READ TABLE LT_SECPOL_DATA WITH KEY ATTRIB_KEY = 'MIN_PASSWORD_LENGTH'.
PWD_POLICY-PARAM = 'LENGTH'.
PWD_POLICY-VALUE = LT_SECPOL_DATA-ATTRIB_VALUE.
APPEND PWD_POLICY. CLEAR PWD_POLICY.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ABAP_VC_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ABAP_VC_CHECK .
DATA: LV_SUBRC TYPE SY-SUBRC,
LV_COUNT1(2) TYPE N,
LV_COUNT2(2) TYPE N,
LV_TEMP_DEST LIKE RFCDISPLAY-RFCDEST.
PERFORM SELECT_DATA.
LV_COUNT1 = 1.
LV_COUNT2 = 1.
LOOP AT GT_DATA.
CLEAR: LV_SUBRC, LV_TEMP_DEST.
CONCATENATE 'ZBC_VC_RFC_DEST_' LV_COUNT1 INTO LV_TEMP_DEST.
"### 패스워드 유효성 검사 전용 RFC Destination 생성
PERFORM CREATE_RFC_DEST USING LV_TEMP_DEST
GT_DATA-SID GT_DATA-TYPE GT_DATA-ID GT_DATA-PASSWORD.
"### 생성된 패스워드 유효성 검사 전용 RFC Desination 을 사용하여, 패스워드 유효 여부 확인
"### 만약 해당 ID/Password 로 로그인 되지 않는 다면, LV_SUBRC 값은 2를 리턴한다.
PERFORM RFC_SYNC_AUTH USING LV_TEMP_DEST
CHANGING LV_SUBRC.
"### 패스워드 유효성 검사 결과에 따라 PW_VC 값 설정
IF LV_SUBRC = 0. GT_DATA-PW_VC = 'O'.
ELSE. GT_DATA-PW_VC = 'X'.
ENDIF.
MODIFY GT_DATA.
"### LOOP 마지막이라면 LV_COUNT1 를 더 증가시키지 않고, LOOP 를 탈출
AT LAST. EXIT. ENDAT.
LV_COUNT1 = LV_COUNT1 + 1.
ENDLOOP.
"### LOOP 카운트(GT_DATA 행 갯수) 만큼 생성된 ZBC_VC_RFC_DEST_$$ 를 다시 삭제
DO LV_COUNT1 TIMES.
CONCATENATE 'ZBC_VC_RFC_DEST_' LV_COUNT2 INTO LV_TEMP_DEST.
PERFORM DELETE_RFC_DEST USING LV_TEMP_DEST.
LV_COUNT2 = LV_COUNT2 + 1.
ENDDO.
PERFORM SAVE_DATA.
MESSAGE '패스워드 유효성 검사 완료' TYPE 'S'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ASK_SAVE_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ASK_SAVE_CHECK.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Save Check'
TEXT_QUESTION = 'Task was not Saved. Do you want to Exit?'
TEXT_BUTTON_1 = 'Yes'
TEXT_BUTTON_2 = 'No'
DEFAULT_BUTTON = '2'
DISPLAY_CANCEL_BUTTON = ''
IMPORTING
ANSWER = POPUP_RET.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form RFC_SYNC_AUTH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM RFC_SYNC_AUTH USING F_DEST CHANGING F_SUBRC.
CALL FUNCTION 'RFC_PING'
DESTINATION F_DEST
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2.
CALL FUNCTION 'RFCPING'
DESTINATION F_DEST
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2.
F_SUBRC = SY-SUBRC.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DATA_CLEANING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_CLEANING .
DATA:LT_DATA LIKE TABLE OF GT_DATA WITH HEADER LINE.
SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_DATA
FROM ZBC_MASTER_PW.
"### 데이터 전체 정렬
SORT LT_DATA BY SYS SID ROLE TYPE ID.
"### 아래 GV_FLAG 값 V는 원래 해당 용도의 FLAG 값이 아니지만, SAVE_DATA 폼 내 동작이 필요해 차용.
GV_FLAG ='V'.
PERFORM SAVE_DATA.
CLEAR: GV_FLAG.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form AUTO_TAGGING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ADD_DATA text
*----------------------------------------------------------------------*
FORM AUTO_TAGGING TABLES T_DATA STRUCTURE ZBC_MASTER_PW.
"### 1. 기본 태깅 설정
"### SUSER TAG
IF T_DATA-SYS = 'SAP'. T_DATA-TAG1 = 'SUSER'. ENDIF.
"### G01 SYS1 TAG
IF T_DATA-SID = 'SD1' OR T_DATA-SID = 'SQ1' OR T_DATA-SID = 'SP1'. T_DATA-TAG1 = 'G01'. T_DATA-TAG2 = 'SYS1'. ENDIF.
"### G01 SYS2 TAG
IF T_DATA-SID = 'SD2' OR T_DATA-SID = 'SQ2' OR T_DATA-SID = 'SP2'. T_DATA-TAG1 = 'G01'. T_DATA-TAG2 = 'SYS2'. ENDIF.
"### G01 SYS3 TAG
IF T_DATA-SID = 'SD3' OR T_DATA-SID = 'SQ3' OR T_DATA-SID = 'SP3'. T_DATA-TAG1 = 'G01'. T_DATA-TAG2 = 'SYS3'. ENDIF.
"### G01 SYS4 TAG
IF T_DATA-SID = 'SD4' OR T_DATA-SID = 'SP4'. T_DATA-TAG1 = 'G01'. T_DATA-TAG2 = 'SYS4'. ENDIF.
"### G01 SYS5 TAG
IF T_DATA-SID = 'SD5' OR T_DATA-SID = 'SP5'. T_DATA-TAG1 = 'G01'. T_DATA-TAG2 = 'SYS5'. ENDIF.
"### G01 SYS6 TAG
IF T_DATA-SID = 'SD6' OR T_DATA-SID = 'SP6'. T_DATA-TAG1 = 'G01'. T_DATA-TAG2 = 'SYS6'. ENDIF.
"### SYS7 TAG
IF T_DATA-SID CP 'S*7'. T_DATA-TAG1 = 'SYS7'. ENDIF.
"### SYS8 TAG
IF T_DATA-SID CP 'A*8' OR T_DATA-SID CP 'B*8' OR T_DATA-SID CP 'C*8'. T_DATA-TAG1 = 'SYS8'. ENDIF.
"### SYS9 TAG
IF T_DATA-SID CP 'A*9' OR T_DATA-SID CP 'B*9' OR T_DATA-SID CP 'C*9'. T_DATA-TAG1 = 'SYS9'. ENDIF.
"### SYS10 TAG
IF T_DATA-SID CP 'X*0' OR T_DATA-SID CP 'Y*0' OR T_DATA-SID CP 'Z*0'. T_DATA-TAG1 = 'SYS10'. ENDIF.
"### SYS11 TAG
IF T_DATA-SID CP 'Z*1'. T_DATA-TAG1 = 'SYS11'. ENDIF.
"### 2. 기본 태깅 이후, ETC 추가 태깅 설정
"### TYPE 이 TST(TEST) 인 경우 ETC
IF T_DATA-TYPE = 'TST'. T_DATA-TAG1 = 'ETC'. CLEAR T_DATA-TAG2. ENDIF.
"### SYS 이 WEB, WIN(Window) 인 경우 ETC
IF T_DATA-SYS = 'WEB' OR T_DATA-SYS = 'WIN'. T_DATA-TAG1 = 'ETC'. CLEAR T_DATA-TAG2. ENDIF.
"### 위 조건을 거쳤는데도 TAG1 값이 없을 경우, ETC 태킹
IF T_DATA-TAG1 IS INITIAL. T_DATA-TAG1 = 'ETC'. ENDIF.
ENDFORM.
2. ABAP DIctionary
2-1. Table ZBC_MASTER_PW
필드 PASSWORD 를 제외한 나머지 필드는 전부 BuiltIn Type
필드 PASSWORD 는 Case Seneitive 설정을 위해 Data element 설정
FieldKeyInitVDTypeLenDesc
SYS | X | X | CHAR | 5 | System |
SID | X | X | CHAR | 3 | SID |
ROLE | X | X | CHAR | 3 | Role |
TYPE | X | X | CHAR | 10 | System Type |
ID | X | X | CHAR | 20 | ID |
PASSWORD | CHAR | 20 | Password (Data Element ZPASSWORD) | ||
IP | CHAR | 16 | System IP | ||
HOSTNAME | CHAR | 20 | System Hostname | ||
DESC_LOG | CHAR | 200 | Description | ||
PW_VC | CHAR | 1 | Password Vaild Check | ||
TAG1 | CHAR | 20 | Tag 1 | ||
TAG2 | CHAR | 20 | Tag 2 | ||
URL | CHAR | 200 | JAVA URL | ||
AENAM | CHAR | 12 | Change User | ||
AEDAT | DATS | 8 | Change Date | ||
AEZET | TIMS | 6 | Change Time |
2-2. Field ZPASSWORD
2-2-1. Domain ZPASSWORD
Data Type : CHAR
No. Characters : 20
Output Length : 20
Lower Case : V
2-2-2. Data Element ZPASSWORD
Domain : ZPASSWORD
2-3. Lock Object EZBC_MASTER_PW
- Primary Table
-> Name : ZBC_MASTER_PW
-> Lock Mode : Write Lock - Lock parameterLock paramTableField
SYS ZBC_MASTER_PW SYS SID ZBC_MASTER_PW SID ROLE ZBC_MASTER_PW ROLE TYPE ZBC_MASTER_PW TYPE ID ZBC_MASTER_PW ID
2-4. GUI Status
GUI Status Name : S100
2-4-1. Application Toolbar
- S_CHG_PWD
-> Function Text : S_CHG_PWD
-> Icon Name : ICON_ANNOTATION
-> Icon Text / Info. Text : Password Change - CHG_PWD
-> Function Text : CHG_PWD
-> Icon Name : ICON_CHANGE_TEXT
-> Icon Text / Info. Text : MASS PWD Change - REMOTE_C
-> Function Text : REMOTE_C
-> Icon Name : ICON_CONNECT
-> Icon Text / Info. Text : Remote Login (ABAP) - REMOTE_JV
-> Function Text : REMOTE_JV
-> Icon Name : ICON_CONNECT
-> Icon Text / Info. Text : Remote Login (JAVA) - SEQ_UP
-> Function Text : SEQ_UP
-> Icon Name : ICON_UNASSIGN
-> Icon Text / Info. Text : Sequential UP - VC_MCHG
-> Function Text : VC_MCHG
-> Icon Name : ICON_ACTIVE_INACTIVE
-> Icon Text / Info. Text : VC Manual Change - ADD_SYSTEM
-> Function Text : ADD_SYSTEM
-> Icon Name : ICON_INSERT_MULTIPLE_LINES
-> Icon Text / Info. Text : ADD SYSTEM
2-4-2. Function Keys
SAVE - BACK1 - EXIT - CANC
'SAP BC-프로그램' 카테고리의 다른 글
사용자 레이아웃 설정 복사 프로그램 (0) | 2024.03.11 |
---|---|
Oracle DB 테이블스페이스 기록 및 알람 프로그램 (0) | 2024.03.11 |
일일 간편 시스템 모니터링 프로그램 (0) | 2024.03.09 |
사용자 일괄 수정/복사 프로그램 (0) | 2024.03.09 |
Tcode 사용 기록 검색 프로그램 (0) | 2024.03.09 |