단순반복 싫어
이게 은근히 귀찮은 작업인데
관리포인트랍시고 개발클래스 통폐합 및 프로그램 앞에 단체로 접두사를 추가하겠다고 한다.
이게 마우스로 일일이 프로그램을 찍어서 해줘야 하는거라 인내심의 한계를 맛보게 된다.
그래서, 한 3개쯤 변경하고 포기한 다음, 프로그램을 만들었다.
하다보니 별별 해괴한 조건이 다 달렸다.
공통사용 INCLUDE의 경우 옮기지 않는게 기본인데
옮겨야 하는 프로그램들에서만 사용하는 프로그램이면 같이 옮겨야 하고..
넣으라는거 다 넣고 돌리면 끝
*--------------------------------------------------------------------*
DATA: gt_bdc_report_assign TYPE bdcdata_tab WITH HEADER LINE,
gt_bdc_tcode_assign TYPE bdcdata_tab WITH HEADER LINE,
gt_bdc_namet TYPE bdcdata_tab WITH HEADER LINE,
gt_bdc_tcodet TYPE bdcdata_tab WITH HEADER LINE,
gt_mtab TYPE tab_bdcmsgcoll WITH HEADER LINE,
gs_para TYPE ctu_params.
DATA: BEGIN OF gt_name OCCURS 0,
name TYPE progname,
namet TYPE char70,
subc TYPE trdir-subc,
END OF gt_name.
DATA: BEGIN OF gt_tcode OCCURS 0,
tcode TYPE progname,
tcodet TYPE char70,
END OF gt_tcode.
"MACROS
DEFINE _set_scr.
&3-program = &1.
&3-dynpro = &2.
&3-dynbegin = 'X'.
APPEND &3. CLEAR &3.
END-OF-DEFINITION.
DEFINE _set_fld.
&3-fnam = &1.
&3-fval = &2.
APPEND &3. CLEAR &3.
END-OF-DEFINITION.
DEFINE _set_okc.
&2-fnam = 'BDC_OKCODE'.
&2-fval = &1.
APPEND &2. CLEAR &2.
END-OF-DEFINITION.
*--------------------------------------------------------------------*
SELECT-OPTIONS: s_tcode FOR sy-tcode.
SELECT-OPTIONS: s_repid FOR sy-repid.
PARAMETERS: p_prefix TYPE char30 DEFAULT '[미사용]'.
PARAMETERS: p_dest TYPE devclass DEFAULT 'ZNOUSE'.
selection-screen begin of line.
selection-screen comment (31) for field p_trkorr.
parameters: p_trkorr type trkorr obligatory.
selection-screen comment (60) comm9.
selection-screen end of line.
PARAMETERS: p_bdcmd TYPE ctu_mode DEFAULT 'N'.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_move AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (12) text-c01.
PARAMETERS: p_namec AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (16) text-c02.
PARAMETERS: p_tcodec AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT (15) text-c03.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN COMMENT /1(72) COMM1.
SELECTION-SCREEN COMMENT /1(72) COMM2.
SELECTION-SCREEN COMMENT /1(72) COMM3.
SELECTION-SCREEN COMMENT /1(72) COMM4.
SELECTION-SCREEN COMMENT /1(72) COMM5.
SELECTION-SCREEN COMMENT /1(72) COMM6.
SELECTION-SCREEN COMMENT /1(72) COMM7.
SELECTION-SCREEN COMMENT /1(72) COMM8.
AT SELECTION-SCREEN OUTPUT.
COMM1 = `*** 필독 및 주의사항 ***`.
COMM2 = `1. Workbench Request를 준비해주세요.`.
COMM3 = `2. 티코드: 티코드에 연결된 프로그램, 프로그램에 연결된 INCLUDE 모두 이동`.
COMM4 = `3. 프로그램: 프로그램에 연결된 INCLUDE 모두 이동`.
COMM5 = `4. 사용처가 2개 이상인 인클루드의 경우 이동하지 않음`.
COMM6 = ` (단, 모든 사용처가 처리 리스트에 포함되어 있는 경우에는 이동처리함)`.
COMM7 = `5. 이동할 프로그램&티코드는 반드시! CTS에 묶이지 않은 상태여야 합니다.`.
COMM8 = `6. 이동 후 SE80에서 별도로 활성화 해주세요.`.
select single as4text
from e07t
into comm9
where langu = sy-langu
and trkorr = p_trkorr.
*----------------------------------------------------------------------*
at selection-screen on value-request for p_trkorr.
perform show_own_orders.
*--------------------------------------------------------------------*
START-OF-SELECTION.
*--------------------------------------------------------------------*
DATA lr_incl TYPE RANGE OF progname.
DATA lv_namet LIKE gt_name-namet.
CLEAR gt_name[].
IF ( s_tcode[] IS INITIAL AND s_repid[] IS INITIAL ).
MESSAGE 'TCODE or REPID 없음' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
IF p_trkorr IS INITIAL.
MESSAGE 'CTS번호 없음' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
*--------------------------------------------------------------------*
"이동할 패키지 -> Z*
CHECK p_dest(1) = 'Z' OR p_dest(1) = 'Y'.
SELECT COUNT( * )
FROM tadir
WHERE devclass = p_dest.
CHECK sy-subrc = 0.
*--------------------------------------------------------------------*
"이동할 TYPE1, MODULE POOL, INCLUDE 목록 생성
IF s_tcode[] IS NOT INITIAL.
SELECT tstc~tcode,
tstct~ttext AS tcodet,
tstc~pgmna AS name,
trdirt~text AS namet,
subc
FROM tstc
JOIN trdir
ON tstc~pgmna = trdir~name
LEFT OUTER JOIN tstct
ON tstc~tcode = tstct~tcode
AND tstct~sprsl = @sy-langu
LEFT OUTER JOIN trdirt
ON trdir~name = trdirt~name
AND trdirt~sprsl = @sy-langu
INTO TABLE @DATA(lt_tcode)
WHERE tstc~tcode IN @s_tcode
AND ( pgmna LIKE 'Z%' OR
pgmna LIKE 'Y%' )
AND subc IN ( '1','M','I' ).
CHECK lt_tcode IS NOT INITIAL.
SELECT master AS name,
include
FROM d010inc
INTO TABLE @DATA(lt_incl)
FOR ALL ENTRIES IN @lt_tcode
WHERE master = @lt_tcode-name
AND ( include LIKE 'Z%' OR
include LIKE 'Y%' ).
CHECK lt_incl IS NOT INITIAL.
ENDIF.
IF s_repid[] IS NOT INITIAL.
SELECT tstc~tcode,
tstct~ttext AS tcodet,
trdir~name AS name,
trdirt~text AS namet,
subc
FROM trdir
LEFT OUTER JOIN tstc
ON trdir~name = tstc~pgmna
LEFT OUTER JOIN tstct
ON tstc~tcode = tstct~tcode
AND tstct~sprsl = @sy-langu
LEFT OUTER JOIN trdirt
ON trdir~name = trdirt~name
AND trdirt~sprsl = @sy-langu
APPENDING TABLE @lt_tcode
WHERE trdir~name IN @s_repid
AND trdir~subc IN ( '1','M','I' ).
SELECT master AS name,
include
FROM d010inc
APPENDING TABLE @lt_incl
WHERE master IN @s_repid
AND ( include LIKE 'Z%' OR
include LIKE 'Y%' ).
ENDIF.
SORT: lt_incl BY name include,
lt_tcode BY tcode name.
*--------------------------------------------------------------------*
"INCLUDE 사용처 확인
DATA(lt_incl_temp) = lt_incl.
SORT lt_incl_temp BY include.
DELETE ADJACENT DUPLICATES FROM lt_incl_temp COMPARING include.
IF lt_incl_temp[] IS NOT INITIAL.
"INCLUDE 사용처 전체 선택
SELECT master AS name,
include
FROM d010inc
INTO TABLE @DATA(lt_incl_check)
FOR ALL ENTRIES IN @lt_incl_temp
WHERE include = @lt_incl_temp-include.
SORT lt_incl_check BY include name.
"LT_INCL에 목록이 존재하면 미사용 사용처로 간주
LOOP AT lt_incl_check INTO DATA(ls_incl_check).
READ TABLE lt_incl WITH KEY name = ls_incl_check-name
include = ls_incl_check-include
BINARY SEARCH
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
DELETE lt_incl_check.
ENDIF.
ENDLOOP.
"처리대상이 아닌 사용처가 있을 경우 -> 처리목록에서 제외
LOOP AT lt_incl INTO DATA(ls_incl).
READ TABLE lt_incl_check WITH KEY include = ls_incl-include
BINARY SEARCH
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
DELETE lt_incl.
ENDIF.
ENDLOOP.
ENDIF.
*--------------------------------------------------------------------*
gt_name[] = CORRESPONDING #( BASE ( gt_name[] )
lt_tcode
MAPPING name = name
namet = namet
subc = subc
EXCEPT *
).
gt_name[] = CORRESPONDING #( BASE ( gt_name[] )
lt_incl
MAPPING name = include
EXCEPT *
).
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
SORT gt_name BY name.
DELETE ADJACENT DUPLICATES FROM gt_name COMPARING name.
SORT lt_tcode BY tcode.
DELETE ADJACENT DUPLICATES FROM lt_tcode COMPARING tcode.
"혹시 공통 INCLUDE 등 잘못 포함된 것이 없는지 GT_NAME, LT_TCODE 테이블 리스트 확인하세요.
BREAK-POINT.
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
"SET BDCDATA: PROGRAM
CLEAR: gt_bdc_report_assign, gt_bdc_namet, gt_bdc_tcodet.
REFRESH: gt_bdc_report_assign, gt_bdc_namet, gt_bdc_tcodet.
"BDC PARAMS
gs_para-dismode = p_bdcmd.
gs_para-updmode = 'S'.
gs_para-defsize = 'X'.
gs_para-racommit = 'X'.
gs_para-nobinpt = 'X'.
gs_para-cattmode = 'A'.
LOOP AT gt_name.
IF p_move = 'X'.
"PKG ASSIGNMENT 변경
_set_scr: 'SAPLWBABAP' '0100' gt_bdc_report_assign.
_set_fld: 'RS38M-PROGRAMM' gt_name-name gt_bdc_report_assign.
_set_okc: '=ADIR' gt_bdc_report_assign.
_set_scr: 'SAPLSTRD' '0100' gt_bdc_report_assign.
_set_okc: '=AZAE' gt_bdc_report_assign.
_set_scr: 'SAPLSTRD' '0100' gt_bdc_report_assign.
_set_fld: 'KO007-L_DEVCLASS' p_dest gt_bdc_report_assign.
_set_okc: '=ADD' gt_bdc_report_assign.
_set_scr: 'SAPLSTRD' '0300' gt_bdc_report_assign.
_set_fld: 'KO008-TRKORR' p_trkorr gt_bdc_report_assign.
_set_okc: '=LOCK' gt_bdc_report_assign.
CALL TRANSACTION 'SE38' USING gt_bdc_report_assign
OPTIONS FROM gs_para
MESSAGES INTO gt_mtab.
CLEAR: gt_bdc_report_assign, gt_bdc_report_assign[].
ENDIF.
"레포트 내역 수정 -> 메인 프로그램만 대상
IF gt_name-namet(5) <> p_prefix AND
( gt_name-subc = '1' OR gt_name-subc = 'M' ).
lv_namet = p_prefix && gt_name-namet.
_set_scr: 'SAPLWBABAP' '0100' gt_bdc_namet.
_set_fld: 'RS38M-PROGRAMM' gt_name-name gt_bdc_namet.
_set_fld: 'RS38M-FUNC_EDIT' ' ' gt_bdc_namet.
_set_fld: 'RS38M-FUNC_HEAD' 'X' gt_bdc_namet.
_set_okc: '=CHAP' gt_bdc_namet.
_set_scr: 'SAPLSEDTATTR' '0200' gt_bdc_namet.
_set_fld: 'RS38M-REPTI' lv_namet gt_bdc_namet.
_set_okc: '=CONT' gt_bdc_namet.
_set_scr: 'SAPLSTRD' '0300' gt_bdc_namet.
_set_fld: 'KO008-TRKORR' p_trkorr gt_bdc_namet.
_set_okc: '=LOCK' gt_bdc_namet.
CALL TRANSACTION 'SE38' USING gt_bdc_namet
OPTIONS FROM gs_para
MESSAGES INTO gt_mtab.
CLEAR: gt_bdc_namet, gt_bdc_namet[].
ENDIF.
ENDLOOP.
LOOP AT lt_tcode INTO DATA(ls_tcode).
"PKG ASSIGNMENT 변경
_set_scr: 'SAPLSEUK' '0390' gt_bdc_tcode_assign.
_set_fld: 'TSTC-TCODE' ls_tcode-tcode gt_bdc_tcode_assign.
_set_okc: '=WB_TADIR_EDIT' gt_bdc_tcode_assign.
_set_scr: 'SAPLSTRD' '0100' gt_bdc_tcode_assign.
_set_okc: '=AZAE' gt_bdc_tcode_assign.
_set_scr: 'SAPLSTRD' '0100' gt_bdc_tcode_assign.
_set_fld: 'KO007-L_DEVCLASS' p_dest gt_bdc_tcode_assign.
_set_okc: '=ADD' gt_bdc_tcode_assign.
_set_scr: 'SAPLSTRD' '0300' gt_bdc_tcode_assign.
_set_fld: 'KO008-TRKORR' p_trkorr gt_bdc_tcode_assign.
_set_okc: '=LOCK' gt_bdc_tcode_assign.
CALL TRANSACTION 'SE93' USING gt_bdc_tcode_assign
OPTIONS FROM gs_para
MESSAGES INTO gt_mtab.
CLEAR: gt_bdc_tcode_assign, gt_bdc_tcode_assign[].
"티코드 내역 수정 -> 메인 프로그램만 대상
IF ls_tcode-tcodet(5) <> p_prefix.
lv_namet = p_prefix && ls_tcode-namet.
_set_scr: 'SAPLSEUK' '0390' gt_bdc_tcodet.
_set_fld: 'TSTC-TCODE' ls_tcode-tcode gt_bdc_tcodet.
_set_okc: '=CHNG' gt_bdc_tcodet.
_set_scr: 'SAPLSEUK' '0320' gt_bdc_tcodet.
_set_fld: 'TSTCT-TTEXT' lv_namet gt_bdc_tcodet.
_set_okc: '=WB_SAVE' gt_bdc_tcodet.
* _set_scr: 'SAPLSTRD' '0300' gt_bdc_tcodet.
* _set_fld: 'KO008-TRKORR' p_trkorr gt_bdc_tcodet.
* _set_okc: '=LOCK' gt_bdc_tcodet.
CALL TRANSACTION 'SE93' USING gt_bdc_tcodet
OPTIONS FROM gs_para
MESSAGES INTO gt_mtab.
CLEAR: gt_bdc_tcodet, gt_bdc_tcodet[].
ENDIF.
ENDLOOP.
WRITE: / '완료'.
*&---------------------------------------------------------------------*
*& Form show_own_orders
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
form show_own_orders .
data: ls_selection type trwbo_selection,
ls_new_request_props type trwbo_new_req_props,
lv_organizer type trwbo_calling_organizer,
ls_request_header type trwbo_request_header,
ls_task_header type trwbo_request_header,
lv_title type trwbo_title,
w_order like ls_request_header-trkorr,
w_trkorr like ls_task_header-trkorr.
* parameters for request selection
"workbench request
ls_selection-client = sy-mandt.
ls_selection-tarsystem = 'EQA'.
ls_selection-taskfunctions = 'RSX'.
lv_organizer = 'W'.
ls_selection-reqfunctions = 'K'.
ls_selection-reqstatus = 'DL'.
ls_selection-taskstatus = 'DL'.
ls_selection-connect_req_task_conditions = 'X'.
if ' ' >< space.
ls_selection-attribute = 'SAP_CTS_PROJECT'.
ls_selection-reference = ' '.
endif.
* parameters for new request
perform get_new_req_props changing ls_new_request_props.
lv_title = 'Workbench'.
call function 'TR_PRESENT_REQUESTS_SEL_POPUP'
exporting
iv_organizer_type = lv_organizer
iv_username = sy-uname
is_selection = ls_selection
iv_title = lv_title
is_new_request_props = ls_new_request_props
iv_prog_top_of_page = 'SAPLSTRD'
iv_form_top_of_page = 'WRITE_REASON_FOR_REQUEST_TYPE'
importing
es_selected_request = ls_request_header
es_selected_task = ls_task_header.
w_order = ls_request_header-trkorr.
w_trkorr = ls_task_header-trkorr.
if w_order <> space.
p_trkorr = w_order.
elseif w_trkorr <> space.
p_trkorr = w_trkorr .
endif.
clear sy-ucomm.
endform.
form get_new_req_props changing ps_props type trwbo_new_req_props.
ps_props-trfunctions = 'K'.
ps_props-tarsystem = 'EQA'.
* task type
ps_props-taskfunc = 'S'.
* source client
ps_props-client = '710'.
endform.