ABAP/BC/Изменение исходной системы разработки
Внешний вид
< ABAP
*&---------------------------------------------------------------------*
*& Report ZBC_CHANGE_SOURCE_SYSTEM
*&
*&---------------------------------------------------------------------*
*& Название разработки: Изменеие исходной системы объектов репозитария *
*& Разработчики: Югов А. *
*& *
*& Описание: Выбор объектов по пакету, а также по запросу - надежней *
*& по пакету *
*& Разработка полезна при внешнем переносе. *
*&---------------------------------------------------------------------*
REPORT zbc_change_source_system.
TYPE-POOLS: sctsc,
trwbo,
trsel,
stms.
TYPES BEGIN OF ltyp_request_pool.
TYPES trkorr TYPE trkorr.
INCLUDE STRUCTURE tadir.
TYPES END OF ltyp_request_pool.
DATA gt_objects_pool TYPE TABLE OF ltyp_request_pool.
DATA gs_objects_pool TYPE ltyp_request_pool.
DATA ls_rfcsi TYPE rfcsi.
PARAMETERS srcsys LIKE tadir-srcsystem.
PARAMETERS devcls LIKE pbpackdata-devclass.
PARAMETERS request LIKE trdyse01sn-tr_trkorr.
INITIALIZATION.
IF srcsys IS INITIAL.
CALL FUNCTION 'RFC_GET_SYSTEM_INFO'
EXPORTING
destination = 'NONE'
IMPORTING
rfcsi_export = ls_rfcsi
EXCEPTIONS
authority_not_available = 1
OTHERS = 2.
srcsys = ls_rfcsi-rfcsysid.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR request.
PERFORM value_trkorr.
START-OF-SELECTION.
CHECK NOT ( devcls IS NOT INITIAL AND
request IS NOT INITIAL ).
REFRESH gt_objects_pool.
IF devcls IS NOT INITIAL.
PERFORM find_devcls_objlist.
ELSEIF request IS NOT INITIAL.
PERFORM read_request_objlist.
ENDIF.
IF gt_objects_pool IS NOT INITIAL.
PERFORM source_system_update.
ENDIF.
*&---------------------------------------------------------------------*
*& Form FIND_DEVCLS_OBJLIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM find_devcls_objlist .
SELECT * FROM tadir
INTO CORRESPONDING FIELDS OF TABLE gt_objects_pool
WHERE devclass EQ devcls.
ENDFORM. " FIND_DEVCLS_OBJLIST
*&---------------------------------------------------------------------*
*& Form READ_REQUEST_OBJLIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_request_objlist .
DATA lt_requests TYPE trwbo_request_headers.
DATA ls_ranges TYPE trsel_ts_ranges.
DATA lsr_trkorr LIKE LINE OF ls_ranges-trkorr.
CLEAR ls_ranges.
lsr_trkorr-sign = 'I'.
lsr_trkorr-option = 'EQ'.
lsr_trkorr-low = request.
APPEND lsr_trkorr TO ls_ranges-trkorr.
" Читаем вложенные задачи.
CALL FUNCTION 'TRINT_SELECT_REQUESTS'
IMPORTING
et_requests = lt_requests
CHANGING
cs_ranges = ls_ranges
EXCEPTIONS
action_aborted_by_user = 1
OTHERS = 2.
" Читаем объекты для всех выбранных задач
DATA lv_request LIKE tmsbuffer-trkorr.
DATA lt_request_infos TYPE stms_wbo_requests.
DATA ls_request_infos LIKE LINE OF lt_request_infos.
DATA ls_e071 LIKE LINE OF ls_request_infos-e071.
FIELD-SYMBOLS <fs_requests> LIKE LINE OF lt_requests.
LOOP AT lt_requests ASSIGNING <fs_requests>.
CLEAR lv_request.
lv_request = <fs_requests>-trkorr.
IF lv_request IS NOT INITIAL.
CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
EXPORTING
iv_request = lv_request
IMPORTING
et_request_infos = lt_request_infos
EXCEPTIONS
read_config_failed = 1
table_of_requests_is_empty = 2
system_not_available = 3
OTHERS = 4.
" Пули выбранное в таблицу рэнжей для обновлений.
LOOP AT lt_request_infos INTO ls_request_infos.
* В этой табличке лежат объекты запроса которые мы и пулим
LOOP AT ls_request_infos-e071 INTO ls_e071.
CLEAR gs_objects_pool.
MOVE-CORRESPONDING ls_e071 TO gs_objects_pool.
APPEND gs_objects_pool TO gt_objects_pool.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM. " READ_REQUEST_OBJLIST
*&---------------------------------------------------------------------*
*& Form value_trkorr
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM value_trkorr.
DATA: lv_trfunctions LIKE trpari-w_longstat,
lv_trstatus LIKE trpari-w_longstat,
lv_trkorr TYPE e070-trkorr,
ls_dynpfield LIKE dynpread,
lt_dynpfields LIKE dynpread OCCURS 0.
lv_trfunctions = sctsc_types_all.
lv_trstatus = sctsc_states_changeable.
GET CURSOR FIELD ls_dynpfield-fieldname.
APPEND ls_dynpfield TO lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = 'ZBC_CHANGE_SOURCE_SYSTEM'
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfields.
READ TABLE lt_dynpfields INTO ls_dynpfield INDEX 1.
lv_trkorr = ls_dynpfield-fieldvalue.
CALL FUNCTION 'TR_F4_REQUESTS'
EXPORTING
iv_username = space
iv_trkorr_pattern = lv_trkorr
iv_trfunctions = lv_trfunctions
iv_trstatus = lv_trstatus
IMPORTING
ev_selected_request = lv_trkorr.
ls_dynpfield-fieldvalue = lv_trkorr.
MODIFY lt_dynpfields FROM ls_dynpfield
INDEX 1
TRANSPORTING fieldvalue.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = 'ZBC_CHANGE_SOURCE_SYSTEM'
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfields.
ENDFORM. " VALUE_TRKORR
*&---------------------------------------------------------------------*
*& Form SOURCE_SYSTEM_UPDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM source_system_update .
DATA ls_objects_pool LIKE LINE OF gt_objects_pool.
LOOP AT gt_objects_pool INTO ls_objects_pool.
UPDATE tadir
SET srcsystem = srcsys
WHERE pgmid EQ ls_objects_pool-pgmid AND
object EQ ls_objects_pool-object AND
obj_name EQ ls_objects_pool-obj_name.
ENDLOOP.
IF sy-subrc EQ 0..
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDFORM. " SOURCE_SYSTEM_UPDATE