-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathCLAS_ZSAPLINK_SMARTFORMS.slnk
454 lines (400 loc) · 21.7 KB
/
CLAS_ZSAPLINK_SMARTFORMS.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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<?xml version="1.0" encoding="iso-8859-1"?>
<CLAS CLSNAME="ZSAPLINK_SMARTFORM" VERSION="0" LANGU="E" DESCRIPT="SAPlink - Programs" UUID="7CB76E9F279C244BADF6EC7E1B9CD6EA" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="BCUSER" CREATEDON="20061007" CHANGEDON="00000000" CHGDANYON="00000000" CLSFINAL="X" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="700" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 " REFCLSNAME="ZSAPLINK">
<publicSection>class ZSAPLINK_SMARTFORM definition
public
inheriting from ZSAPLINK
final
create public .
*"* public components of class ZSAPLINK_SMARTFORM
*"* do not include other source files here!!!
public section.
methods CHECKEXISTS
redefinition .
methods CREATEIXMLDOCFROMOBJECT
redefinition .
methods CREATEOBJECTFROMIXMLDOC
redefinition .</publicSection>
<protectedSection>*"* protected components of class ZSAPLINK_PROGRAM
*"* do not include other source files here!!!
protected section.
methods DELETEOBJECT
redefinition .
methods GETOBJECTTYPE
redefinition .</protectedSection>
<privateSection>*"* private components of class ZSAPLINK_SMARTFORM
*"* do not include other source files here!!!
private section.</privateSection>
<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>
<method CLSNAME="ZSAPLINK" CMPNAME="CHECKEXISTS" VERSION="0" LANGU="E" DESCRIPT="Check if object exists" EXPOSURE="2" STATE="1" EDITORDER="9 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" R3RELEASE="700" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="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 .
SELECT SINGLE formname FROM stxfadm INTO objname WHERE formname = objname.
IF sy-subrc = 0.
exists = 'X'.
ENDIF.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEIXMLDOCFROMOBJECT" VERSION="0" LANGU="E" DESCRIPT="Creates an IF_IXML_DOCUMENT from the OBJNAME Attribute" EXPOSURE="2" STATE="1" EDITORDER="5 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="700" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<exception CLSNAME="ZSAPLINK" CMPNAME="CREATEIXMLDOCFROMOBJECT" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000"/>
<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 .
DATA rootnode TYPE REF TO if_ixml_element.
DATA sourcenode TYPE REF TO if_ixml_element.
DATA rc TYPE sysubrc.
DATA sourcestring TYPE string.
DATA _objtype TYPE string.
DATA: l_filename TYPE string,
l_file_filter TYPE string,
l_user_action TYPE i.
DATA: wa_node type ssfgnode,
l_element TYPE REF TO if_ixml_element.
DATA: l_language_str TYPE string,
l_language(2) TYPE c.
DATA: l_lines TYPE i,
l_splitted_name_tab TYPE TABLE OF string.
DATA: l_stylename TYPE tdssname,
l_stylevari TYPE tdvariant,
l_save_style TYPE tdssname.
TYPES: t_raw(250) TYPE x.
CONSTANTS: c_xml_ns_uri_sf(255) TYPE c
VALUE 'urn:sap-com:SmartForms:2000:internal-structure',"#EC NOTEXT
c_xml_ns_uri_ifr(255) TYPE c
VALUE 'urn:sap-com:sdixml-ifr:2000'. "#EC NOTEXT
DATA: g_ixml TYPE REF TO if_ixml,
xml_macro_rc TYPE i,
xml_document TYPE REF TO if_ixml_document,
xml_ns_prefix_sf TYPE string,
xml_ns_uri_sf TYPE string,
xml_ns_uri_ifr TYPE string,
xml_document_size TYPE i,
xml_xtable TYPE TABLE OF t_raw,
xml_xtable2 TYPE TABLE OF string,
sform_name TYPE tdsfname.
DATA ref_ssf TYPE REF TO cl_ssf_fb_smart_form.
sform_name = objname.
IF g_ixml IS INITIAL.
g_ixml = cl_ixml=>create( ).
ENDIF.
xml_document = g_ixml->create_document( ).
xml_ns_prefix_sf = 'sf'.
xml_ns_uri_sf = c_xml_ns_uri_sf.
xml_ns_uri_ifr = c_xml_ns_uri_ifr.
CLEAR: xml_document_size, xml_xtable[], xml_xtable2[].
CREATE OBJECT ref_ssf.
TRY.
CALL METHOD ref_ssf->load
EXPORTING
im_formname = sform_name.
ref_ssf->xml_init( ).
CALL METHOD ref_ssf->xml_download
EXPORTING
parent = xml_document
CHANGING
document = xml_document.
* namespace
l_element = xml_document->get_root_element( ).
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = 'xmlns'
value = xml_ns_uri_sf ).
l_element->set_attribute( name = 'xmlns'
value = xml_ns_uri_ifr ).
* language
WRITE sy-langu TO l_language.
l_language_str = l_language.
xml_macro_rc = l_element->set_attribute(
name = 'language'
namespace = xml_ns_prefix_sf
value = l_language_str ).
* convert DOM to xml
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
document = xml_document
IMPORTING
size = xml_document_size
TABLES
xml_as_table = xml_xtable
EXCEPTIONS
OTHERS = 1.
CHECK sy-subrc EQ 0.
_objtype = getobjecttype( ).
rootnode = xmldoc->create_element( _objtype ).
DATA: wa_stxfadm TYPE stxfadm.
SELECT SINGLE * FROM stxfadm INTO wa_stxfadm WHERE formname = objname.
setattributesfromstructure( node = rootnode structure = wa_stxfadm
).
sourcenode = xmldoc->create_element( 'smartform' ).
xml_xtable2 = xml_xtable[].
sourcestring = buildsourcestring( sourcetable = xml_xtable2[] ).
rc = sourcenode->if_ixml_node~set_value( sourcestring ).
rc = rootnode->append_child( sourcenode ).
rc = xmldoc->append_child( rootnode ).
ixmldocument = xmldoc.
FREE: xml_document, xml_xtable[], xml_document_size.
CATCH cx_ssf_fb .
CLEAR ixmldocument.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>not_found.
ENDTRY.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEOBJECTFROMIXMLDOC" VERSION="0" LANGU="E" DESCRIPT="Creates Object on System from IXMLDocument passed in" EXPOSURE="2" STATE="1" EDITORDER="4 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="700" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<exception CLSNAME="ZSAPLINK" CMPNAME="CREATEOBJECTFROMIXMLDOC" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000"/>
<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 .
TYPES: t_raw(250) TYPE x.
DATA rootnode TYPE REF TO if_ixml_element.
DATA progattribs TYPE trdir.
DATA sourcenode TYPE REF TO if_ixml_element.
DATA l_xml_node TYPE REF TO if_ixml_element.
DATA source TYPE string.
DATA sourcetable TYPE table_of_strings.
DATA _objtype TYPE string.
DATA checkexists TYPE flag.
DATA: wa_stxfadm TYPE stxfadm,
formname TYPE tdsfname,
master_language TYPE sylangu,
lv_devclass TYPE devclass,
korrnum TYPE trkorr,
modif_language TYPE sylangu.
DATA: g_ixml TYPE REF TO if_ixml,
xml_macro_rc TYPE i,
xml_document TYPE REF TO if_ixml_document,
l_element TYPE REF TO if_ixml_element,
xml_ns_prefix_sf TYPE string,
xml_ns_uri_sf TYPE string,
xml_ns_uri_ifr TYPE string,
xml_document_size TYPE i,
xml_xtable TYPE TABLE OF t_raw,
l_ns_uri TYPE string,
l_name TYPE string,
l_language TYPE string,
p_dequeue TYPE tdbool,
l_cancel TYPE tdsfflag,
sf_exception TYPE REF TO cx_ssf_fb.
DATA: ref_ssf TYPE REF TO cl_ssf_fb_smart_form,
l_upload_smartform TYPE REF TO cl_ssf_fb_smart_form.
_objtype = getobjecttype( ).
xmldoc = ixmldocument.
rootnode = xmldoc->find_from_name( _objtype ).
CALL METHOD getstructurefromattributes
EXPORTING
node = rootnode
CHANGING
structure = wa_stxfadm.
objname = wa_stxfadm-formname.
checkexists = checkexists( ).
IF checkexists IS NOT INITIAL.
IF overwrite IS INITIAL.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=>existing.
ELSE.
* delete object for new install
deleteobject( ).
ENDIF.
ENDIF.
sourcenode = rootnode->find_from_name( 'smartform' ).
source = sourcenode->get_value( ).
sourcetable = buildtablefromstring( source ).
xml_xtable = sourcetable.
xml_document_size = STRLEN( source ).
CREATE OBJECT ref_ssf.
formname = objname.
* Check access permission and enqueue smart form
master_language = sy-langu.
TRY.
CALL METHOD ref_ssf->enqueue
EXPORTING
suppress_corr_check = space
language_upd_exit = ' '
master_language = master_language
mode = 'INSERT'
formname = formname
IMPORTING
devclass = lv_devclass
new_master_language = master_language
korrnum = korrnum
modification_language = modif_language.
CATCH cx_ssf_fb INTO sf_exception.
CASE sf_exception->textid.
WHEN cx_ssf_fb=>enqueued_by_user OR cx_ssf_fb=>enqueue_system_failure.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = 'Enqueued by user'.
WHEN cx_ssf_fb=>no_modify_permission OR cx_ssf_fb=>no_show_permission.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = 'Permission Error'.
WHEN cx_ssf_fb=>permission_failure.
EXIT.
WHEN cx_ssf_fb=>request_language_denied.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = 'Language request denied'.
WHEN OTHERS.
EXIT.
ENDCASE.
ENDTRY.
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = xml_xtable[]
size = xml_document_size
IMPORTING
document = xml_document
EXCEPTIONS
OTHERS = 1.
l_xml_node = xml_document->get_root_element( ).
l_ns_uri = l_xml_node->get_namespace_uri( ).
l_name = l_xml_node->get_name( ).
l_element ?= l_xml_node->query_interface( ixml_iid_element ).
l_language = l_element->get_attribute( name = 'language'
namespace = xml_ns_prefix_sf ).
CREATE OBJECT l_upload_smartform.
CALL METHOD l_upload_smartform->xml_upload
EXPORTING
dom = l_xml_node
formname = formname
language = master_language
CHANGING
sform = ref_ssf.
ref_ssf = l_upload_smartform.
PERFORM save_form IN PROGRAM saplstxb
USING
' ' 'X'
CHANGING
ref_ssf
l_cancel.
FREE: xml_document.
* dequeue form
ref_ssf->dequeue( formname = formname ).
* successful install
name = objname.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="DELETEOBJECT" VERSION="0" LANGU="E" DESCRIPT="Delete object" EXPOSURE="1" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="700" BCMTDCAT="00" BCMTDSYN="0">
<exception CLSNAME="ZSAPLINK" CMPNAME="DELETEOBJECT" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000"/>
<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 .
CALL FUNCTION 'FB_DELETE_FORM'
EXPORTING
I_FORMNAME = OBJNAME
* I_FORMTYPE = ' '
* I_WITH_DIALOG = 'X'
* I_WITH_CONFIRM_DIALOG = 'X'
* IMPORTING
* O_FORMNAME =
EXCEPTIONS
NO_NAME = 1
NO_FORM = 2
FORM_LOCKED = 3
NO_ACCESS_PERMISSION = 4
ILLEGAL_LANGUAGE = 5
ILLEGAL_FORMTYPE = 6
OTHERS = 7
.
IF sy-subrc <> 0.
ENDIF.
ENDMETHOD. "createobjectfromixmldoc</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="GETOBJECTTYPE" VERSION="0" LANGU="E" DESCRIPT="Get object type of plugin" EXPOSURE="1" STATE="1" EDITORDER="8 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" R3RELEASE="700" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="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 .
objectType = 'SSFO'. "SAP Smartforms
endmethod.</source>
</method>
</CLAS>