-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathCLAS_ZSAPLINK_MESSAGE_CLASS.slnk
432 lines (385 loc) · 18 KB
/
CLAS_ZSAPLINK_MESSAGE_CLASS.slnk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<?xml version="1.0" encoding="utf-8"?>
<CLAS CLSNAME="ZSAPLINK_MESSAGE_CLASS" VERSION="1" LANGU="E" DESCRIPT="SAPLink - Message Class plugin" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" CLSCCINCL="X" FIXPT="X" UNICODE="X" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 " REFCLSNAME="ZSAPLINK">
<localImplementation>*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes</localImplementation>
<localTypes>*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature</localTypes>
<localMacros>*"* use this source file for any macro definitions you need
*"* in the implementation part of the class</localMacros>
<inheritance CLSNAME="ZSAPLINK_MESSAGE_CLASS" REFCLSNAME="ZSAPLINK" VERSION="1" STATE="1">
<redefinition CLSNAME="ZSAPLINK_MESSAGE_CLASS" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="CHECKEXISTS"/>
<redefinition CLSNAME="ZSAPLINK_MESSAGE_CLASS" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="CREATEIXMLDOCFROMOBJECT"/>
<redefinition CLSNAME="ZSAPLINK_MESSAGE_CLASS" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="CREATEOBJECTFROMIXMLDOC"/>
<redefinition CLSNAME="ZSAPLINK_MESSAGE_CLASS" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="DELETEOBJECT"/>
<redefinition CLSNAME="ZSAPLINK_MESSAGE_CLASS" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="GETOBJECTTYPE"/>
</inheritance>
<method CLSNAME="ZSAPLINK" CMPNAME="CHECKEXISTS" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
METHOD checkexists .
* Plugin created by:
* John Patterson
DATA: ls_t100a TYPE t100a,
lv_msgid TYPE msgid.
lv_msgid = objname.
SELECT SINGLE *
INTO ls_t100a
FROM t100a
WHERE arbgb = lv_msgid.
IF sy-subrc = 0.
exists = 'X'.
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEIXMLDOCFROMOBJECT" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
METHOD createixmldocfromobject .
* Plugin created by:
* John Patterson
DATA: lt_t100 TYPE STANDARD TABLE OF t100,
lt_t100t TYPE STANDARD TABLE OF t100t,
ls_t100 LIKE LINE OF lt_t100,
ls_t100t LIKE LINE OF lt_t100t,
ls_t100a TYPE t100a.
DATA: lv_msgid TYPE msgid,
lv_rc TYPE sysubrc,
lv_objtype TYPE string.
*xml nodes
DATA: lr_rootnode TYPE REF TO if_ixml_element,
lr_t100_node TYPE REF TO if_ixml_element,
lr_t100t_node TYPE REF TO if_ixml_element.
lv_msgid = objname.
SELECT SINGLE *
INTO ls_t100a
FROM t100a WHERE arbgb = lv_msgid.
IF sy-subrc NE 0.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>not_found.
ENDIF.
CALL FUNCTION 'RS_ACCESS_PERMISSION'
EXPORTING
authority_check = 'X'
global_lock = space
mode = 'SHOW'
object = lv_msgid
object_class = 'T100'
EXCEPTIONS
canceled_in_corr = 01
enqueued_by_user = 02
enqueue_system_failure = 03
illegal_parameter_values = 04
locked_by_author = 05
no_modify_permission = 06
no_show_permission = 07
permission_failure = 08.
CASE sy-subrc.
WHEN 0.
WHEN 2 OR 5.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>locked.
WHEN 6 OR 7 OR 8 OR 9.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>not_authorized.
WHEN OTHERS.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>system_error.
ENDCASE.
*--- get messages for all maintained languages
SELECT *
INTO TABLE lt_t100
FROM t100
WHERE arbgb = lv_msgid
ORDER BY sprsl msgnr.
*--- get text for t100a
SELECT *
INTO TABLE lt_t100t
FROM t100t
WHERE arbgb = lv_msgid
ORDER BY sprsl.
*-- Create parent node
lv_objtype = getobjecttype( ).
lr_rootnode = xmldoc->create_element( lv_objtype ).
setattributesfromstructure( node = lr_rootnode
structure = ls_t100a ).
*--- Create Elements for Messages
LOOP AT lt_t100 INTO ls_t100.
lr_t100_node = xmldoc->create_element( 't100' ).
setattributesfromstructure( node = lr_t100_node
structure = ls_t100 ).
lv_rc = lr_rootnode->append_child( lr_t100_node ).
ENDLOOP.
*--- Create Elements for Texts
LOOP AT lt_t100t INTO ls_t100t.
lr_t100t_node = xmldoc->create_element( 't100t' ).
setattributesfromstructure( node = lr_t100t_node
structure = ls_t100t ).
lv_rc = lr_rootnode->append_child( lr_t100t_node ).
ENDLOOP.
lv_rc = xmldoc->append_child( lr_rootnode ).
ixmldocument = xmldoc.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEOBJECTFROMIXMLDOC" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
METHOD createobjectfromixmldoc .
* Plugin created by:
* John Patterson
DATA: lt_t100 TYPE STANDARD TABLE OF t100,
lt_t100t TYPE STANDARD TABLE OF t100t,
ls_t100 LIKE LINE OF lt_t100,
ls_t100t LIKE LINE OF lt_t100t,
ls_t100a TYPE t100a.
DATA: lv_msgid TYPE msgid,
lv_rc TYPE sysubrc,
lv_objtype TYPE string,
lv_checkexists TYPE char1,
lv_len TYPE i.
*--- xml data objects
DATA: lr_rootnode TYPE REF TO if_ixml_element,
lr_t100_node TYPE REF TO if_ixml_element,
lr_t100t_node TYPE REF TO if_ixml_element,
lr_filter TYPE REF TO if_ixml_node_filter,
lr_iterator TYPE REF TO if_ixml_node_iterator.
lv_msgid = objname.
lv_objtype = getobjecttype( ).
xmldoc = ixmldocument.
lr_rootnode = xmldoc->find_from_name( lv_objtype ).
CALL METHOD getstructurefromattributes
EXPORTING
node = lr_rootnode
CHANGING
structure = ls_t100a.
objname = ls_t100a-arbgb.
lv_checkexists = checkexists( ).
IF lv_checkexists IS NOT INITIAL.
IF overwrite IS INITIAL.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>existing.
ELSE.
deleteobject( ).
ENDIF.
ENDIF.
*--- Read Elements for Messages
FREE: lr_filter, lr_iterator, lr_t100_node, lr_t100t_node.
lr_filter = xmldoc->create_filter_name( 't100' ).
lr_iterator = xmldoc->create_iterator_filtered( lr_filter ).
lr_t100_node ?= lr_iterator->get_next( ).
WHILE lr_t100_node IS NOT INITIAL.
CLEAR ls_t100.
CALL METHOD getstructurefromattributes
EXPORTING
node = lr_t100_node
CHANGING
structure = ls_t100.
APPEND ls_t100 TO lt_t100.
lr_t100_node ?= lr_iterator->get_next( ).
ENDWHILE.
*--- Create Elements for Texts
FREE: lr_filter, lr_iterator, lr_t100_node, lr_t100t_node.
lr_filter = xmldoc->create_filter_name( 't100t' ).
lr_iterator = xmldoc->create_iterator_filtered( lr_filter ).
lr_t100t_node ?= lr_iterator->get_next( ).
WHILE lr_t100t_node IS NOT INITIAL.
CLEAR ls_t100t.
CALL METHOD getstructurefromattributes
EXPORTING
node = lr_t100t_node
CHANGING
structure = ls_t100t.
APPEND ls_t100t TO lt_t100t.
lr_t100t_node ?= lr_iterator->get_next( ).
ENDWHILE.
CALL FUNCTION 'RS_ACCESS_PERMISSION'
EXPORTING
mode = 'FREE'
object = lv_msgid
object_class = 'T100'.
*--- Check permission
CALL FUNCTION 'RS_ACCESS_PERMISSION'
EXPORTING
authority_check = 'X'
global_lock = 'X'
mode = 'INSERT'
language_upd_exit = 'UPDATE_MASTER'
master_language = ls_t100a-masterlang
object = lv_msgid
object_class = 'T100'
suppress_language_check = ' '
EXCEPTIONS
canceled_in_corr = 01
enqueued_by_user = 02
enqueue_system_failure = 03
illegal_parameter_values = 04
locked_by_author = 05
no_modify_permission = 06
no_show_permission = 07
permission_failure = 08.
CASE sy-subrc.
WHEN 0.
WHEN 2 OR 5.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>locked.
WHEN 6 OR 7 OR 8 OR 9.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>not_authorized.
WHEN OTHERS.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>system_error.
ENDCASE.
CALL FUNCTION 'RS_CORR_INSERT'
EXPORTING
author = sy-uname
global_lock = 'X'
object = objname
object_class = 'T100'
devclass = devclass
master_language = sy-langu
mode = 'INSERT'
* IMPORTING
* AUTHOR = UNAME
* KORRNUM = CORRNUMBER_LOCAL
* DEVCLASS = DEVCLASS_LOCAL
EXCEPTIONS
cancelled = 1
permission_failure = 2
unknown_objectclass = 3.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 2.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>not_authorized.
WHEN OTHERS.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>system_error.
ENDCASE.
ENDIF.
*--- update message tables
CLEAR: ls_t100a-applclass.
ls_t100a-lastuser = sy-uname.
ls_t100a-ldate = sy-datum.
ls_t100a-ltime = sy-uzeit.
MODIFY t100a FROM ls_t100a.
MODIFY t100 FROM TABLE lt_t100.
MODIFY t100t FROM TABLE lt_t100t.
CALL FUNCTION 'RS_TREE_OBJECT_PLACEMENT'
EXPORTING
object = lv_msgid
operation = 'INSERT'
type = 'CN'.
CALL FUNCTION 'RS_ACCESS_PERMISSION'
EXPORTING
mode = 'FREE'
object = lv_msgid
object_class = 'T100'.
name = objname.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="DELETEOBJECT" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
method DELETEOBJECT .
* Plugin created by:
* John Patterson
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="GETOBJECTTYPE" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
METHOD getobjecttype .
* Plugin created by:
* John Patterson
objecttype = 'MSAG'. "Message Class
ENDMETHOD.</source>
</method>
</CLAS>