Eigenschaften | Quelltext
Titel | Include LSVIMF5A |
Originalsprache | DE | Deutsch
Erstellt | 22.04.1999 |  | SAP |
Letzte Änderung | 23.06.2003 |  | SAP |
Status | aktiv |
Attribute
Typ | Include-Programm |
Status | Testprogramm |
Anwendung | Basis (System) |
Paket | SVIM | Basis Viewmaintenance
| Editorsperre
txt
    1
    *----------------------------------------------------------------------*
    2
    ***INCLUDE LSVIMF5A .
    3
    *----------------------------------------------------------------------*
    4
    *&---------------------------------------------------------------------*
    5
    *&      Form  VIM_BC_LOGS_PUT
    6
    *&---------------------------------------------------------------------*
    7
    *       text
    8
    *----------------------------------------------------------------------*
    9
    *      <--P_BC_ENTRY_LIST  text
    10
    *----------------------------------------------------------------------*
    11
    FORM vim_bc_logs_put CHANGING p_bc_entry_list LIKE
    12
                                  vim_bc_entry_list.
    13
    14
      DATA: corr_keytab_save LIKE TABLE OF e071k, first,
    15
            dummy LIKE sy-subrc, transport_active LIKE t000-cccoractiv,
    16
            w_tabkey_value TYPE scpractr,
    17
            tabkey_values_n TYPE vim_bc_tab_logs,
    18
            tabkey_values_u TYPE vim_bc_tab_logs,
    19
            tabkey_values_d TYPE vim_bc_tab_logs,
    20
            w_bc_entry TYPE scpr_viewdata, bc_entries TYPE scpr_viewdatas,
    21
            w_bc_entry_list TYPE vimty_bc_entry_list_type,
    22
            bc_keytab TYPE bc_keytab_type,
    23
            bc_keytab_wa LIKE LINE OF bc_keytab,
    24
            p_msgid, p_msgty, p_msgno, bc_key_needed(1) TYPE c,
    25
            foreign_langu TYPE sy-langu,
    26
            rc LIKE sy-subrc, keys_identical TYPE xfeld,
    27
            subrc TYPE sy-subrc, tabix TYPE sy-tabix.
    28
    29
      STATICS: viewname_old TYPE vimdesc-viewname,
    30
               keylen_real TYPE i.
    31
    32
      CONSTANTS: bc_id_length TYPE i VALUE 32,
    33
                 bc_recno_length TYPE i VALUE 10.
    34
    35
      FIELD-SYMBOLS: <bc_entry_keyx> TYPE x, <key> TYPE x,
    36
                     <vim_bc_keyx> TYPE x, <w_bc_entry_x> TYPE x,
    37
                     <xlangu> TYPE x, <namtab> type vimnamtab.
    38
    39
      ASSIGN: w_bc_entry_list-keys(x_header-keylen) TO <bc_entry_keyx>.
    40
      ASSIGN: bc_keytab_wa-bc_tabkey TO <vim_bc_keyx> CASTING.
    41
      ASSIGN: w_bc_entry-data TO <w_bc_entry_x> CASTING.
    42
    43
      IF x_header-viewname NE viewname_old. "HCG: has table align gap?
    44
        viewname_old = x_header-viewname.
    45
        CLEAR keylen_real.
    46
        LOOP AT x_namtab ASSIGNING <namtab> WHERE keyflag = 'X' AND
    47
                                                    texttabfld IS INITIAL.
    48
          keylen_real = keylen_real + <namtab>-flength.
    49
        ENDLOOP.
    50
      ENDIF.
    51
      LOOP AT p_bc_entry_list INTO w_bc_entry_list WHERE
    52
       viewname = x_header-viewname AND action <> original.
    53
    *    IF w_bc_entry_list-action = neuer_geloescht.   Obsolete, was only
    54
    *      DELETE p_bc_entry_list. CONTINUE.            possible at bc-set
    55
    *    ENDIF.                              activation in dialog via SM30
    56
        IF first = space.
    57
          first = 'X'.
    58
          INSERT LINES OF corr_keytab INTO TABLE corr_keytab_save.
    59
          REFRESH corr_keytab.
    60
          CLEAR <table1>.
    61
          transport_active = vim_client_state.
    62
        ENDIF.
    63
    * fill corr_keytab
    64
        IF x_header-keylen = keylen_real.
    65
          READ TABLE total WITH KEY <bc_entry_keyx> BINARY SEARCH.
    66
        ELSE.
    67
          PERFORM vim_read_table_with_gap
    68
                        TABLES   total
    69
                        USING    <bc_entry_keyx>
    70
                                 x_namtab[]
    71
                        CHANGING subrc
    72
                                 tabix.
    73
          IF subrc = 0.
    74
            READ TABLE total INDEX tabix.
    75
          ENDIF.
    76
        ENDIF.
    77
        IF x_header-bastab EQ space.                            "view
    78
          MOVE <bc_entry_keyx> TO <f1_x>.
    79
          PERFORM (corr_formname) IN PROGRAM (sy-repid) USING
    80
                                                vim_writing_bc_imp_log
    81
                                                dummy.
    82
          REFRESH bc_keytab.
    83
          CLEAR bc_key_needed.
    84
          IF x_header-keylen > vim_max_trsp_keylength. "HCG tabkey up to 255
    85
            bc_key_needed = 'X'.
    86
          ENDIF.
    87
          IF bc_key_needed NE 'X'.           "Look for non-char field in key
    88
            LOOP AT x_namtab WHERE keyflag = 'X'.
    89
              IF 'CNDT' NS x_namtab-inttype. "non charlike field
    90
                bc_key_needed = 'X'.
    91
                EXIT.
    92
              ENDIF.
    93
            ENDLOOP.
    94
          ENDIF.
    95
          IF bc_key_needed NE 'X'.             "Look if viewkey > primtabkey
    96
            CLEAR keys_identical.
    97
            PERFORM vim_comp_roottabkey USING x_header
    98
                                              x_namtab[]
    99
                                     CHANGING keys_identical
    100
                                              rc.
    101
            IF keys_identical EQ space. bc_key_needed = 'X'. ENDIF.
    102
          ENDIF.
    103
          IF bc_key_needed NE space.                 "Tabkeys via new coding
    104
            LOOP AT corr_keytab.
    105
              MOVE-CORRESPONDING corr_keytab TO bc_keytab_wa.
    106
              APPEND bc_keytab_wa TO bc_keytab.
    107
            ENDLOOP.
    108
            PERFORM vim_build_bc_tabkeys USING w_bc_entry_list
    109
                                      CHANGING bc_keytab.
    110
          ELSE.  "Tabkeys as up to now via generated coding (corr_maint_...)
    111
            LOOP AT corr_keytab.
    112
              MOVE-CORRESPONDING corr_keytab TO bc_keytab_wa.
    113
              MOVE corr_keytab-tabkey TO bc_keytab_wa-bc_tabkey.
    114
              APPEND bc_keytab_wa TO bc_keytab.
    115
            ENDLOOP.
    116
    *     Look for other languages in bc-set and append to corr_keytab too
    117
            IF x_header-texttbexst NE space.
    118
              READ TABLE bc_keytab into bc_keytab_wa
    119
                                   with key objname = x_header-texttab.
    120
              LOOP AT w_bc_entry_list-forlangu INTO foreign_langu.
    121
                ASSIGN foreign_langu TO <xlangu> casting.
    122
                MOVE <xlangu> TO
    123
        <vim_bc_keyx>+x_header-sprasfdpos(cl_abap_char_utilities=>charsize).
    124
                APPEND bc_keytab_wa TO bc_keytab.
    125
              ENDLOOP.
    126
            ENDIF.
    127
          ENDIF.
    128
        ELSE.                                                   "base table
    129
          MOVE <vim_xtotal> TO <table1_x>.
    130
          MOVE-CORRESPONDING e071k TO bc_keytab_wa.
    131
          MOVE e071k-tabkey TO bc_keytab_wa-bc_tabkey.
    132
          bc_keytab_wa-objname = x_header-maintview.
    133
          MOVE <bc_entry_keyx> TO <vim_bc_keyx>(x_header-keylen).
    134
          APPEND bc_keytab_wa TO bc_keytab.
    135
          IF x_header-bastab <> space AND
    136
             x_header-texttbexst NE space AND         "base table with
    137
             <vim_xtotal_text> NE <text_initial_x>.   "text table
    138
            MOVE-CORRESPONDING e071k TO bc_keytab_wa.
    139
            MOVE e071k-tabkey TO bc_keytab_wa-bc_tabkey.
    140
            bc_keytab_wa-objname = x_header-texttab.
    141
            MOVE <vim_xtotal_text> TO <vim_bc_keyx>(x_header-textkeylen).
    142
            APPEND bc_keytab_wa TO bc_keytab.
    143
    *       other languages
    144
            READ TABLE x_namtab WITH KEY keyflag = 'X'         "langu field
    145
                                   primtabkey = '0000'.
    146
            LOOP AT w_bc_entry_list-forlangu INTO foreign_langu.
    147
              ASSIGN foreign_langu TO <xlangu> CASTING.
    148
              MOVE <xlangu> TO
    149
                   <vim_bc_keyx>+x_namtab-texttabpos(x_namtab-flength).
    150
              APPEND bc_keytab_wa TO bc_keytab.
    151
            ENDLOOP.
    152
          ENDIF.
    153
        ENDIF.                             "base table or view
    154
        CASE w_bc_entry_list-action.
    155
          WHEN neuer_eintrag.
    156
    * bc-set imported
    157
            PERFORM bc_entry_log_fill USING     x_header
    158
                                                x_namtab[]
    159
                                                bc_keytab[]
    160
                                                w_bc_entry_list
    161
                                          CHANGING tabkey_values_n.
    162
            CLEAR w_bc_entry_list-action.
    163
          WHEN aendern.
    164
    * bc-set entry modified
    165
            PERFORM bc_entry_log_fill USING     x_header
    166
                                                x_namtab[]
    167
                                                bc_keytab[]
    168
                                                w_bc_entry_list
    169
                                          CHANGING tabkey_values_u.
    170
            CLEAR w_bc_entry_list-action.
    171
            MOVE: w_bc_entry_list-id TO w_bc_entry-bcset_id,
    172
                  w_bc_entry_list-recnumber TO w_bc_entry-recnumber,
    173
                  x_header-viewname TO w_bc_entry-viewname,
    174
                  <vim_xtotal> TO <w_bc_entry_x>.
    175
            APPEND w_bc_entry TO bc_entries.
    176
          WHEN geloescht.
    177
    * bc-set entry deleted.
    178
            PERFORM bc_entry_log_fill USING     x_header
    179
                                                x_namtab[]
    180
                                                bc_keytab[]
    181
                                                w_bc_entry_list
    182
                                          CHANGING tabkey_values_d.
    183
            DELETE p_bc_entry_list.
    184
        ENDCASE.
    185
        REFRESH corr_keytab.   "weg???
    186
        REFRESH bc_keytab.
    187
      ENDLOOP.
    188
      IF NOT tabkey_values_n IS INITIAL.
    189
        DELETE ADJACENT DUPLICATES FROM tabkey_values_n COMPARING ALL
    190
         FIELDS.
    191
        LOOP AT tabkey_values_n INTO w_tabkey_value.
    192
          CALL FUNCTION 'SCPR_EXT_SCPRACTR_FILL'
    193
            EXPORTING
    194
              tablename         = w_tabkey_value-tablename
    195
              profid            = w_tabkey_value-profid
    196
              recnumber         = w_tabkey_value-recnumber
    197
              viewname          = x_header-maintview
    198
              viewvar           = x_header-viewname
    199
              del_record        = ' '
    200
              new_record        = 'X'
    201
              key               = w_tabkey_value-tabkey
    202
            EXCEPTIONS
    203
              wrong_parameters  = 1
    204
              internal_error    = 2
    205
              key_not_supportet = 3
    206
              fielddescr_error  = 4
    207
              OTHERS            = 5.
    208
          IF sy-subrc <> 0.
    209
            p_msgid = 'SCPR'.
    210
            CASE sy-subrc.
    211
              WHEN 1.
    212
                p_msgty = 'E'.
    213
                p_msgno = '273'.
    214
              WHEN 3.
    215
                p_msgty = 'W'.
    216
                p_msgno = '408'.
    217
              WHEN 4.
    218
                p_msgty = 'E'.
    219
                p_msgno = '395'.
    220
              WHEN OTHERS.
    221
                p_msgty = 'E'.
    222
                p_msgno = '320'.
    223
            ENDCASE.
    224
            PERFORM vim_process_message USING sy-msgid sy-msgty sy-msgty
    225
                                      sy-msgno space space space space.
    226
          ENDIF.
    227
        ENDLOOP.
    228
      ENDIF.
    229
      IF NOT tabkey_values_u IS INITIAL.
    230
        DELETE ADJACENT DUPLICATES FROM tabkey_values_u COMPARING ALL
    231
         FIELDS.
    232
        LOOP AT tabkey_values_u INTO w_tabkey_value.
    233
          CALL FUNCTION 'SCPR_EXT_SCPRACTR_FILL'
    234
            EXPORTING
    235
              tablename         = w_tabkey_value-tablename
    236
              profid            = w_tabkey_value-profid
    237
              recnumber         = w_tabkey_value-recnumber
    238
              viewname          = x_header-maintview
    239
              viewvar           = x_header-viewname
    240
              del_record        = ' '
    241
              new_record        = ' '
    242
              key               = w_tabkey_value-tabkey
    243
            EXCEPTIONS
    244
              wrong_parameters  = 1
    245
              internal_error    = 2
    246
              key_not_supportet = 3
    247
              fielddescr_error  = 4
    248
              OTHERS            = 5.
    249
          IF sy-subrc <> 0.
    250
            p_msgid = 'SCPR'.
    251
            CASE sy-subrc.
    252
              WHEN 1.
    253
                p_msgty = 'E'.
    254
                p_msgno = '273'.
    255
              WHEN 3.
    256
                p_msgty = 'W'.
    257
                p_msgno = '408'.
    258
              WHEN 4.
    259
                p_msgty = 'E'.
    260
                p_msgno = '395'.
    261
              WHEN OTHERS.
    262
                p_msgty = 'E'.
    263
                p_msgno = '320'.
    264
            ENDCASE.
    265
            PERFORM vim_process_message USING sy-msgid sy-msgty sy-msgty
    266
                                      sy-msgno space space space space.
    267
          ENDIF.
    268
        ENDLOOP.
    269
      ENDIF.
    270
      IF NOT tabkey_values_d IS INITIAL.
    271
        DELETE ADJACENT DUPLICATES FROM tabkey_values_d COMPARING ALL
    272
         FIELDS.
    273
        LOOP AT tabkey_values_d INTO w_tabkey_value.
    274
          CALL FUNCTION 'SCPR_EXT_SCPRACTR_FILL'
    275
            EXPORTING
    276
              tablename         = w_tabkey_value-tablename
    277
              profid            = w_tabkey_value-profid
    278
              recnumber         = w_tabkey_value-recnumber
    279
              viewname          = x_header-maintview
    280
              viewvar           = x_header-viewname
    281
              del_record        = 'X'
    282
              new_record        = ' '
    283
              key               = w_tabkey_value-tabkey
    284
            EXCEPTIONS
    285
              wrong_parameters  = 1
    286
              internal_error    = 2
    287
              key_not_supportet = 3
    288
              fielddescr_error  = 4
    289
              OTHERS            = 5.
    290
          IF sy-subrc <> 0.
    291
            p_msgid = 'SCPR'.
    292
            CASE sy-subrc.
    293
              WHEN 1.
    294
                p_msgty = 'E'.
    295
                p_msgno = '273'.
    296
              WHEN 3.
    297
                p_msgty = 'W'.
    298
                p_msgno = '408'.
    299
              WHEN 4.
    300
                p_msgty = 'E'.
    301
                p_msgno = '395'.
    302
              WHEN OTHERS.
    303
                p_msgty = 'E'.
    304
                p_msgno = '320'.
    305
            ENDCASE.
    306
            PERFORM vim_process_message USING sy-msgid sy-msgty sy-msgty
    307
                                      sy-msgno space space space space.
    308
          ENDIF.
    309
        ENDLOOP.
    310
      ENDIF.
    311
      IF NOT corr_keytab_save IS INITIAL.
    312
        INSERT LINES OF corr_keytab_save INTO TABLE corr_keytab.
    313
      ENDIF.
    314
    ENDFORM.                               " VIM_BC_LOGS_PUT
    315
    316
    *&---------------------------------------------------------------------*
    317
    *&      Form  bc_entry_log_fill
    318
    *&---------------------------------------------------------------------*
    319
    *       fills value table for BC-set activation log for every fix entity
    320
    *       field
    321
    *----------------------------------------------------------------------*
    322
    *      -->P_HEADER  text
    323
    *      -->P_NAMTAB  text
    324
    *      -->P_CORR_KEYTAB  text
    325
    *      -->P_BC_ENTRY  text
    326
    *      <--P_TABKEY_VALUE  text
    327
    *----------------------------------------------------------------------*
    328
    FORM bc_entry_log_fill USING        p_header TYPE vimdesc
    329
                                        p_namtab LIKE x_namtab[]
    330
                                        p_bc_keytab TYPE bc_keytab_type
    331
                                   p_bc_entry TYPE vimty_bc_entry_list_type
    332
                              CHANGING p_tabkey_values TYPE vim_bc_tab_logs.
    333
    334
      STATICS: dd28j_tab TYPE TABLE OF dd28j.
    335
      DATA: w_dd28j TYPE dd28j, w_tabkey_value TYPE scpractr,
    336
            w_fields TYPE vimty_fields_type.
    337
      FIELD-SYMBOLS: <namtab> TYPE vimnamtab, <dfies> TYPE dfies,
    338
                     <keytab> TYPE bc_key_type.
    339
    340
      IF p_header-bastab = space.
    341
        READ TABLE dd28j_tab INTO w_dd28j INDEX 1.
    342
        IF sy-subrc <> 0 OR p_header-viewname <> w_dd28j-viewname.
    343
    * get join-conditions
    344
          REFRESH dd28j_tab.
    345
          CALL FUNCTION 'DDIF_VIEW_GET'
    346
            EXPORTING
    347
              name          = p_header-viewname
    348
            TABLES
    349
              dd28j_tab     = dd28j_tab
    350
            EXCEPTIONS
    351
              illegal_input = 1
    352
              OTHERS        = 2.
    353
          IF sy-subrc <> 0.
    354
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    355
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    356
          ENDIF.
    357
        ENDIF.
    358
      ENDIF.
    359
      w_tabkey_value-client = sy-mandt.
    360
      w_tabkey_value-profid = p_bc_entry-id.
    361
      w_tabkey_value-recnumber = p_bc_entry-recnumber.
    362
      w_tabkey_value-viewname = p_header-maintview.             "HCG 6.8.02
    363
      LOOP AT p_namtab ASSIGNING <namtab> WHERE keyflag = space OR
    364
       texttabfld = space.
    365
        READ TABLE p_bc_entry-fields INTO w_fields WITH KEY fieldname =
    366
         <namtab>-viewfield.
    367
        CHECK sy-subrc = 0.
    368
        READ TABLE p_tabkey_values WITH KEY client = sy-mandt
    369
          tablename = <namtab>-bastabname profid = p_bc_entry-id
    370
          recnumber = p_bc_entry-recnumber viewname = p_header-viewname
    371
          TRANSPORTING NO FIELDS.
    372
        IF sy-subrc <> 0.
    373
          LOOP AT p_bc_keytab ASSIGNING <keytab> WHERE
    374
                                    pgmid = 'R3TR' AND
    375
                                   object = 'TABU' AND
    376
                                  objname = <namtab>-bastabname.
    377
            w_tabkey_value-tablename = <namtab>-bastabname.
    378
            w_tabkey_value-tabkey = <keytab>-bc_tabkey.
    379
            APPEND w_tabkey_value TO p_tabkey_values.
    380
          ENDLOOP.
    381
          CHECK sy-subrc = 0.
    382
        ENDIF.
    383
        IF x_header-bastab = space.
    384
    * view
    385
          LOOP AT dd28j_tab INTO w_dd28j WHERE viewname = p_header-viewname
    386
           AND ltab = <namtab>-bastabname AND lfield = <namtab>-viewfield.
    387
            READ TABLE p_tabkey_values WITH KEY client = sy-mandt
    388
              tablename = w_dd28j-rtab profid = p_bc_entry-id
    389
              recnumber = p_bc_entry-recnumber viewname = p_header-viewname
    390
              TRANSPORTING NO FIELDS.
    391
            IF sy-subrc <> 0.
    392
              READ TABLE p_bc_keytab WITH KEY pgmid = 'R3TR'
    393
                                object = 'TABU'
    394
                                  objname = w_dd28j-rtab ASSIGNING <keytab>.
    395
              CHECK sy-subrc = 0.
    396
              w_tabkey_value-tablename = w_dd28j-rtab.
    397
              w_tabkey_value-tabkey = <keytab>-bc_tabkey.
    398
              APPEND w_tabkey_value TO p_tabkey_values.
    399
            ENDIF.
    400
          ENDLOOP.
    401
          LOOP AT dd28j_tab INTO w_dd28j WHERE viewname = p_header-viewname
    402
           AND rtab = <namtab>-bastabname AND rfield = <namtab>-viewfield.
    403
            READ TABLE p_tabkey_values WITH KEY client = sy-mandt
    404
              tablename = w_dd28j-ltab profid = p_bc_entry-id
    405
              recnumber = p_bc_entry-recnumber viewname = p_header-viewname
    406
              TRANSPORTING NO FIELDS.
    407
            IF sy-subrc <> 0.
    408
              LOOP AT p_bc_keytab ASSIGNING <keytab> WHERE
    409
                                    pgmid = 'R3TR' AND
    410
                                   object = 'TABU' AND
    411
                                  objname = w_dd28j-ltab.
    412
                w_tabkey_value-tablename = w_dd28j-ltab.
    413
                w_tabkey_value-tabkey = <keytab>-bc_tabkey.
    414
                APPEND w_tabkey_value TO p_tabkey_values.
    415
              ENDLOOP.
    416
              CHECK sy-subrc = 0.
    417
            ENDIF.
    418
          ENDLOOP.
    419
        ENDIF.
    420
      ENDLOOP.
    421
    ENDFORM.                               " bc_entry_log_fill
    422
    *&---------------------------------------------------------------------*
    423
    *&      Form  VIM_BC_LOGS_GET
    424
    *&---------------------------------------------------------------------*
    425
    *       text
    426
    *----------------------------------------------------------------------*
    427
    *      <--P_C_ENTRY_LIST  text
    428
    *      -->P_VIEW_NAME  text
    429
    *      -->P_HEADER  text
    430
    *      -->P_NAMTAB  text
    431
    *----------------------------------------------------------------------*
    432
    FORM vim_bc_logs_get USING    p_view_name TYPE tabname
    433
                                  p_header TYPE vimdesc
    434
                                  p_namtab LIKE x_namtab[]
    435
                    CHANGING p_bc_entry_list TYPE vimty_bc_entry_list_ttype.
    436
    437
      STATICS: tablist TYPE TABLE OF scprxtabl, viewname TYPE tabname.
    438
    439
      DATA:    tabkeys TYPE TABLE OF scpractr, w_tablist TYPE scprxtabl,
    440
               bc_entry_list_wa TYPE vimty_bc_entry_list_type, failed(1),
    441
               rc LIKE sy-subrc, keys_identical TYPE xfeld,
    442
               x030l_root TYPE x030l,
    443
               x030l_bastab TYPE x030l,
    444
               root_entry TYPE REF TO data,
    445
               bastab_entry TYPE REF TO data,
    446
               tabflags TYPE scpr_actfs, tabflags_wa TYPE scpr_actf,
    447
    *           tabflags_quick TYPE HASHED TABLE OF scpr_actf
    448
    *            WITH UNIQUE KEY tablename fieldname bcset_id
    449
               tabflags_quick TYPE SORTED TABLE OF scpr_actf
    450
                WITH NON-UNIQUE KEY tablename fieldname bcset_id
    451
                recnumber tabkey INITIAL SIZE 100,
    452
               fields_wa TYPE vimty_fields_type,
    453
               bc_entry_list TYPE STANDARD TABLE OF
    454
                vimty_bc_entry_list_type WITH KEY viewname keys,
    455
                tabkey_wa TYPE scpractr-tabkey,
    456
                tabkeys_wa TYPE scpractr,
    457
                roottab TYPE tabname,
    458
                tabix TYPE sy-tabix,
    459
                tabkey_struc(1024) TYPE c.
    460
      FIELD-SYMBOLS: <namtab> TYPE vimnamtab, <tabkeys> TYPE scpractr,
    461
                     <tabkeys_main> TYPE scpractr,
    462
                     <bastab> TYPE ANY, <bastab_x> TYPE x,
    463
                     <roottab> TYPE ANY, <roottab_x> TYPE x,
    464
                     <rootfld> TYPE ANY,
    465
                     <tabkey> TYPE x, <viewfld> TYPE ANY,
    466
                     <clnt> TYPE ANY,
    467
                     <tabkey_c> TYPE c.
    468
    469
      DELETE p_bc_entry_list WHERE viewname = p_header-maintview."HCG 6.8.02
    470
      CHECK vim_import_profile = space.
    471
    * CHECK 'TS' NS maint_mode.   "HCG Necessary in show and transport mode
    472
    *                   too, e.g. for selection show only data from BC-Sets
    473
      IF viewname <> p_header-viewname.
    474
    * make table list
    475
        viewname = p_header-viewname.
    476
        REFRESH tablist.
    477
        w_tablist-sign = 'I'. w_tablist-option = 'EQ'.
    478
        IF p_header-bastab EQ 'X'.                              "S-table
    479
          w_tablist-low = viewname.         "HCG only roottab in tablist
    480
          roottab = viewname.
    481
          COLLECT w_tablist INTO tablist.
    482
        ELSE.                                                      "View
    483
          w_tablist-low = p_header-roottab. "HCG only roottab in tablist
    484
          roottab = p_header-roottab.
    485
          COLLECT w_tablist INTO tablist.
    486
        ENDIF.
    487
      ENDIF.
    488
      CALL FUNCTION 'SCPR_BCSET_PROT_GET_TABKEYS'
    489
        EXPORTING
    490
          viewname = viewname
    491
        IMPORTING
    492
          actkeys  = tabkeys
    493
          tabflags = tabflags
    494
        TABLES
    495
          tabnames = tablist
    496
        EXCEPTIONS
    497
          no_data  = 1
    498
          OTHERS   = 2.
    499
      CHECK sy-subrc = 0 AND NOT tabkeys IS INITIAL.
    500
      IF p_header-bastab EQ 'X'.                              "S-table
    501
        roottab = viewname.
    502
      ELSE.                                                      "View
    503
        roottab = p_header-roottab.
    504
      ENDIF.
    505
      LOOP AT tabkeys INTO tabkeys_wa.
    506
        tabkey_wa = tabkeys_wa-tabkey.
    507
        tabix = sy-tabix.
    508
        CALL FUNCTION 'SCPR_EXT_ACTKEY_TO_KEY'
    509
          EXPORTING
    510
            tablename              = roottab
    511
            tablekey               = tabkey_wa
    512
          IMPORTING
    513
            key                    = tabkey_struc
    514
          EXCEPTIONS
    515
            WRONG_PARAMETERS       = 1
    516
            KEY_TOO_LARGE          = 2
    517
            FIELDDESCR_ERROR       = 3
    518
            INTERNAL_ERROR         = 4
    519
            OTHERS                 = 5.
    520
        IF sy-subrc NE 0.
    521
          MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
    522
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    523
        ENDIF.
    524
        ASSIGN tabkey_struc TO <tabkey_c> CASTING.
    525
        tabkeys_wa-tabkey = <tabkey_c>.
    526
        MODIFY tabkeys FROM tabkeys_wa INDEX tabix.
    527
      ENDLOOP.
    528
      bc_entry_list_wa-viewname = p_header-maintview.          "HCG 6.8.02
    529
      IF p_header-clidep <> space.
    530
        READ TABLE p_namtab ASSIGNING <namtab>
    531
         WITH KEY datatype = 'CLNT'.
    532
        ASSIGN COMPONENT <namtab>-viewfield
    533
         OF STRUCTURE <table1_wa> TO <clnt>.
    534
      ENDIF.
    535
      IF p_header-bastab = space.
    536
    * build up viewkeys and put'em into entry list
    537
    ***********************************************************************
    538
    * viewkey and roottabkey identical?
    539
        PERFORM vim_comp_roottabkey USING p_header
    540
                                          p_namtab
    541
                                    CHANGING keys_identical
    542
                                             rc.
    543
        CHECK rc = 0.
    544
        IF keys_identical = space.
    545
          PERFORM vim_get_x030l USING p_header-roottab
    546
                                CHANGING x030l_root
    547
                                         rc.
    548
          CHECK rc = 0.
    549
          CREATE DATA root_entry TYPE (p_header-roottab).
    550
          ASSIGN: root_entry->* TO <roottab>,
    551
                  <roottab> TO <roottab_x> CASTING.
    552
        ENDIF.
    553
        INSERT LINES OF tabflags INTO TABLE tabflags_quick.
    554
        LOOP AT tabkeys ASSIGNING <tabkeys_main> WHERE
    555
         tablename = p_header-roottab.
    556
          CLEAR: failed, <table1_wa>.
    557
    * get all primary table entries
    558
          bc_entry_list_wa-id = <tabkeys_main>-profid.
    559
          bc_entry_list_wa-recnumber = <tabkeys_main>-recnumber.
    560
          ASSIGN <tabkeys_main>-tabkey TO <tabkey> CASTING.
    561
          IF keys_identical <> space.
    562
    * move complete table key to view key
    563
            MOVE <tabkey>(p_header-keylen) TO <f1_wax>.
    564
          ELSE.
    565
    * fill view key field by field
    566
            CLEAR: <roottab>.
    567
            MOVE <tabkey>(x030l_root-keylen)
    568
             TO <roottab_x>(x030l_root-keylen).
    569
            LOOP AT p_namtab ASSIGNING <namtab> WHERE keyflag <> space AND
    570
             texttabfld = space.
    571
    * build viewkey...
    572
              CHECK <namtab>-datatype <> 'CLNT' OR p_header-clidep = space.
    573
              ASSIGN COMPONENT <namtab>-viewfield
    574
               OF STRUCTURE <table1_wa> TO <viewfld>.
    575
              IF <namtab>-bastabname = p_header-roottab.
    576
    * ... from primary table
    577
                ASSIGN COMPONENT <namtab>-bastabfld OF STRUCTURE <roottab>
    578
                 TO <rootfld>.
    579
                MOVE <rootfld> TO <viewfld>.
    580
              ELSE.
    581
    * ... from secondary table
    582
                failed = 'X'.
    583
                IF NOT <tabkeys> IS ASSIGNED
    584
                 OR <tabkeys>-tablename <> <namtab>-bastabname.
    585
                  READ TABLE tabkeys ASSIGNING <tabkeys>
    586
                   WITH KEY tablename = <namtab>-bastabname
    587
                            recnumber = <tabkeys_main>-recnumber
    588
                            profid = <tabkeys_main>-profid.
    589
                  IF sy-subrc <> 0.
    590
                    UNASSIGN <tabkeys>.
    591
                    EXIT.
    592
                  ENDIF.
    593
                  PERFORM vim_get_x030l USING <namtab>-bastabname
    594
                                        CHANGING x030l_bastab
    595
                                                 rc.
    596
                  CHECK rc = 0.
    597
                  CREATE DATA bastab_entry TYPE (<namtab>-bastabname).
    598
                  ASSIGN: bastab_entry->* TO <bastab>,
    599
                          <bastab> TO <bastab_x> CASTING.
    600
                ENDIF.
    601
                MOVE <tabkey>(x030l_bastab-keylen)
    602
                 TO <bastab_x>(x030l_bastab-keylen).
    603
                ASSIGN COMPONENT <namtab>-bastabfld OF STRUCTURE <bastab>
    604
                 TO <rootfld>.
    605
                MOVE <rootfld> TO <viewfld>.
    606
                CLEAR failed.
    607
              ENDIF.
    608
            ENDLOOP.
    609
            CHECK failed IS INITIAL.
    610
          ENDIF.
    611
          IF p_header-clidep <> space.
    612
    * fill client-field
    613
            MOVE sy-mandt TO <clnt>.
    614
          ENDIF.
    615
          MOVE <f1_wax> TO bc_entry_list_wa-keys.
    616
          REFRESH bc_entry_list_wa-fields.
    617
          LOOP AT p_namtab ASSIGNING <namtab>.
    618
            CHECK <namtab>-datatype <> 'CLNT' OR p_header-clidep = space.
    619
    * get bc-set field attributes
    620
            READ TABLE tabflags_quick INTO tabflags_wa WITH KEY
    621
             tablename = p_header-viewname fieldname = <namtab>-viewfield
    622
             bcset_id = bc_entry_list_wa-id
    623
             recnumber = bc_entry_list_wa-recnumber.
    624
            CHECK sy-subrc = 0.
    625
            fields_wa-fieldname = <namtab>-viewfield.
    626
            fields_wa-flag = tabflags_wa-flag.
    627
            APPEND fields_wa TO bc_entry_list_wa-fields.
    628
          ENDLOOP.
    629
          INSERT bc_entry_list_wa INTO TABLE bc_entry_list.
    630
        ENDLOOP.
    631
      ELSE.
    632
    * move table keys into entry list
    633
    ***********************************************************************
    634
        LOOP AT tabkeys ASSIGNING <tabkeys_main> WHERE
    635
         tablename = p_header-viewname.
    636
          bc_entry_list_wa-id = <tabkeys_main>-profid.
    637
          bc_entry_list_wa-recnumber = <tabkeys_main>-recnumber.
    638
          ASSIGN <tabkeys_main>-tabkey TO <tabkey> CASTING.
    639
          MOVE <tabkey>(p_header-keylen) TO <table1_wax>(p_header-keylen).
    640
          IF p_header-clidep <> space.
    641
    * fill client-field
    642
            MOVE sy-mandt TO <clnt>.
    643
          ENDIF.
    644
          MOVE <f1_wax> TO bc_entry_list_wa-keys.
    645
    * get bc-set field attributes
    646
          LOOP AT tabflags INTO tabflags_wa WHERE ( tablename =
    647
           p_header-viewname OR tablename = p_header-texttab ) AND
    648
           bcset_id = bc_entry_list_wa-id
    649
           AND recnumber = bc_entry_list_wa-recnumber.
    650
            fields_wa-fieldname = tabflags_wa-fieldname.
    651
            fields_wa-flag = tabflags_wa-flag.
    652
            APPEND fields_wa TO bc_entry_list_wa-fields.
    653
          ENDLOOP.
    654
          INSERT bc_entry_list_wa INTO TABLE bc_entry_list.
    655
        ENDLOOP.
    656
      ENDIF.
    657
      SORT bc_entry_list.
    658
    * should normally not be necessary:
    659
      DELETE ADJACENT DUPLICATES FROM bc_entry_list.
    660
      DESCRIBE TABLE bc_entry_list.
    661
    * changing of fix BC-set-entries?
    662
      CLEAR <status>-bcfixnochg.
    663
      IF sy-tfill > 0.
    664
        INSERT LINES OF bc_entry_list INTO TABLE p_bc_entry_list.
    665
        CALL FUNCTION 'SCPR_AUTHORITY_CHECK'
    666
          EXPORTING
    667
            task             = 'CHGFIXVAL'
    668
          EXCEPTIONS
    669
            wrong_parameters = 1
    670
            no_authority     = 2
    671
            OTHERS           = 3.
    672
        IF sy-subrc <> 0.
    673
          <status>-bcfixnochg = 'N'.
    674
        ELSE.
    675
          <status>-bcfixnochg = 'Y'.
    676
        ENDIF.
    677
      ENDIF.
    678
    ENDFORM.                               " VIM_GET_BC_LOGS
    679
    *&---------------------------------------------------------------------*
    680
    *&      Form  VIM_BC_LOGS_MAINTAIN
    681
    *&---------------------------------------------------------------------*
    682
    *       text
    683
    *----------------------------------------------------------------------*
    684
    *      -->P_HEADER         Header info of maintenance dialog
    685
    *      -->P_BACKGROUND     Flag: 'X' means BC-set import in background
    686
    *                                running.
    687
    *      <--P_BC_ENTRY_LIST  List of entries coming from BC-set
    688
    *----------------------------------------------------------------------*
    689
    FORM vim_bc_logs_maintain USING    p_header TYPE vimdesc
    690
                                       p_background TYPE xfeld
    691
                              CHANGING p_bc_entry_list LIKE
    692
                                       vim_bc_entry_list.
    693
    694
      DATA: fields_wa TYPE vimty_fields_type,
    695
            subrc TYPE sy-subrc, tabix TYPE sy-tabix.
    696
      STATICS:       viewname_old TYPE vimdesc-viewname,
    697
                     keylen_real TYPE i.
    698
      FIELD-SYMBOLS: <bc_entry> TYPE vimty_bc_entry_list_type,
    699
                     <key> TYPE x, <namtab> type vimnamtab.
    700
    701
      IF p_background = space.
    702
    * bc import running in dialogue
    703
        LOOP AT total.
    704
          CHECK ' N' NS <action>.
    705
          READ TABLE p_bc_entry_list ASSIGNING <bc_entry> WITH KEY
    706
           viewname = p_header-viewname keys = <vim_xtotal_key>.
    707
          CHECK sy-subrc = 0.
    708
          CASE <action>.
    709
            WHEN aendern.
    710
    * Rel. 4.6 only: does entry contain fix values?
    711
    *          LOOP AT <bc_entry>-fields INTO fields_wa
    712
    *           WHERE flag = vim_profile_fix.
    713
    *            TRANSLATE <bc_entry>-action USING ' U'.
    714
    *            EXIT.
    715
    *          ENDLOOP.
    716
            WHEN geloescht.
    717
    * deleting bc-set-entry
    718
              CASE <bc_entry>-action.
    719
                WHEN neuer_eintrag.
    720
                  <bc_entry>-action = neuer_geloescht.
    721
                WHEN OTHERS.
    722
                  <bc_entry>-action = geloescht.
    723
              ENDCASE.
    724
    *      WHEN zurueckholen.
    725
    ** undeleting BC-set-entry --> maintain table of BC-Set-entries
    726
    *        CASE <bc_entry>-action.
    727
    *          WHEN neuer_geloescht.
    728
    *            <bc_entry>-action = neuer_eintrag.
    729
    *          WHEN OTHERS.
    730
    *            <bc_entry>-action = original.
    731
          ENDCASE.
    732
        ENDLOOP.
    733
      ELSE.
    734
    * bc import running in background
    735
        DELETE vim_bc_entry_list WHERE viewname = p_header-viewname.
    736
        PERFORM vim_get_global_table IN PROGRAM saplsvim
    737
                    USING 'VIM_BC_ENTRY_LIST'
    738
                           vim_bc_entry_list
    739
                           sy-subrc.
    740
        IF sy-subrc <> 0.
    741
          EXIT.
    742
        ENDIF.
    743
        IF p_header-viewname NE viewname_old. "HCG: has table align gap?
    744
          viewname_old = p_header-viewname.
    745
          CLEAR keylen_real.
    746
          LOOP AT x_namtab ASSIGNING <namtab> WHERE keyflag = 'X' AND
    747
                                                    texttabfld IS INITIAL.
    748
            keylen_real = keylen_real + <namtab>-flength.
    749
          ENDLOOP.
    750
        ENDIF.
    751
        LOOP AT vim_bc_entry_list ASSIGNING <bc_entry> WHERE
    752
         viewname = p_header-viewname.
    753
          ASSIGN <bc_entry>-keys(x_header-keylen) TO <key>.
    754
          IF p_header-keylen = keylen_real.
    755
            READ TABLE total WITH KEY <key> BINARY SEARCH.
    756
            subrc = sy-subrc.
    757
          ELSE.
    758
            PERFORM vim_read_table_with_gap
    759
                        TABLES   total
    760
                        USING    <key>
    761
                                 x_namtab[]
    762
                        CHANGING subrc
    763
                                 tabix.
    764
            IF subrc = 0.
    765
              READ TABLE total INDEX tabix.
    766
            ENDIF.
    767
          ENDIF.
    768
    * bc-set entry really imported?
    769
          IF subrc <> 0 OR 'NU' NS <action>.
    770
            DELETE vim_bc_entry_list.
    771
          ENDIF.
    772
        ENDLOOP.
    773
      ENDIF.
    774
    ENDFORM.                               " VIM_BC_LOGS_MAINTAIN
    775
    *&---------------------------------------------------------------------*
    776
    *&      Form  VIM_BC_LOGS_USE
    777
    *&---------------------------------------------------------------------*
    778
    *       delivers field attribute defined in BC-sets
    779
    *----------------------------------------------------------------------*
    780
    *      -->P_FIELD         text
    781
    *      -->P_VIM_BC_ENTRY  text
    782
    *      <--P_SCREEN_INPUT  text
    783
    *      <--P_MODIFY_SCREEN  text
    784
    *----------------------------------------------------------------------*
    785
    FORM vim_bc_logs_use USING p_field TYPE fieldname
    786
                               p_vim_bc_entry TYPE vimty_bc_entry_list_type
    787
                         CHANGING p_screen LIKE screen
    788
                                  p_modify_screen TYPE xfeld.
    789
    790
      DATA w_field TYPE vimty_fields_type.
    791
    792
      READ TABLE p_vim_bc_entry-fields INTO w_field
    793
       WITH TABLE KEY fieldname = p_field.
    794
      CHECK sy-subrc = 0.
    795
      IF w_field-flag = vim_profile_fix.
    796
        p_screen-input = 0.
    797
        p_modify_screen = 'X'.
    798
      ENDIF.
    799
    ENDFORM.                               " VIM_BC_LOGS_USE
    800
    *&---------------------------------------------------------------------*
    801
    *&      Form  vim_chng_fix_flds
    802
    *&---------------------------------------------------------------------*
    803
    *       make fix values form bc-sets modifiable
    804
    *----------------------------------------------------------------------*
    805
    *  -->  p1        text
    806
    *  <--  p2        text
    807
    *----------------------------------------------------------------------*
    808
    FORM vim_chng_fix_flds.
    809
      IF <status>-bcfixnochg = 'Y'.
    810
        vim_bc_chng_allowed = 'X'.
    811
      ELSE.
    812
        MESSAGE e202(sv).
    813
    *   Sie haben keine Berechtigung, Felder mit fixen BC-Set-Werten zu ände
    814
      ENDIF.
    815
    ENDFORM.                               " vim_chng_fix_flds
    816
    *&---------------------------------------------------------------------*
    817
    *&      Form  vim_get_x030l
    818
    *&---------------------------------------------------------------------*
    819
    *       Delivers X030l fron dictionary.
    820
    *----------------------------------------------------------------------*
    821
    *      -->P_TABNAME     tablename
    822
    *      <--P_X030L
    823
    *      <--P_RC
    824
    *----------------------------------------------------------------------*
    825
    FORM vim_get_x030l  USING    p_tabname TYPE tabname
    826
                        CHANGING p_x030l TYPE x030l
    827
                                 p_rc LIKE sy-subrc.
    828
      CALL FUNCTION 'DDIF_NAMETAB_GET'
    829
        EXPORTING
    830
          tabname  = p_tabname
    831
        IMPORTING
    832
          x030l_wa = p_x030l
    833
        EXCEPTIONS
    834
          OTHERS   = 1.
    835
      p_rc = sy-subrc.
    836
    ENDFORM.                    " vim_get_x030l
    837
    *&---------------------------------------------------------------------*
    838
    *&      Form  vim_bc_show_fix_flds
    839
    *&---------------------------------------------------------------------*
    840
    *       text
    841
    *----------------------------------------------------------------------*
    842
    *  -->  p1        text
    843
    *  <--  p2        text
    844
    *----------------------------------------------------------------------*
    845
    FORM vim_bc_show_fix_flds.
    846
    DATA: p_tabtype TYPE objh-objecttype,
    847
          p_tabname TYPE scpr_tabl.
    848
    849
      p_tabname = x_header-maintview. "HCG 6.8.02 actlinks for maintview
    850
      if x_header-bastab = space.
    851
        p_tabtype = 'V'.
    852
      ELSE.
    853
        p_tabtype = 'S'.
    854
      ENDIF.
    855
      LOOP AT extract.
    856
        IF <xmark> NE markiert.
    857
          CONTINUE.
    858
        ELSE.
    859
          MOVE <vim_extract_struc> TO <table1>.
    860
          CALL FUNCTION 'SCPR_ACTIVATION_INFOS_SHOW'
    861
            EXPORTING
    862
              tablename     = p_tabname
    863
              tabletype     = p_tabtype
    864
              record        = <table1>
    865
            EXCEPTIONS
    866
              FIELDDEFINITION_ERROR  = 1
    867
              NO_TVDIR_ENTRY         = 2
    868
              TABLE_NOT_FOUND        = 3
    869
              TABLE_TO_LARGE         = 4
    870
              DDIF_INTERNAL_ERROR    = 5
    871
              WRONG_PARAMETERS       = 6
    872
              INTERNAL_ERROR         = 7
    873
              NO_ACTLINKS            = 8
    874
              KEY_TOO_LARGE          = 9
    875
              OTHERS                 = 10.
    876
          case sy-subrc.
    877
            when 0.
    878
            when 1.
    879
              message e395(SCPR) raising FIELDDEFINITION_ERROR.
    880
            when 2.
    881
              message e028(SCPR) with p_tabname raising NO_TVDIR_ENTRY.
    882
            when 3.
    883
              message e120(SCPR) with p_tabname raising TABLE_NOT_FOUND.
    884
            when 4.
    885
              message e026(SCPR) with p_tabname raising TABLE_TO_LARGE.
    886
            when 5.
    887
              message e035(SCPR) raising DDIF_INTERNAL_ERROR.
    888
            when 6.
    889
              message e273(SCPR) raising WRONG_PARAMETERS.
    890
            when 8.
    891
              message s399(SCPR) raising NO_ACTLINKS.
    892
            when 9.
    893
              message e408(SCPR) raising KEY_TOO_LARGE.
    894
            when others.
    895
              message e320(SCPR) raising INTERNAL_ERROR.
    896
          endcase.
    897
        ENDIF.
    898
      ENDLOOP.
    899
    ENDFORM.                    " vim_bc_show_fix_flds
    900
    *&---------------------------------------------------------------------*
    901
    *&      Form  vim_build_bc_tabkeys
    902
    *&---------------------------------------------------------------------*
    903
    *   To build up table keys for views with keylen > 120 up to 256
    904
    *   and / or non-character like fields.
    905
    *----------------------------------------------------------------------*
    906
    *      <--P_BC_KEYTAB  text
    907
    *----------------------------------------------------------------------*
    908
    FORM vim_build_bc_tabkeys USING bc_entry_list_wa TYPE
    909
                                           vimty_bc_entry_list_type
    910
                           CHANGING p_bc_keytab TYPE bc_keytab_type.
    911
    912
      TYPES: BEGIN OF tablist_type,
    913
               tabname TYPE objs-tabname,
    914
             END OF tablist_type.
    915
    916
      STATICS: cg_dd28j_tab LIKE dd28j OCCURS 30,
    917
               old_viewname LIKE vimdesc-viewname,
    918
               all_dfiestab LIKE dfies OCCURS 40.
    919
    920
      DATA: objstablist TYPE TABLE OF tablist_type,
    921
            namtab_wa TYPE vimnamtab,
    922
            tabname_wa TYPE objs-tabname,
    923
            dd28j_wa LIKE LINE OF cg_dd28j_tab,
    924
            primtab_entry TYPE REF TO data,
    925
            sektab_entry TYPE REF TO data,
    926
            p_bc_keytab_wa LIKE LINE OF p_bc_keytab,
    927
            keytab_index TYPE sy-tabix,
    928
            bc_keylen TYPE i, flag(1) TYPE c,
    929
            cg_langu(1) TYPE c,
    930
            cg_dfiestab LIKE dfies OCCURS 10,
    931
            dfies_wa LIKE LINE OF cg_dfiestab,
    932
            piecelist TYPE TABLE OF objs-tabname,
    933
            foreign_langu LIKE sy-langu,
    934
            langu_fieldname TYPE dfies-fieldname,
    935
            p_bc_keytab_langu TYPE bc_keytab_type,
    936
            w_bc_entry_list TYPE vimty_bc_entry_list_type.
    937
    938
      FIELD-SYMBOLS: <primtab> TYPE ANY, <sektab> TYPE ANY,
    939
                     <viewfld> TYPE ANY,
    940
                     <primtabfld> TYPE ANY, <sektabfld> TYPE ANY,
    941
                     <bc_tabkey> TYPE bc_key_type-bc_tabkey,
    942
                     <tabkey_x> TYPE x, <tabkey_struc_x> TYPE x.
    943
    944
      IF x_header-viewname NE old_viewname.
    945
        old_viewname = x_header-viewname.
    946
        CALL FUNCTION 'DDIF_VIEW_GET'
    947
          EXPORTING
    948
            name          = x_header-viewname
    949
            state         = 'A'
    950
            langu         = sy-langu
    951
          IMPORTING
    952
            gotstate      = flag
    953
          TABLES
    954
            dd28j_tab     = cg_dd28j_tab
    955
          EXCEPTIONS
    956
            illegal_input = 1
    957
            OTHERS        = 2.
    958
        IF sy-subrc <> 0.
    959
          MESSAGE e164(sv) WITH tabname_wa RAISING view_not_found.
    960
        ENDIF.
    961
        IF flag = space.
    962
          MESSAGE e306(sv) WITH tabname_wa RAISING view_not_found.
    963
        ENDIF.
    964
    *   Get tables from piecelist
    965
        SELECT tabname FROM objs INTO tabname_wa
    966
                           WHERE objectname = x_header-viewname
    967
                             AND objecttype = 'V'.
    968
          APPEND tabname_wa TO piecelist.
    969
        ENDSELECT.
    970
        REFRESH all_dfiestab.
    971
        LOOP AT piecelist INTO tabname_wa.
    972
          REFRESH cg_dfiestab.
    973
          CALL FUNCTION 'DDIF_NAMETAB_GET'
    974
            EXPORTING
    975
              tabname   = tabname_wa
    976
            TABLES
    977
              dfies_tab = cg_dfiestab[]
    978
            EXCEPTIONS
    979
              not_found = 1
    980
              OTHERS    = 2.
    981
          IF sy-subrc NE 0.
    982
            MESSAGE e028(sv) WITH tabname_wa RAISING view_not_found.
    983
          ENDIF.
    984
          LOOP AT cg_dfiestab INTO dfies_wa.
    985
            APPEND dfies_wa TO all_dfiestab.
    986
          ENDLOOP.
    987
        ENDLOOP.
    988
      ENDIF.
    989
      LOOP AT p_bc_keytab INTO p_bc_keytab_wa.
    990
        keytab_index = sy-tabix.
    991
        IF p_bc_keytab_wa-objname = x_header-roottab.
    992
    *-----Build tabkey for root-table from viewkey-------------------------
    993
          CREATE DATA primtab_entry TYPE (x_header-roottab).
    994
          ASSIGN primtab_entry->* TO <primtab>.
    995
          LOOP AT x_namtab WHERE keyflag = 'X' AND
    996
                               bastabname = x_header-roottab.
    997
            ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE
    998
                       <vim_total_struc> TO <viewfld>.
    999
            ASSIGN COMPONENT x_namtab-bastabfld OF STRUCTURE <primtab>
    1000
                       TO <primtabfld>.
    1001
            MOVE <viewfld> TO <primtabfld>.
    1002
          ENDLOOP.                 " Primtabkey completely in <primtab>
    1003
          PERFORM vim_get_bc_keylen    "Analog corr_maint_>>viewname<<
    1004
                  USING x_header-roottab
    1005
               CHANGING bc_keylen.
    1006
          ASSIGN <primtab> TO <tabkey_struc_x> CASTING.
    1007
          ASSIGN p_bc_keytab_wa-bc_tabkey TO <tabkey_x> CASTING.
    1008
          MOVE <tabkey_struc_x>(bc_keylen) TO <tabkey_x>(bc_keylen).
    1009
          MODIFY p_bc_keytab INDEX keytab_index FROM p_bc_keytab_wa.
    1010
        ELSEIF p_bc_keytab_wa-objname EQ x_header-texttab.
    1011
    *-----Build tabkeys for textable of view from viewkey field by field---
    1012
          REFRESH p_bc_keytab_langu.
    1013
          tabname_wa = p_bc_keytab_wa-objname.
    1014
          CREATE DATA sektab_entry TYPE (tabname_wa).
    1015
          ASSIGN sektab_entry->* TO <sektab>.
    1016
          PERFORM vim_get_bc_keylen    "Analog corr_maint_>>viewname<<
    1017
                      USING tabname_wa
    1018
                      CHANGING bc_keylen.
    1019
          LOOP AT all_dfiestab INTO dfies_wa WHERE tabname = tabname_wa
    1020
                                              AND keyflag = 'X'.
    1021
            CLEAR cg_langu.
    1022
            READ TABLE cg_dd28j_tab WITH KEY rtab = tabname_wa
    1023
                                           rfield = dfies_wa-fieldname
    1024
                                        INTO dd28j_wa.
    1025
            IF sy-subrc EQ 0.
    1026
              READ TABLE x_namtab WITH KEY bastabname = dd28j_wa-ltab
    1027
                                            bastabfld = dd28j_wa-lfield.
    1028
            ELSE.       "Field not in join -> additional keyfield in view
    1029
              READ TABLE x_namtab WITH KEY bastabname = tabname_wa
    1030
                                        bastabfld = dfies_wa-fieldname.
    1031
              IF sy-subrc NE 0.    "Then it must be langu field of texttab
    1032
                cg_langu = 'X'.
    1033
              ENDIF.
    1034
            ENDIF.
    1035
            IF cg_langu EQ space.                 "Field is not langu field
    1036
              ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE
    1037
                         <vim_total_struc> TO <viewfld>.
    1038
              ASSIGN COMPONENT dfies_wa-fieldname OF STRUCTURE
    1039
                                               <sektab> TO <sektabfld>.
    1040
              MOVE <viewfld> TO <sektabfld>.
    1041
            ELSE.                                     "Field is langu field
    1042
              langu_fieldname = dfies_wa-fieldname.
    1043
              ASSIGN COMPONENT dfies_wa-fieldname OF STRUCTURE
    1044
                                               <sektab> TO <sektabfld>.
    1045
              MOVE sy-langu TO <sektabfld>.
    1046
            ENDIF.
    1047
            ASSIGN <sektab> TO <tabkey_struc_x> CASTING.
    1048
            ASSIGN p_bc_keytab_wa-bc_tabkey TO <tabkey_x> CASTING.
    1049
            MOVE <tabkey_struc_x>(bc_keylen) TO <tabkey_x>(bc_keylen).
    1050
          ENDLOOP.
    1051
          MODIFY p_bc_keytab INDEX keytab_index FROM p_bc_keytab_wa.
    1052
    *     Look for other languages in bc-set and append to p_bc_keytab too
    1053
          ASSIGN COMPONENT langu_fieldname OF STRUCTURE
    1054
                                               <sektab> TO <sektabfld>.
    1055
          LOOP AT bc_entry_list_wa-forlangu INTO foreign_langu.
    1056
            MOVE foreign_langu TO <sektabfld>.
    1057
            MOVE <tabkey_struc_x>(bc_keylen) TO <tabkey_x>(bc_keylen).
    1058
            APPEND p_bc_keytab_wa TO p_bc_keytab_langu.
    1059
          ENDLOOP.
    1060
        ELSE.
    1061
    *-----Build tabkeys for secondary tabs from viewkey field by field-----
    1062
          tabname_wa = p_bc_keytab_wa-objname.
    1063
          CREATE DATA sektab_entry TYPE (tabname_wa).
    1064
          ASSIGN sektab_entry->* TO <sektab>.
    1065
          PERFORM vim_get_bc_keylen    "Analog corr_maint_>>viewname<<
    1066
                      USING tabname_wa
    1067
                      CHANGING bc_keylen.
    1068
          LOOP AT all_dfiestab INTO dfies_wa WHERE tabname = tabname_wa
    1069
                                              AND keyflag = 'X'.
    1070
            CLEAR cg_langu.
    1071
            READ TABLE cg_dd28j_tab WITH KEY rtab = tabname_wa
    1072
                                           rfield = dfies_wa-fieldname
    1073
                                        INTO dd28j_wa.
    1074
            IF sy-subrc EQ 0.
    1075
              READ TABLE x_namtab WITH KEY bastabname = dd28j_wa-ltab
    1076
                                            bastabfld = dd28j_wa-lfield.
    1077
            ELSE.       "Field not in join -> additional keyfield in view
    1078
              READ TABLE x_namtab WITH KEY bastabname = tabname_wa
    1079
                                        bastabfld = dfies_wa-fieldname.
    1080
              IF sy-subrc NE 0.                 "Then it must be an error
    1081
    *            error.!!!!
    1082
              ENDIF.
    1083
            ENDIF.
    1084
            ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE
    1085
                       <vim_total_struc> TO <viewfld>.
    1086
            ASSIGN COMPONENT dfies_wa-fieldname OF STRUCTURE
    1087
                                             <sektab> TO <sektabfld>.
    1088
            MOVE <viewfld> TO <sektabfld>.
    1089
            ASSIGN <sektab> TO <tabkey_struc_x> CASTING.
    1090
            ASSIGN p_bc_keytab_wa-bc_tabkey TO <tabkey_x> CASTING.
    1091
            MOVE <tabkey_struc_x>(bc_keylen) TO <tabkey_x>(bc_keylen).
    1092
          ENDLOOP.
    1093
          MODIFY p_bc_keytab INDEX keytab_index FROM p_bc_keytab_wa.
    1094
        ENDIF.
    1095
      ENDLOOP.
    1096
      APPEND LINES OF p_bc_keytab_langu TO p_bc_keytab.
    1097
    ENDFORM.                    " vim_build_bc_tabkeys
    1098
    *&---------------------------------------------------------------------*
    1099
    *&      Form  vim_read_table_with_gap
    1100
    *&---------------------------------------------------------------------*
    1101
    *       Implementierung des
    1102
    *         READ TABLE <it_data> WITH KEY <key> BINARY SEARCH
    1103
    *       für Tabellen mit Alignment-Lücken (Nicht-Character-Feld wie
    1104
    *       z.B. ein INT4-Feld im Schlüssel)
    1105
    *
    1106
    *       Voraussetzung zum Aufruf: gap_table ist sortiert
    1107
    *
    1108
    *       Rückgabewert: SUBRC = 0    1. Datensatz passend zum KEY
    1109
    *       (analog                    wurde gefunden (wichtig für
    1110
    *        BINARY                    BC-Sets mit Schlüsselkonflikt)
    1111
    *        SEARCH)                   Datensatznummer in TABIX
    1112
    *
    1113
    *                     SUBRC = 4    Eintrag wurde nicht gefunden
    1114
    *                                  Datensatznummer + 1 in TABIX
    1115
    *
    1116
    *                     SUBRC = 8    Eintrag wurde nicht gefunden
    1117
    *                                  Letzte Datensatznummer + 1 in TABIX
    1118
    *----------------------------------------------------------------------*
    1119
    *     To use function SCPR_CTRL_CT_COMP_TWO_RECORDS table of field
    1120
    *     description in SCPR format is created and filled partly.
    1121
    *----------------------------------------------------------------------*
    1122
    FORM vim_read_table_with_gap TABLES   gap_table
    1123
                             USING    key   TYPE x
    1124
                                      namtab LIKE x_namtab[]
    1125
                             CHANGING subrc TYPE sy-subrc
    1126
                                      tabix TYPE sy-tabix.
    1127
    1128
      TYPES: scpr_x8192(8192) TYPE x.
    1129
      DATA: result  TYPE scpr_txt20,
    1130
            tab_i   TYPE sy-tabix,
    1131
            tab_j   TYPE sy-tabix,
    1132
            tab_k   TYPE sy-tabix,
    1133
            tab_len TYPE sy-tabix.
    1134
    1135
      DATA: align TYPE f, wa_8192 TYPE scpr_x8192,
    1136
            it_fldnames TYPE STANDARD TABLE OF scpr_flddescr,
    1137
            fldnames_wa LIKE LINE OF it_fldnames,
    1138
            gap_table_wa(2048) TYPE c.
    1139
      FIELD-SYMBOLS: <wa_it_data> TYPE x,
    1140
                     <namtab> TYPE vimnamtab.
    1141
    1142
    * Fill necessary fields in it_fieldnames from namtab
    1143
      LOOP AT namtab ASSIGNING <namtab> WHERE keyflag = 'X'
    1144
                                        AND texttabfld = space.
    1145
        fldnames_wa-fieldname = <namtab>-viewfield.
    1146
        fldnames_wa-position = <namtab>-position.
    1147
        fldnames_wa-intlen = <namtab>-flength.
    1148
        fldnames_wa-keyflag = 'X'.
    1149
        fldnames_wa-flag = 'FKY'. "KEY would do the same job...
    1150
        APPEND fldnames_wa TO it_fldnames.
    1151
      ENDLOOP.
    1152
    1153
      DESCRIBE TABLE gap_table LINES tab_len.
    1154
      tab_i = 1.
    1155
      tab_j = tab_len.
    1156
      subrc = 8.
    1157
      tabix = tab_len + 1.
    1158
      ASSIGN wa_8192 TO <wa_it_data>.
    1159
      ASSIGN gap_table_wa TO <wa_it_data> CASTING.
    1160
    1161
      DO.
    1162
        IF tab_i > tab_j.
    1163
    *     Datensatz wurde nicht gefunden
    1164
          subrc = 4.
    1165
          tabix = tab_k + 1.
    1166
          EXIT.
    1167
        ENDIF.
    1168
        tab_k = ( tab_i + tab_j ) / 2.
    1169
    1170
        READ TABLE gap_table INTO gap_table_wa INDEX tab_k.
    1171
    1172
        CALL FUNCTION 'SCPR_CTRL_CT_COMP_TWO_RECORDS'
    1173
          EXPORTING
    1174
            cu_lines    = <wa_it_data>
    1175
            bc_lines    = key
    1176
            compare_key = 'X'
    1177
          IMPORTING
    1178
            RESULT      = RESULT
    1179
          tables
    1180
            it_fldnames = it_fldnames.
    1181
    1182
        IF result = 'LT'.
    1183
          tab_j = tab_k - 1.
    1184
        ELSEIF result = 'GT'.
    1185
          tab_i = tab_k + 1.
    1186
        ELSE.
    1187
          subrc = 0.
    1188
          tabix = tab_k.
    1189
          EXIT.
    1190
        ENDIF.
    1191
      ENDDO.
    1192
    ENDFORM.                    " read_table_with_gap