Properties SourceCde
txt
1
*&--------------------------------------------------------------------*
2
*&      Form UPGRADE                                                  *
3
*&--------------------------------------------------------------------*
4
* process upgrade                                                     *
5
*---------------------------------------------------------------------*
6
* U_MODE --> ' ' - client 000, 'O' - other client, others - remote sys*
7
*---------------------------------------------------------------------*
8
FORM upgrade USING value(u_mode) TYPE c.
9
  DATA: u_kind, u_update_happened, trans_pattern(8) TYPE c,
10
        hf TYPE i, u_client LIKE sy-mandt, u_tabind LIKE sy-tabix,
11
        u_it000 LIKE vim_t000 OCCURS 10, u_title(40) TYPE c,
12
        u_remote_sys LIKE rfcdes-rfcdest, u_t000 LIKE vim_t000,
13
        u_counter TYPE i, u_del_cnt TYPE i, u_rc TYPE i, hf1 TYPE i,
14
        u_funcsafe(4) TYPE c, u_txt_fu_beg TYPE i, u_txt_fu_lg TYPE i,
15
        u_newversion(1) TYPE c VALUE 'X', u_mark_entries(1) TYPE c,
16
        u_action(1) TYPE c, u_specmode_safe(1) TYPE c,
17
        u_called_from(1) TYPE c, u_oc_exst LIKE ntab_cmp-flag,
18
        u_sellist TYPE vimsellist_type, sellines TYPE i.
19
  CONSTANTS: u_text_frm(30) TYPE c VALUE 'FILL_TEXTTAB_KEY'.
20
  FIELD-SYMBOLS: <u_f1> TYPE x, <u_sellist> TYPE vimsellist_type,
21
                 <w_sellist> TYPE vimsellist.
22
 
23
* data and field symbols for copying the extract to and from
24
* the compare tool container:
25
  DATA:
26
    cmp_container_ref    TYPE REF TO data,
27
    cmp_container_wa_ref TYPE REF TO data,
28
    extract_len          TYPE i,
29
    subrc_buf            TYPE sy-subrc.
30
  FIELD-SYMBOLS:
31
    <cmp_cont>    TYPE STANDARD TABLE,
32
    <cmp_cont_wa> TYPE ANY,
33
    <x_dummy>     TYPE x.
34
 
35
  READ TABLE excl_cua_funct WITH KEY function = 'CMPR'.
36
  IF sy-subrc EQ 0.                    "upgrade is not allowed
37
    MESSAGE s001(sv).
38
    EXIT.
39
  ENDIF.
40
* upgrade with client 0 only if current client <> 000
41
* upgrade with other clients only if objects are clientdependent
42
  IF u_mode EQ space AND sy-mandt EQ '000' OR  "upgrade with client 000
43
     ( u_mode EQ space OR u_mode EQ 'O' ) AND
44
     x_header-clidep EQ space.
45
    MESSAGE s001(sv).
46
    EXIT.
47
  ENDIF.
48
* send warning if address number could be changed
49
  IF status-action EQ aendern AND
50
   ( x_header-adrnbrflag NE space AND x_header-adrnbrflag <> 'N' ).
51
    PERFORM set_pf_status USING 'ERROR'.
52
    MESSAGE i139(sv). "Adreßdaten werden nicht übernommen
53
    PERFORM set_pf_status USING status.
54
  ENDIF.
55
  CLEAR: u_client, u_remote_sys.
56
  IF u_mode EQ space.
57
    u_client = '000'.
58
  ELSEIF u_mode EQ 'O'.
59
    IF vim_default_upgr_clnt-client NE space AND
60
       vim_default_upgr_clnt-viewname EQ x_header-viewname.
61
      u_client = vim_default_upgr_clnt-client.
62
    ENDIF.
63
  ELSE.
64
    IF vim_default_rfc_dest-rfcdest NE space AND
65
       vim_default_rfc_dest-viewname EQ x_header-viewname.
66
      u_remote_sys = vim_default_rfc_dest-rfcdest.
67
    ENDIF.
68
  ENDIF.
69
  IF vim_special_mode EQ vim_direct_upgrade.
70
    function = 'ABR'.                  "avoid processing detail screen
71
    PERFORM fill_extract. CLEAR function.
72
    u_specmode_safe = vim_special_mode.
73
    ASSIGN dba_sellist[] TO <u_sellist>.
74
  ELSE.
75
    ASSIGN <vim_ck_sellist> TO <u_sellist>.
76
  ENDIF.
77
  vim_special_mode = vim_upgrade.
78
  MOVE: geloescht TO trans_pattern, aendern TO trans_pattern+1(1),
79
        neuer_geloescht TO trans_pattern+2(1),
80
        neuer_eintrag   TO trans_pattern+3(1),
81
        update_geloescht TO trans_pattern+4(1),
82
        aendern         TO trans_pattern+5(1),
83
        original  TO trans_pattern+6(1),
84
        aendern TO trans_pattern+7(1).
85
  IF x_header-bastab EQ space.         "view
86
    u_kind = 'V'.
87
  ELSE.
88
    IF x_header-texttbexst EQ space.   "base table
89
      u_kind = 'T'.
90
    ELSE.                              "base table with text table
91
      u_kind = 'X'.
92
    ENDIF.
93
  ENDIF.
94
 
95
* Add collapsed or merged timedep. entries
96
  IF x_header-delmdtflag NE space.
97
    DESCRIBE TABLE vim_collapsed_mainkeys LINES hf.
98
    DESCRIBE TABLE vim_merged_entries.
99
    IF sy-tfill GT 0 OR hf GT 0.
100
      vim_ignore_collapsed_mainkeys = 'X'.
101
      PERFORM fill_extract.
102
      CLEAR vim_ignore_collapsed_mainkeys.
103
    ENDIF.
104
  ENDIF.
105
  IF ( vim_system_type NE 'SAP' AND sy-mandt EQ '000' )
106
   OR x_header-importable = vim_not_importable.
107
    u_action = anzeigen.
108
  ELSE.
109
    u_action = status-action.
110
  ENDIF.
111
  TRANSLATE u_action USING 'SCUA'.
112
  IF vim_adjust_middle_level_mode NE space.
113
    TRANSLATE u_action USING 'Aa'.
114
  ENDIF.
115
  u_called_from = vim_special_adjust_mode.
116
  TRANSLATE u_called_from USING ' VSFXF'.
117
  IF NOT vim_oc_inst IS INITIAL.
118
* data access restricted?
119
    IF ( u_action = 'C'
120
         AND NOT vim_oc_inst->oc_selcrit_read_tab IS INITIAL )
121
     OR ( 'Aa' CS u_action
122
          AND NOT vim_oc_inst->oc_selcrit_maint_tab IS INITIAL ).
123
      u_oc_exst = 'X'.
124
    ENDIF.
125
  ENDIF.
126
  APPEND LINES OF <u_sellist> TO u_sellist.
127
  DELETE u_sellist WHERE from_auth <> space
128
   AND ddic <> 'S' AND ddic <> 'B'.
129
  IF sy-subrc = 0.
130
    DESCRIBE TABLE u_sellist LINES sellines.
131
    IF sellines GT 0.
132
      READ TABLE u_sellist INDEX sellines ASSIGNING <w_sellist>.
133
      CLEAR <w_sellist>-and_or.
134
    ENDIF.
135
  ENDIF.
136
 
137
* copy extract to compare tool container
138
  DESCRIBE FIELD extract LENGTH extract_len IN BYTE MODE.
139
  IF extract_len <= 64.
140
    CREATE DATA cmp_container_ref TYPE TABLE OF tbl64.
141
    ASSIGN cmp_container_ref->* TO <cmp_cont>.
142
    CREATE DATA cmp_container_wa_ref TYPE tbl64.
143
    ASSIGN cmp_container_wa_ref->* TO <cmp_cont_wa>.
144
  ELSEIF extract_len <= 256.
145
    CREATE DATA cmp_container_ref TYPE TABLE OF tbl256.
146
    ASSIGN cmp_container_ref->* TO <cmp_cont>.
147
    CREATE DATA cmp_container_wa_ref TYPE tbl256.
148
    ASSIGN cmp_container_wa_ref->* TO <cmp_cont_wa>.
149
  ELSEIF extract_len <= 1024.
150
    CREATE DATA cmp_container_ref TYPE TABLE OF tbl1024.
151
    ASSIGN cmp_container_ref->* TO <cmp_cont>.
152
    CREATE DATA cmp_container_wa_ref TYPE tbl1024.
153
    ASSIGN cmp_container_wa_ref->* TO <cmp_cont_wa>.
154
  ELSEIF extract_len <= 4096.
155
    CREATE DATA cmp_container_ref TYPE TABLE OF tbl4096.
156
    ASSIGN cmp_container_ref->* TO <cmp_cont>.
157
    CREATE DATA cmp_container_wa_ref TYPE tbl4096.
158
    ASSIGN cmp_container_wa_ref->* TO <cmp_cont_wa>.
159
  ELSEif extract_len <= 8192.
160
    CREATE DATA cmp_container_ref TYPE TABLE OF tbl8192.
161
    ASSIGN cmp_container_ref->* TO <cmp_cont>.
162
    CREATE DATA cmp_container_wa_ref TYPE tbl8192.
163
    ASSIGN cmp_container_wa_ref->* TO <cmp_cont_wa>.
164
  else.
165
    CREATE DATA cmp_container_ref TYPE TABLE OF tbl32000.
166
    ASSIGN cmp_container_ref->* TO <cmp_cont>.
167
    CREATE DATA cmp_container_wa_ref TYPE tbl32000.
168
    ASSIGN cmp_container_wa_ref->* TO <cmp_cont_wa>.
169
  ENDIF.
170
 
171
  ASSIGN <cmp_cont_wa> TO <x_dummy> CASTING.
172
  LOOP AT extract.
173
    CLEAR <x_dummy>.
174
    <x_dummy> = <vim_xextract>.
175
    APPEND <cmp_cont_wa> TO <cmp_cont>.
176
  ENDLOOP.
177
 
178
  CALL FUNCTION 'SCT1_VIEW_COMPARE_AND_ADJUST'
179
       EXPORTING
180
            iv_view_name              = x_header-maintview  "VIEWNAME
181
*             IV_VIEW_VARIANT    =
182
            iv_kind                   = u_kind
183
            iv_mode                   = u_action
184
*             IV_LANGUAGE        = SY-LANGU
185
*             IV_CLIENT_REMOTE   = U_CLIENT
186
            iv_rfc_destination        = u_remote_sys
187
            iv_called_from            = u_called_from
188
            iv_data_access_restricted = u_oc_exst
189
       IMPORTING
190
            ev_update          = u_update_happened
191
            ev_mark_entries    = u_mark_entries
192
       TABLES
193
            it_header          = x_header
194
            it_namtab          = x_namtab
195
            it_sellist         = u_sellist
196
            ct_box             = <cmp_cont>
197
       EXCEPTIONS
198
            canceled           = 1
199
            wrong_parameter    = 2
200
            compare_error      = 3
201
            OTHERS             = 4.
202
  subrc_buf = sy-subrc.
203
 
204
* copy compare tool container back to extract
205
  REFRESH extract.
206
  LOOP AT <cmp_cont> ASSIGNING <cmp_cont_wa>.
207
    ASSIGN <cmp_cont_wa> TO <x_dummy> CASTING.
208
    <vim_xextract> = <x_dummy>(extract_len).
209
    APPEND extract.
210
  ENDLOOP.
211
 
212
  sy-subrc = subrc_buf.
213
  IF sy-subrc GT 01.
214
    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
215
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
216
    MESSAGE s135(sv). sy-subrc = 01.
217
  ENDIF.
218
  IF status-action EQ anzeigen AND u_update_happened NE space.
219
    sy-subrc = 1.
220
  ENDIF.
221
  CASE sy-subrc.
222
    WHEN 0.
223
      IF u_update_happened NE space.
224
* transfer changed entries from EXTRACT into TOTAL
225
        CLEAR: u_counter, u_del_cnt. replace_mode = 'X'.
226
        DESCRIBE TABLE extract LINES maxlines.
227
* 1st: handle deleted entries
228
        LOOP AT extract.
229
          IF <xact> EQ original.
230
            DELETE extract. CONTINUE.
231
          ENDIF.
232
          CHECK <xact> EQ geloescht OR <xact> EQ neuer_geloescht OR
233
                <xact> EQ update_geloescht.
234
          hf = sy-tabix.
235
          READ TABLE total WITH KEY <vim_xextract_key> BINARY SEARCH.
236
          IF sy-subrc NE 0 OR ( sy-subrc EQ 0 AND <action> EQ <xact> ).
237
            DELETE extract. CONTINUE.
238
          ENDIF.
239
          <mark> = markiert. ADD 1 TO mark_total.
240
          MODIFY total INDEX sy-tabix.
241
          <xmark> = markiert. ADD 1 TO mark_extract.
242
          MODIFY extract.
243
          IF vim_special_adjust_mode EQ subset.
244
            PERFORM vim_restore_subset_conds.
245
          ENDIF.
246
          PERFORM vim_process_view_entry USING hf 'DELE' u_rc.
247
          CHECK u_rc NE 4.
248
          IF u_rc EQ 8.
249
            EXIT.
250
          ENDIF.
251
          ADD: counter TO u_del_cnt, 1 TO u_counter.
252
        ENDLOOP.
253
        IF u_counter GT u_del_cnt.
254
          SUBTRACT u_del_cnt FROM u_counter.
255
          MESSAGE i116(sv) WITH u_counter. "& Einträge konnten nicht g
256
        ENDIF.
257
        CLEAR u_counter.
258
        IF status-type EQ einstufig.
259
          CLEAR: ok_code, function.
260
        ELSE.
261
          function = ok_code = 'COMP'.
262
        ENDIF.
263
* 2nd: handle changed entries
264
        ASSIGN <vim_xtotal>(x_header-tablen) TO <u_f1>.
265
        LOOP AT extract.
266
          IF <xact> NE aendern AND <xact> NE neuer_eintrag.
267
            DELETE extract. CONTINUE.
268
          ENDIF.
269
          hf = sy-tabix.
270
          READ TABLE total WITH KEY <vim_xextract_key> BINARY SEARCH.
271
          IF sy-subrc EQ 0.            "entry exists in current client
272
            IF extract EQ total. "no changes -> delete and continue
273
              DELETE extract. CONTINUE.
274
            ELSEIF <xact> EQ neuer_eintrag AND "new entry exists and
275
                <action> EQ geloescht OR <action> EQ neuer_geloescht OR
276
                 <action> EQ update_geloescht."entry deleted in cur clnt
277
              status-delete = geloescht. " -> first undelete it
278
              <xact> = <action>. MODIFY extract. u_funcsafe = function.
279
              IF vim_special_adjust_mode EQ subset.
280
                PERFORM vim_restore_subset_conds.
281
              ENDIF.
282
              PERFORM vim_mark_and_process USING hf 'UNDO' hf1 u_rc.
283
              CLEAR status-delete. function = u_funcsafe.
284
              vim_special_mode = vim_upgrade.
285
              CHECK u_rc NE 4.
286
              IF u_rc EQ 8.
287
                EXIT.
288
              ENDIF.
289
              READ TABLE extract INDEX hf.
290
              READ TABLE total WITH KEY <vim_xextract_key>
291
                                                      BINARY SEARCH.
292
              IF <u_f1> EQ <table2_x>.   "no changes after undo
293
                DELETE extract. CONTINUE."delete & continue
294
              ELSE.
295
                <xact> = aendern. MODIFY extract.
296
              ENDIF.
297
            ELSEIF <u_f1> EQ <table2_x>. "no changes -> delete and cont
298
              DELETE extract. CONTINUE.
299
            ELSEIF <xact> EQ neuer_eintrag AND <action> EQ original.
300
              <xact> = aendern. MODIFY extract.
301
            ENDIF.
302
          ENDIF.                       "sy-subrc eq 0.
303
          IF vim_special_adjust_mode EQ subset.
304
            PERFORM vim_restore_subset_conds.
305
          ENDIF.
306
          PERFORM vim_modify_view_entry USING hf u_rc.
307
          CHECK u_rc NE 4.
308
          IF u_rc EQ 8.
309
            EXIT.
310
          ENDIF.
311
          IF u_mark_entries NE space.  "mark ajusted entries
312
            READ TABLE total WITH KEY <vim_xtotal_key> BINARY SEARCH
313
                             TRANSPORTING NO FIELDS.
314
            IF <mark> EQ nicht_markiert.
315
              <mark> = markiert. ADD 1 TO mark_total.
316
              MODIFY total INDEX sy-tabix.
317
              ADD 1 TO mark_extract.
318
            ENDIF.
319
          ENDIF.
320
          extract = total.
321
          MODIFY extract.
322
          ADD 1 TO u_counter.
323
        ENDLOOP.
324
        IF temporal_delimitation_happened NE space.
325
          REFRESH vim_delim_entries.
326
          CLEAR temporal_delimitation_happened.
327
        ENDIF.
328
        status-data = title-data = auswahldaten.
329
        nextline = l = 1.
330
        IF u_del_cnt NE 0 AND u_counter NE 0.
331
          MESSAGE s140(sv) "&1 Einträge geloescht, &2 Einträge übernom
332
            WITH u_del_cnt u_counter.
333
        ELSEIF u_del_cnt NE 0.
334
          MESSAGE s011(sv) WITH u_del_cnt. "Anzahl gelöschter Einträge
335
        ELSE.
336
          MESSAGE s012(sv) WITH u_counter. "Anzahl veränderter Einträg
337
        ENDIF.
338
        CLEAR replace_mode.
339
      ELSE.                            "no update happened
340
        IF x_header-delmdtflag NE space.
341
          PERFORM fill_extract. "consider collapsed or merged entries
342
        ENDIF.
343
      ENDIF.                           "u_update_happend ne space
344
      DESCRIBE TABLE extract LINES maxlines.
345
      nextline = 1.
346
      IF vim_special_adjust_mode NE space.
347
        CLEAR: vim_special_mode, vim_special_adjust_mode,
348
               <status>-upd_flag, maxlines, <status>-maxlines.
349
        vim_next_screen = 0. vim_leave_screen = 'X'.
350
        IF vim_adjust_middle_level_mode NE space.
351
          function = 'SAVE'.
352
        ENDIF.
353
      ENDIF.
354
    WHEN 1. "ignore changes in EXTRACT --> restore EXTRACT from TOTAL
355
      IF vim_special_adjust_mode NE space.
356
        CLEAR: vim_special_mode, vim_special_adjust_mode,
357
               <status>-upd_flag, maxlines, <status>-maxlines.
358
        vim_next_screen = 0. vim_leave_screen = 'X'.
359
        IF vim_adjust_middle_level_mode NE space.
360
          function = 'SAVE'.
361
        ENDIF.
362
      ENDIF.
363
      PERFORM fill_extract.
364
    WHEN OTHERS. RAISE upgrade_view_failed.
365
  ENDCASE.
366
  CLEAR vim_special_mode.
367
ENDFORM.                               " UPGRADE