1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | FORM vim_address_adjust. |
14 | DATA: addr_comp_tab TYPE szadr_compare_addr1_tab, |
15 | addr_comp_line TYPE szadr_compare_addr1_line, |
16 | handle TYPE ad_handle, |
17 | create_address(1) TYPE c, |
18 | retcode LIKE szad_field-returncode, |
19 | error_info LIKE addr_error OCCURS 0 WITH HEADER LINE, |
20 | einfo LIKE addr_error, |
21 | i_msgv1 LIKE sy-msgv1, |
22 | space_msgv LIKE sy-msgv1 VALUE space, |
23 | dum TYPE i, pos_char TYPE i. |
24 | |
25 | FIELD-SYMBOLS: <handle_x> TYPE x, <field_loc> TYPE ANY. |
26 | |
27 |
28 | CHECK x_header-adrnbrflag = 'N' AND adrnbr_roflag = space. |
29 | ASSIGN handle TO <handle_x> CASTING. |
30 | IF vim_import_mode_active = space. "interaktive Übernahme |
31 | IF vim_upgr_address_number <> '@ADJUSTED@'. "cmpwl_addr_adjusted |
32 | EXIT. |
33 | ENDIF. |
34 | IF <address_number> = space. |
35 | <handle_x> = <f1_x>. |
36 |
37 | create_address = 'X'. |
38 | ELSE. |
39 | READ TABLE vim_locked_addresses FROM <address_number> |
40 | TRANSPORTING NO FIELDS. |
41 | IF sy-subrc <> 0. "not yet locked |
42 | CALL FUNCTION 'ADDR_ENQUEUE' |
43 | EXPORTING |
44 | address_number = <address_number> |
45 |
46 | EXCEPTIONS |
47 | address_not_exist = 1 |
48 | foreign_lock = 2 |
49 | system_failure = 3 |
50 | internal_error = 4. |
51 | CASE sy-subrc. |
52 | WHEN 0. |
53 | INSERT <address_number> INTO TABLE vim_locked_addresses. |
54 | WHEN 1. |
55 | <handle_x> = <f1_x>. |
56 |
57 | create_address = 'X'. |
58 | CLEAR <address_number>. |
59 | WHEN 2. |
60 | PERFORM vim_process_message |
61 | USING 'SV' 'E' 'E' '049' |
62 | sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
63 | WHEN OTHERS. |
64 |
65 | LOOP AT x_namtab. "HCG write field by field instead |
66 | ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE <table1> |
67 | TO <field_loc>. |
68 | dum = ( x_namtab-position + x_namtab-flength ) / |
69 | cl_abap_char_utilities=>charsize. |
70 | pos_char = x_namtab-position / |
71 | cl_abap_char_utilities=>charsize. |
72 | IF dum <= 13. |
73 | WRITE <field_loc> TO i_msgv1+pos_char. |
74 | ELSE. |
75 | dum = 13 - pos_char. |
76 | WRITE <field_loc>(dum) TO i_msgv1+pos_char. |
77 | EXIT. "HCG i_msgv1 filled |
78 | ENDIF. |
79 | ENDLOOP. |
80 | PERFORM vim_process_message |
81 | USING 'SV' 'E' 'E' '050' |
82 | i_msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
83 | ENDCASE. |
84 | ENDIF. " SY-SUBRC <> 0. |
85 | ENDIF. "<Address_Number> = SPACE |
86 | |
87 | ELSE. "automat. Übernahme |
88 | IF vim_upgr_address_number = space. |
89 |
90 | LOOP AT x_namtab. "HCG write field by field instead |
91 | ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE <table1> |
92 | TO <field_loc>. |
93 | dum = ( x_namtab-position + x_namtab-flength ) / |
94 | cl_abap_char_utilities=>charsize. |
95 | pos_char = x_namtab-position / |
96 | cl_abap_char_utilities=>charsize. |
97 | IF dum <= 13. |
98 | WRITE <field_loc> TO i_msgv1+pos_char. |
99 | ELSE. |
100 | dum = 13 - pos_char. |
101 | WRITE <field_loc>(dum) TO i_msgv1+pos_char. |
102 | EXIT. "HCG i_msgv1 filled |
103 | ENDIF. |
104 | ENDLOOP. |
105 | PERFORM vim_process_message |
106 | USING 'SV' 'I' 'I' '165' |
107 | i_msgv1 space_msgv space_msgv space_msgv. |
108 | EXIT. "keine Löschung |
109 | ENDIF. |
110 | |
111 | addr_comp_line-addrnumber = <address_number>. |
112 | IF <address_number> = space. |
113 | <handle_x> = <f1_x>. |
114 | addr_comp_line-addrhandle = handle. |
115 |
116 |
117 | create_address = 'X'. |
118 | ENDIF. |
119 | addr_comp_line-remote_addrnumber = vim_upgr_address_number. |
120 | APPEND addr_comp_line TO addr_comp_tab. |
121 | CALL FUNCTION 'ADDR_COMPARE' |
122 | EXPORTING |
123 | rfc_destination = vim_default_rfc_dest-rfcdest |
124 | TABLES |
125 | compare_tab = addr_comp_tab |
126 | EXCEPTIONS |
127 | rfc_error = 1 |
128 | OTHERS = 2. |
129 | IF sy-subrc <> 0. |
130 | PERFORM vim_process_message |
131 | USING sy-msgid 'E' 'E' sy-msgno |
132 | sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
133 | EXIT. |
134 | ENDIF. |
135 | READ TABLE addr_comp_tab INDEX 1 INTO addr_comp_line. |
136 | IF addr_comp_line-parameter_error = 'X' OR |
137 | addr_comp_line-internal_error = 'X'. |
138 | einfo = addr_comp_line-error_table. |
139 | PERFORM vim_process_message |
140 | USING einfo-msg_id 'E' 'E' einfo-msg_number |
141 | einfo-msg_var1 einfo-msg_var2 einfo-msg_var3 einfo-msg_var4. |
142 |
143 | EXIT. |
144 | ENDIF. |
145 | |
146 | IF addr_comp_line-rem_address_not_exist = 'X'. "keine Löschung! |
147 |
148 | LOOP AT x_namtab. "HCG write field by field instead |
149 | ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE <table1> |
150 | TO <field_loc>. |
151 | dum = ( x_namtab-position + x_namtab-flength ) / |
152 | cl_abap_char_utilities=>charsize. |
153 | pos_char = x_namtab-position / |
154 | cl_abap_char_utilities=>charsize. |
155 | IF dum <= 13. |
156 | WRITE <field_loc> TO i_msgv1+pos_char. |
157 | ELSE. |
158 | dum = 13 - pos_char. |
159 | WRITE <field_loc>(dum) TO i_msgv1+pos_char. |
160 | EXIT. "HCG i_msgv1 filled |
161 | ENDIF. |
162 | ENDLOOP. |
163 | PERFORM vim_process_message |
164 | USING 'SV' 'I' 'I' '165' |
165 | i_msgv1 space_msgv space_msgv space_msgv. |
166 | EXIT. |
167 | ELSEIF addr_comp_line-address_not_exist = 'X' AND |
168 | create_address = space. |
169 | <handle_x> = <f1_x>. |
170 |
171 | create_address = 'X'. |
172 | CLEAR: <address_number>, <vim_total_address_number>. |
173 | REFRESH addr_comp_tab. CLEAR addr_comp_line. |
174 | addr_comp_line = handle. |
175 |
176 | addr_comp_line-remote_addrnumber = vim_upgr_address_number. |
177 | APPEND addr_comp_line TO addr_comp_tab. |
178 | CALL FUNCTION 'ADDR_COMPARE' |
179 | EXPORTING |
180 | rfc_destination = vim_default_rfc_dest-rfcdest |
181 | TABLES |
182 | compare_tab = addr_comp_tab |
183 | EXCEPTIONS |
184 | rfc_error = 1 |
185 | OTHERS = 2. |
186 | IF sy-subrc <> 0. |
187 | PERFORM vim_process_message |
188 | USING sy-msgid 'E' 'E' sy-msgno |
189 | sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
190 | EXIT. |
191 | ENDIF. |
192 | READ TABLE addr_comp_tab INDEX 1 INTO addr_comp_line. |
193 | IF addr_comp_line-parameter_error = 'X' OR |
194 | addr_comp_line-internal_error = 'X'. |
195 | einfo = addr_comp_line-error_table. |
196 | PERFORM vim_process_message |
197 | USING einfo-msg_id 'E' 'E' einfo-msg_number |
198 | einfo-msg_var1 einfo-msg_var2 einfo-msg_var3 einfo-msg_var4. |
199 |
200 | EXIT. |
201 | ENDIF. |
202 |
203 | |
204 | ELSEIF addr_comp_line-address_is_equal = 'X'. |
205 | EXIT. |
206 | ELSEIF create_address = space. |
207 | READ TABLE vim_locked_addresses FROM <address_number> |
208 | TRANSPORTING NO FIELDS. |
209 | IF sy-subrc <> 0. "not yet locked |
210 | CALL FUNCTION 'ADDR_ENQUEUE' |
211 | EXPORTING |
212 | address_number = <address_number> |
213 |
214 | EXCEPTIONS |
215 | address_not_exist = 1 |
216 | foreign_lock = 2 |
217 | system_failure = 3 |
218 | internal_error = 4. |
219 | CASE sy-subrc. |
220 | WHEN 0. |
221 | INSERT <address_number> INTO TABLE vim_locked_addresses. |
222 | WHEN 1. " würde schon in ADDR_COMPARE auftreten |
223 | PERFORM vim_process_message "eigentlich überflüssig |
224 | USING 'SV' 'E' 'E' '049' |
225 | sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
226 | WHEN 2. |
227 | PERFORM vim_process_message |
228 | USING 'SV' 'E' 'E' '049' |
229 | sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
230 | WHEN OTHERS. |
231 |
232 | LOOP AT x_namtab. "HCG write field by field instead |
233 | ASSIGN COMPONENT x_namtab-viewfield OF STRUCTURE <table1> |
234 | TO <field_loc>. |
235 | dum = ( x_namtab-position + x_namtab-flength ) / |
236 | cl_abap_char_utilities=>charsize. |
237 | pos_char = x_namtab-position / |
238 | cl_abap_char_utilities=>charsize. |
239 | IF dum <= 13. |
240 | WRITE <field_loc> TO i_msgv1+pos_char. |
241 | ELSE. |
242 | dum = 13 - pos_char. |
243 | WRITE <field_loc>(dum) TO i_msgv1+pos_char. |
244 | EXIT. "HCG i_msgv1 filled |
245 | ENDIF. |
246 | ENDLOOP. |
247 | PERFORM vim_process_message |
248 | USING 'SV' 'E' 'E' '050' |
249 | i_msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
250 | ENDCASE. |
251 | ENDIF. "SY-SUBRC |
252 | ENDIF. |
253 | ENDIF. " vim_import_mode_active |
254 | |
255 | CALL FUNCTION 'ADDR_ADJUST' |
256 | EXPORTING |
257 | addrnumber = <address_number> |
258 | addrhandle = handle |
259 | address_group = 'CA01' |
260 | IMPORTING |
261 | returncode = retcode |
262 | TABLES |
263 | error_table = error_info |
264 | EXCEPTIONS |
265 | parameter_error = 1 |
266 | address_not_exist = 2 |
267 | handle_exist = 3 |
268 | internal_error = 4 |
269 | address_not_compared = 5 |
270 | OTHERS = 6. |
271 | IF sy-subrc <> 0. |
272 | PERFORM vim_process_message |
273 | USING sy-msgid 'E' 'E' sy-msgno |
274 | sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. |
275 | ELSE. |
276 | IF retcode = 'E'. |
277 | READ TABLE error_info INDEX 1. |
278 | PERFORM vim_process_message |
279 | USING error_info-msg_id 'E' 'E' error_info-msg_number |
280 | error_info-msg_var1 error_info-msg_var2 |
281 | error_info-msg_var3 error_info-msg_var4. |
282 | ELSE. "ok |
283 | IF create_address = 'X'. |
284 | <address_number> = '@NEW'. |
285 | <address_number>+4(6) = <status>-newadrcnt. |
286 | ADD 1 TO <status>-newadrcnt. |
287 | <status>-upd_flag = 'X'. |
288 | ENDIF. |
289 | <vim_total_address_number> = <address_number>. |
290 | READ TABLE vim_addresses_to_save |
291 | WITH KEY viewname = x_header-viewname |
292 | addrnumber = <address_number> |
293 | BINARY SEARCH TRANSPORTING NO FIELDS. |
294 | IF sy-subrc NE 0. |
295 | vim_addresses_to_save-viewname = x_header-viewname. |
296 | vim_addresses_to_save-addrnumber = <address_number>. |
297 | <vim_addr_handle_x> = <f1_x>. |
298 |
299 | INSERT vim_addresses_to_save INDEX sy-tabix. |
300 | ENDIF. |
301 | IF vim_client_state EQ vim_log AND |
302 | x_header-flag NE vim_transport_denied. |
303 | <status>-upd_flag = 'X'. "nec. for transport of master entry |
304 | ENDIF. |
305 | ENDIF. "RETCODE |
306 | ENDIF. "SY-SUBRC |
307 | ENDFORM. "vim_address_adjust |