ABAP/BC/Изменение исходной системы разработки

Материал из Викиучебника — открытых книг для открытого мира
Перейти к навигации Перейти к поиску
  1 *&---------------------------------------------------------------------*
  2 *& Report  ZBC_CHANGE_SOURCE_SYSTEM
  3 *&
  4 *&---------------------------------------------------------------------*
  5 *& Название разработки: Изменеие исходной системы объектов репозитария *
  6 *& Разработчики: Югов А.                                               *
  7 *&                                                                     *
  8 *& Описание: Выбор объектов по пакету, а также по запросу - надежней   *
  9 *& по пакету                                                           *
 10 *& Разработка полезна при внешнем переносе.                            *
 11 *&---------------------------------------------------------------------*
 12 
 13 REPORT  zbc_change_source_system.
 14 TYPE-POOLS: sctsc,
 15             trwbo,
 16             trsel,
 17             stms.
 18 
 19 TYPES BEGIN OF ltyp_request_pool.
 20 TYPES trkorr TYPE trkorr.
 21         INCLUDE STRUCTURE tadir.
 22 TYPES END OF ltyp_request_pool.
 23 
 24 DATA gt_objects_pool TYPE TABLE OF ltyp_request_pool.
 25 DATA gs_objects_pool TYPE ltyp_request_pool.
 26 
 27 DATA ls_rfcsi TYPE rfcsi.
 28 
 29 
 30 PARAMETERS srcsys LIKE tadir-srcsystem.
 31 PARAMETERS devcls LIKE pbpackdata-devclass.
 32 PARAMETERS request LIKE trdyse01sn-tr_trkorr.
 33 
 34 INITIALIZATION.
 35   IF srcsys IS INITIAL.
 36     CALL FUNCTION 'RFC_GET_SYSTEM_INFO'
 37       EXPORTING
 38         destination             = 'NONE'
 39       IMPORTING
 40         rfcsi_export            = ls_rfcsi
 41       EXCEPTIONS
 42         authority_not_available = 1
 43         OTHERS                  = 2.
 44 
 45     srcsys = ls_rfcsi-rfcsysid.
 46   ENDIF.
 47 
 48 AT SELECTION-SCREEN ON VALUE-REQUEST FOR request.
 49   PERFORM value_trkorr.
 50 
 51 START-OF-SELECTION.
 52 
 53   CHECK NOT ( devcls IS NOT INITIAL AND
 54             request IS NOT INITIAL ).
 55 
 56   REFRESH gt_objects_pool.
 57   IF devcls IS NOT INITIAL.
 58     PERFORM find_devcls_objlist.
 59   ELSEIF request IS NOT INITIAL.
 60     PERFORM read_request_objlist.
 61   ENDIF.
 62 
 63   IF gt_objects_pool IS NOT INITIAL.
 64     PERFORM source_system_update.
 65   ENDIF.
 66 *&---------------------------------------------------------------------*
 67 *&      Form  FIND_DEVCLS_OBJLIST
 68 *&---------------------------------------------------------------------*
 69 *       text
 70 *----------------------------------------------------------------------*
 71 *  -->  p1        text
 72 *  <--  p2        text
 73 *----------------------------------------------------------------------*
 74 FORM find_devcls_objlist .
 75   SELECT * FROM tadir
 76     INTO CORRESPONDING FIELDS OF TABLE gt_objects_pool
 77     WHERE devclass EQ devcls.
 78 ENDFORM.                    " FIND_DEVCLS_OBJLIST
 79 *&---------------------------------------------------------------------*
 80 *&      Form  READ_REQUEST_OBJLIST
 81 *&---------------------------------------------------------------------*
 82 *       text
 83 *----------------------------------------------------------------------*
 84 *  -->  p1        text
 85 *  <--  p2        text
 86 *----------------------------------------------------------------------*
 87 FORM read_request_objlist .
 88   DATA lt_requests TYPE trwbo_request_headers.
 89   DATA ls_ranges TYPE trsel_ts_ranges.
 90   DATA lsr_trkorr LIKE LINE OF ls_ranges-trkorr.
 91 
 92   CLEAR ls_ranges.
 93   lsr_trkorr-sign = 'I'.
 94   lsr_trkorr-option = 'EQ'.
 95   lsr_trkorr-low = request.
 96 
 97   APPEND lsr_trkorr TO ls_ranges-trkorr.
 98 
 99   " Читаем вложенные задачи.
100   CALL FUNCTION 'TRINT_SELECT_REQUESTS'
101     IMPORTING
102       et_requests            = lt_requests
103     CHANGING
104       cs_ranges              = ls_ranges
105     EXCEPTIONS
106       action_aborted_by_user = 1
107       OTHERS                 = 2.
108 
109   " Читаем объекты для всех выбранных задач
110   DATA lv_request LIKE tmsbuffer-trkorr.
111   DATA lt_request_infos TYPE stms_wbo_requests.
112   DATA ls_request_infos LIKE LINE OF lt_request_infos.
113   DATA ls_e071 LIKE LINE OF ls_request_infos-e071.
114   FIELD-SYMBOLS <fs_requests> LIKE LINE OF lt_requests.
115 
116   LOOP AT lt_requests ASSIGNING <fs_requests>.
117     CLEAR lv_request.
118     lv_request = <fs_requests>-trkorr.
119     IF lv_request IS NOT INITIAL.
120       CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
121         EXPORTING
122           iv_request                 = lv_request
123         IMPORTING
124           et_request_infos           = lt_request_infos
125         EXCEPTIONS
126           read_config_failed         = 1
127           table_of_requests_is_empty = 2
128           system_not_available       = 3
129           OTHERS                     = 4.
130 
131       " Пули выбранное в таблицу рэнжей для обновлений.
132       LOOP AT lt_request_infos INTO ls_request_infos.
133 * В этой табличке лежат объекты запроса которые мы и пулим
134         LOOP AT ls_request_infos-e071 INTO ls_e071.
135           CLEAR gs_objects_pool.
136           MOVE-CORRESPONDING ls_e071 TO gs_objects_pool.
137           APPEND gs_objects_pool TO gt_objects_pool.
138         ENDLOOP.
139 
140       ENDLOOP.
141 
142     ENDIF.
143   ENDLOOP.
144 ENDFORM.                    " READ_REQUEST_OBJLIST
145 
146 
147 *&---------------------------------------------------------------------*
148 *&      Form  value_trkorr
149 *&---------------------------------------------------------------------*
150 *       text
151 *----------------------------------------------------------------------*
152 FORM value_trkorr.
153   DATA: lv_trfunctions  LIKE  trpari-w_longstat,
154         lv_trstatus     LIKE  trpari-w_longstat,
155         lv_trkorr       TYPE  e070-trkorr,
156         ls_dynpfield  LIKE dynpread,
157         lt_dynpfields LIKE dynpread    OCCURS 0.
158 
159   lv_trfunctions = sctsc_types_all.
160   lv_trstatus    = sctsc_states_changeable.
161 
162   GET CURSOR FIELD ls_dynpfield-fieldname.
163   APPEND ls_dynpfield TO lt_dynpfields.
164 
165   CALL FUNCTION 'DYNP_VALUES_READ'
166     EXPORTING
167       dyname     = 'ZBC_CHANGE_SOURCE_SYSTEM'
168       dynumb     = sy-dynnr
169     TABLES
170       dynpfields = lt_dynpfields.
171   READ TABLE lt_dynpfields INTO ls_dynpfield INDEX 1.
172   lv_trkorr = ls_dynpfield-fieldvalue.
173 
174   CALL FUNCTION 'TR_F4_REQUESTS'
175     EXPORTING
176       iv_username         = space
177       iv_trkorr_pattern   = lv_trkorr
178       iv_trfunctions      = lv_trfunctions
179       iv_trstatus         = lv_trstatus
180     IMPORTING
181       ev_selected_request = lv_trkorr.
182 
183   ls_dynpfield-fieldvalue = lv_trkorr.
184   MODIFY lt_dynpfields FROM ls_dynpfield
185                        INDEX 1
186                        TRANSPORTING fieldvalue.
187   CALL FUNCTION 'DYNP_VALUES_UPDATE'
188     EXPORTING
189       dyname     = 'ZBC_CHANGE_SOURCE_SYSTEM'
190       dynumb     = sy-dynnr
191     TABLES
192       dynpfields = lt_dynpfields.
193 
194 ENDFORM.                               " VALUE_TRKORR
195 *&---------------------------------------------------------------------*
196 *&      Form  SOURCE_SYSTEM_UPDATE
197 *&---------------------------------------------------------------------*
198 *       text
199 *----------------------------------------------------------------------*
200 *  -->  p1        text
201 *  <--  p2        text
202 *----------------------------------------------------------------------*
203 FORM source_system_update .
204   DATA ls_objects_pool LIKE LINE OF gt_objects_pool.
205   LOOP AT gt_objects_pool INTO ls_objects_pool.
206     UPDATE tadir
207       SET srcsystem = srcsys
208       WHERE pgmid     EQ ls_objects_pool-pgmid    AND
209             object    EQ ls_objects_pool-object   AND
210             obj_name  EQ ls_objects_pool-obj_name.
211   ENDLOOP.
212   IF sy-subrc EQ 0..
213     COMMIT WORK AND WAIT.
214   ELSE.
215     ROLLBACK WORK.
216   ENDIF.
217 ENDFORM.                    " SOURCE_SYSTEM_UPDATE