Properties SourceCde
txt
1
*-------------------------------------------------------------------
2
***INCLUDE LSVIMFTX .
3
*-------------------------------------------------------------------
4
*&--------------------------------------------------------------------*
5
*&      Form  TABLE_CALL_FUNCTION                                     *
6
*---------------------------------------------------------------------*
7
* call function TABLEPROC with proper parameters
8
*---------------------------------------------------------------------*
9
* TCF_FCODE    ---> current function code                             *
10
* TCF_TABTYPE  ---> type of int. table: SHORT, MIDDLE, LONG, VERY_LONG*
11
* TCF_UPD_fLAG <--- flag: update required                             *
12
*---------------------------------------------------------------------*
13
FORM table_call_function TABLES dba_sellist dpl_sellist
14
                                x_header STRUCTURE vimdesc
15
                                x_namtab excl_cua_funct
16
                         USING value(tcf_fcode) value(tcf_tabtype)
17
                               tcf_upd_flag.
18
 
19
  DATA: function_name LIKE tfdir-funcname VALUE 'TABLEPROC_',
20
        prefix_len TYPE i VALUE '10'.
21
 
22
  READ TABLE x_header INDEX 1.
23
  MOVE x_header-area TO function_name+prefix_len.
24
  IF function_name CA forbidden_func_name_chars.
25
    PERFORM replace_forbidden_chars USING forbidden_func_name_chars
26
                                          function_name.
27
  ENDIF.
28
  CASE tcf_tabtype.
29
    WHEN 'ULTRA_SHORT'.
30
      CALL FUNCTION function_name
31
        EXPORTING
32
          fcode                    = tcf_fcode
33
          view_action              = maint_mode
34
          view_name                = x_header-viewname
35
          corr_number              = corr_nbr
36
        IMPORTING
37
          ucomm                    = function
38
          update_required          = tcf_upd_flag
39
        TABLES
40
          dba_sellist              = dba_sellist
41
          dpl_sellist              = dpl_sellist
42
          excl_cua_funct           = excl_cua_funct
43
          x_header                 = x_header
44
          x_namtab                 = x_namtab
45
          corr_keytab              = e071k_tab
46
          extract                  = extract_us
47
          total                    = total_us
48
        EXCEPTIONS
49
          missing_corr_number      = 01
50
          saving_correction_failed = 03.
51
    WHEN 'VERY_SHORT'.
52
      CALL FUNCTION function_name
53
        EXPORTING
54
          fcode                    = tcf_fcode
55
          view_action              = maint_mode
56
          view_name                = x_header-viewname
57
          corr_number              = corr_nbr
58
        IMPORTING
59
          ucomm                    = function
60
          update_required          = tcf_upd_flag
61
        TABLES
62
          dba_sellist              = dba_sellist
63
          dpl_sellist              = dpl_sellist
64
          excl_cua_funct           = excl_cua_funct
65
          x_header                 = x_header
66
          x_namtab                 = x_namtab
67
          corr_keytab              = e071k_tab
68
          extract                  = extract_vs
69
          total                    = total_vs
70
        EXCEPTIONS
71
          missing_corr_number      = 01
72
          saving_correction_failed = 03.
73
    WHEN 'SHORT'.
74
      CALL FUNCTION function_name
75
        EXPORTING
76
          fcode                    = tcf_fcode
77
          view_action              = maint_mode
78
          view_name                = x_header-viewname
79
          corr_number              = corr_nbr
80
        IMPORTING
81
          ucomm                    = function
82
          update_required          = tcf_upd_flag
83
        TABLES
84
          dba_sellist              = dba_sellist
85
          dpl_sellist              = dpl_sellist
86
          excl_cua_funct           = excl_cua_funct
87
          x_header                 = x_header
88
          x_namtab                 = x_namtab
89
          corr_keytab              = e071k_tab
90
          extract                  = extract_s
91
          total                    = total_s
92
        EXCEPTIONS
93
          missing_corr_number      = 01
94
          saving_correction_failed = 03.
95
    WHEN 'MIDDLE'.
96
      CALL FUNCTION function_name
97
        EXPORTING
98
          fcode                    = tcf_fcode
99
          view_action              = maint_mode
100
          view_name                = x_header-viewname
101
          corr_number              = corr_nbr
102
        IMPORTING
103
          ucomm                    = function
104
          update_required          = tcf_upd_flag
105
        TABLES
106
          dba_sellist              = dba_sellist
107
          dpl_sellist              = dpl_sellist
108
          excl_cua_funct           = excl_cua_funct
109
          x_header                 = x_header
110
          x_namtab                 = x_namtab
111
          corr_keytab              = e071k_tab
112
          extract                  = extract_m
113
          total                    = total_m
114
        EXCEPTIONS
115
          missing_corr_number      = 01
116
          saving_correction_failed = 03.
117
    WHEN 'LONG'.
118
      CALL FUNCTION function_name
119
        EXPORTING
120
          fcode                    = tcf_fcode
121
          view_action              = maint_mode
122
          view_name                = x_header-viewname
123
          corr_number              = corr_nbr
124
        IMPORTING
125
          ucomm                    = function
126
          update_required          = tcf_upd_flag
127
        TABLES
128
          dba_sellist              = dba_sellist
129
          dpl_sellist              = dpl_sellist
130
          excl_cua_funct           = excl_cua_funct
131
          x_header                 = x_header
132
          x_namtab                 = x_namtab
133
          corr_keytab              = e071k_tab
134
          extract                  = extract_l
135
          total                    = total_l
136
        EXCEPTIONS
137
          missing_corr_number      = 01
138
          saving_correction_failed = 03.
139
    WHEN 'VERY_LONG'.
140
      CALL FUNCTION function_name
141
        EXPORTING
142
          fcode                    = tcf_fcode
143
          view_action              = maint_mode
144
          view_name                = x_header-viewname
145
          corr_number              = corr_nbr
146
        IMPORTING
147
          ucomm                    = function
148
          update_required          = tcf_upd_flag
149
        TABLES
150
          dba_sellist              = dba_sellist
151
          dpl_sellist              = dpl_sellist
152
          excl_cua_funct           = excl_cua_funct
153
          x_header                 = x_header
154
          x_namtab                 = x_namtab
155
          corr_keytab              = e071k_tab
156
          extract                  = extract_vl
157
          total                    = total_vl
158
        EXCEPTIONS
159
          missing_corr_number      = 01
160
          saving_correction_failed = 03.
161
    WHEN 'ULTRA_LONG'.
162
      CALL FUNCTION function_name
163
        EXPORTING
164
          fcode                    = tcf_fcode
165
          view_action              = maint_mode
166
          view_name                = x_header-viewname
167
          corr_number              = corr_nbr
168
        IMPORTING
169
          ucomm                    = function
170
          update_required          = tcf_upd_flag
171
        TABLES
172
          dba_sellist              = dba_sellist
173
          dpl_sellist              = dpl_sellist
174
          excl_cua_funct           = excl_cua_funct
175
          x_header                 = x_header
176
          x_namtab                 = x_namtab
177
          corr_keytab              = e071k_tab
178
          extract                  = extract_ul
179
          total                    = total_ul
180
        EXCEPTIONS
181
          missing_corr_number      = 01
182
          saving_correction_failed = 03.
183
  ENDCASE.
184
ENDFORM.                               " TABLE_CALL_FUNCTION
185
 
186
*&--------------------------------------------------------------------*
187
*&      Form  TABLE_GET_DATA                                          *
188
*---------------------------------------------------------------------*
189
* get data from database
190
*---------------------------------------------------------------------*
191
FORM table_get_data.
192
  CONSTANTS maxsellines TYPE i VALUE 500.
193
  DATA: tgd_sellist LIKE vimsellist OCCURS 10, tgd_sel LIKE vimsellist,
194
        tgd_sellangu LIKE vimsellist,
195
        short_sellist LIKE vimsellist OCCURS 10,
196
        short_sel LIKE vimsellist,
197
        tgd_ind TYPE i, tgd_field LIKE vimnamtab-viewfield,
198
        selnumber TYPE i, selindex TYPE i, selcut TYPE i,
199
        selpieces TYPE i.
200
  FIELD-SYMBOLS: <text_key>.
201
  DATA: primtab TYPE REF TO data, texttab TYPE REF TO data,
202
        w_texttab_save TYPE REF TO data, w_texttab TYPE REF TO data,
203
        text_keyflds TYPE vim_flds_tab_type.
204
 
205
  FIELD-SYMBOLS: <primtab> TYPE STANDARD TABLE,
206
                 <texttab> TYPE SORTED TABLE, <w_texttab> TYPE ANY,
207
                 <w_texttab_save> TYPE ANY, <textline_x> TYPE x.
208
 
209
  REFRESH total. CLEAR total.
210
  IF x_header-selection NE space.
211
    DESCRIBE TABLE dba_sellist LINES selnumber.
212
    IF selnumber > maxsellines.  "fragmentation of too large sellists
213
      CLEAR selpieces.
214
      CLEAR selindex.
215
      CREATE DATA primtab TYPE STANDARD TABLE OF (x_header-maintview).
216
      ASSIGN primtab->* TO <primtab>.
217
      WHILE selindex < selnumber.
218
        selpieces = selpieces + maxsellines.
219
        REFRESH short_sellist.
220
        CLEAR selcut.
221
        WHILE selcut EQ 0 AND selindex < selnumber.
222
          selindex = selindex + 1.
223
          READ TABLE dba_sellist INTO short_sel INDEX selindex.
224
          APPEND short_sel TO short_sellist.
225
          IF selindex > selpieces AND short_sel-and_or NE 'AND'.
226
            selcut = 1.
227
          ENDIF.
228
        ENDWHILE.
229
        CLEAR short_sel-and_or.      "last line without logic operation
230
        MODIFY short_sellist FROM short_sel INDEX selindex.
231
        CALL FUNCTION 'VIEW_FILL_WHERETAB'
232
           EXPORTING
233
                tablename               = x_header-maintview
234
*             ONLY_CNDS_FOR_KEYFLDS   = 'X' "use default SPACE
235
           TABLES
236
                sellist                 = short_sellist
237
                wheretab                = vim_wheretab
238
                x_namtab                = x_namtab
239
           EXCEPTIONS
240
                no_conditions_for_table = 01.
241
*       read data from database with morer wheretabs...................*
242
        SELECT * FROM (x_header-maintview) APPENDING TABLE <primtab>
243
                                          WHERE (vim_wheretab).
244
        CLEAR selcut.
245
      ENDWHILE.
246
    ELSE.                                  "selnumber > maxsellines
247
      CALL FUNCTION 'VIEW_FILL_WHERETAB'
248
           EXPORTING
249
                tablename               = x_header-maintview
250
*             ONLY_CNDS_FOR_KEYFLDS   = 'X' "use default SPACE
251
           TABLES
252
                sellist                 = dba_sellist
253
                wheretab                = vim_wheretab
254
                x_namtab                = x_namtab
255
           EXCEPTIONS
256
                no_conditions_for_table = 01.
257
*   read data from database with one wheretab..........................*
258
    CREATE DATA primtab TYPE STANDARD TABLE OF (x_header-maintview)."UCb
259
    ASSIGN primtab->* TO <primtab>.
260
    SELECT * FROM (x_header-maintview) INTO TABLE <primtab>
261
                                        WHERE (vim_wheretab).
262
    ENDIF.                                   "if selnumber > maxsellines
263
  ELSE.                                  "if x_header-selection NE space
264
    REFRESH vim_wheretab.
265
*   read data from database without wheretab...........................*
266
    CREATE DATA primtab TYPE STANDARD TABLE OF (x_header-maintview)."UCb
267
    ASSIGN primtab->* TO <primtab>.
268
    SELECT * FROM (x_header-maintview) INTO TABLE <primtab>.
269
  ENDIF.                                "if x_header-selection NE space
270
  IF x_header-texttbexst EQ space.
271
* no texttable
272
    LOOP AT <primtab> INTO <vim_total_struc>.
273
      APPEND total.
274
    ENDLOOP.                                                "UCe
275
    SORT total BY <vim_xtotal_key>. <status>-alr_sorted = 'R'.
276
    IF x_header-selection EQ space AND x_header-delmdtflag NE space.
277
* time dependence
278
      PERFORM build_mainkey_tab_0.
279
    ENDIF.
280
    LOOP AT total.
281
      CLEAR: <action>, <mark>.
282
      MODIFY total.
283
      IF x_header-selection EQ space AND x_header-delmdtflag NE space.
284
        PERFORM build_mainkey_tab_1.
285
      ENDIF.
286
    ENDLOOP.
287
    IF x_header-selection EQ space AND x_header-delmdtflag NE space.
288
      PERFORM build_mainkey_tab_2.
289
    ENDIF.
290
  ELSE.
291
* texttable exists
292
    PERFORM vim_get_text_keyflds USING x_header-texttab
293
                                 CHANGING text_keyflds.
294
    CREATE DATA texttab TYPE SORTED TABLE OF (x_header-texttab)
295
     WITH UNIQUE KEY (text_keyflds).                        "UCb
296
    ASSIGN texttab->* TO <texttab>.
297
    IF x_header-selection NE space.
298
* get selection for texttable
299
*      READ TABLE dba_sellist INTO dpl_sellist INDEX 1.
300
      DESCRIBE TABLE dba_sellist LINES selnumber.
301
      selindex = 0.
302
      WHILE selindex < selnumber.
303
        selindex = selindex + 1.
304
        READ TABLE dba_sellist INTO tgd_sel INDEX selindex.
305
        READ TABLE x_namtab WITH KEY
306
          viewfield = tgd_sel-viewfield texttabfld = space.
307
      CHECK x_namtab-keyflag = 'X'.        " key fields for texttab only
308
        tgd_sel-viewfield = x_namtab-txttabfldn.
309
        READ TABLE x_namtab WITH KEY
310
          viewfield = tgd_sel-viewfield texttabfld = 'X'.
311
        tgd_sel-tabix = sy-tabix.
312
        IF tgd_sel-and_or NE 'AND' OR selindex = 1.          "Langufield
313
          READ TABLE x_namtab WITH KEY primtabkey = 0 keyflag = 'X'.
314
          tgd_sellangu-viewfield = x_namtab-viewfield.
315
          tgd_sellangu-tabix     = sy-tabix.
316
          tgd_sellangu-operator = 'EQ'.
317
          tgd_sellangu-value = sy-langu.
318
          tgd_sellangu-and_or = 'AND'.
319
          IF tgd_sellangu-value EQ space.
320
            tgd_sellangu-initial = 'X'.
321
          ENDIF.
322
          tgd_sellangu-cond_kind = dpl_sellist-cond_kind.
323
          CLEAR tgd_sellangu-converted.
324
          APPEND tgd_sellangu TO tgd_sellist.
325
        ENDIF.
326
        APPEND tgd_sel TO tgd_sellist.
327
*      Did not work for sellist to describe more than one dataset in
328
*      transport request                                          "HCG
329
*      LOOP AT x_namtab WHERE keyflag NE space    "fill sellist for
330
*                         AND texttabfld NE space. "texttab
331
*        tgd_field = x_namtab-viewfield.
332
*        tgd_ind   = sy-tabix.
333
*        IF x_namtab-primtabkey EQ 0.   "langufield
334
*          tgd_sel-viewfield = tgd_field.
335
*          tgd_sel-tabix     = tgd_ind.
336
*          tgd_sel-operator = 'EQ'.
337
*          tgd_sel-value = sy-langu.
338
*          tgd_sel-and_or = 'AND'.
339
*          IF tgd_sel-value EQ space.
340
*            tgd_sel-initial = 'X'.
341
*          ENDIF.
342
*          tgd_sel-cond_kind = dpl_sellist-cond_kind.
343
*          clear tgd_sel-converted.
344
*          APPEND tgd_sel TO tgd_sellist.
345
*        ELSE.
346
*          READ TABLE x_namtab INDEX x_namtab-primtabkey.
347
*          LOOP AT dba_sellist WHERE viewfield EQ x_namtab-viewfield.
348
*            tgd_sel = dba_sellist.
349
*            tgd_sel-viewfield = tgd_field.
350
*            tgd_sel-tabix     = tgd_ind.
351
*            IF tgd_sel-and_or EQ space.
352
*              tgd_sel-and_or = 'AND'.
353
*            ENDIF.
354
*            APPEND tgd_sel TO tgd_sellist.
355
*          ENDLOOP.
356
*        ENDIF.
357
*      ENDLOOP.
358
      ENDWHILE.
359
      DESCRIBE TABLE tgd_sellist.
360
      READ TABLE tgd_sellist INDEX sy-tfill INTO tgd_sel.
361
      IF tgd_sel-and_or NE space.
362
        CLEAR tgd_sel-and_or.
363
        MODIFY tgd_sellist INDEX sy-tfill FROM tgd_sel.
364
      ENDIF.
365
    ELSE.
366
* no selection for primary table: fill selection with langu-field only
367
      LOOP AT x_namtab WHERE keyflag NE space    "fill sellist with
368
                         AND texttabfld NE space  "language condition
369
                         AND primtabkey EQ 0.
370
        tgd_sel-viewfield = x_namtab-viewfield.
371
        tgd_sel-tabix     = sy-tabix.
372
        tgd_sel-operator = 'EQ'.
373
        tgd_sel-value = sy-langu.
374
        tgd_sel-and_or = space.
375
        IF tgd_sel-value EQ space.
376
          tgd_sel-initial = 'X'.
377
        ENDIF.
378
        APPEND tgd_sel TO tgd_sellist.
379
        EXIT.
380
      ENDLOOP.
381
    ENDIF.
382
*    CALL FUNCTION 'VIEW_FILL_WHERETAB'
383
*      EXPORTING
384
*        tablename               = x_header-texttab
385
*        only_cnds_for_keyflds   = 'X'
386
*      TABLES
387
*        sellist                 = tgd_sellist
388
*        wheretab                = vim_wheretab
389
*        x_namtab                = x_namtab
390
*      EXCEPTIONS
391
*        no_conditions_for_table = 01.
392
** read texttable from database
393
*    SELECT * FROM (x_header-texttab) INTO TABLE <texttab>
394
*                                      WHERE (vim_wheretab).
395
    DESCRIBE TABLE tgd_sellist LINES selnumber.
396
    IF selnumber > maxsellines.  "fragmentation of too large sellists
397
      CLEAR selpieces.
398
      CLEAR selindex.
399
      WHILE selindex < selnumber.
400
        selpieces = selpieces + maxsellines.
401
        REFRESH short_sellist.
402
        CLEAR selcut.
403
        WHILE selcut EQ 0 AND selindex < selnumber.
404
          selindex = selindex + 1.
405
          READ TABLE tgd_sellist INTO short_sel INDEX selindex.
406
          APPEND short_sel TO short_sellist.
407
          IF selindex > selpieces AND short_sel-and_or NE 'AND'.
408
            selcut = 1.
409
          ENDIF.
410
        ENDWHILE.
411
        CLEAR short_sel-and_or.      "last line without logic operation
412
        MODIFY short_sellist FROM short_sel INDEX selindex.
413
        CALL FUNCTION 'VIEW_FILL_WHERETAB'
414
          EXPORTING
415
            tablename               = x_header-texttab
416
            only_cnds_for_keyflds   = 'X'
417
          TABLES
418
            sellist                 = short_sellist
419
            wheretab                = vim_wheretab
420
            x_namtab                = x_namtab
421
          EXCEPTIONS
422
            no_conditions_for_table = 01.
423
*       read data from database with morer wheretabs...................*
424
        SELECT * FROM (x_header-texttab) APPENDING TABLE <texttab>
425
                                          WHERE (vim_wheretab).
426
        CLEAR selcut.
427
      ENDWHILE.
428
    ELSE.                                  "selnumber > maxsellines
429
      CALL FUNCTION 'VIEW_FILL_WHERETAB'
430
        EXPORTING
431
          tablename               = x_header-texttab
432
          only_cnds_for_keyflds   = 'X'
433
        TABLES
434
          sellist                 = tgd_sellist
435
          wheretab                = vim_wheretab
436
          x_namtab                = x_namtab
437
        EXCEPTIONS
438
          no_conditions_for_table = 01.
439
*   read data from database with one wheretab..........................*
440
      SELECT * FROM (x_header-texttab) INTO TABLE <texttab>
441
                                        WHERE (vim_wheretab).
442
    ENDIF.                                   "if selnumber > maxsellines
443
    IF x_header-selection EQ space AND x_header-delmdtflag NE space.
444
      PERFORM build_mainkey_tab_0.
445
    ENDIF.
446
    CREATE DATA w_texttab_save TYPE (x_header-texttab).
447
    CREATE DATA w_texttab TYPE (x_header-texttab).
448
    ASSIGN: w_texttab->* TO <w_texttab>,
449
            w_texttab_save->* TO <w_texttab_save>,
450
            <w_texttab_save> TO <textline_x> CASTING.
451
    LOOP AT <primtab> INTO <vim_total_struc>.
452
*       hier aufbauen schlüssel texttabelle in feld text_key
453
      CLEAR <w_texttab>.
454
      PERFORM fill_texttab_key_uc USING <vim_total_struc>
455
                                  CHANGING <w_texttab>.
456
      IF <w_texttab> NE <w_texttab_save>.
457
        READ TABLE <texttab> INTO <w_texttab_save>
458
         FROM <w_texttab>.
459
        IF sy-subrc = 0.
460
*          MOVE <w_texttab_save> TO <w_textline>.
461
*          MOVE textline(x_header-texttablen) TO <total_text>.
462
        ELSE.
463
          MOVE <text_initial> TO <w_texttab_save>.
464
        ENDIF.
465
*      ELSE.
466
*        MOVE <w_texttab_save> TO <w_textline>.
467
*        MOVE textline(x_header-texttablen) TO <total_text>.
468
      ENDIF.
469
      MOVE <textline_x> TO <vim_xtotal_text>.
470
      CLEAR: <action>, <mark>, <action_text>.
471
      APPEND total.
472
      IF x_header-selection EQ space AND x_header-delmdtflag NE space.
473
        PERFORM build_mainkey_tab_1.
474
      ENDIF.
475
    ENDLOOP.
476
    SORT total BY <vim_xtotal_key>. <status>-alr_sorted = 'R'.
477
    IF x_header-selection EQ space AND x_header-delmdtflag NE space.
478
      PERFORM build_mainkey_tab_2.
479
    ENDIF.
480
  ENDIF.
481
*.check dynamic selectoptions (not in DDIC)...........................*
482
  IF x_header-selection NE space.
483
    PERFORM check_dynamic_select_options.
484
  ENDIF.
485
ENDFORM.                               " TABLE_GET_DATA
486
 
487
*&--------------------------------------------------------------------*
488
*&      Form  TABLE_DB_UPD                                            *
489
*---------------------------------------------------------------------*
490
* process data base updates/inserts/deletes
491
*---------------------------------------------------------------------*
492
FORM table_db_upd.
493
  DATA: modified_entries TYPE i, prt_frky_entries TYPE i, rc TYPE i,
494
        h_ix TYPE i,
495
        primtab_mod TYPE REF TO data,
496
        primtab_mod_wa TYPE REF TO data,
497
        texttab_mod TYPE REF TO data,
498
        w_texttab_mod TYPE REF TO data,
499
        e071_loctab TYPE vim_ko200_tab_type.
500
  FIELD-SYMBOLS: <mod_elem_tab> TYPE STANDARD TABLE, <h_keyx> TYPE x,
501
                 <mod_elem_wa> TYPE ANY,
502
                 <texttab> TYPE STANDARD TABLE, <w_texttab> TYPE ANY,
503
                 <textline_x> TYPE x.
504
 
505
* first of all: delete requests
506
  CREATE DATA primtab_mod TYPE TABLE OF (x_header-maintview).
507
  CREATE DATA primtab_mod_wa TYPE (x_header-maintview).
508
  ASSIGN: primtab_mod->* TO <mod_elem_tab>,
509
          primtab_mod_wa->* TO <mod_elem_wa>.
510
  LOOP AT total.
511
    CHECK ( <action> EQ geloescht OR <action> EQ update_geloescht OR
512
            <action> EQ neuer_geloescht ).
513
    IF <action> EQ neuer_geloescht.
514
      IF status-delete EQ geloescht.
515
        READ TABLE extract WITH KEY <vim_xtotal_key>.
516
        IF sy-subrc EQ 0.
517
          DELETE extract INDEX sy-tabix.
518
        ENDIF.
519
      ENDIF.
520
      DELETE total.
521
    ELSE.
522
      APPEND <vim_total_struc> TO <mod_elem_tab>.
523
      ADD 1 TO modified_entries.
524
      IF x_header-texttbexst EQ space. "no texttab
525
        IF status-delete EQ geloescht.
526
          READ TABLE extract WITH KEY <vim_xtotal_key>.
527
          IF sy-subrc EQ 0.
528
            DELETE extract INDEX sy-tabix.
529
          ENDIF.
530
        ENDIF.
531
        DELETE total.
532
      ENDIF.
533
    ENDIF.
534
  ENDLOOP.
535
  IF modified_entries NE 0.
536
    DELETE (x_header-maintview) FROM TABLE <mod_elem_tab>.
537
  ENDIF.
538
  IF x_header-texttbexst NE space.
539
    CLEAR modified_entries.
540
    CREATE DATA texttab_mod TYPE STANDARD TABLE OF (x_header-texttab).
541
    CREATE DATA w_texttab_mod TYPE (x_header-texttab).
542
    ASSIGN: texttab_mod->* TO <texttab>,
543
            w_texttab_mod->* TO <w_texttab>,
544
            <w_texttab> TO <textline_x> CASTING.
545
* delete texts for all deleted entities
546
    LOOP AT <mod_elem_tab> INTO <table1_wa>.
547
      READ TABLE total WITH KEY <f1_wax> BINARY SEARCH.
548
      h_ix = sy-tabix.
549
      IF x_header-ptfrkyexst NE space.
550
* partial foreign key relation:
551
* Are there still any primary table entries?
552
        PERFORM create_wheretab_new USING x_namtab[]
553
                                          <vim_total_struc>
554
                                          <vim_tot_txt_struc>
555
                                          x_header-maintview
556
                                          'X' rc.
557
        IF rc NE 0.                    "something seems to be wrong
558
          prt_frky_entries = 1.        "don't delete
559
        ELSE.
560
          SELECT COUNT(*) FROM (x_header-maintview) UP TO 1 ROWS
561
                          WHERE (vim_wheretab).
562
          prt_frky_entries = sy-dbcnt.
563
        ENDIF.
564
      ELSE.
565
        CLEAR prt_frky_entries.
566
      ENDIF.
567
      IF prt_frky_entries EQ 0.
568
* No, there aren't.
569
*        MODIFY mod_elem_tab FROM <total_text>.
570
        MOVE <vim_xtotal_text> TO <textline_x>.
571
        APPEND <w_texttab> TO <texttab>.
572
        ADD 1 TO modified_entries.
573
      ENDIF.
574
      IF status-delete EQ geloescht.
575
        READ TABLE extract WITH KEY <vim_xtotal_key>
576
         TRANSPORTING NO FIELDS.
577
        IF sy-subrc EQ 0.
578
          DELETE extract INDEX sy-tabix.
579
        ENDIF.
580
      ENDIF.
581
      DELETE total INDEX h_ix.
582
    ENDLOOP.
583
    IF modified_entries NE 0.
584
* delete text entries in all languages
585
      DO modified_entries TIMES.
586
*        READ TABLE mod_elem_tab INDEX 1.
587
*        DELETE mod_elem_tab INDEX 1.
588
        READ TABLE <texttab> INTO <w_texttab> INDEX 1.
589
*        PERFORM create_wheretab TABLES x_namtab
590
*                                USING mod_elem_tab
591
*                                      x_header-texttab space rc.
592
        PERFORM create_wheretab_new USING x_namtab[]
593
                                          <vim_total_struc>
594
                                          <vim_tot_txt_struc>
595
                                          x_header-texttab
596
                                          space
597
                                          rc.
598
        SELECT * FROM (x_header-texttab) APPENDING TABLE <texttab>
599
                                         WHERE (vim_wheretab).
600
      ENDDO.
601
*      DELETE (x_header-texttab) FROM TABLE mod_elem_tab.
602
      DELETE (x_header-texttab) FROM TABLE <texttab>.
603
    ENDIF.
604
  ENDIF.
605
* now update requests
606
  REFRESH: <mod_elem_tab>.
607
  CLEAR modified_entries.
608
  LOOP AT total.
609
    CHECK <action> EQ aendern.
610
*    MOVE: total TO <table1>,
611
*          <table1> TO mod_elem_tab.
612
*    APPEND mod_elem_tab.
613
    APPEND <vim_total_struc> TO <mod_elem_tab>.
614
    ADD 1 TO modified_entries.
615
    IF x_header-texttbexst EQ space OR
616
       <action_text> EQ original.
617
      READ TABLE extract WITH KEY <vim_xtotal_key>.
618
      <action> = original.
619
      IF sy-subrc = 0.
620
        <xact> = original.
621
        MODIFY extract INDEX sy-tabix.
622
      ENDIF.
623
      MODIFY total.
624
    ENDIF.
625
  ENDLOOP.
626
  IF modified_entries NE 0.
627
    UPDATE (x_header-maintview) FROM TABLE <mod_elem_tab>.
628
  ENDIF.
629
  IF x_header-texttbexst NE space.
630
    REFRESH <texttab>.
631
    CLEAR modified_entries.
632
    LOOP AT total.
633
      CHECK <action_text> EQ aendern.
634
*      MOVE: <total_text> TO mod_elem_tab.
635
*      APPEND mod_elem_tab.
636
      MOVE <vim_xtotal_text> TO <textline_x>.
637
      APPEND <w_texttab> TO <texttab>.
638
      ADD 1 TO modified_entries.
639
      READ TABLE extract WITH KEY <vim_xtotal_key>.
640
      IF <action> EQ aendern.
641
        <action> = original. <xact> = original.
642
      ENDIF.
643
      <action_text> = original. <xact_text> = original.
644
      IF sy-subrc = 0.
645
        MODIFY extract INDEX sy-tabix.
646
      ENDIF.
647
      MODIFY total.
648
    ENDLOOP.
649
    IF modified_entries NE 0.
650
*      UPDATE (x_header-texttab) FROM TABLE mod_elem_tab.
651
      UPDATE (x_header-texttab) FROM TABLE <texttab>.
652
    ENDIF.
653
  ENDIF.
654
* last not least: insert requests
655
  REFRESH: <mod_elem_tab>. CLEAR modified_entries.
656
  LOOP AT total.
657
    CHECK <action> EQ neuer_eintrag.
658
*    MOVE: total TO <table1>,
659
*          <table1> TO mod_elem_tab.
660
*    APPEND mod_elem_tab.
661
    APPEND <vim_total_struc> TO <mod_elem_tab>.
662
    ADD 1 TO modified_entries.
663
    IF x_header-texttbexst EQ space OR
664
       <action_text> EQ original.
665
      READ TABLE extract WITH KEY <vim_xtotal_key>.
666
      <action> = original.
667
      IF sy-subrc = 0.
668
        <xact> = original.
669
        MODIFY extract INDEX sy-tabix.
670
      ENDIF.
671
      MODIFY total.
672
    ENDIF.
673
  ENDLOOP.
674
  IF modified_entries NE 0.
675
    INSERT (x_header-maintview) FROM TABLE <mod_elem_tab>.
676
  ENDIF.
677
  IF x_header-texttbexst NE space.
678
    REFRESH <texttab>.
679
    CLEAR modified_entries.
680
    LOOP AT total.
681
      CHECK <action_text> EQ neuer_eintrag.
682
*      MOVE: <total_text> TO mod_elem_tab.
683
*      APPEND mod_elem_tab.
684
      MOVE <vim_xtotal_text> TO <textline_x>.
685
      APPEND <w_texttab> TO <texttab>.
686
      ADD 1 TO modified_entries.
687
      READ TABLE extract WITH KEY <vim_xtotal_key>.
688
      IF <action> EQ neuer_eintrag.
689
        <action> = original. <xact> = original.
690
      ENDIF.
691
      <action_text> = original. <xact_text> = original.
692
      IF sy-subrc = 0.
693
        MODIFY extract INDEX sy-tabix.
694
      ENDIF.
695
      MODIFY total.
696
    ENDLOOP.
697
    IF modified_entries NE 0.
698
*      INSERT (x_header-texttab) FROM TABLE mod_elem_tab
699
*                                ACCEPTING DUPLICATE KEYS.
700
      INSERT (x_header-texttab) FROM TABLE <texttab>
701
                                ACCEPTING DUPLICATE KEYS.
702
      IF sy-subrc NE 0. "duplicate keys -> process additional update
703
*        UPDATE (x_header-texttab) FROM TABLE mod_elem_tab.
704
        UPDATE (x_header-texttab) FROM TABLE <texttab>.
705
      ENDIF.
706
    ENDIF.
707
  ENDIF.
708
*    Call synchronizer
709
*  REFRESH e071_loctab.
710
*  APPEND e071 TO e071_loctab.
711
*  PERFORM vim_synchronizer_call
712
*                USING e071_loctab[]
713
*                      corr_keytab[]
714
*                      'X'.
715
 
716
  CLEAR: <status>-upd_flag,
717
         <status>-upd_checkd.
718
  MESSAGE s018(sv).
719
ENDFORM.                               " TABLE_DB_UPD
720
 
721
*&--------------------------------------------------------------------*
722
*&      Form  TABLE_READ_SINGLE_ENTRY                                 *
723
*---------------------------------------------------------------------*
724
* read single entry from data base
725
*---------------------------------------------------------------------*
726
FORM table_read_single_entry.
727
  DATA: tab TYPE REF TO data, texttab TYPE REF TO data,
728
        textline TYPE REF TO data.
729
 
730
  FIELD-SYMBOLS: <tab> TYPE STANDARD TABLE,
731
                 <texttab> TYPE STANDARD TABLE,
732
                 <textline> TYPE ANY, <textline_x> TYPE x.
733
 
734
  CREATE DATA tab TYPE STANDARD TABLE OF (x_header-maintview).
735
  ASSIGN tab->* TO <tab>.
736
*  REFRESH mod_elem_tab.
737
*  MOVE <f1> TO gen_key.
738
  CALL FUNCTION 'DB_SELECT_GENERIC_TABLE'
739
       EXPORTING
740
            tablename   = x_header-maintview
741
*            genkey      = gen_key
742
            genkey      = <f1_x>
743
            genkey_ln   = x_header-keylen
744
       TABLES
745
*            inttab      = mod_elem_tab
746
            inttab      = <tab>
747
       EXCEPTIONS
748
            db_error    = 12
749
            not_found   = 04
750
            wrong_param = 08.
751
  IF sy-subrc > 4. RAISE get_table_error. ENDIF.
752
*  READ TABLE mod_elem_tab INDEX 1.
753
  READ TABLE <tab> INTO <table1> INDEX 1.
754
  IF sy-subrc <> 0.
755
    MOVE <initial> TO <table1>.
756
*  ELSE.
757
*    <table1> = mod_elem_tab.
758
  ENDIF.
759
  IF x_header-texttbexst NE space.
760
* read text table
761
    CREATE DATA texttab TYPE STANDARD TABLE OF (x_header-texttab).
762
    CREATE DATA textline TYPE (x_header-texttab).
763
    ASSIGN: texttab->* TO <texttab>,
764
            textline->* TO <textline>,
765
            <textline> TO <textline_x> CASTING.
766
*    REFRESH mod_elem_tab.
767
*    CLEAR gen_key.
768
*    WRITE <table1_text> TO gen_key(x_header-textkeylen).
769
    CALL FUNCTION 'DB_SELECT_GENERIC_TABLE'
770
         EXPORTING
771
              tablename   = x_header-texttab
772
*              genkey      = gen_key
773
              genkey      = <textkey_x>
774
              genkey_ln   = x_header-textkeylen
775
         TABLES
776
*              inttab      = mod_elem_tab
777
              inttab      = <texttab>
778
         EXCEPTIONS
779
              db_error    = 12
780
              not_found   = 04
781
              wrong_param = 08.
782
    IF sy-subrc > 4. RAISE get_table_error. ENDIF.
783
*    READ TABLE mod_elem_tab INDEX 1.
784
    READ TABLE <texttab> INTO <table1_text> INDEX 1.
785
    IF sy-subrc <> 0.
786
      MOVE <text_initial> TO <table1_text>.
787
      CLEAR sy-subrc.
788
*    ELSE.
789
*      <table1_text> = mod_elem_tab.
790
    ENDIF.
791
  ENDIF.
792
ENDFORM.                               " TABLE_READ_SINGLE_ENTRY
793
 
794
*&--------------------------------------------------------------------*
795
*&      Form  SET_TXT_UPDATE_FLAG                                     *
796
*---------------------------------------------------------------------*
797
* note, if texttab entry was modified on screen
798
*---------------------------------------------------------------------*
799
FORM set_txt_update_flag.
800
 
801
  IF <textkey_x> EQ <initial_textkey_x> OR "textkey not filled yet OR
802
     status-action EQ kopieren OR      "copy mode              OR
803
     neuer EQ 'J' OR <xact> EQ leer OR "real new entry         OR
804
     ( temporal_delimitation_happened EQ 'X' AND "temporal delimitation
805
        x_header-delmdtflag EQ 'B' ).
806
    PERFORM fill_texttab_key_uc USING <table1> <table1_text>.
807
  ENDIF.
808
  IF status-action EQ hinzufuegen.
809
    <status>-upd_flag = 'X'.           "always both tables must be added
810
  ELSE.
811
    TRANSLATE <status>-upd_flag USING ' TEX'.
812
  ENDIF.
813
ENDFORM.                               " SET_TXT_UPDATE_FLAG
814
 
815
*&--------------------------------------------------------------------*
816
*&      Form  FILL_TEXTTAB_KEY                                        *
817
*&--------------------------------------------------------------------*
818
*       Kept for downward compatibility only. Never use in unicode-
819
*       system. Use FILL_TEXTTAB_KEY instead                          *
820
*&--------------------------------------------------------------------*
821
FORM fill_texttab_key USING enti_wa text_wa.
822
  FIELD-SYMBOLS: <enti>, <text>.
823
  DATA: index TYPE i.
824
  LOOP AT x_namtab WHERE texttabfld NE space
825
                     AND keyflag NE space. "all keyfields of text table
826
    index = x_namtab-position - x_header-tablen.
827
    ASSIGN text_wa+index(x_namtab-flength) TO <text>.
828
    IF x_namtab-primtabkey EQ space.   "language key
829
      MOVE sy-langu TO <text>.
830
    ELSE.
831
      index = x_namtab-primtabkey.
832
      READ TABLE x_namtab INDEX index. "corresponding field of entity tb
833
      IF sy-subrc EQ 0.
834
        ASSIGN enti_wa+x_namtab-position(x_namtab-flength) TO <enti>.
835
        MOVE <enti> TO <text>.
836
      ENDIF.
837
    ENDIF.
838
  ENDLOOP.
839
ENDFORM.                               "FILL_TEXTTAB_KEY
840
 
841
*&--------------------------------------------------------------------*
842
*&      Form  FILL_TEXTTAB_KEY_UC                                     *
843
*&--------------------------------------------------------------------*
844
* ENTI_WA ---> WA of entity table                                     *
845
* TEXT_WA <--- WA of text table                                       *
846
*&--------------------------------------------------------------------*
847
FORM fill_texttab_key_uc USING enti_wa
848
                         CHANGING text_wa.
849
  FIELD-SYMBOLS: <namtab> TYPE vimnamtab, <namtab2> TYPE vimnamtab,
850
                 <enti> TYPE ANY, <text> TYPE ANY.
851
  DATA: index TYPE i.
852
  LOOP AT x_namtab ASSIGNING <namtab> WHERE texttabfld NE space
853
                     AND keyflag NE space.
854
* keyfield of text table
855
    ASSIGN COMPONENT <namtab>-viewfield OF STRUCTURE text_wa
856
     TO <text>.
857
    IF <namtab>-primtabkey EQ space.   "language key
858
      MOVE sy-langu TO <text>.
859
    ELSE.
860
      index = <namtab>-primtabkey.
861
      READ TABLE x_namtab ASSIGNING <namtab2> INDEX index.
862
* corresponding field of entity tb
863
      IF sy-subrc EQ 0.
864
        ASSIGN COMPONENT <namtab2>-viewfield OF STRUCTURE enti_wa
865
         TO <enti>.
866
        MOVE <enti> TO <text>.
867
      ENDIF.
868
    ENDIF.
869
  ENDLOOP.
870
ENDFORM.                               "FILL_TEXTTAB_KEY_UC
871
 
872
*&--------------------------------------------------------------------*
873
*&      Form CREATE_WHERETAB_NEW                                      *
874
*&--------------------------------------------------------------------*
875
* create where-tab for dynamic select                                 *
876
*&--------------------------------------------------------------------*
877
*        --> CW_TOTAL        table line
878
*            CW_TABLE        table the wheretab has to be filled for
879
*            CW_ENTI_KEY
880
*            CW_RC
881
*&--------------------------------------------------------------------*
882
FORM create_wheretab_new USING cw_namtab LIKE x_namtab[]
883
                               total_struc TYPE any
884
                               total_txt_struc TYPE any
885
                               value(cw_table) LIKE vimdesc-viewname
886
                               value(cw_enti_key) TYPE xfeld
887
                               cw_rc TYPE i.
888
 
889
  DATA: cw_sellist LIKE vimsellist OCCURS 10, cw_sel LIKE vimsellist,
890
        first(1) TYPE c VALUE 'X', w_namtab TYPE vimnamtab.
891
  FIELD-SYMBOLS: <cw_value> TYPE ANY,
892
                 <w_namtab2> TYPE vimnamtab.
893
 
894
  LOOP AT cw_namtab INTO w_namtab
895
                    WHERE keyflag NE space    "all textkeyfields
896
                      AND texttabfld NE space "with relations to
897
                      AND primtabkey NE 0.    "entity key fields
898
    CHECK w_namtab-datatype NE 'CLNT' OR first EQ space.
899
    TRANSLATE first USING 'X '.
900
*    IF cw_enti_key EQ space.
901
*      SUBTRACT x_header-tablen FROM w_namtab-position.
902
*    ENDIF.
903
*    ASSIGN cw_total+w_namtab-position(w_namtab-flength) "value of
904
*              TO <cw_value>.           "textkey
905
    IF cw_enti_key NE space.
906
      READ TABLE cw_namtab INDEX w_namtab-primtabkey
907
       ASSIGNING <w_namtab2>.           "corresp. enti key
908
      ASSIGN COMPONENT <w_namtab2>-viewfield OF
909
       STRUCTURE total_struc TO <cw_value>.
910
      cw_sel-viewfield = <w_namtab2>-viewfield.
911
    ELSE.
912
      ASSIGN COMPONENT w_namtab-viewfield OF
913
       STRUCTURE total_txt_struc TO <cw_value>.
914
      cw_sel-viewfield = w_namtab-viewfield.
915
    ENDIF.
916
    cw_sel-tabix     = sy-tabix.
917
    cw_sel-operator = 'EQ'.
918
    cw_sel-and_or = 'AND'.
919
    CALL FUNCTION 'VIEW_CONVERSION_OUTPUT'
920
         EXPORTING
921
              tabname      = cw_table
922
              fieldname    = cw_sel-viewfield
923
              value_intern = <cw_value>
924
*              inttype      = w_namtab-inttype
925
*              datatype     = w_namtab-datatype
926
*              decimals     = w_namtab-decimals
927
*              convexit     = w_namtab-convexit
928
*              sign         = w_namtab-sign
929
              outputlen    = w_namtab-outputlen
930
              intlen       = w_namtab-flength
931
         IMPORTING
932
              value_extern = cw_sel-value.
933
    IF cw_sel-value EQ space.
934
      cw_sel-initial = 'X'.
935
    ENDIF.
936
    CASE w_namtab-inttype.
937
      WHEN 'F'. cw_sel-fltp_value = <cw_value>.
938
      WHEN 'D'. cw_sel-date_value = <cw_value>.
939
      WHEN 'T'. cw_sel-time_value = <cw_value>.
940
      WHEN 'P'. cw_sel-pckd_value(w_namtab-flength) = <cw_value>.
941
      WHEN 'N'. cw_sel-numc_value(w_namtab-flength) = <cw_value>.
942
      WHEN 'C'. cw_sel-invd_value(w_namtab-flength) = <cw_value>.
943
      WHEN 'I'. cw_sel-int4_value = <cw_value>.
944
      WHEN 'X'.
945
        CASE w_namtab-datatype.
946
          WHEN 'INT1'. cw_sel-int1_value = <cw_value>.
947
          WHEN 'INT2'. cw_sel-int2_value = <cw_value>.
948
          WHEN 'INT4'. cw_sel-int4_value = <cw_value>.
949
          WHEN 'RAW'. cw_sel-raw_value(w_namtab-flength) = <cw_value>.
950
        ENDCASE.
951
    ENDCASE.
952
    cw_sel-converted = 'X'.
953
    APPEND cw_sel TO cw_sellist.
954
    CLEAR cw_sel.
955
  ENDLOOP.
956
  DESCRIBE TABLE cw_sellist.
957
  READ TABLE cw_sellist INTO cw_sel INDEX sy-tfill.
958
  IF cw_sel-and_or NE space.
959
    CLEAR cw_sel-and_or. MODIFY cw_sellist INDEX sy-tfill FROM cw_sel.
960
  ENDIF.
961
  CALL FUNCTION 'VIEW_FILL_WHERETAB'
962
    EXPORTING
963
      tablename               = cw_table
964
      only_cnds_for_keyflds   = 'X'
965
    TABLES
966
      sellist                 = cw_sellist
967
      wheretab                = vim_wheretab
968
      x_namtab                = cw_namtab
969
    EXCEPTIONS
970
      no_conditions_for_table = 01.
971
  cw_rc = sy-subrc.
972
ENDFORM.                               "create_wheretab_new
973
*&--------------------------------------------------------------------*
974
*&      Form CREATE_WHERETAB                                          *
975
*&--------------------------------------------------------------------*
976
*       Kept for downward compatibility only. Never use in unicode-
977
*       system. Use CREATE_WHERETAB_NEW instead.
978
*&--------------------------------------------------------------------*
979
*        --> CW_TOTAL        table line
980
*            CW_TABLE        table name
981
*            CW_ENTI_KEY
982
*            CW_RC
983
*&--------------------------------------------------------------------*
984
FORM create_wheretab TABLES cw_namtab STRUCTURE vimnamtab
985
                     USING value(cw_total)
986
                           value(cw_table) LIKE vimdesc-viewname
987
                           value(cw_enti_key) TYPE c
988
                           cw_rc TYPE i.
989
  DATA: cw_sellist LIKE vimsellist OCCURS 10, cw_sel LIKE vimsellist,
990
        first(1) TYPE c VALUE 'X'.
991
  FIELD-SYMBOLS: <cw_value>.
992
 
993
  LOOP AT cw_namtab WHERE keyflag NE space    "all textkeyfields
994
                      AND texttabfld NE space "with relations to
995
                      AND primtabkey NE 0.    "entity key fields
996
    CHECK cw_namtab-datatype NE 'CLNT' OR first EQ space.
997
    TRANSLATE first USING 'X '.
998
    IF cw_enti_key EQ space.
999
      SUBTRACT x_header-tablen FROM cw_namtab-position.
1000
    ENDIF.
1001
    ASSIGN cw_total+cw_namtab-position(cw_namtab-flength) "value of
1002
              TO <cw_value>.           "textkey
1003
    IF cw_enti_key NE space.
1004
      READ TABLE cw_namtab INDEX cw_namtab-primtabkey."corresp. enti key
1005
    ENDIF.
1006
    cw_sel-viewfield = cw_namtab-viewfield.
1007
    cw_sel-tabix     = sy-tabix.
1008
    cw_sel-operator = 'EQ'.
1009
    cw_sel-and_or = 'AND'.
1010
    CALL FUNCTION 'VIEW_CONVERSION_OUTPUT'
1011
      EXPORTING
1012
        value_intern = <cw_value>
1013
        inttype      = cw_namtab-inttype
1014
        datatype     = cw_namtab-datatype
1015
        decimals     = cw_namtab-decimals
1016
        convexit     = cw_namtab-convexit
1017
        sign         = cw_namtab-sign
1018
        outputlen    = cw_namtab-outputlen
1019
        intlen       = cw_namtab-flength
1020
      IMPORTING
1021
        value_extern = cw_sel-value.
1022
    IF cw_sel-value EQ space.
1023
      cw_sel-initial = 'X'.
1024
    ENDIF.
1025
* SW 5.8.98 ..
1026
* folgende MOVE's führen zu unerwünschten impliziten Konvertierungen
1027
* und damit zu Laufzeitfehler
1028
    CLEAR cw_sel-converted.
1029
*   case cw_namtab-inttype.
1030
*     when 'F'. cw_sel-fltp_value = <cw_value>.
1031
*     when 'D'. cw_sel-date_value = <cw_value>.
1032
*     when 'T'. cw_sel-time_value = <cw_value>.
1033
*     when 'P'. cw_sel-pckd_value(cw_namtab-flength) = <cw_value>.
1034
*     when 'N'. cw_sel-numc_value(cw_namtab-flength) = <cw_value>.
1035
*     when 'C'. cw_sel-invd_value(cw_namtab-flength) = <cw_value>.
1036
*     when 'I'. cw_sel-int4_value = <cw_value>.
1037
*     when 'X'.
1038
*       case cw_namtab-datatype.
1039
*         when 'INT1'. cw_sel-int1_value = <cw_value>.
1040
*         when 'INT2'. cw_sel-int2_value = <cw_value>.
1041
*         when 'INT4'. cw_sel-int4_value = <cw_value>.
1042
*         when 'RAW'. cw_sel-raw_value(cw_namtab-flength) = <cw_value>.
1043
*       endcase.
1044
*   endcase.
1045
*   cw_sel-converted = 'X'.                                ".. SW 5.8.98
1046
    APPEND cw_sel TO cw_sellist.
1047
  ENDLOOP.
1048
  DESCRIBE TABLE cw_sellist.
1049
  READ TABLE cw_sellist INTO cw_sel INDEX sy-tfill.
1050
  IF cw_sel-and_or NE space.
1051
    CLEAR cw_sel-and_or. MODIFY cw_sellist INDEX sy-tfill FROM cw_sel.
1052
  ENDIF.
1053
  CALL FUNCTION 'VIEW_FILL_WHERETAB'
1054
    EXPORTING
1055
      tablename               = cw_table
1056
      only_cnds_for_keyflds   = 'X'
1057
    TABLES
1058
      sellist                 = cw_sellist
1059
      wheretab                = vim_wheretab
1060
      x_namtab                = cw_namtab
1061
    EXCEPTIONS
1062
      no_conditions_for_table = 01.
1063
  cw_rc = sy-subrc.
1064
ENDFORM.                               "create_wheretab
1065
 
1066
*&--------------------------------------------------------------------*
1067
*&      Form  TABLEFRAME                                              *
1068
*&--------------------------------------------------------------------*
1069
* program for function TABLEFRAME_<area>                              *
1070
*&--------------------------------------------------------------------*
1071
FORM  tableframe TABLES header STRUCTURE vimdesc
1072
                        namtab STRUCTURE vimnamtab
1073
                        dbasellist STRUCTURE vimsellist
1074
                        dplsellist STRUCTURE vimsellist
1075
                        exclcuafunct STRUCTURE vimexclfun
1076
                 USING  corrnumber
1077
                        viewaction
1078
                        viewname.
1079
 
1080
  DATA: enqueue_processed TYPE c, "flag: view enqueued by VIEWFRAME_..
1081
        table_type(11) TYPE c,         "type of table to use
1082
        table_length TYPE i.           "length of current table
1083
 
1084
*-<<<-------------------------------------------------------------->>>>*
1085
* first of all: determine well-sized internal tables etc.              *
1086
*-<<<-------------------------------------------------------------->>>>*
1087
  READ TABLE header INDEX 1.
1088
  table_length = header-tablen / cl_abap_char_utilities=>charsize + 2.
1089
*  tab lg. + action + mark
1090
  IF header-texttbexst NE space.
1091
    table_length = table_length
1092
     + header-texttablen / cl_abap_char_utilities=>charsize + 1.
1093
* txtb+txtact
1094
  ENDIF.
1095
  IF table_length LE ultra_short_tab.
1096
    MOVE 'ULTRA_SHORT'     TO table_type.
1097
    FREE: extract_vs, total_vs,
1098
          extract_s, total_s,
1099
          extract_m, total_m,
1100
          extract_l, total_l,
1101
          extract_vl, total_vl,
1102
          extract_ul, total_ul.
1103
  ELSEIF table_length LE very_short_tab.
1104
    MOVE 'VERY_SHORT'     TO table_type.
1105
    FREE: extract_us, total_us,
1106
          extract_s, total_s,
1107
          extract_m, total_m,
1108
          extract_l, total_l,
1109
          extract_vl, total_vl,
1110
          extract_ul, total_ul.
1111
  ELSEIF table_length LE short_tab.
1112
    MOVE 'SHORT'     TO table_type.
1113
    FREE: extract_us, total_us,
1114
          extract_vs, total_vs,
1115
          extract_m, total_m,
1116
          extract_l, total_l,
1117
          extract_vl, total_vl,
1118
          extract_ul, total_ul.
1119
  ELSEIF table_length LE middle_tab.
1120
    MOVE 'MIDDLE'    TO table_type.
1121
    FREE: extract_us, total_us,
1122
          extract_vs, total_vs,
1123
          extract_s, total_s,
1124
          extract_l, total_l,
1125
          extract_vl, total_vl,
1126
          extract_ul, total_ul.
1127
  ELSEIF table_length LE long_tab.
1128
    MOVE 'LONG'    TO table_type.
1129
    FREE: extract_us, total_us,
1130
          extract_vs, total_vs,
1131
          extract_s, total_s,
1132
          extract_m, total_m,
1133
          extract_vl, total_vl,
1134
          extract_ul, total_ul.
1135
  ELSEIF table_length LE very_long_tab.
1136
    MOVE 'VERY_LONG'    TO table_type.
1137
    FREE: extract_us, total_us,
1138
          extract_vs, total_vs,
1139
          extract_s, total_s,
1140
          extract_m, total_m,
1141
          extract_l, total_l,
1142
          extract_ul, total_ul.
1143
  ELSEIF table_length LE ultra_long_tab.
1144
    MOVE 'ULTRA_LONG'    TO table_type.
1145
    FREE: extract_us, total_us,
1146
          extract_vs, total_vs,
1147
          extract_s, total_s,
1148
          extract_m, total_m,
1149
          extract_l, total_l,
1150
          extract_vl, total_vl.
1151
  ENDIF.
1152
  maint_mode = viewaction.
1153
  corr_nbr = corrnumber.
1154
*-<<<-------------------------------------------------------------->>>>*
1155
* Entrypoint after changing maintenance mode (show <--> update)        *
1156
*-<<<-------------------------------------------------------------->>>>*
1157
  DO.
1158
*----------------------------------------------------------------------*
1159
* Select data from database                                            *
1160
*----------------------------------------------------------------------*
1161
    PERFORM table_call_function TABLES dbasellist dplsellist
1162
                                header namtab exclcuafunct
1163
                                USING read table_type update_flag.
1164
    CASE sy-subrc.
1165
      WHEN 1.
1166
        RAISE missing_corr_number.
1167
    ENDCASE.
1168
*-<<<-------------------------------------------------------------->>>>*
1169
* Entrypoint after saving data into database                           *
1170
* Entrypoint after refreshing selected entries from database           *
1171
*-<<<-------------------------------------------------------------->>>>*
1172
    DO.
1173
*----------------------------------------------------------------------*
1174
* Edit data                                                            *
1175
*----------------------------------------------------------------------*
1176
      DO.
1177
        PERFORM table_call_function
1178
                             TABLES dbasellist dplsellist
1179
                                    header namtab exclcuafunct
1180
                             USING edit table_type <status>-upd_flag.
1181
        CASE sy-subrc.
1182
          WHEN 1.
1183
            IF maint_mode EQ transportieren AND viewaction EQ aendern.
1184
              MOVE viewaction TO maint_mode.
1185
            ELSE.
1186
              RAISE missing_corr_number.
1187
            ENDIF.
1188
          WHEN OTHERS.
1189
            EXIT.
1190
        ENDCASE.
1191
      ENDDO.
1192
*----------------------------------------------------------------------*
1193
*  Handle usercommands...                                              *
1194
*  ...at first handle commands which could cause loss of data          *
1195
*----------------------------------------------------------------------*
1196
      IF function EQ back.
1197
        function = end.
1198
      ENDIF.
1199
      IF ( function EQ switch_to_show_mode OR
1200
           function EQ get_another_view    OR
1201
           function EQ switch_transp_to_upd_mode OR
1202
           function EQ end ) AND
1203
         <status>-upd_flag NE space.
1204
        PERFORM beenden.
1205
        CASE sy-subrc.
1206
          WHEN 0.
1207
            PERFORM table_call_function
1208
                         TABLES dbasellist dplsellist
1209
                                header namtab exclcuafunct
1210
                         USING save table_type <status>-upd_flag.
1211
            CASE sy-subrc.
1212
              WHEN 0.
1213
                IF <status>-upd_flag EQ space. EXIT. ENDIF.
1214
              WHEN 1.
1215
                RAISE missing_corr_number.
1216
              WHEN 3.
1217
            ENDCASE.
1218
          WHEN 8.
1219
            EXIT.
1220
          WHEN 12.
1221
        ENDCASE.
1222
*----------------------------------------------------------------------*
1223
*  ...2nd: transport request                                           *
1224
*----------------------------------------------------------------------*
1225
      ELSEIF function EQ transport.
1226
        IF <status>-upd_flag NE space.
1227
          PERFORM transportieren.
1228
          CASE sy-subrc.
1229
            WHEN 0.
1230
              PERFORM table_call_function
1231
                              TABLES dbasellist dplsellist
1232
                                     header namtab exclcuafunct
1233
                              USING save table_type <status>-upd_flag.
1234
              CASE sy-subrc.
1235
                WHEN 0.
1236
                  maint_mode = transportieren.
1237
                WHEN 1.
1238
                  RAISE missing_corr_number.
1239
                WHEN 3.
1240
              ENDCASE.
1241
            WHEN 8.
1242
              EXIT.
1243
            WHEN 12.
1244
          ENDCASE.
1245
        ELSE.
1246
          maint_mode = transportieren.
1247
        ENDIF.
1248
*----------------------------------------------------------------------*
1249
*  ...now reset or save requests                                       *
1250
*----------------------------------------------------------------------*
1251
      ELSEIF function EQ reset_list  OR
1252
             function EQ reset_entry OR
1253
             function EQ save.
1254
*----------------------------------------------------------------------*
1255
*  Refresh selected entries from database or save data into database   *
1256
*----------------------------------------------------------------------*
1257
        PERFORM table_call_function
1258
                          TABLES dbasellist dplsellist
1259
                                 header namtab exclcuafunct
1260
                          USING function table_type <status>-upd_flag.
1261
        CASE sy-subrc.
1262
          WHEN 1.
1263
            RAISE missing_corr_number.
1264
          WHEN 3.
1265
        ENDCASE.
1266
      ELSE.
1267
        EXIT.
1268
      ENDIF.
1269
    ENDDO.
1270
*----------------------------------------------------------------------*
1271
*  ...now other commands...                                            *
1272
*----------------------------------------------------------------------*
1273
    CASE function.
1274
      WHEN switch_to_show_mode.
1275
*   change maintenance mode from update to show
1276
        PERFORM enqueue USING 'D' header-frm_af_enq. "dequeue view
1277
        CLEAR enqueue_processed.
1278
        maint_mode = anzeigen.
1279
      WHEN switch_to_update_mode.
1280
*     change maintenance mode from show to update
1281
        PERFORM enqueue USING 'E' header-frm_af_enq.  "enqueue view
1282
        IF sy-subrc EQ 0.
1283
          MOVE 'X' TO enqueue_processed.
1284
          maint_mode = aendern.
1285
        ENDIF.
1286
      WHEN switch_transp_to_upd_mode.
1287
*     change maintenance mode from transport to update
1288
        maint_mode = aendern.
1289
      WHEN transport.
1290
*     change maintenance mode from update to transport
1291
        maint_mode = transportieren.
1292
      WHEN OTHERS.
1293
        IF enqueue_processed NE space.
1294
          PERFORM enqueue USING 'D' header-frm_af_enq."dequeue view
1295
        ENDIF.
1296
        PERFORM before_leaving_frame_function
1297
                                      USING header-frm_bf_end.
1298
        EXIT.
1299
    ENDCASE.
1300
  ENDDO.
1301
ENDFORM.                                                    "
1302
 
1303
*&--------------------------------------------------------------------*
1304
*&      Form TABLEPROC                                                *
1305
*&--------------------------------------------------------------------*
1306
* program for function TABLEPROC_<area>                               *
1307
*&--------------------------------------------------------------------*
1308
FORM  tableproc.
1309
*----------------------------------------------------------------------*
1310
* Initialization: set field-symbols etc.                               *
1311
*----------------------------------------------------------------------*
1312
  IF last_view_info NE view_name.
1313
    PERFORM initialisieren.
1314
  ENDIF.
1315
  PERFORM justify_action_mode.
1316
  MOVE: view_action TO maint_mode,
1317
        corr_number TO corr_nbr.
1318
 
1319
*----------------------------------------------------------------------*
1320
* Get data from database                                               *
1321
*----------------------------------------------------------------------*
1322
  IF fcode EQ read OR fcode EQ read_and_edit.
1323
    PERFORM prepare_read_request.
1324
    IF x_header-frm_rp_get NE space.
1325
      PERFORM (x_header-frm_rp_get) IN PROGRAM (sy-repid).
1326
    ELSE.
1327
      PERFORM table_get_data.
1328
    ENDIF.
1329
    IF fcode EQ read_and_edit. fcode = edit. ENDIF.
1330
  ENDIF.
1331
 
1332
  CASE fcode.
1333
    WHEN  edit.                        " Edit read data
1334
      PERFORM call_dynpro.
1335
      PERFORM check_upd.
1336
*....................................................................*
1337
 
1338
    WHEN save.                         " Write data into database
1339
      PERFORM prepare_saving.
1340
      IF <status>-upd_flag NE space.
1341
        IF x_header-frm_rp_upd NE space.
1342
          PERFORM (x_header-frm_rp_upd) IN PROGRAM.
1343
        ELSE.
1344
          IF sy-subrc EQ 0.
1345
            PERFORM table_db_upd.
1346
          ENDIF.
1347
        ENDIF.
1348
        PERFORM after_saving.
1349
      ENDIF.
1350
*....................................................................*
1351
 
1352
    WHEN reset_list.     " Refresh all marked entries of EXTRACT from db
1353
      PERFORM reset_entries USING list_bild.
1354
*....................................................................*
1355
 
1356
    WHEN reset_entry.               " Refresh single entry from database
1357
      PERFORM reset_entries USING detail_bild.
1358
*.......................................................................
1359
  ENDCASE.
1360
  MOVE: <status>-upd_flag TO update_required,
1361
        function TO ucomm.
1362
ENDFORM.                               "tableproc
1363
 
1364
*&--------------------------------------------------------------------*
1365
*&      FORM  REPLACE_FORBIDDEN_CHARS                                 *
1366
*&--------------------------------------------------------------------*
1367
* replace forbidden characters with internal code into NAME           *
1368
*---------------------------------------------------------------------*
1369
* ---> NAME - name to correct                                         *
1370
* ---> FORBIDDEN_CHARS - chars which must be replaced                 *
1371
* <--- NAME - corrected name                                          *
1372
*&--------------------------------------------------------------------*
1373
FORM  replace_forbidden_chars USING value(forbidden_chars) name.
1374
  FIELD-SYMBOLS: <code>.
1375
  DATA: suspect_char(1) TYPE c, code(2) TYPE c.
1376
 
1377
  DO.
1378
    IF name CA forbidden_chars.
1379
      ASSIGN name+sy-fdpos(1)  TO <code>.
1380
      MOVE <code> TO suspect_char.
1381
      ASSIGN <code> TO <code> TYPE 'X'.
1382
      MOVE <code> TO code.
1383
      REPLACE suspect_char WITH code INTO name.
1384
    ELSE.
1385
      EXIT.
1386
    ENDIF.
1387
  ENDDO.
1388
ENDFORM.                               "replace_forbidden_chars
1389
*&---------------------------------------------------------------------*
1390
*&      Form  vim_get_text_keyflds
1391
*&---------------------------------------------------------------------*
1392
*       inserts all key field names of a texttable into a table
1393
*----------------------------------------------------------------------*
1394
*      -->P_TEXTTABNAME   text table name
1395
*      <--P_TEXT_KEYFLDS  table of keyfields
1396
*----------------------------------------------------------------------*
1397
FORM vim_get_text_keyflds USING p_texttabname TYPE tabname
1398
                         CHANGING p_text_keyflds TYPE vim_flds_tab_type.
1399
 
1400
  STATICS: texttabname_save TYPE tabname,
1401
           text_keyflds_save TYPE vim_flds_tab_type.
1402
 
1403
  FIELD-SYMBOLS: <namtab> TYPE vimnamtab.
1404
 
1405
  REFRESH p_text_keyflds.
1406
  IF texttabname_save = p_texttabname.
1407
    APPEND LINES OF text_keyflds_save TO p_text_keyflds.
1408
  ELSE.
1409
    texttabname_save = p_texttabname.
1410
    REFRESH text_keyflds_save.
1411
    LOOP AT x_namtab ASSIGNING <namtab> WHERE texttabfld NE space
1412
                       AND keyflag NE space.
1413
      APPEND <namtab>-viewfield TO p_text_keyflds.
1414
    ENDLOOP.
1415
    APPEND LINES OF p_text_keyflds TO text_keyflds_save.
1416
  ENDIF.
1417
ENDFORM.                               " vim_get_text_keyflds