Properties | SourceCde
Title | Subroutines for activating profiles |
Original language | DE | Englisch
Created | 03.06.1998 |  | SAP |
Last changed by | 23.06.2003 |  | SAP |
Status | Active |
Attributes
Type | INCLUDE program |
Status | Test program |
Application | Basis |
Package | SVIM | Basis View Maintenance
| Editor lock
txt
    1
    *----------------------------------------------------------------------*
    2
    *   INCLUDE LSVIMFXP  form routines to activate profiles               *
    3
    *----------------------------------------------------------------------*
    4
    *&---------------------------------------------------------------------*
    5
    *&      Form  GET_PROFILES
    6
    *&---------------------------------------------------------------------*
    7
    * NOT IN USE ANYMORE BUT CALLED IN APPLICATION FUNCTION GROUPS e.g.0WCA
    8
    *       Get customizing profiles using Function
    9
    *       SCPR_SHOW_CUT_OF_VIEW
    10
    *----------------------------------------------------------------------*
    11
    *  <--  p_selected  Flag X: Profil wurde bereits ausgewählt und
    12
    *                           importiert ==> nur anzeigen
    13
    *----------------------------------------------------------------------*
    14
    FORM get_profiles USING p_selected TYPE c.
    15
    16
      DATA: cobj_type VALUE 'V'.           "customizing-objecttype
    17
    18
      IF x_header-bastab NE space.
    19
        cobj_type = vim_tabl.
    20
      ENDIF.
    21
      CLEAR vim_pr_activating.
    22
      CALL FUNCTION 'SCPR_SHOW_OUT_OF_VIEW'
    23
           EXPORTING
    24
                tabname            = x_header-viewname
    25
                tabtype            = cobj_type
    26
                preselection       = p_selected
    27
                cluster            = vim_called_by_cluster
    28
           TABLES
    29
                header             = x_header
    30
                namtab             = x_namtab
    31
                sellist            = <vim_ck_sellist>
    32
           EXCEPTIONS
    33
                user_abort         = 1
    34
                no_profile_found   = 2
    35
                profile_dont_exist = 3
    36
                no_data            = 4
    37
                OTHERS             = 5.
    38
      CASE sy-subrc.
    39
        WHEN 2.
    40
          MESSAGE s820(sv).
    41
    *   Kein Profil gefunden.
    42
        WHEN 3.
    43
          IF cobj_type = 'S'.
    44
            MESSAGE s822(sv) WITH x_header-viewname.
    45
    *   Zur Tabelle & existiert kein Profil.
    46
          ELSE.
    47
            MESSAGE s821(sv) WITH x_header-viewname.
    48
    *   Zur View & existiert kein Profil.
    49
          ENDIF.
    50
      ENDCASE.
    51
    ENDFORM.                               " GET_PROFILES
    52
    *&---------------------------------------------------------------------*
    53
    *&      Form  IMPORT_PROFILE
    54
    *&---------------------------------------------------------------------*
    55
    *       text
    56
    *----------------------------------------------------------------------*
    57
    *  -->  p1        text
    58
    *----------------------------------------------------------------------*
    59
    FORM import_profile USING actopts TYPE scpractopt.
    60
    61
      DATA:          ext_field(1000),
    62
                     pr_field(1000),
    63
                     next,
    64
                     i TYPE i VALUE 1,
    65
                     extr_lin TYPE i,
    66
                     len_text TYPE i, profile_used,
    67
                     imported_to_all VALUE 'X'.
    68
      FIELD-SYMBOLS: <pr_field>, <bc_total_key>,
    69
                     <bc_total>, <bc_total_action>, <bc_total_mark>,
    70
                     <w_record> TYPE vim_pr_tab_type.
    71
    72
      len_text = x_header-texttablen - x_header-textkeylen.
    73
      CASE status-action.
    74
        WHEN aendern.
    75
    * import in update mode
    76
          IF status-mode = list_bild.
    77
    * import in list screen
    78
            LOOP AT vim_pr_tab ASSIGNING <w_record>.
    79
              IF <w_record>-action = aendern.
    80
    * update existing entry
    81
                LOOP AT extract.
    82
                  CHECK <w_record>-keys = <vim_xextract_key>.
    83
                  PERFORM bcset_force_into_entry USING    <w_record>
    84
                                                          aendern actopts.
    85
                  MODIFY extract.
    86
                  EXIT.
    87
                ENDLOOP.
    88
              ELSE.
    89
    * new entry
    90
                MOVE <initial_x> TO <vim_xextract>.
    91
                <vim_xextract_key> = <w_record>-keys.
    92
                PERFORM bcset_force_into_entry USING    <w_record>
    93
                                                      neuer_eintrag actopts.
    94
                APPEND extract.
    95
                ADD 1 TO maxlines.
    96
              ENDIF.
    97
            ENDLOOP.
    98
            SORT extract BY <vim_xextract_key>.
    99
          ELSE.
    100
    * import in detail mode
    101
            LOOP AT vim_pr_tab ASSIGNING <w_record> WHERE
    102
             action = neuer_eintrag.
    103
              MOVE <initial_x> TO <vim_xextract>.
    104
              <vim_xextract_key> = <w_record>-keys.
    105
              PERFORM bcset_force_into_entry USING    <w_record>
    106
                                                   neuer_eintrag actopts.
    107
              APPEND extract.
    108
              ADD 1 TO maxlines.
    109
            ENDLOOP.
    110
    * update existing entries
    111
            LOOP AT vim_pr_tab ASSIGNING <w_record> WHERE action = aendern.
    112
              CLEAR profile_used.
    113
              LOOP AT extract.
    114
                CHECK <w_record>-keys = <vim_xextract_key>.
    115
                PERFORM bcset_force_into_entry USING    <w_record>
    116
                                                        aendern actopts.
    117
                MODIFY extract.
    118
                profile_used = 'X'.
    119
                EXIT.
    120
              ENDLOOP.
    121
              IF profile_used = space.
    122
                LOOP AT total INTO extract.
    123
                  CHECK <w_record>-keys = <vim_xextract_key>.
    124
                  PERFORM bcset_force_into_entry USING    <w_record>
    125
                                                          aendern actopts.
    126
                  APPEND extract.
    127
                  ADD 1 TO maxlines.
    128
                  EXIT.
    129
                ENDLOOP.
    130
              ENDIF.
    131
            ENDLOOP.
    132
            SORT extract BY <vim_xextract_key>.
    133
          ENDIF.
    134
        WHEN hinzufuegen.
    135
    * import from append status
    136
          IF status-mode = list_bild.
    137
    * import in list mode
    138
            DESCRIBE TABLE extract LINES extr_lin.
    139
            LOOP AT vim_pr_tab ASSIGNING <w_record> WHERE
    140
             action = neuer_eintrag.
    141
              IF extr_lin LE i.
    142
    * add blank line to extract
    143
                CLEAR extract. MOVE leer TO <xact>.
    144
                APPEND extract.
    145
              ENDIF.
    146
    * new entry
    147
              LOOP AT extract FROM i.
    148
                CHECK <xact> = leer.
    149
                i = sy-tabix + 1.
    150
                ADD 1 TO maxlines.
    151
                <vim_xextract_key> = <w_record>-keys.
    152
                PERFORM bcset_force_into_entry USING    <w_record>
    153
                                                     neuer_eintrag actopts.
    154
                MODIFY extract.
    155
                EXIT.
    156
              ENDLOOP.
    157
            ENDLOOP.
    158
          ELSE.
    159
    * import in detail mode
    160
            MOVE <initial_x> TO <vim_xextract>.
    161
            LOOP AT vim_pr_tab ASSIGNING <w_record> WHERE
    162
             action = neuer_eintrag.
    163
              <vim_xextract_key> = <w_record>-keys.
    164
              PERFORM bcset_force_into_entry USING    <w_record>
    165
                                                   neuer_eintrag actopts.
    166
              APPEND extract.
    167
              ADD 1 TO maxlines.
    168
            ENDLOOP.
    169
          ENDIF.
    170
    * update existing entries
    171
          LOOP AT vim_pr_tab ASSIGNING <w_record> WHERE action = aendern.
    172
            LOOP AT total INTO extract.
    173
              CHECK <w_record>-keys = <vim_xextract_key>.
    174
              PERFORM bcset_force_into_entry USING    <w_record>
    175
                                                      aendern actopts.
    176
              APPEND extract.
    177
              EXIT.
    178
            ENDLOOP.
    179
          ENDLOOP.
    180
          SORT extract BY <vim_xextract_key>.
    181
      ENDCASE.
    182
    ENDFORM.                               " IMPORT_PROFILE
    183
    *&---------------------------------------------------------------------*
    184
    *&      Form  GET_PROFILE_STATUS
    185
    *&---------------------------------------------------------------------*
    186
    *       Checks key fields of the profile whether they're fixed or not
    187
    *       and concatenates profile keys into the lines of vim_pr_tab
    188
    *       according to their nametab-position.
    189
    *       Table & Texttable: Fills textfield value and initial text key
    190
    *       into VIM_PR_TAB.
    191
    *----------------------------------------------------------------------*
    192
    *  <--  VIM_PR_TAB     contains for every record key status, key values
    193
    *                      and textfields
    194
    *  <--  VIM_PR_FIELDS  Contains all profile fields filled with
    195
    *                      values. Used to set the request-flag in PBO.
    196
    *----------------------------------------------------------------------*
    197
    FORM get_profile_status CHANGING vim_pr_tab LIKE vim_pr_tab
    198
                                     vim_pr_fields LIKE vim_pr_fields[].
    199
    200
      DATA:          w_profile TYPE scpr_vals,
    201
                     w_vim_pr_tab TYPE vim_pr_tab_type,
    202
                     w_vim_pr_fields TYPE vim_pr_fields_type,
    203
                     recnumber LIKE scprvals-recnumber,
    204
                     text(1000), value LIKE vimsellist-value,
    205
                     gottext, first, rc LIKE sy-subrc,
    206
                     fieldname TYPE fnam_____4.
    207
      FIELD-SYMBOLS: <pr_key>, <x_keys> TYPE x, <x_text> TYPE x,
    208
                     <bc_val> TYPE ANY, <imp_val> TYPE ANY,
    209
                     <keys_struc> TYPE ANY, <text_struc> TYPE ANY.
    210
    211
      ASSIGN: w_vim_pr_tab-keys TO <x_keys> CASTING,
    212
              <x_keys> TO <keys_struc> CASTING TYPE (x_header-maintview).
    213
      IF x_header-bastab <> space AND x_header-texttbexst <> space.
    214
        ASSIGN: w_vim_pr_tab-textrecord TO <x_text> CASTING,
    215
                <x_text> TO <text_struc> CASTING TYPE (x_header-texttab).
    216
      ENDIF.
    217
      RANGES dont_use FOR scprvals-recnumber.
    218
      dont_use-sign = 'E'. dont_use-option = 'EQ'.
    219
    220
      LOOP AT vim_pr_tab INTO w_vim_pr_tab.
    221
        READ TABLE vim_pr_fields INTO w_vim_pr_fields WITH KEY
    222
         recnumber = w_vim_pr_tab-recnumber.
    223
        <x_keys> = <initial_x>(x_header-keylen).
    224
    *    w_vim_pr_tab-keys = <initial>(x_header-keylen).
    225
        IF x_header-bastab <> space AND x_header-texttbexst <> space.
    226
          <x_text> = <initial_textkey_x>.
    227
    *      w_vim_pr_tab-textrecord = <initial_textkey>.
    228
        ENDIF.
    229
    * Fill key fields
    230
        LOOP AT x_namtab WHERE keyflag = 'X' AND texttabfld IS INITIAL.
    231
          IF x_namtab-datatype = 'CLNT' AND x_header-clidep <> space.
    232
    *        MOVE sy-mandt TO
    233
    *             w_vim_pr_tab-keys+x_namtab-position(x_namtab-flength).
    234
            DELETE TABLE w_vim_pr_fields-fields WITH TABLE KEY
    235
             fieldname = x_namtab-viewfield.
    236
            MODIFY TABLE vim_pr_fields FROM w_vim_pr_fields.
    237
    *        IF x_header-bastab <> space AND x_header-texttbexst <> space.
    238
    *          MOVE sy-mandt TO
    239
    *         w_vim_pr_tab-textrecord+x_namtab-texttabpos(x_namtab-flength).
    240
    *        ENDIF.
    241
          ELSE.
    242
            CLEAR w_profile.
    243
            READ TABLE vim_profile_values INTO w_profile WITH KEY
    244
                       tablename = x_header-viewname
    245
                       fieldname = x_namtab-viewfield
    246
                       recnumber = w_vim_pr_tab-recnumber.
    247
            IF w_profile-flag = vim_profile_fixkey.
    248
              CASE w_vim_pr_tab-keys_fix.
    249
                WHEN space.
    250
                  w_vim_pr_tab-keys_fix = vim_pr_all_fix.
    251
                WHEN vim_pr_open.
    252
                  w_vim_pr_tab-keys_fix = vim_pr_some_fix.
    253
              ENDCASE.
    254
            ELSE.
    255
              CASE w_vim_pr_tab-keys_fix.
    256
                WHEN space.
    257
                  w_vim_pr_tab-keys_fix = vim_pr_open.
    258
                WHEN vim_pr_all_fix.
    259
                  w_vim_pr_tab-keys_fix = vim_pr_some_fix.
    260
              ENDCASE.
    261
            ENDIF.
    262
            IF x_namtab-readonly <> subset."subsetf. already in <initial>
    263
    * use profile keyfield
    264
              CONCATENATE x_header-maintview x_namtab-viewfield
    265
               INTO fieldname SEPARATED BY '-'.
    266
              ASSIGN: w_profile-value TO <bc_val> CASTING TYPE (fieldname),
    267
                          COMPONENT x_namtab-viewfield
    268
                           OF STRUCTURE <keys_struc> TO <imp_val>.
    269
              <imp_val> = <bc_val>.
    270
    *          MOVE w_profile-value(x_namtab-flength) TO
    271
    *          w_vim_pr_tab-keys+x_namtab-position(x_namtab-flength).
    272
              IF x_header-bastab <> space AND x_header-texttbexst <> space.
    273
    * make text table key (for finding the suitable text value only)
    274
                ASSIGN COMPONENT x_namtab-txttabfldn
    275
                       OF STRUCTURE <text_struc> TO <imp_val>.
    276
                <imp_val> = <bc_val>.
    277
    *            MOVE w_profile-value(x_namtab-flength) TO
    278
    *         w_vim_pr_tab-textrecord+x_namtab-texttabpos(x_namtab-flength).
    279
              ENDIF.
    280
            ENDIF.                         "x_namtab-readonly <> subset
    281
            w_vim_pr_fields-keys_fix = w_vim_pr_tab-keys_fix.
    282
            MODIFY vim_pr_fields FROM w_vim_pr_fields TRANSPORTING keys_fix
    283
                     WHERE recnumber = w_vim_pr_fields-recnumber.
    284
          ENDIF.                           "x_namtab-datatype = 'CLNT'
    285
        ENDLOOP.
    286
        IF x_header-bastab <> space AND x_header-texttbexst <> space AND
    287
           w_vim_pr_tab-keys_fix <> vim_pr_error.
    288
    * get record for text table
    289
          CLEAR recnumber.
    290
          IF vim_pr_records > 1.
    291
            WHILE gottext = space.
    292
              gottext = 'X'.
    293
              first = 'X'.
    294
              LOOP AT vim_profile_values INTO w_profile WHERE
    295
                              tablename = x_header-texttab
    296
                              AND recnumber IN dont_use[].
    297
                IF first = 'X'.
    298
                  recnumber = w_profile-recnumber.
    299
                  CLEAR first.
    300
                ELSE.
    301
                  IF recnumber <> w_profile-recnumber.
    302
                    IF gottext <> space. EXIT. ENDIF.
    303
                    recnumber = w_profile-recnumber.
    304
                  ENDIF.
    305
                ENDIF.
    306
                IF w_profile-flag+2 = 'Y'. "keY, ukY or fkY -> Key fields
    307
    * check key-value
    308
                  IF w_profile-fieldname = x_header-sprasfield.
    309
                    IF w_profile-value(1) <> sy-langu.
    310
                      dont_use-low = recnumber.
    311
                      APPEND dont_use.
    312
                      CLEAR: text, gottext.
    313
                      CONTINUE.
    314
                    ENDIF.
    315
                  ELSE.
    316
                    READ TABLE x_namtab WITH KEY
    317
                                        viewfield = w_profile-fieldname
    318
                                        keyflag = 'X' texttabfld = 'X'.
    319
                    CONCATENATE x_header-texttab x_namtab-txttabfldn
    320
                             INTO fieldname SEPARATED BY '-'.
    321
                    ASSIGN: w_profile-value TO <bc_val>
    322
                             CASTING TYPE (fieldname),
    323
                            COMPONENT x_namtab-txttabfldn
    324
                             OF STRUCTURE <text_struc> TO <imp_val>.
    325
    *                ASSIGN w_profile-value(x_namtab-flength) TO <vgl1>.
    326
    *   ASSIGN w_vim_pr_tab-textrecord+x_namtab-texttabpos(x_namtab-flength)
    327
    *                                                          TO <vgl2>.
    328
    *                IF <vgl1> <> <vgl2>.
    329
                    IF <imp_val> <> <bc_val>.
    330
                      CLEAR gottext.
    331
                      dont_use-low = recnumber.
    332
                      APPEND dont_use.
    333
    *                    CLEAR text.
    334
                      CONTINUE.
    335
                    ENDIF.
    336
                  ENDIF.
    337
    *              ELSE.
    338
    ** store textfield.
    339
    *                text = w_profile-value.
    340
    *                APPEND w_profile-fieldname TO w_vim_pr_fields-fields.
    341
                ENDIF.                                          "key field
    342
              ENDLOOP.
    343
            ENDWHILE.
    344
            IF gottext <> space.
    345
              recnumber = w_profile-recnumber.
    346
            ENDIF.
    347
    *          IF NOT text IS INITIAL.
    348
    *            READ TABLE x_namtab WITH KEY keyflag = space
    349
    *                                         texttabfld = 'X'.
    350
    *            MOVE text TO
    351
    *         w_vim_pr_tab-textrecord+x_namtab-texttabpos(x_namtab-flength).
    352
    *            CLEAR: text, gottext.
    353
    *          ENDIF.
    354
          ELSEIF vim_pr_records = 1.
    355
    * insert language into text table key
    356
    *           READ TABLE x_namtab WITH KEY viewfield = x_header-sprasfield
    357
    *                                        keyflag = 'X' texttabfld = 'X'.
    358
            ASSIGN COMPONENT x_header-sprasfield
    359
                          OF STRUCTURE <text_struc> TO <imp_val>.
    360
            <imp_val> = sy-langu.
    361
    *            MOVE sy-langu TO
    362
    *         w_vim_pr_tab-textrecord+x_namtab-texttabpos(x_namtab-flength).
    363
            READ TABLE vim_profile_values INTO w_profile WITH KEY
    364
                       tablename = x_header-texttab
    365
                       fieldname = x_header-sprasfield
    366
                       value = sy-langu.
    367
            IF sy-subrc = 0.
    368
    * textfield value found
    369
              recnumber = w_profile-recnumber.
    370
            ENDIF.
    371
          ENDIF.                                                "lines = 1
    372
          IF NOT recnumber IS INITIAL.
    373
    *textvalue in bc-set found
    374
            LOOP AT x_namtab WHERE keyflag = space AND
    375
                                         texttabfld = 'X'.
    376
              CONCATENATE x_header-texttab x_namtab-viewfield
    377
                       INTO fieldname SEPARATED BY '-'.
    378
              READ TABLE vim_profile_values INTO w_profile WITH KEY
    379
                               tablename = x_header-texttab
    380
                               recnumber = recnumber
    381
                               fieldname = x_namtab-viewfield.
    382
              ASSIGN: w_profile-value TO <bc_val>
    383
                       CASTING TYPE (fieldname),
    384
                      COMPONENT x_namtab-viewfield
    385
                       OF STRUCTURE <text_struc> TO <imp_val>.
    386
              <imp_val> = <bc_val>.
    387
    *                MOVE w_profile-value
    388
    *      TO w_vim_pr_tab-textrecord+x_namtab-texttabpos(x_namtab-flength).
    389
              APPEND w_profile-fieldname TO w_vim_pr_fields-fields.
    390
            ENDLOOP.
    391
          ELSE.
    392
    * no text value in bc-set
    393
            MOVE <text_initial_x> TO <x_text>.
    394
          ENDIF.
    395
        ENDIF.                             "text table exists
    396
        MODIFY vim_pr_tab FROM w_vim_pr_tab.
    397
        MODIFY TABLE vim_pr_fields FROM w_vim_pr_fields.
    398
      ENDLOOP.
    399
    ENDFORM.                                            "get_profile_status
    400
    *&---------------------------------------------------------------------*
    401
    *&      Form  ACTIVATE_PROFILE
    402
    *&---------------------------------------------------------------------*
    403
    *     No longer in use: For 6.20 the funcionality of BC set activation
    404
    *     via SM30 was abolished
    405
    *----------------------------------------------------------------------*
    406
    *  -->  p1        text
    407
    *  <--  p2        text
    408
    *----------------------------------------------------------------------*
    409
    FORM activate_profile CHANGING p_selected
    410
    TYPE c.
    411
    412
      DATA: pr_rc TYPE i, pr_funcsafe(4), pr_counter TYPE i,
    413
            pr_mark_entries VALUE 'X', hf1  TYPE i, hf  TYPE i,
    414
            cobj_type VALUE 'V', pr_key_da, pr_recnumber TYPE scpr_recnr,
    415
            bc_id TYPE scpr_id, bc_rec_found(1) TYPE c,
    416
            actopts TYPE scpractopt."HCG always empty, only nec. 46C 610
    417
      STATICS: viewname LIKE vimdesc-viewname.
    418
      FIELD-SYMBOLS: <pr_f1> TYPE x, <w_record> TYPE vim_pr_tab_type,
    419
                     <bc_key> TYPE x.
    420
    421
      CHECK status-action NE anzeigen AND  "ignore wrong setted requestflags
    422
            status-action NE transportieren. "due to individual F4 modules
    423
      CLEAR vim_pr_activating.
    424
      IF p_selected IS INITIAL.
    425
    * read profile
    426
        REFRESH: vim_profile_values, vim_pr_tab.
    427
    *    CALL FUNCTION 'SCPR_ACTIVATE'     // Ast stillgelegt, der Baustein
    428
    *                                      // existiert nicht mehr
    429
    *        EXPORTING
    430
    *             tabname          = x_header-viewname
    431
    *             initial          = <initial>
    432
    *       IMPORTING
    433
    *            PROFID           =
    434
    *        TABLES
    435
    *             values           = vim_profile_values
    436
    *             sellist          = dpl_sellist
    437
    *        EXCEPTIONS
    438
    *             user_abort       = 1
    439
    *             no_profile_found = 2
    440
    *             OTHERS           = 3.
    441
    *    CASE sy-subrc.
    442
    *      WHEN 0.
    443
    *        p_selected = 'X'. viewname = x_header-viewname.
    444
    *        SORT vim_profile_values BY id version tablename recnumber.
    445
    *        IF 'AU' CA status-action.
    446
    * get records the profile contains
    447
    *          PERFORM get_pr_nbr_records USING vim_profile_values
    448
    *                                           x_header
    449
    *                                     CHANGING pr_rc
    450
    *                                              bc_id
    451
    *                                              vim_pr_records
    452
    *                                              vim_pr_tab
    453
    *                                              vim_pr_fields.
    454
    * check key-status
    455
    *          PERFORM get_profile_status CHANGING vim_pr_tab
    456
    *                                              vim_pr_fields.
    457
    *        ENDIF.
    458
    *      WHEN 1.
    459
    *        EXIT.
    460
    *      WHEN 2.
    461
    *        IF x_header-bastab NE space.
    462
    *          cobj_type = vim_tabl.
    463
    *        ENDIF.
    464
    *        IF cobj_type = 'S'.
    465
    *          MESSAGE e822(sv) WITH x_header-viewname.
    466
    *   Zur Tabelle & existiert kein Profil.
    467
    *        ELSE.
    468
    *          MESSAGE e821(sv) WITH x_header-viewname.
    469
    *   Zur View & existiert kein Profil.
    470
    *        ENDIF.
    471
    *    ENDCASE.
    472
      ELSE.
    473
        IF vim_called_by_cluster <> space AND
    474
         viewname <> x_header-viewname.
    475
    * update key values according to current view and selection
    476
          viewname = x_header-viewname.
    477
          IF 'AU' CA status-action.
    478
    * get records the profile contains
    479
            PERFORM get_pr_nbr_records USING vim_profile_values
    480
                                             x_header
    481
                                       CHANGING pr_rc
    482
                                                bc_id
    483
                                                vim_pr_records
    484
                                                vim_pr_tab
    485
                                                vim_pr_fields.
    486
    * check key-status
    487
            PERFORM get_profile_status CHANGING vim_pr_tab
    488
                                                vim_pr_fields.
    489
          ENDIF.
    490
        ENDIF.
    491
      ENDIF.
    492
    * check, if bc-set-records refer to existing datasets
    493
      PERFORM bcset_key_check_in_total.
    494
      PERFORM markiere_alle USING nicht_markiert.
    495
      PERFORM import_profile USING actopts.
    496
    * viewcluster: show list of views to work on
    497
      IF vim_called_by_cluster <> space.
    498
        CALL FUNCTION 'VIEWCLUSTER_PR_IMPORT_CTRL'
    499
             EXPORTING
    500
                  viewname        = x_header-viewname
    501
                  action          = 'M'
    502
             TABLES
    503
                  profile_values  = vim_profile_values
    504
             EXCEPTIONS
    505
                  wrong_parameter = 1
    506
                  OTHERS          = 2.
    507
      ENDIF.
    508
      replace_mode = 'X'.
    509
      vim_special_mode = vim_upgrade.
    510
    * handle changed entries
    511
      ASSIGN <vim_xtotal>(x_header-tablen) TO <pr_f1> CASTING.
    512
      LOOP AT extract.
    513
        CHECK <xact> = aendern OR <xact> = neuer_eintrag.
    514
        CLEAR vim_bc_entry_list_wa.
    515
        vim_bc_entry_list_wa-id = bc_id.
    516
        vim_bc_entry_list_wa-viewname = x_header-viewname.
    517
        hf = sy-tabix.
    518
        READ TABLE total WITH KEY <vim_xextract_key> BINARY SEARCH.
    519
        IF sy-subrc EQ 0.                  "entry exists in current client
    520
          hf1 = sy-tabix.
    521
          IF <xact> EQ neuer_eintrag AND
    522
          <action> EQ geloescht OR <action> EQ neuer_geloescht OR
    523
          <action> EQ update_geloescht.
    524
            status-delete = geloescht.
    525
    * entry deleted in cur clnt -> first undelete it
    526
            <xact> = <action>.
    527
            MODIFY extract.
    528
            pr_funcsafe = function.
    529
            clear pr_rc.
    530
            PERFORM vim_mark_and_process USING hf 'UNDO' hf1
    531
                                               pr_rc.
    532
            CLEAR status-delete. function = pr_funcsafe.
    533
            CHECK pr_rc NE 4.
    534
            IF pr_rc EQ 8.
    535
              EXIT.
    536
            ENDIF.
    537
            READ TABLE extract INDEX hf.
    538
            READ TABLE total WITH KEY <vim_xextract_key> BINARY SEARCH.
    539
            hf1 = sy-tabix.
    540
            <xact> = aendern. MODIFY extract.
    541
          ENDIF.
    542
          IF <vim_xtotal_key> = <vim_xextract_key>.
    543
    * record already exists: do not import but save
    544
            <action> = aendern.
    545
            MODIFY total INDEX hf1.
    546
            IF x_header-bastab NE space AND x_header-texttbexst NE space.
    547
              TRANSLATE <status>-upd_flag USING ' ETX'.
    548
            ELSE.
    549
              <status>-upd_flag = 'X'.
    550
            ENDIF.
    551
          ENDIF.
    552
        ENDIF.                             "sy-subrc eq 0.
    553
        CLEAR vim_pr_fields_wa.
    554
        CLEAR bc_rec_found.
    555
        LOOP AT vim_pr_tab ASSIGNING <w_record>.
    556
          ASSIGN <w_record>-keys(x_header-keylen) TO <bc_key>.
    557
          CHECK <bc_key> = <vim_xextract_key>.
    558
          bc_rec_found = 'X'.
    559
          READ TABLE vim_pr_fields INTO vim_pr_fields_wa WITH KEY
    560
           recnumber = <w_record>-recnumber.
    561
          vim_bc_entry_list_wa-id = bc_id.
    562
          vim_bc_entry_list_wa-recnumber = <w_record>-recnumber.
    563
          vim_bc_entry_list_wa-keys = <bc_key>.
    564
    *      if x_header-bastab <> space and x_header-texttbexst <> space.
    565
    ** table with text table
    566
    *        vim_bc_entry_list_wa-keys + x_header-keylen =
    567
    *         <w_record>-textrecord(x_header-textkeylen).
    568
    *      endif.
    569
          vim_bc_entry_list_wa-action = neuer_eintrag.
    570
          INSERT LINES OF vim_pr_fields_wa-fields INTO TABLE
    571
           vim_bc_entry_list_wa-fields.
    572
          EXIT.
    573
        ENDLOOP.
    574
        CHECK NOT bc_rec_found IS INITIAL.
    575
        IF <xact> <> aendern OR <pr_f1> <> <table2_x>.
    576
    * import bc-set record
    577
          CHECK NOT vim_pr_fields_wa IS INITIAL.
    578
          <status>-prof_found = vim_pr_into_view.
    579
          PERFORM vim_modify_view_entry USING hf pr_rc.
    580
          <status>-prof_found = vim_profile_found.
    581
          CHECK pr_rc NE 4.
    582
          IF pr_rc EQ 8.
    583
            EXIT.
    584
          ENDIF.
    585
        ENDIF.
    586
        READ TABLE total WITH KEY <vim_xtotal_key> BINARY SEARCH
    587
                         TRANSPORTING NO FIELDS.
    588
        IF <mark> EQ nicht_markiert.
    589
          <mark> = markiert. ADD 1 TO mark_total.
    590
          MODIFY total INDEX sy-tabix.
    591
        ENDIF.
    592
        extract = total.
    593
        MODIFY extract.
    594
        INSERT vim_bc_entry_list_wa INTO TABLE vim_bc_entry_list.
    595
        IF sy-subrc = 4.
    596
          MODIFY TABLE vim_bc_entry_list FROM vim_bc_entry_list_wa.
    597
        ENDIF.
    598
        ADD 1 TO pr_counter.
    599
      ENDLOOP.
    600
      IF pr_counter < vim_pr_records.
    601
        MESSAGE s818(sv) WITH pr_counter vim_pr_records.
    602
    *   Es wurden &1 von &2 Einträgen des Business-Configuration-Sets import
    603
      ELSE.
    604
        MESSAGE s819(sv).
    605
    *   Das Business-Configuration-Set wurde vollständig importiert.
    606
      ENDIF.
    607
      nextline = 1.
    608
      CLEAR: vim_special_mode, replace_mode.
    609
      PERFORM fill_extract.
    610
      IF status-action EQ hinzufuegen.
    611
        status-action = aendern.
    612
        title-action  = aendern.
    613
        CLEAR <status>-selected.
    614
      ENDIF.
    615
      IF status-mode = detail_bild.
    616
    * return to list screen
    617
        vim_next_screen = liste. vim_leave_screen = 'X'.
    618
      ENDIF.
    619
    ENDFORM.                               " ACTIVATE_PROFILE
    620
    *&---------------------------------------------------------------------*
    621
    *&      Form  SET_PROFILE_KEY_ATTRIBUTES
    622
    *&---------------------------------------------------------------------*
    623
    *       sets screen input attribute according to profile attributes
    624
    *       of key field p_name
    625
    *----------------------------------------------------------------------*
    626
    *      <--P_SCREEN_INPUT  text
    627
    *      <--P_VIM_MODIFY_SCREEN  text
    628
    *----------------------------------------------------------------------*
    629
    FORM set_profile_key_attributes
    630
                        USING p_name LIKE vim_objfield
    631
                        CHANGING p_screen_input LIKE screen-input
    632
                                 p_modify_screen LIKE vim_modify_screen.
    633
    634
      DATA: w_field TYPE vimty_fields_type.
    635
    636
      p_screen_input = '0'.
    637
      CASE vim_pr_fields_wa-keys_fix.
    638
        WHEN vim_pr_open.
    639
          p_screen_input = '1'. p_modify_screen = 'X'.
    640
        WHEN vim_pr_all_fix.
    641
          p_screen_input = '0'.
    642
        WHEN vim_pr_some_fix.
    643
          READ TABLE vim_pr_fields_wa-fields INTO w_field
    644
              WITH KEY fieldname = p_name.
    645
          IF w_field-flag <> vim_profile_fixkey.
    646
            p_screen_input = '1'. p_modify_screen = 'X'.
    647
          ENDIF.
    648
      ENDCASE.
    649
    ENDFORM.                               " SET_PROFILE_KEY_ATTRIBUTES
    650
    *&---------------------------------------------------------------------*
    651
    *&      Form  PROFILE_PUT_INTO_WA
    652
    *&---------------------------------------------------------------------*
    653
    *       text
    654
    *----------------------------------------------------------------------*
    655
    *  -->  p_record  bc-set
    656
    *  -->  p_subset  flag: put "initial" value into subsetfield
    657
    *  -->  p_action  action-flag from EXTRACT
    658
    *  <--  p_field   view-maintenance dataset
    659
    *----------------------------------------------------------------------*
    660
    FORM profile_put_into_wa USING p_bc_set LIKE vim_profile_values
    661
                                   p_record TYPE vim_pr_tab_type
    662
                                   p_header TYPE vimdesc
    663
                                   p_namtab LIKE x_namtab[]
    664
                                   p_subset TYPE xfeld
    665
                                   p_action TYPE char1
    666
                                   actopts type scpractopt
    667
                             CHANGING p_field.
    668
      DATA:          w_profile TYPE scpr_vals,
    669
                     fieldname TYPE fnam_____4,
    670
                     old_guid TYPE REF TO data,
    671
                     tabname_wa TYPE objs-tabname,
    672
                     objecttype TYPE objs-objecttype VALUE 'S'.
    673
      STATICS:       loc_viewname TYPE objs-objectname,
    674
                     piecelist TYPE TABLE OF objs-tabname.
    675
    676
      FIELD-SYMBOLS: <namtab> TYPE vimnamtab, <field> TYPE ANY,
    677
                     <old_guid> TYPE ANY, <work_area> TYPE ANY,
    678
                     <bc_value> type any.
    679
    680
      CONSTANTS: no_standard(1) TYPE c VALUE 'F',
    681
                 stan(3) TYPE c VALUE 'USE'.
    682
    683
      ASSIGN p_field TO <work_area> CASTING TYPE (p_header-maintview).
    684
      LOOP AT p_namtab ASSIGNING <namtab> WHERE keyflag = space
    685
       AND texttabfld = space.
    686
        ASSIGN COMPONENT <namtab>-viewfield OF STRUCTURE <work_area>
    687
         TO <field>.
    688
        CONCATENATE p_header-maintview <namtab>-viewfield
    689
         INTO fieldname SEPARATED BY '-'.
    690
        IF <namtab>-domname IN vim_guid_domain.
    691
    * GUID field
    692
          IF p_action = neuer.
    693
    *     Overtake GUID from BC-Set for new entries.
    694
          ELSE.
    695
          IF p_record-keys_fix = vim_pr_all_fix.
    696
            IF p_header-frm_af_uid <> space.
    697
    * prepare event 27
    698
              CREATE DATA old_guid TYPE (fieldname).
    699
    *          ASSIGN p_field+<namtab>-position(<namtab>-flength)
    700
    *           TO <guid> CASTING TYPE (fieldname).
    701
              ASSIGN: old_guid->* TO <old_guid>.
    702
              <old_guid> = <field>.
    703
            ENDIF.
    704
          ELSE.
    705
            CONTINUE.
    706
    * Use GUID from BC-Set only if complete key is given fix
    707
          ENDIF.
    708
        ENDIF.
    709
        ENDIF.
    710
        CASE <namtab>-readonly.
    711
          WHEN space.
    712
            READ TABLE p_bc_set INTO w_profile WITH KEY
    713
            tablename = p_header-viewname fieldname = <namtab>-viewfield
    714
            recnumber = p_record-recnumber TRANSPORTING flag value.
    715
            CHECK sy-subrc = 0.
    716
            ASSIGN w_profile-value TO <bc_value> CASTING TYPE (fieldname).
    717
    *       Do not overwrite field of existing dataset with BC-Set value
    718
    *       if standard field (flag = USE) and actopts-no_standard = Y.
    719
            if actopts-no_standrd NE no_standard OR w_profile-flag NE stan.
    720
              <field> = <bc_value>.
    721
            endif.
    722
    *        MOVE w_profile-value(<namtab>-flength)
    723
    *             TO p_field+<namtab>-position(<namtab>-flength).
    724
          WHEN rdonly OR vim_hidden.       "HCG Check if table in piece list
    725
            IF p_header-viewname NE loc_viewname.
    726
              loc_viewname = p_header-viewname.
    727
              REFRESH piecelist.
    728
              IF p_header-bastab EQ space. objecttype = 'V'. ENDIF.
    729
              SELECT tabname FROM objs INTO tabname_wa   "Get info from OBJS
    730
                           WHERE objectname = p_header-viewname
    731
                           AND   objecttype = objecttype.
    732
                APPEND tabname_wa TO piecelist.
    733
              ENDSELECT.
    734
            ENDIF.
    735
            READ TABLE p_bc_set INTO w_profile WITH KEY
    736
               tablename = p_header-viewname fieldname = <namtab>-viewfield
    737
                  recnumber = p_record-recnumber TRANSPORTING flag value.
    738
            CHECK sy-subrc = 0.
    739
            READ TABLE piecelist INTO tabname_wa WITH KEY
    740
                                                   <namtab>-bastabname.
    741
            IF sy-subrc EQ 0. "HCG If table is not in piecelist: skip field
    742
              ASSIGN w_profile-value TO <bc_value> CASTING TYPE (fieldname).
    743
    *         Do not overwrite field of existing dataset with BC-Set value
    744
    *         if standard field (flag = USE) and actopts-no_standard = Y.
    745
              IF actopts-no_standrd NE no_standard OR
    746
                                       w_profile-flag NE stan.
    747
                <field> = <bc_value>.
    748
              ENDIF.
    749
            ENDIF.
    750
          WHEN subset.
    751
            CHECK p_subset <> space.
    752
            ASSIGN COMPONENT <namtab>-viewfield OF STRUCTURE <initial>
    753
             TO <bc_value>.
    754
    *        MOVE <initial>+<namtab>-position(<namtab>-flength)
    755
    *         TO p_field+<namtab>-position(<namtab>-flength).
    756
        ENDCASE.
    757
        IF <namtab>-domname IN vim_guid_domain
    758
         AND p_record-keys_fix = vim_pr_all_fix
    759
         AND  p_header-frm_af_uid <> space.
    760
    * event 27 for GUID field
    761
          PERFORM (p_header-frm_af_uid) IN PROGRAM (p_header-fpoolname)
    762
                                        USING <old_guid>
    763
                                        CHANGING <field>
    764
                                                 <work_area>.
    765
        ENDIF.
    766
      ENDLOOP.
    767
    ENDFORM.                               " PROFILE_PUT_INTO_WA
    768
    *&---------------------------------------------------------------------*
    769
    *&      Form  GET_PR_NBR_RECORDS
    770
    *&---------------------------------------------------------------------*
    771
    *       Get the number of records the chosen profile contains and get
    772
    *       the fields every record contains.
    773
    *----------------------------------------------------------------------*
    774
    *      -->VIM_PROFILE_VALUES  contains bc-set
    775
    *      -->X_HEADER
    776
    *      -->P_RC                = 4: no record found
    777
    *      <--VIM_PR_RECORDS      number of records in bc-set
    778
    *      <--VIM_PR_TAB          table of bc-set-records, initialized
    779
    *      <--VIM_PR_FIELDS       lists of matched fields for every record
    780
    *----------------------------------------------------------------------*
    781
    FORM get_pr_nbr_records USING vim_profile_values
    782
                                   LIKE vim_profile_values
    783
                                  x_header TYPE vimdesc
    784
                            CHANGING p_rc like sy-subrc
    785
                                     p_bc_id TYPE scpr_id
    786
                                     vim_pr_records TYPE i
    787
                                     vim_pr_tab LIKE vim_pr_tab
    788
                                     vim_pr_fields LIKE vim_pr_fields.
    789
    790
      DATA: w_vim_pr_tab TYPE vim_pr_tab_type, first VALUE 'X',
    791
            w_vim_pr_fields TYPE vim_pr_fields_type,
    792
            w_fields TYPE vimty_fields_type, recnumber TYPE scpr_recnr.
    793
      FIELD-SYMBOLS: <profile_value> LIKE LINE OF vim_profile_values.
    794
    795
      REFRESH: vim_pr_tab, vim_pr_fields.
    796
      CLEAR: vim_pr_records, p_rc.
    797
      LOOP AT vim_profile_values ASSIGNING <profile_value>
    798
           WHERE tablename = x_header-viewname.
    799
        IF <profile_value>-recnumber <> recnumber.
    800
          recnumber = <profile_value>-recnumber.
    801
          IF first = space.
    802
            APPEND w_vim_pr_tab TO vim_pr_tab.
    803
            APPEND w_vim_pr_fields TO vim_pr_fields. CLEAR w_vim_pr_fields.
    804
          ENDIF.
    805
          CLEAR first.
    806
          w_vim_pr_fields-recnumber = w_vim_pr_tab-recnumber
    807
           = <profile_value>-recnumber.
    808
          ADD 1 TO vim_pr_records.
    809
        ENDIF.
    810
        w_fields-fieldname = <profile_value>-fieldname.
    811
        w_fields-flag = <profile_value>-flag.
    812
        APPEND w_fields TO w_vim_pr_fields-fields.
    813
      ENDLOOP.
    814
      p_rc = sy-subrc.
    815
      CHECK sy-subrc = 0.
    816
      APPEND w_vim_pr_tab TO vim_pr_tab.
    817
      APPEND w_vim_pr_fields TO vim_pr_fields.
    818
      p_bc_id = <profile_value>-id.
    819
    *  IF w_vim_pr_tab-recnumber IS INITIAL.
    820
    *    w_vim_pr_tab-recnumber = 1. APPEND w_vim_pr_tab TO vim_pr_tab.
    821
    *    ADD 1 TO vim_pr_records.
    822
    *  ENDIF.
    823
    ENDFORM.                               " GET_PR_NBR_RECORDS
    824
    *&---------------------------------------------------------------------*
    825
    *&      Form  GET_PR_FIELD_FROM_SEL
    826
    *&---------------------------------------------------------------------*
    827
    *       extracts value for field P_PR_NAMTAB-VIEWFIELD from P_PR_SELLIST
    828
    *       into P_VIM_SEL_VALUE.
    829
    *----------------------------------------------------------------------*
    830
    *      <--P_SEL_VALUE   extracted value, P_SEL_VALUE remain sunchanged
    831
    *      <--P_RC          0: o.k.  1: no selection defined, P_SEL_VALUE
    832
    *                       remains unchanged  2: no unambiguous
    833
    *                       extraction possible, P_SEL_VALUE cleared
    834
    *      -->P_PR_SELLIST  text
    835
    *      -->P_PR_NAMTAB   text
    836
    *      -->P_PR_CLUSTER  Flag: View maintenance called by cluster
    837
    *----------------------------------------------------------------------*
    838
    FORM get_pr_field_from_sel
    839
           USING    p_pr_sellist TYPE vimsellist_type
    840
                    p_pr_namtab LIKE vimnamtab
    841
           CHANGING p_sel_value LIKE dpl_sellist-value
    842
                    p_rc LIKE sy-subrc.
    843
    844
      DATA: w_sellist LIKE vimsellist, first.
    845
    846
      p_rc = 1. first = 'X'.
    847
      LOOP AT p_pr_sellist INTO w_sellist.
    848
        CHECK w_sellist-viewfield = p_pr_namtab-viewfield.
    849
        IF first = space OR w_sellist-operator <> 'EQ'.
    850
          CLEAR p_sel_value. p_rc = 2. EXIT.
    851
        ELSE.
    852
          MOVE w_sellist-value(p_pr_namtab-flength) TO
    853
           p_sel_value(p_pr_namtab-flength).
    854
          p_rc = 0.
    855
        ENDIF.
    856
        CLEAR first.
    857
      ENDLOOP.
    858
    ENDFORM.                               " GET_PR_FIELD_FROM_SEL
    859
    *&---------------------------------------------------------------------*
    860
    *&      Form  VIM_PR_mand_fields
    861
    *&---------------------------------------------------------------------*
    862
    *       Appending profiles in detail mode: Leaves screen to reset
    863
    *       mandatory attribute and to process sreen in background if
    864
    *       at least one dynpro-field is mandatory.
    865
    *----------------------------------------------------------------------*
    866
    FORM vim_pr_mand_fields.
    867
      LOOP AT SCREEN.
    868
        CHECK screen-required <> '0'.
    869
        vim_pr_activating = 'X'.
    870
        SET SCREEN detail. LEAVE SCREEN.
    871
      ENDLOOP.
    872
    ENDFORM.                               " VIM_PR_AT_EXIT_COM
    873
    *&---------------------------------------------------------------------*
    874
    *&      Form  bcset_key_check_in_total
    875
    *&---------------------------------------------------------------------*
    876
    *       check, if bc-set-key already exists
    877
    *----------------------------------------------------------------------*
    878
    *----------------------------------------------------------------------*
    879
    FORM bcset_key_check_in_total.
    880
    881
      DATA: w_record TYPE vim_pr_tab_type.
    882
      FIELD-SYMBOLS: <bc_key> TYPE x.
    883
    884
      ASSIGN w_record-keys(x_header-keylen) TO <bc_key>.
    885
      LOOP AT vim_pr_tab INTO w_record.
    886
        CLEAR w_record-action.
    887
        READ TABLE total WITH KEY <bc_key> BINARY SEARCH
    888
         TRANSPORTING NO FIELDS.
    889
        IF sy-subrc = 0.
    890
          w_record-action = aendern.
    891
        ELSE.
    892
          w_record-action = neuer_eintrag.
    893
        ENDIF.
    894
        MODIFY vim_pr_tab FROM w_record.
    895
      ENDLOOP.
    896
    ENDFORM.                               " bcset_key_check_in_total
    897
    *&---------------------------------------------------------------------*
    898
    *&      Form  bcset_force_into_entry
    899
    *&---------------------------------------------------------------------*
    900
    *       text
    901
    *----------------------------------------------------------------------*
    902
    *      -->P_<W_RECORD>  text
    903
    *      <--P_AENDERN  text
    904
    *----------------------------------------------------------------------*
    905
    FORM bcset_force_into_entry USING    p_record TYPE vim_pr_tab_type
    906
                                         p_action TYPE char1
    907
                                         actopts TYPE scpractopt.
    908
    909
      field-symbols: <textrec_x> type x.
    910
    911
        IF <xmark> = nicht_markiert.
    912
        <xmark> = markiert. ADD 1 TO mark_extract.
    913
      ENDIF.
    914
      <xact> = p_action.
    915
      PERFORM profile_put_into_wa USING vim_profile_values
    916
                                        p_record
    917
                                        x_header
    918
                                        x_namtab[]
    919
                                        'X'
    920
                                        p_action
    921
                                        actopts
    922
                                  CHANGING <vim_xextract>.
    923
    *                              CHANGING <table2>.
    924
      IF x_header-texttbexst <> space AND x_header-bastab <> space.
    925
        assign p_record-textrecord(x_header-texttablen)
    926
         to <textrec_x> casting.
    927
        move <textrec_x> to <vim_xextract_text>.
    928
    *    MOVE p_record-textrecord+x_header-textkeylen(len_text)
    929
    *             TO <extract_text>+x_header-textkeylen(len_text).
    930
      ENDIF.
    931
    ENDFORM.                               " bcset_force_into_entry