Properties SourceCde
txt
1
*&--------------------------------------------------------------------*
2
*&      Form PREPARE_SAVING                                           *
3
*&--------------------------------------------------------------------*
4
* prepare saving of changed data in data base                         *
5
*&--------------------------------------------------------------------*
6
* <-- SY-SUBRC: 0 - ok, save, others: - don't save                    *
7
* SY-SUBRC soll abgelöst werden durch:
8
* <-- VIM_ABORT_SAVING: space -> save, others -> don't save
9
*&--------------------------------------------------------------------*
10
FORM prepare_saving.
11
  DATA: rc LIKE sy-subrc,
12
        ps_addr_ref LIKE addr_ref, ps_transp_addrs(1) TYPE c,
13
        ps_e071k_tab LIKE e071k OCCURS 0, ps_tot_ix TYPE i,
14
        ps_ko200 LIKE ko200, ps_addrrc LIKE szad_field-returncode,
15
        ps_ko200_tab LIKE ko200 OCCURS 0, addr_e071 LIKE e071,
16
        addr_e071k LIKE e071k, dummy TYPE char1,
17
        ps_addr_errtab LIKE addr_error OCCURS 0 WITH HEADER LINE,
18
        new_addr_group TYPE ad_group, object_key TYPE ad_objkey.
19
 
20
  FIELD-SYMBOLS: <object_key_x> TYPE x, <addr_key> TYPE x.
21
 
22
  IF vim_adjust_middle_level_mode EQ subset.
23
    x_header[] = vim_adj_header.
24
    READ TABLE x_header INDEX 1.
25
    x_namtab[] = vim_adj_namtab.
26
  ENDIF.
27
  CLEAR vim_abort_saving.
28
  IF <status>-upd_checkd EQ space.
29
    PERFORM check_upd.
30
  ENDIF.
31
  IF <status>-upd_flag NE space.
32
    IF maint_mode EQ aendern.
33
      CLEAR sy-subrc.
34
      IF x_header-frm_bf_sav NE space.
35
        PERFORM (x_header-frm_bf_sav) IN PROGRAM.
36
*       CHECK SY-SUBRC EQ 0. "if sy-subrc ne 0 don't save -> exit
37
        IF sy-subrc <> 0 OR vim_abort_saving NE space.
38
          vim_abort_saving = 'X'. sy-subrc = 8.
39
          EXIT.
40
        ENDIF.
41
      ENDIF.
42
      IF x_header-texttbexst <> space.
43
        PERFORM vim_set_texttab_action_delete.          "SW Texttransl
44
      ENDIF.
45
      IF vim_client_state IS INITIAL OR
46
       ( vim_called_by_cluster <> space AND       "SW  CSS 80009987/1998
47
          vim_client_state = vim_noact ).
48
        CALL FUNCTION 'VIEW_GET_CLIENT_STATE'
49
             IMPORTING
50
                  transp_state = vim_client_state.
51
      ENDIF.
52
    ENDIF.
53
    PERFORM vim_bc_logs_maintain USING x_header
54
                                       vim_import_profile
55
                                 CHANGING vim_bc_entry_list.
56
   IF ( vim_no_dialog EQ space OR vim_import_mode_active NE space ) AND
57
        ( vim_client_state EQ vim_log OR maint_mode EQ transportieren ).
58
      IF corr_nbr NE space AND corr_nbr NE <status>-corr_nbr.
59
        <status>-corr_nbr = corr_nbr.
60
      ENDIF.
61
      IF maint_mode EQ transportieren.
62
        IF <status>-corr_nbr EQ space.
63
          PERFORM request_corr_number.
64
          IF x_header-flag NE vim_transport_denied AND
65
             <status>-l_corr_nbr NE <status>-corr_nbr.
66
            PERFORM prepare_corr.
67
          ENDIF.
68
        ENDIF.
69
      ELSE.
70
        PERFORM check_transp_objs_for_maint USING rc.
71
        IF rc NE 0.
72
          RAISE missing_corr_number.
73
        ENDIF.
74
        IF x_header-flag NE vim_transport_denied.
75
          PERFORM prepare_corr.
76
          PERFORM update_corr.
77
        ENDIF.
78
      ENDIF.
79
      PERFORM corr_upd.
80
*    elseif not VIM_BC_ENTRY_LIST is initial.
81
* fill corr_keytab for bc-set import log
82
*      perform vim_bc_fill_corr_keytab.
83
    ENDIF.
84
    IF vim_import_testmode NE space.   "testrun for import
85
      CLEAR <status>-upd_flag.         "do not save if testrun happens
86
      vim_import_no_message = 'X'.
87
      PERFORM vim_process_message USING 'SV' 'I' 'I' '154'
88
                                        space space space space.
89
      CLEAR vim_import_no_message.
90
    ELSE.
91
* log begin of database changes
92
      CALL FUNCTION 'VIEW_WRITE_CHANGELOG_HEADER'
93
           EXPORTING
94
                viewname = x_header-viewname
95
                bastab   = x_header-bastab
96
                begin    = 'X'
97
                clidep   = x_header-clidep.
98
* save addresses.
99
      IF x_header-adrnbrflag EQ 'N'.   "only new technique
100
        ASSIGN: object_key TO <object_key_x> CASTING,
101
                ps_addr_ref-appl_key TO <addr_key> CASTING.
102
        IF ( maint_mode EQ transportieren OR
103
             vim_client_state EQ vim_log ) AND
104
           x_header-flag NE vim_transport_denied.
105
          IF x_header-flag EQ space.   "standard logging required
106
            LOOP AT vim_addr_e071_tab INTO addr_e071.
107
              addr_e071-trkorr = <status>-corr_nbr.
108
              MODIFY vim_addr_e071_tab FROM addr_e071.
109
              ps_ko200 = addr_e071.
110
              APPEND ps_ko200 TO ps_ko200_tab.
111
            ENDLOOP.
112
            ps_transp_addrs = 'X'.
113
          ENDIF.
114
        ENDIF.
115
        LOOP AT vim_addresses_to_save
116
                                  WHERE viewname EQ x_header-viewname.
117
*          <f1_x> = vim_addresses_to_save-handle.
118
          <f1_x> = <vim_addr_handle_x>.
119
          READ TABLE total WITH KEY <f1_x> BINARY SEARCH.
120
          ps_tot_ix = sy-tabix.
121
          object_key = vim_addresses_to_save-handle.
122
          IF <action> NE geloescht AND <action> NE neuer_geloescht AND
123
             <action> NE update_geloescht.
124
* save adress
125
            REFRESH ps_e071k_tab.
126
            APPEND LINES OF vim_addr_e071k_tab TO ps_e071k_tab.
127
            IF vim_addresses_to_save-addrnumber CP '@NEW*'.
128
* new address
129
              ps_addr_ref-appl_table = vim_tsadrv-tablename.
130
              ps_addr_ref-appl_field = vim_tsadrv-fieldname.
131
              ps_addr_ref-appl_key   = object_key.
132
              ps_addr_ref-addr_group = vim_addr_group.
133
              ps_addr_ref-owner = 'X'.
134
              CALL FUNCTION 'ADDR_NUMBER_GET'
135
                   EXPORTING
136
                       address_handle    = vim_addresses_to_save-handle
137
                        address_reference = ps_addr_ref
138
*                     PERSONAL_ADDRESS           = ' '
139
*                     NUMBERRANGE_NUMBER         = '01'
140
                        generate_transport_entries = ps_transp_addrs
141
*                     OWNER                      = 'X'
142
                        table_name  = vim_addr_basetable
143
                        field_name  = vim_addr_bastab_field
144
                        objkey      = object_key
145
                   IMPORTING
146
                      address_number = vim_addresses_to_save-addrnumber
147
*                     RETURNCODE_NUMBERRANGE     =
148
                   TABLES
149
                        e071k_tab                  = ps_e071k_tab
150
                   EXCEPTIONS
151
                        address_handle_not_exist   = 1
152
                        internal_error             = 2
153
                        parameter_error            = 3.
154
              IF sy-subrc NE 0.
155
                MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno WITH
156
                           sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
157
                RAISE saving_correction_failed.
158
              ENDIF.
159
            ELSE.
160
* existing address
161
              IF ps_transp_addrs NE space.
162
                CALL FUNCTION 'ADDR_TRANSPORT_ENTRIES'
163
                     EXPORTING
164
                          addrnumber = vim_addresses_to_save-addrnumber
165
                          table_name = vim_addr_basetable
166
                          field_name = vim_addr_bastab_field
167
                          objkey     = object_key
168
                     TABLES
169
                          e071k_tab  = ps_e071k_tab.
170
              ENDIF.
171
            ENDIF.                       "new address
172
          <vim_total_address_number> = vim_addresses_to_save-addrnumber.
173
            TRANSLATE <action> USING ' U'.
174
            READ TABLE extract WITH KEY <vim_xtotal_key>
175
                               TRANSPORTING NO FIELDS.
176
            IF sy-subrc EQ 0.
177
              extract = total. MODIFY extract INDEX sy-tabix.
178
            ENDIF.
179
            MODIFY total INDEX ps_tot_ix.
180
            IF ps_transp_addrs NE space.
181
              CALL FUNCTION 'TR_OBJECTS_INSERT'
182
                   EXPORTING
183
                        wi_order = <status>-order_nbr
184
                   TABLES
185
                        wt_ko200 = ps_ko200_tab
186
                        wt_e071k = ps_e071k_tab
187
                   EXCEPTIONS
188
                        OTHERS   = 8.
189
              IF sy-subrc NE 0.
190
                MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno WITH
191
                           sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
192
                RAISE saving_correction_failed.
193
              ENDIF.
194
            ENDIF.
195
            CALL FUNCTION 'ADDR_SINGLE_SAVE'
196
                 EXPORTING
197
                    address_number         = <vim_total_address_number>
198
*                   PERSON_NUMBER          = ' '
199
*                   ADDRESS_TYPE           = 1
200
*                   EXECUTE_IN_UPDATE_TASK = ' '
201
                 EXCEPTIONS
202
                      address_not_exist      = 1
203
                      person_not_exist       = 2
204
                      address_number_missing = 3
205
                      reference_missing      = 4
206
                      internal_error         = 5
207
                      database_error         = 6
208
                      parameter_error        = 7.
209
            IF sy-subrc NE 0.
210
              MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno WITH
211
                         sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
212
              RAISE saving_correction_failed.
213
            ENDIF.
214
            CALL FUNCTION 'ADDR_DEQUEUE'
215
                 EXPORTING
216
                      address_number    = <vim_total_address_number>
217
                 EXCEPTIONS
218
                      address_not_exist = 1
219
                      internal_error    = 2
220
                      OTHERS            = 3.
221
          ELSEIF <action> EQ neuer_geloescht.
222
* reset address (UF557286/2000)
223
            CALL FUNCTION 'ADDR_SINGLE_RESET'
224
              EXPORTING
225
                address_handle         = vim_addresses_to_save-handle
226
              EXCEPTIONS
227
*               NUMBER_NOT_FOUND       = 1
228
*               HANDLE_NOT_FOUND       = 2
229
*               PARAMETER_ERROR        = 3
230
                internal_error         = 1
231
                OTHERS                 = 0.
232
            IF sy-subrc = 1.
233
              MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
234
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
235
            ENDIF.
236
          ENDIF.
237
          DELETE vim_addresses_to_save.
238
        ENDLOOP.                       "at vim_addresses to save.
239
* Delete addresses (temporary: put address into address-groups CADE or
240
* ZADE)
241
        IF vim_addr_group = 'CA01'.
242
          new_addr_group = 'CADE'.
243
        ELSEIF vim_addr_group = 'ZA01'.
244
          new_addr_group = 'ZADE'.
245
        ENDIF.
246
        IF NOT new_addr_group IS INITIAL.
247
          LOOP AT total.
248
            CHECK
249
             ( <action> EQ geloescht OR <action> EQ update_geloescht )
250
             AND <vim_total_address_number> NP '@NEW*'.
251
            <object_key_x> = <f1_x>.
252
            IF ps_transp_addrs NE space.
253
              REFRESH ps_e071k_tab.
254
              APPEND LINES OF vim_addr_e071k_tab TO ps_e071k_tab.
255
              CALL FUNCTION 'ADDR_TRANSPORT_ENTRIES'
256
                   EXPORTING
257
                        addrnumber = <vim_total_address_number>
258
                        table_name = vim_addr_basetable
259
                        field_name = vim_addr_bastab_field
260
                        objkey     = object_key
261
                   TABLES
262
                        e071k_tab  = ps_e071k_tab.
263
              CALL FUNCTION 'TR_OBJECTS_INSERT'
264
                   EXPORTING
265
                        wi_order = <status>-order_nbr
266
                   TABLES
267
                        wt_ko200 = ps_ko200_tab
268
                        wt_e071k = ps_e071k_tab
269
                   EXCEPTIONS
270
                        OTHERS   = 8.
271
              IF sy-subrc NE 0.
272
                MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno WITH
273
                           sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
274
                RAISE saving_correction_failed.
275
              ENDIF.
276
            ENDIF.
277
*            PS_ADDR_REF-APPL_TABLE = vim_tsadrv-TABLENAME.
278
*            PS_ADDR_REF-APPL_FIELD = vim_tsadrv-FIELDNAME.
279
*            PS_ADDR_REF-APPL_KEY   = <VIM_TOTAL_KEY>.
280
*            PS_ADDR_REF-ADDR_GROUP = VIM_ADDR_GROUP.
281
*            PS_ADDR_REF-OWNER = 'X'.
282
*            CALL FUNCTION 'ADDR_DELETE'
283
*                 EXPORTING
284
**                   ADDRESS_HANDLE      = ' '
285
*                      ADDRESS_NUMBER      = <VIM_TOTAL_ADDRESS_NUMBER>
286
*                      ADDRESS_REFERENCE   = PS_ADDR_REF
287
**                   DATE_FROM           = '00010101'
288
*                 IMPORTING
289
*                      RETURNCODE          = PS_ADDRRC
290
*                 TABLES
291
*                      ERROR_TABLE         = PS_ADDR_ERRTAB
292
*                 EXCEPTIONS
293
*                      ADDRESS_NOT_EXIST   = 1
294
*                      PARAMETER_ERROR     = 2
295
*                      INTERNAL_ERROR      = 3
296
*                      REFERENCE_NOT_EXIST = 4.
297
*            IF SY-SUBRC NE 0.
298
            IF NOT <vim_total_address_number> IS INITIAL.
299
              CALL FUNCTION 'ADDR_GROUP_CHANGE'
300
                   EXPORTING
301
                        address_number    = <vim_total_address_number>
302
*                    ADDRESS_HANDLE    = ' '
303
                        new_address_group = new_addr_group
304
                   EXCEPTIONS
305
                        address_not_exist = 1
306
                        parameter_error   = 2
307
                        internal_error    = 3
308
                        OTHERS            = 4.
309
              IF sy-subrc = 1.
310
              ELSEIF sy-subrc = 2.
311
                MESSAGE i298(am) WITH new_addr_group.
312
*   Adreßgruppe & nicht definiert, Löschvormerkung für Adresse nicht mög
313
                RAISE saving_correction_failed.
314
              ELSEIF sy-subrc <> 0.
315
                MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
316
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
317
                RAISE saving_correction_failed.
318
              ENDIF.
319
*            ENDIF.
320
*            IF PS_ADDRRC NE SPACE.
321
*              LOOP AT PS_ADDR_ERRTAB.
322
*                MESSAGE ID PS_ADDR_ERRTAB-MSG_ID TYPE 'I'
323
*                        NUMBER PS_ADDR_ERRTAB-MSG_NUMBER WITH
324
*                        PS_ADDR_ERRTAB-MSG_VAR1 PS_ADDR_ERRTAB-MSG_VAR2
325
*                       PS_ADDR_ERRTAB-MSG_VAR3 PS_ADDR_ERRTAB-MSG_VAR4.
326
*              ENDLOOP.
327
*              IF PS_ADDRRC EQ 'E'.
328
*                RAISE SAVING_CORRECTION_FAILED.
329
*              ENDIF.
330
*            ENDIF.
331
              CALL FUNCTION 'ADDR_SINGLE_SAVE'
332
                   EXPORTING
333
                    address_number         = <vim_total_address_number>
334
*                   PERSON_NUMBER          = ' '
335
*                   ADDRESS_TYPE           = 1
336
*                   EXECUTE_IN_UPDATE_TASK = ' '
337
                   EXCEPTIONS
338
                        address_not_exist      = 1
339
                        person_not_exist       = 2
340
                        address_number_missing = 3
341
                        reference_missing      = 4
342
                        internal_error         = 5
343
                        database_error         = 6
344
                        parameter_error        = 7.
345
              IF sy-subrc NE 0 AND  sy-subrc NE 1.
346
                MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno WITH
347
                           sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
348
                RAISE saving_correction_failed.
349
              ENDIF.
350
            ENDIF.            "not <vim_total_address_number> is initial
351
          ENDLOOP.                                          "at total
352
        ENDIF.                         "new_addr_group not initial
353
        CLEAR sy-subrc.
354
      ENDIF.                           "x_header-adrnbrflag eq 'N'.
355
    ENDIF.                             "vim_import_testmode ne space.
356
  ELSE.
357
    IF vim_adjust_middle_level_mode EQ space.
358
      MESSAGE s043(sv).
359
      IF function = save AND vim_called_by_cluster = space.
360
        PERFORM vim_add_img_notices_pai USING 'S'
361
                                        CHANGING dummy.
362
      ENDIF.
363
    ELSE.
364
      vim_adjust_middle_level_mode = 'L'.
365
    ENDIF.
366
  ENDIF.                               "<status>-upd_flag ne space
367
ENDFORM.                               "prepare_saving