Properties SourceCde
txt
1
*---------------------------------------------------------------------*
2
*       FORM CHECK_KEY                                                *
3
*---------------------------------------------------------------------*
4
*       ........                                                      *
5
*---------------------------------------------------------------------*
6
FORM check_key.
7
  DATA: s LIKE sy-tabix, mess_type(1) TYPE c VALUE 'E', ck_tabix TYPE i,
8
        ck_check_tab LIKE vimdesc-viewname, ck_slcnds_nokey(1) TYPE c,
9
        ck_clause TYPE vim_ck_selcond, ck_wa TYPE REF TO data,
10
        ck_wheretab LIKE vimwheretb OCCURS 10, ck_rc LIKE sy-subrc,
11
        oc_keys TYPE occheckkeyflds, n(1) TYPE n, ocmes TYPE fieldname,
12
        field1 TYPE fieldname, field2 TYPE fieldname,
13
        field3 TYPE fieldname, field4 TYPE fieldname,
14
        w_oc_keys TYPE occheckkey, fieldname TYPE fnam_____4.
15
  FIELD-SYMBOLS: <ck_1> TYPE ANY, <noauth> TYPE fieldname,
16
                 <namtab> TYPE vimnamtab, <ck_wa> TYPE ANY,
17
                 <table1_txt_loc> type any.
18
 
19
  CHECK neuer CO 'JX'.
20
  IF vim_key_alr_checked NE space.
21
    READ TABLE total WITH KEY <f1_x> BINARY SEARCH.
22
    EXIT.
23
  ELSE.
24
    vim_key_alr_checked = 'X'.
25
  ENDIF.
26
* first check namespace
27
  IF x_header-customauth CO sap_cust_classes OR
28
     vim_ale_keyspec_check NE space.
29
    PERFORM check_allowed_keyranges.
30
  ENDIF.
31
* check if user is authorised for this key
32
  IF NOT vim_oc_inst IS INITIAL.
33
    CALL METHOD vim_oc_inst->build_key_value_tab
34
      EXPORTING
35
        entry     = <table1>
36
      IMPORTING
37
        keyvalues = oc_keys.
38
    CALL METHOD vim_oc_inst->check_oc_authority
39
      EXPORTING
40
        activity        = '02'
41
      CHANGING
42
        key_values      = oc_keys
43
      EXCEPTIONS
44
        no_auth         = 1
45
*        key_incomplete  = 2
46
        wrong_parameter = 3
47
        OTHERS          = 4.
48
    CASE sy-subrc.
49
      WHEN 1.
50
        PERFORM set_pf_status USING 'ERROR'.
51
        CLEAR vim_key_alr_checked.
52
        LOOP AT oc_keys INTO w_oc_keys WHERE noauth = 'X'.
53
          n = n + 1.
54
          CONCATENATE 'FIELD' n INTO ocmes.
55
          IF n <= '4'.
56
            ASSIGN (ocmes) TO <noauth>.
57
            READ TABLE x_namtab ASSIGNING <namtab> WITH KEY
58
             viewfield = w_oc_keys-keyname.
59
            CHECK sy-subrc = 0.
60
            IF <namtab>-scrtext_s <> space.
61
              <noauth> = <namtab>-scrtext_s.
62
            ELSE.
63
              <noauth> = w_oc_keys-keyname.
64
            ENDIF.
65
          ELSE.
66
*            ocmiss4 = text-001.
67
          ENDIF.
68
        ENDLOOP.
69
        MESSAGE e757(sv) WITH field1 field2 field3 field4.
70
      WHEN OTHERS.
71
*     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
72
*                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
73
    ENDCASE.
74
  ENDIF.
75
* second check if entry fits selection conditions
76
  IF x_header-selection NE space.
77
    if x_header-bastab <> space and x_header-texttbexst <> space.
78
      assign <table1_text> to <table1_txt_loc>.
79
    else.
80
      assign <table1> to <table1_txt_loc>.
81
    endif.
82
    CALL FUNCTION 'TABLE_RANGE_CHECK'
83
         EXPORTING
84
              tabname                   = x_header-maintview
85
              entry                     = <table1>
86
              entry_text                = <table1_txt_loc>
87
              ddic                      = 'J'
88
              key                       = 'J'
89
              ignore_blank_subsetfields = 'N'
90
         TABLES
91
              x_namtab                  = x_namtab
92
              x_header                  = x_header
93
              sellist                   = <vim_ck_sellist>
94
         EXCEPTIONS
95
              entry_not_fits            = 1.
96
    IF sy-subrc EQ 1.
97
      PERFORM set_pf_status USING 'ERROR'.
98
      CLEAR vim_key_alr_checked.
99
      MESSAGE e033(sv).
100
    ENDIF.
101
  ENDIF.                               "x_header-selection ne space.
102
* Forkey-Check for subset fields in import mode
103
  IF vim_called_by_cluster = space AND
104
   ( vim_import_mode_active <> space OR
105
     vim_special_mode = vim_upgrade ).
106
    CALL FUNCTION 'VIEW_FORKEY_CHECK'
107
         EXPORTING
108
              viewname     = view_name
109
              entry        = <table1>
110
         TABLES
111
              namtab       = x_namtab
112
         EXCEPTIONS
113
              forkey_error = 1.
114
    IF sy-subrc EQ 1.
115
      PERFORM set_pf_status USING 'ERROR'.
116
      CLEAR vim_key_alr_checked.
117
      MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
118
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
119
    ENDIF.
120
  ENDIF.
121
* third check against TOTAL anyway
122
  READ TABLE total WITH KEY <f1_x> BINARY SEARCH.
123
  ck_tabix = sy-tabix.
124
* fourth check against db if not found and nokey-selconds exist
125
  IF sy-subrc NE 0 AND                 "entry not found in TOTAL and
126
     x_header-selection NE space AND   "selconds exist and
127
   <status>-nokeyslcds NE space.       "nokey-selconds: check against db
128
    IF x_header-bastab EQ space.
129
      ck_check_tab = x_header-roottab.
130
    ELSE.
131
      ck_check_tab = x_header-maintview.
132
    ENDIF.
133
    LOOP AT x_namtab WHERE keyflag NE space. "all keyfields
134
      IF x_header-bastab NE space AND x_header-texttbexst NE space.
135
        CHECK x_namtab-texttabfld EQ space. "ignore texttab-keyfields
136
      ELSEIF x_header-bastab EQ space. "view -> safety check langu key
137
        CHECK x_namtab-bastabname EQ x_header-roottab.
138
      ENDIF.
139
      PERFORM vim_ck_append_wheretab TABLES ck_wheretab
140
                                     USING ck_clause.
141
      IF x_header-bastab EQ space.
142
        ck_clause-field = x_namtab-bastabfld.
143
      ELSE.
144
        ck_clause-field = x_namtab-viewfield.
145
      ENDIF.
146
      ck_clause-operator = 'EQ'.
147
      ck_clause-hk1 = ''''.
148
      ck_clause-hk2 = ''''.
149
      ck_clause-and = 'AND'.
150
      IF x_namtab-inttype CO 'DTN'.
151
        ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE <table1>
152
         TO <ck_1> CASTING TYPE c.
153
*        ASSIGN <f1>+x_namtab-position(x_namtab-flength) TO <ck_1>
154
*                                                        TYPE 'C'.
155
*      ELSEIF x_namtab-inttype CO 'IPX'.
156
      ELSE.
157
       CONCATENATE x_header-maintview x_namtab-viewfield INTO fieldname
158
           SEPARATED BY '-'.
159
        ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE <table1>
160
         TO <ck_1> CASTING TYPE (fieldname).
161
*        ASSIGN <f1>+x_namtab-position(x_namtab-flength) TO <ck_1>
162
*                                            TYPE x_namtab-inttype.
163
*      ELSE.
164
*        ASSIGN <f1>+x_namtab-position(x_namtab-flength) TO <ck_1>.
165
      ENDIF.
166
      ck_clause-value = <ck_1>.
167
    ENDLOOP.
168
    CLEAR ck_clause-and.
169
    PERFORM vim_ck_append_wheretab TABLES ck_wheretab
170
                                   USING ck_clause.
171
    CREATE DATA ck_wa TYPE (ck_check_tab).
172
    ASSIGN ck_wa->* TO <ck_wa>.
173
    SELECT SINGLE * INTO <ck_wa> FROM (ck_check_tab)
174
                                 WHERE (ck_wheretab).
175
    IF sy-subrc EQ 8.                  "key not qualified
176
      RAISE impossible_error.
177
    ENDIF.
178
    ck_rc = sy-subrc.
179
  ELSE. "entry found in TOTAL or no nokey-selconds
180
    ck_rc = sy-subrc.
181
  ENDIF.                               "x_header-selection ne space.
182
  IF ck_rc NE 0 AND vim_called_by_cluster NE space.
183
    CALL FUNCTION 'VIEWCLUSTER_CHECK_MASTER_ENTRY'
184
         EXPORTING
185
              check_entry   = <table1>
186
              view_name     = x_header-viewname
187
         EXCEPTIONS
188
              invalid_key   = 1
189
              invalid_value = 2.
190
    IF sy-subrc NE 0.
191
      IF status-mode EQ list_bild.
192
        SET CURSOR FIELD sy-msgv1 LINE l.
193
      ELSE.
194
        SET CURSOR FIELD sy-msgv1.
195
      ENDIF.
196
      CLEAR vim_key_alr_checked.
197
      PERFORM set_pf_status USING 'ERROR'.
198
      MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
199
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
200
    ENDIF.
201
  ENDIF.
202
  sy-subrc = ck_rc. sy-tabix = ck_tabix.
203
  CHECK ck_rc EQ 0.
204
  IF x_header-delmdtflag NE space AND status-mode EQ detail_bild.
205
    mess_type = 'S'.
206
  ENDIF.
207
  PERFORM set_pf_status USING 'ERROR'.
208
  CLEAR vim_key_alr_checked.
209
  IF <action> EQ geloescht
210
  OR <action> EQ neuer_geloescht
211
  OR <action> EQ update_geloescht.
212
    MESSAGE ID 'SV' TYPE mess_type NUMBER '010'.
213
  ELSE.
214
    MESSAGE ID 'SV' TYPE mess_type NUMBER '009'.
215
  ENDIF.
216
  IF x_header-delmdtflag NE space AND status-mode EQ detail_bild.
217
    <vim_h_old_mkey>(x_header-keylen) = <f1_x>.
218
*    vim_old_viewkey = <f1>.
219
    TRANSLATE neuer USING 'JX'.
220
    CLEAR: function, ok_code. LEAVE SCREEN.
221
  ENDIF.
222
ENDFORM.