Properties SourceCde
txt
1
*&--------------------------------------------------------------------*
2
*&      Form  EDIT_VIEW_ENTRY                                         *
3
*&--------------------------------------------------------------------*
4
*       edit entry in TOTAL/EXTRACT due to foreign request            *
5
*---------------------------------------------------------------------*
6
* ENTRY  ---> entry to edit                                           *
7
* ACTION ---> action: UPD - add/update, DEL - delete, UDL - undelete  *
8
*             IGN - mark entry as to ignore, MRK - mark/unmark entry  *
9
* SY_SUBRC -> return code: 0 - all right, others: failure             *
10
* EXT    ---> table containing selected view entries                  *
11
* TOT    ---> table containing all view entries                       *
12
* HEADER ---> table containing header information of current view     *
13
* NAMTAB ---> table containing information about current viewfields   *
14
* SELLIST --> table containing select options                         *
15
*---------------------------------------------------------------------*
16
FORM edit_view_entry TABLES ext tot
17
                            header  STRUCTURE vimdesc
18
                            namtab  STRUCTURE vimnamtab
19
                            sellist STRUCTURE vimsellist
20
                     USING value(entry) value(action).
21
  DATA: state_vect_name(37) TYPE c,
22
        rc LIKE sy-subrc, pos LIKE sy-fdpos,
23
        texttablename(31) TYPE c VALUE '*          ', mmark(1) TYPE c,
24
        tab_rc LIKE sy-subrc, tab_ix LIKE sy-tabix,
25
        dummy_tab LIKE vimexclfun OCCURS 1, name(20) TYPE c.
26
  FIELD-SYMBOLS: <tot_x> TYPE x, <ext_x> TYPE x, <ent_x> TYPE x,
27
                 <viewkey> TYPE x, <act> TYPE c, <xact> TYPE c,
28
                 <mrk> TYPE c, <xmrk> TYPE c,
29
                 <txt_act> TYPE c,
30
                 <tot_struc> TYPE ANY, <ent_struc> TYPE ANY,
31
                 <tot_txt> TYPE x, <ent_txt> TYPE x, <ent_txt2> TYPE x,
32
                 <tot_txt_struc> TYPE ANY, <txt_init> TYPE ANY.
33
 
34
  READ TABLE header INDEX 1.
35
  pos = header-after_tabc.
36
*  MOVE HEADER-TABLEN TO POS.
37
  ASSIGN: tot TO <tot_x> CASTING, ext TO <ext_x> CASTING,
38
          entry TO <ent_x> CASTING,
39
          <tot_x> TO <tot_struc> CASTING TYPE (header-maintview),
40
          <ent_x> TO <ent_struc> CASTING TYPE (header-maintview).
41
  IF header-bastab NE space AND header-texttbexst NE space.
42
* tab+txttb
43
    ADD header-aft_txttbc TO pos.
44
    MOVE header-texttab TO texttablename+1.
45
    ASSIGN: <tot_x>+header-after_tabc(header-texttablen) TO <tot_txt>,
46
            <ent_x>+header-after_tabc(header-texttablen) TO <ent_txt>,
47
            <tot_txt> TO <tot_txt_struc> CASTING TYPE (header-texttab),
48
            (texttablename) TO <txt_init>.
49
*    ASSIGN: TOT+HEADER-TABLEN(HEADER-TEXTTABLEN) TO <TOT_TXT>,
50
*            ENTRY+HEADER-TABLEN(HEADER-TEXTTABLEN) TO <ENT_TXT>,
51
*            (TEXTTABLENAME) TO <TXT_INIT>.
52
  ENDIF.
53
  ASSIGN: <ent_x>(header-keylen) TO <viewkey>,
54
          <tot_x>+pos(cl_abap_char_utilities=>charsize)
55
           TO <act> CASTING,
56
          <ext_x>+pos(cl_abap_char_utilities=>charsize)
57
           TO <xact> CASTING.
58
  ADD cl_abap_char_utilities=>charsize TO pos.
59
  ASSIGN: <tot_x>+pos(cl_abap_char_utilities=>charsize)
60
           TO <mrk> CASTING,
61
          <ext_x>+pos(cl_abap_char_utilities=>charsize)
62
           TO <xmrk> CASTING.
63
  IF header-bastab NE space AND header-texttbexst NE space."tab+txttb
64
    ADD cl_abap_char_utilities=>charsize TO pos.
65
    ASSIGN <tot_x>+pos(cl_abap_char_utilities=>charsize)
66
     TO <txt_act> CASTING.
67
  ENDIF.
68
*  ASSIGN: ENTRY(HEADER-KEYLEN) TO <VIEWKEY>,
69
*          TOT+POS(1) TO <ACT>.
70
*  ADD 1 TO POS.
71
*  ASSIGN TOT+POS(1) TO <MRK>.
72
*  IF HEADER-BASTAB NE SPACE AND HEADER-TEXTTBEXST NE SPACE."tab+txttb
73
*    ADD 1 TO POS.
74
*    ASSIGN TOT+POS(1) TO <TXT_ACT>.
75
*    SUBTRACT 1 FROM POS.
76
*  ENDIF.
77
  IF header-viewname NE last_ext_modif_view.
78
    MOVE state_vect_prefix TO state_vect_name.
79
    WRITE header-maintview TO state_vect_name+state_vect_prefix_length.
80
    ASSIGN (state_vect_name) TO <state>.
81
    MOVE header-viewname TO last_ext_modif_view.
82
  ENDIF.
83
  READ TABLE tot WITH KEY <viewkey> BINARY SEARCH.
84
  tab_rc = sy-subrc. tab_ix = sy-tabix.
85
  IF sy-subrc EQ 0.                    " entry found in TOT
86
    CASE action.
87
      WHEN 'DEL'.
88
        CASE <act>.
89
          WHEN neuer_eintrag.
90
            <act> = neuer_geloescht.
91
          WHEN original.
92
            <act> = geloescht.
93
          WHEN aendern.
94
            <act> = update_geloescht.
95
        ENDCASE.
96
        IF header-bastab NE space AND header-texttbexst NE space.
97
          CASE <txt_act>.
98
            WHEN neuer_eintrag.
99
              <txt_act>            = neuer_geloescht.
100
            WHEN original.
101
              IF <tot_txt_struc> NE <txt_init>.
102
                <txt_act>             = geloescht.
103
              ENDIF.
104
            WHEN aendern.
105
              <txt_act>             = update_geloescht.
106
          ENDCASE.
107
        ENDIF.
108
        mmark = <mrk>.
109
        IF <mrk> EQ markiert.
110
          <mrk> = nicht_markiert. SUBTRACT 1 FROM <state>-mk_to.
111
        ENDIF.
112
        MODIFY tot INDEX sy-tabix.
113
        READ TABLE ext WITH KEY <viewkey>.
114
        IF sy-subrc EQ 0.
115
          IF mmark EQ markiert.
116
            SUBTRACT 1 FROM <state>-mk_xt.
117
          ENDIF.
118
          DELETE ext INDEX sy-tabix.
119
          SUBTRACT 1 FROM <state>-maxlines.
120
        ENDIF.
121
      WHEN 'UPD'.
122
        IF header-bastab NE space AND header-texttbexst NE space.
123
          IF <tot_txt> NE <ent_txt>.
124
            IF <tot_txt_struc> EQ <txt_init>.
125
              <txt_act> = neuer_eintrag.
126
            ELSE.
127
              IF <txt_act> EQ original.
128
                <txt_act> = aendern.
129
              ENDIF.
130
            ENDIF.
131
            MOVE <ent_txt> TO <tot_txt>.
132
          ENDIF.
133
        ENDIF.
134
        MOVE <ent_struc> TO <tot_struc>.
135
        IF <act> EQ original.
136
          <act> = aendern.
137
        ENDIF.
138
        MODIFY tot INDEX sy-tabix.
139
        READ TABLE ext WITH KEY <viewkey>.
140
        IF sy-subrc EQ 0.
141
          MOVE tot TO ext.
142
          MODIFY ext INDEX sy-tabix.
143
        ENDIF.
144
      WHEN 'UDL'.
145
        CASE <act>.
146
          WHEN neuer_geloescht.
147
            <act> = neuer_eintrag.
148
          WHEN geloescht.
149
            <act> = original.
150
          WHEN update_geloescht.
151
            <act> = aendern.
152
          WHEN OTHERS.
153
            rc = 8.
154
        ENDCASE.
155
        IF rc EQ 0.
156
          IF header-bastab NE space AND header-texttbexst NE space.
157
            CASE <txt_act>.
158
              WHEN neuer_geloescht.
159
                <txt_act>         = neuer_eintrag.
160
              WHEN geloescht.
161
                <txt_act>         = original.
162
              WHEN update_geloescht.
163
                <txt_act>         = aendern.
164
            ENDCASE.
165
          ENDIF.
166
          MODIFY tot INDEX sy-tabix.
167
          READ TABLE ext WITH KEY <viewkey>.
168
          IF sy-subrc EQ 0.
169
            IF <state>-selected EQ geloescht.
170
              DELETE ext INDEX sy-tabix.
171
            ELSE.
172
              <xmrk> = <mrk>.
173
              <xact> = <act>.
174
              MODIFY ext INDEX sy-tabix.
175
            ENDIF.
176
          ENDIF.
177
        ENDIF.
178
      WHEN 'IGN'.
179
        IF <mrk> EQ markiert.
180
          MOVE uebergehen TO <mrk>.
181
          MODIFY tot INDEX sy-tabix.
182
          READ TABLE ext WITH KEY <viewkey>.
183
          IF sy-subrc EQ 0.
184
            <xmrk> = <mrk>.
185
            MODIFY ext INDEX sy-tabix.
186
          ENDIF.
187
        ENDIF.
188
        rc = 1.
189
      WHEN 'MRK'.
190
        IF <mrk> EQ markiert.
191
          MOVE nicht_markiert TO <mrk>.
192
        ELSE.
193
          MOVE markiert TO <mrk>.
194
        ENDIF.
195
        MODIFY tot INDEX sy-tabix.
196
        IF <mrk> EQ markiert.
197
          ADD 1 TO <state>-mk_to.
198
        ELSE.
199
          SUBTRACT 1 FROM <state>-mk_to.
200
        ENDIF.
201
        READ TABLE ext WITH KEY <viewkey>.
202
        IF sy-subrc EQ 0.
203
          <xmrk> = <mrk>.
204
          MODIFY ext INDEX sy-tabix.
205
          IF <mrk> EQ markiert.
206
            ADD 1 TO <state>-mk_xt.
207
          ELSE.
208
            SUBTRACT 1 FROM <state>-mk_xt.
209
          ENDIF.
210
        ENDIF.
211
        rc = 1.
212
    ENDCASE.
213
  ELSE.                                "entry NOT found in TOT
214
    CLEAR sy-subrc.
215
    IF action NE 'UPD'.
216
      rc = 8.
217
    ELSE.
218
      IF header-selection NE space.
219
        IF header-bastab <> space AND header-texttbexst <> space.
220
          ASSIGN <ent_txt> TO <ent_txt2>.
221
        ELSE.
222
          ASSIGN <ent_x> TO <ent_txt2>.
223
        ENDIF.
224
        CALL FUNCTION 'TABLE_RANGE_CHECK'
225
          EXPORTING
226
            tabname                   = header-maintview
227
            entry                     = entry
228
            entry_text                = <ent_txt2>
229
            ddic                      = 'J'
230
            key                       = 'J'
231
            ignore_blank_subsetfields = 'N'
232
          TABLES
233
            x_namtab                  = namtab
234
            x_header                  = header
235
            sellist                   = sellist
236
          EXCEPTIONS
237
            entry_not_fits            = 8.
238
      ENDIF.
239
      IF sy-subrc EQ 0.
240
        MOVE <ent_struc> TO <tot_struc>.
241
        <act> = neuer_eintrag.
242
        <mrk> = nicht_markiert.
243
        IF header-bastab NE space AND header-texttbexst NE space.
244
          <tot_txt> = <ent_txt>.
245
          IF <tot_txt_struc> NE <txt_init>.
246
            <txt_act> = neuer_eintrag.
247
          ELSE.
248
            <txt_act> = original.
249
          ENDIF.
250
        ENDIF.
251
        CASE tab_rc.
252
          WHEN 4.
253
            INSERT tot INDEX tab_ix.
254
          WHEN 8.
255
            APPEND tot.
256
        ENDCASE.
257
      ELSE.
258
        rc = sy-subrc.
259
      ENDIF.
260
    ENDIF.
261
  ENDIF.
262
  IF rc EQ 0.
263
    MOVE 'X' TO <state>-upd_flag.
264
  ENDIF.
265
  sy-subrc = ( rc DIV 8 ) * 8.
266
ENDFORM.                               " EDIT_VIEW_ENTRY